diff options
Diffstat (limited to 'src/main/java')
8 files changed, 690 insertions, 21 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java index e0384239ba..56d15fa479 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java @@ -35,21 +35,33 @@ import com.github.bartimaeusnek.bartworks.common.loaders.BioLabLoader; import com.github.bartimaeusnek.bartworks.common.loaders.GTNHBlocks; import com.github.bartimaeusnek.bartworks.common.loaders.LoaderRegistry; import com.github.bartimaeusnek.bartworks.common.net.BW_Network; +import com.github.bartimaeusnek.bartworks.util.BW_Util; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.event.FMLServerStartedEvent; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.NetworkRegistry; +import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.enums.SubTag; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import java.util.HashSet; + +import static com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_ElectricImplosionCompressor.eicMap; + @Mod( modid = MainMod.MOD_ID, name = MainMod.NAME, version = MainMod.VERSION, dependencies = "required-after:IC2; " @@ -110,4 +122,29 @@ public final class MainMod { new GTNHBlocks().run(); BioObjectAdder.regenerateBioFluids(); } + + @Mod.EventHandler + public void onServerStarted(FMLServerStartedEvent event){ + eicMap = new GT_Recipe.GT_Recipe_Map(new HashSet(GT_Recipe.GT_Recipe_Map.sImplosionRecipes.mRecipeList.size()), "gt.recipe.electricimplosioncompressor", "Electric Implosion Compressor", (String)null, "gregtech:textures/gui/basicmachines/Default", 1, 2, 1, 0, 1, "", 1, "", true, true); + for (GT_Recipe recipe : GT_Recipe.GT_Recipe_Map.sImplosionRecipes.mRecipeList){ + if (recipe == null || recipe.mInputs == null) + continue; + ItemStack input = recipe.mInputs[0]; + int i = 0; + while(checkForExplosives(input)){ + try { + i++; + input = recipe.mInputs[i]; + }catch (ArrayIndexOutOfBoundsException e){ + LOGGER.error("CAUGHT DEFECTIVE IMPLOSION COMPRESSOR RECIPE."); + e.printStackTrace(); + } + } + eicMap.addRecipe(true,new ItemStack[]{input}, recipe.mOutputs,null,null,null,recipe.mDuration, BW_Util.getMachineVoltageFromTier(10),0); + } + } + + private boolean checkForExplosives(ItemStack input){ + return (GT_Utility.areStacksEqual(input,new ItemStack(Blocks.tnt)) || GT_Utility.areStacksEqual(input, GT_ModHandler.getIC2Item("industrialTnt", 1L)) || GT_Utility.areStacksEqual(input, GT_ModHandler.getIC2Item("dynamite", 1L))|| GT_Utility.areStacksEqual(input, ItemList.Block_Powderbarrel.get(1L))); + } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java index bdfe5c9850..c945a19d14 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java @@ -31,6 +31,7 @@ import com.github.bartimaeusnek.bartworks.common.items.*; import com.github.bartimaeusnek.bartworks.common.tileentities.classic.BW_RotorBlock; import com.github.bartimaeusnek.bartworks.common.tileentities.classic.BW_TileEntity_HeatedWaterPump; import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_DEHP; +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_ElectricImplosionCompressor; import com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega.GT_TileEntity_MegaBlastFurnace; import com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega.GT_TileEntity_MegaVacuumFreezer; import com.github.bartimaeusnek.bartworks.common.tileentities.tiered.GT_MetaTileEntity_AcidGenerator; @@ -161,7 +162,7 @@ public class ItemRegistry { dehp = new GT_TileEntity_DEHP(ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 1, 1, "DEHP", "Deep Earth Heating Pump").getStackForm(1L); megaMachines[0] = new GT_TileEntity_MegaBlastFurnace(ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 2, "MegaBlastFurnace", StatCollector.translateToLocal("tile.bw.mbf.name")).getStackForm(1L); megaMachines[1] = new GT_TileEntity_MegaVacuumFreezer(ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 3, "MegaVacuumFreezer", StatCollector.translateToLocal("tile.bw.mvf.name")).getStackForm(1L); - + new GT_TileEntity_ElectricImplosionCompressor( ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 4,"Electric Implosion Compressor","Electric Implosion Compressor"); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java index 972eacef2d..fe2af47746 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java @@ -24,6 +24,7 @@ package com.github.bartimaeusnek.bartworks.common.loaders; import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_ElectricImplosionCompressor; import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_LESU; import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_ManualTrafo; import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_Windmill; @@ -56,16 +57,16 @@ public class RecipeLoader implements Runnable { * GTNH "hardmode" Recipes */ - GT_Values.RA.addFluidSolidifierRecipe(new ItemStack(Blocks.lapis_block), Materials.Iron.getMolten(1296L), new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 0), 100, (int) (GT_Values.V[3] - (GT_Values.V[3] / 10))); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 0), Materials.Lapis.getPlates(9), GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 2L), GT_Utility.getIntegratedCircuit(17)}, FluidRegistry.getFluidStack("ic2coolant", 1000), new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 1), 100, (int) (GT_Values.V[3] - (GT_Values.V[3] / 10))); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 1), Materials.Lapis.getBlocks(8), GT_Utility.getIntegratedCircuit(17)}, GT_Values.NF, new ItemStack(ItemRegistry.BW_BLOCKS[1]), 100, (int) (GT_Values.V[3] - (GT_Values.V[3] / 10))); + GT_Values.RA.addFluidSolidifierRecipe(new ItemStack(Blocks.lapis_block), Materials.Iron.getMolten(1296L), new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 0), 100, BW_Util.getMachineVoltageFromTier(3)); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 0), Materials.Lapis.getPlates(9), GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 2L), GT_Utility.getIntegratedCircuit(17)}, FluidRegistry.getFluidStack("ic2coolant", 1000), new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 1), 100, BW_Util.getMachineVoltageFromTier(3)); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 1), Materials.Lapis.getBlocks(8), GT_Utility.getIntegratedCircuit(17)}, GT_Values.NF, new ItemStack(ItemRegistry.BW_BLOCKS[1]), 100, BW_Util.getMachineVoltageFromTier(3)); } else { /* * Vanilla Recipes */ - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{Materials.Lapis.getBlocks(8), GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Basic, 1L), GT_Utility.getIntegratedCircuit(17)}, GT_Values.NF, new ItemStack(ItemRegistry.BW_BLOCKS[1]), 100, (int) (GT_Values.V[1] - (GT_Values.V[1] / 10))); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{Materials.Lapis.getBlocks(8), GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Basic, 1L), GT_Utility.getIntegratedCircuit(17)}, GT_Values.NF, new ItemStack(ItemRegistry.BW_BLOCKS[1]), 100, BW_Util.getMachineVoltageFromTier(1)); GT_ModHandler.addCraftingRecipe( new ItemStack(ItemRegistry.BW_BLOCKS[1]), @@ -78,9 +79,9 @@ public class RecipeLoader implements Runnable { 'C', "circuitBasic" }); - GT_Values.RA.addCutterRecipe(new ItemStack(ItemRegistry.BW_BLOCKS[1]), new ItemStack(ItemRegistry.BW_BLOCKS[0], 9, 1), GT_Values.NI, 100, (int) (GT_Values.V[1] - (GT_Values.V[1] / 10))); - GT_Values.RA.addCompressorRecipe(new ItemStack(ItemRegistry.BW_BLOCKS[0], 9, 1), new ItemStack(ItemRegistry.BW_BLOCKS[1]), 100, (int) (GT_Values.V[1] - (GT_Values.V[1] / 10))); - GT_Values.RA.addCompressorRecipe(new ItemStack(ItemRegistry.BW_BLOCKS[0], 9, 0), new ItemStack(ItemRegistry.BW_BLOCKS[1]), 100, (int) (GT_Values.V[1] - (GT_Values.V[1] / 10))); + GT_Values.RA.addCutterRecipe(new ItemStack(ItemRegistry.BW_BLOCKS[1]), new ItemStack(ItemRegistry.BW_BLOCKS[0], 9, 1), GT_Values.NI, 100, BW_Util.getMachineVoltageFromTier(1)); + GT_Values.RA.addCompressorRecipe(new ItemStack(ItemRegistry.BW_BLOCKS[0], 9, 1), new ItemStack(ItemRegistry.BW_BLOCKS[1]), 100, BW_Util.getMachineVoltageFromTier(1)); + GT_Values.RA.addCompressorRecipe(new ItemStack(ItemRegistry.BW_BLOCKS[0], 9, 0), new ItemStack(ItemRegistry.BW_BLOCKS[1]), 100, BW_Util.getMachineVoltageFromTier(1)); GT_ModHandler.addShapelessCraftingRecipe(new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 0), RecipeLoader.BITSD, new Object[]{new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 1)}); GT_ModHandler.addShapelessCraftingRecipe(new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 1), RecipeLoader.BITSD, new Object[]{new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 0)}); } @@ -462,7 +463,7 @@ public class RecipeLoader implements Runnable { Materials.Plastic.getMolten(1152L), new ItemStack(ItemRegistry.BW_BLOCKS[2], 1, 1), 20, - (int) (GT_Values.V[3] - (GT_Values.V[3] / 10)) + BW_Util.getMachineVoltageFromTier(3) ); GT_ModHandler.addCraftingRecipe( @@ -479,7 +480,7 @@ public class RecipeLoader implements Runnable { } ); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Good, 1L), Materials.Aluminium.getPlates(1), ItemList.Circuit_Board_Plastic.get(1L), ItemList.Battery_RE_LV_Lithium.get(1L)}, Materials.SolderingAlloy.getMolten(288L), new ItemStack(ItemRegistry.CIRCUIT_PROGRAMMER), 600, (int) (GT_Values.V[2] - (GT_Values.V[2] / 10))); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Good, 1L), Materials.Aluminium.getPlates(1), ItemList.Circuit_Board_Plastic.get(1L), ItemList.Battery_RE_LV_Lithium.get(1L)}, Materials.SolderingAlloy.getMolten(288L), new ItemStack(ItemRegistry.CIRCUIT_PROGRAMMER), 600, BW_Util.getMachineVoltageFromTier(2)); GT_ModHandler.addCraftingRecipe( new GT_TileEntity_Windmill(ConfigHandler.IDOffset + GT_Values.VN.length * 6 + 2, "bw.windmill", StatCollector.translateToLocal("tile.bw.windmill.name")).getStackForm(1L), @@ -614,6 +615,63 @@ public class RecipeLoader implements Runnable { 'W', "logWood", } ); + + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 6), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[]{ + "WEs", + "WZh", + "WDf", + 'Z', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 3), + 'E', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 4), + 'D', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 5), + 'W', "logWood", + } + ); + + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 6), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[]{ + "WEs", + "WZh", + "WDf", + 'D', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 3), + 'Z', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 4), + 'E', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 5), + 'W', "logWood", + } + ); + + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 6), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[]{ + "WEs", + "WZh", + "WDf", + 'E', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 3), + 'D', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 4), + 'Z', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 5), + 'W', "logWood", + } + ); + + GT_ModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 6), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[]{ + "WEs", + "WZh", + "WDf", + 'Z', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 3), + 'D', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 4), + 'E', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 5), + 'W', "logWood", + } + ); + GT_ModHandler.addCraftingRecipe( new ItemStack(ItemRegistry.LEATHER_ROTOR), GT_ModHandler.RecipeBits.NOT_REMOVABLE, @@ -672,8 +730,6 @@ public class RecipeLoader implements Runnable { ); } - - - } + } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CrackingDistillTower.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CrackingDistillTower.java new file mode 100644 index 0000000000..d0a242b23f --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CrackingDistillTower.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.multis; + +import com.github.bartimaeusnek.bartworks.util.BWRecipes; +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_DistillationTower; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import java.util.ArrayList; + +public class GT_TileEntity_CrackingDistillTower extends GT_MetaTileEntity_DistillationTower { + + public GT_TileEntity_CrackingDistillTower(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_TileEntity_CrackingDistillTower(String aName) { + super(aName); + } + + @Override + public boolean checkRecipe(ItemStack itemStack) { + if (!GT_Utility.areStacksEqual(itemStack, GT_Utility.getIntegratedCircuit(0),true)) + return false; + else{ + FluidStack[] array = new FluidStack[0]; + ArrayList<FluidStack> fluidInputs = new ArrayList<FluidStack>(); + for (GT_MetaTileEntity_Hatch_Input hatch : this.mInputHatches){ + if (hatch != null){ + fluidInputs.add(hatch.getFluid()); + } + } + array = fluidInputs.toArray(array); + GT_Recipe.GT_Recipe_Map rMapCracking = GT_Recipe.GT_Recipe_Map.sCrakingRecipes; + GT_Recipe.GT_Recipe_Map rMapDistillTower = GT_Recipe.GT_Recipe_Map.sDistillationRecipes; + GT_Recipe recipeCracking = rMapCracking.findRecipe(this.getBaseMetaTileEntity(),false,this.getMaxInputVoltage(),array,itemStack); + if (recipeCracking == null) + return false; + GT_Recipe recipeDistill = rMapDistillTower.findRecipe(this.getBaseMetaTileEntity(),false,this.getMaxInputVoltage(),recipeCracking.mFluidOutputs); + if (recipeDistill == null) + return false; + float ratio = (float)recipeCracking.mFluidOutputs[0].amount/(float)recipeDistill.mFluidInputs[0].amount; + FluidStack[] nuoutputs = new FluidStack[recipeDistill.mFluidOutputs.length]; + for (int i = 0; i < nuoutputs.length; i++) { + nuoutputs[i]=recipeDistill.mFluidOutputs[i]; + nuoutputs[i].amount=(int)(Math.floor(recipeDistill.mFluidOutputs[i].amount*ratio)); + } + BWRecipes.DynamicGTRecipe combined = new BWRecipes.DynamicGTRecipe(true,null,recipeDistill.mOutputs,null,recipeDistill.mChances,recipeCracking.mFluidInputs,nuoutputs,(int)(Math.floor(recipeDistill.mDuration*ratio))+recipeCracking.mDuration,Math.max((int)(Math.floor(recipeDistill.mEUt*ratio)),recipeCracking.mEUt),0); + if (combined.isRecipeInputEqual(true, array)){ + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + BW_Util.calculateOverclockedNessMulti(combined.mEUt, combined.mDuration, 1, this.getMaxInputVoltage(), this); + if (this.mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) + return false; + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + this.mOutputFluids=combined.mFluidOutputs.clone(); + this.mOutputItems=combined.mOutputs.clone(); + this.updateSlots(); + return true; + } + } + return false; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java new file mode 100644 index 0000000000..2c326887ed --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java @@ -0,0 +1,263 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.multis; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.common.GT_Pollution; +import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_ImplosionCompressor; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import java.util.ArrayList; +import java.util.Iterator; + +import static com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry.BW_BLOCKS; + +public class GT_TileEntity_ElectricImplosionCompressor extends GT_MetaTileEntity_ImplosionCompressor { + + private boolean piston; + + public GT_TileEntity_ElectricImplosionCompressor(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_TileEntity_ElectricImplosionCompressor(String aName) { + super(aName); + } + + public static GT_Recipe.GT_Recipe_Map eicMap; + + @Override + public boolean checkRecipe(ItemStack aStack) { + + if (this.mEnergyHatches.get(0).getEUVar() <= 0 || this.mEnergyHatches.get(1).getEUVar() <= 0 ) + return false; + + ArrayList<ItemStack> tInputList = this.getStoredInputs(); + int tInputList_sS = tInputList.size(); + + for(int i = 0; i < tInputList_sS - 1; ++i) { + for(int j = i + 1; j < tInputList_sS; ++j) { + if (GT_Utility.areStacksEqual((ItemStack)tInputList.get(i), (ItemStack)tInputList.get(j))) { + if (((ItemStack)tInputList.get(i)).stackSize < ((ItemStack)tInputList.get(j)).stackSize) { + tInputList.remove(i--); + tInputList_sS = tInputList.size(); + break; + } + + tInputList.remove(j--); + tInputList_sS = tInputList.size(); + } + } + } + + ItemStack[] tInputs = (ItemStack[])tInputList.toArray(new ItemStack[tInputList.size()]); + if (tInputList.size() > 0) { + GT_Recipe tRecipe = eicMap.findRecipe(this.getBaseMetaTileEntity(), false, 9223372036854775807L, (FluidStack[])null, tInputs); + if (tRecipe != null && tRecipe.isRecipeInputEqual(true, (FluidStack[])null, tInputs)) { + this.mEfficiency = 10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000; + this.mEfficiencyIncrease = 10000; + this.mEUt = -tRecipe.mEUt; + this.mMaxProgresstime = Math.max(1, tRecipe.mDuration); + this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)}; + this.sendLoopStart((byte)20); + this.updateSlots(); + return true; + } + } + + return false; + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + if (this.mRuntime % 10 == 0) + togglePiston(); + return super.onRunningTick(aStack); + } + + public void stopMachine(){ + resetPiston(); + super.stopMachine(); + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + piston = true; + } + + private void resetPiston(){ + if (this.getBaseMetaTileEntity().getWorld().isRemote) + return; + if (!piston){ + int xDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetZ; + int aX = this.getBaseMetaTileEntity().getXCoord(),aY = this.getBaseMetaTileEntity().getYCoord() ,aZ = this.getBaseMetaTileEntity().getZCoord(); + for (int x = -1; x <= 1; x++) { + for (int z = -1; z <= 1; z++) { + if (!(Math.abs(x) == 1 && Math.abs(z) == 1)) + this.getBaseMetaTileEntity().getWorld().setBlock(xDir + aX + x, aY + 2, zDir + aZ + z, GregTech_API.sBlockMetal5, 2, 3); + } + } + GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(5), 10, 1.0F, aX, aY, aZ); + piston = !piston; + } + } + private void togglePiston() { + if (this.getBaseMetaTileEntity().getWorld().isRemote) + return; + int xDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetZ; + int aX = this.getBaseMetaTileEntity().getXCoord(),aY = this.getBaseMetaTileEntity().getYCoord() ,aZ = this.getBaseMetaTileEntity().getZCoord(); + boolean hax = false; + if(piston){ + for (int x = -1; x <= 1; x++) { + for (int z = -1; z <= 1; z++) { + if (!(Math.abs(x) == 1 && Math.abs(z) == 1)) { + if (this.getBaseMetaTileEntity().getBlock(xDir+aX+x,aY+2,zDir+aZ+z) != GregTech_API.sBlockMetal5 && this.getBaseMetaTileEntity().getMetaID(xDir+aX+x,aY+2,zDir+aZ+z) != 2 ) { + hax = true; + } + this.getBaseMetaTileEntity().getWorld().setBlockToAir(xDir + aX + x, aY + 2, zDir + aZ + z); + } + } + } + GT_Utility.doSoundAtClient((String)GregTech_API.sSoundList.get(5), 10, 1.0F, aX, aY, aZ); + piston=!piston; + } else { + for (int x = -1; x <= 1; x++) { + for (int z = -1; z <= 1; z++) { + if (!(Math.abs(x) == 1 && Math.abs(z) == 1)) + this.getBaseMetaTileEntity().getWorld().setBlock(xDir+aX+x,aY+2,zDir+aZ+z,GregTech_API.sBlockMetal5,2,3); + } + } + GT_Utility.doSoundAtClient((String)GregTech_API.sSoundList.get(5), 10, 1.0F, aX, aY, aZ); + piston = !piston; + } + if (hax) + this.explodeMultiblock(); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setBoolean("piston",piston); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + piston=aNBT.getBoolean("piston"); + super.loadNBTData(aNBT); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + + for (int x = -1; x <= 1; x++) { + for (int y = -2; y < 7; y++) { + for (int z = -1; z <= 1; z++) { + IGregTechTileEntity te = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir+x,y,z+zDir); + if (y == -2 || y == 6) { + if (!(x == 0 && z == 0)) { + if (!this.addMaintenanceToMachineList(te, 16) && !this.addMufflerToMachineList(te, 16) && !this.addInputToMachineList(te, 16) && !this.addOutputToMachineList(te, 16)) { + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z); + byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z); + if ((tBlock != GregTech_API.sBlockCasings2 || tMeta != 0) && (tBlock != GregTech_API.sBlockCasings3 || tMeta != 4)) { + return false; + } + } + } + else if (x == 0 && z == 0) { + if (y == -2) + if (!this.addEnergyInputToMachineList(te, 16)) + return false; + if (y == 6) + if (!this.addEnergyInputToMachineList(te, 16)) + return false; + } + } + else if ((y > -2 && y < 1) || (y > 3 && y < 6)){ + if (y == 0 && xDir+x == 0 && zDir+z==0) + continue; + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z); + byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z); + if (x == 0 && z == 0) { + if (tBlock != BW_BLOCKS[2] || tMeta != 0) + return false; + }else{ + if (tBlock != BW_BLOCKS[2] || tMeta != 1) + return false; + } + + } + else if (y == 1) { + if (!GT_Utility.areStacksEqual(new ItemStack(aBaseMetaTileEntity.getBlockOffset(xDir + x, 1, zDir + z),1,aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z)), Materials.Neutronium.getBlocks(1))) + return false; + } + else if (y == 2) { + if (!piston) { + if (Math.abs(x) == 1 && Math.abs(z) == 1) { + if (!GT_Utility.areStacksEqual(new ItemStack(aBaseMetaTileEntity.getBlockOffset(xDir + x, 2, zDir + z),1,aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z)), Materials.Neutronium.getBlocks(1))) + return false; + } + }else if (!GT_Utility.areStacksEqual(new ItemStack(aBaseMetaTileEntity.getBlockOffset(xDir + x, 2, zDir + z),1,aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z)), Materials.Neutronium.getBlocks(1))) + return false; + } + else if (y == 3) { + if (!GT_Utility.areStacksEqual(new ItemStack(aBaseMetaTileEntity.getBlockOffset(xDir + x, 3, zDir + z),1,aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z)), Materials.Neutronium.getBlocks(1))) + return false; + } + } + } + } + return true; + } + + + @Override + public int getPollutionPerTick(ItemStack itemStack) { + return 0; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_TileEntity_ElectricImplosionCompressor(this.mName); + } + + @Override + public String[] getDescription() { + return new String[0]; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaProcessingArray.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaProcessingArray.java new file mode 100644 index 0000000000..414b7b3122 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaProcessingArray.java @@ -0,0 +1,207 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega; + +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import gregtech.GT_Mod; +import gregtech.api.enums.GT_Values; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_ProcessingArray; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; +import org.apache.commons.lang3.ArrayUtils; + +import java.util.ArrayList; +import java.util.List; + +import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine.isValidForLowGravity; + +public class GT_TileEntity_MegaProcessingArray extends GT_MetaTileEntity_ProcessingArray { + public GT_TileEntity_MegaProcessingArray(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_TileEntity_MegaProcessingArray(String aName) { + super(aName); + } + + private GT_Recipe mLastRecipe; + private int tTier = 0; + private int mMult = 0; + private String mMachine = ""; + + private GT_MetaTileEntity_Hatch_InputBus machineBus; + + public boolean checkRecipe(ItemStack aStack) { + if (!isCorrectMachinePart(machineBus.mInventory[0])) { + return false; + } + + GT_Recipe.GT_Recipe_Map map = getRecipeMap(); + if (map == null) return false; + ArrayList<ItemStack> tInputList = getStoredInputs(); + + if (mInventory[1].getUnlocalizedName().endsWith("10")) { + tTier = 9; + mMult = 2;//u need 4x less machines and they will use 4x less power + } else if (mInventory[1].getUnlocalizedName().endsWith("11")) { + tTier = 9; + mMult = 4;//u need 16x less machines and they will use 16x less power + } else if (mInventory[1].getUnlocalizedName().endsWith("12") || + mInventory[1].getUnlocalizedName().endsWith("13") || + mInventory[1].getUnlocalizedName().endsWith("14") || + mInventory[1].getUnlocalizedName().endsWith("15")) { + tTier = 9; + mMult = 6;//u need 64x less machines and they will use 64x less power + } else if (mInventory[1].getUnlocalizedName().endsWith("1")) { + tTier = 1; + mMult = 0;//*1 + } else if (mInventory[1].getUnlocalizedName().endsWith("2")) { + tTier = 2; + mMult = 0;//*1 + } else if (mInventory[1].getUnlocalizedName().endsWith("3")) { + tTier = 3; + mMult = 0;//*1 + } else if (mInventory[1].getUnlocalizedName().endsWith("4")) { + tTier = 4; + mMult = 0;//*1 + } else if (mInventory[1].getUnlocalizedName().endsWith("5")) { + tTier = 5; + mMult = 0;//*1 + } else if (mInventory[1].getUnlocalizedName().endsWith("6")) { + tTier = 6; + mMult = 0;//*1 + } else if (mInventory[1].getUnlocalizedName().endsWith("7")) { + tTier = 7; + mMult = 0;//*1 + } else if (mInventory[1].getUnlocalizedName().endsWith("8")) { + tTier = 8; + mMult = 0;//*1 + } else if (mInventory[1].getUnlocalizedName().endsWith("9")) { + tTier = 9; + mMult = 0;//*1 + } else { + tTier = 0; + mMult = 0;//*1 + } + + if (!mMachine.equals(mInventory[1].getUnlocalizedName())) mLastRecipe = null; + mMachine = mInventory[1].getUnlocalizedName();< |
