aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/goodgenerator/blocks
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/goodgenerator/blocks')
-rw-r--r--src/main/java/goodgenerator/blocks/myFluids/BaseFluid.java54
-rw-r--r--src/main/java/goodgenerator/blocks/myFluids/FluidsBuilder.java176
-rw-r--r--src/main/java/goodgenerator/blocks/regularBlock/Casing.java123
-rw-r--r--src/main/java/goodgenerator/blocks/regularBlock/ComplexTextureCasing.java58
-rw-r--r--src/main/java/goodgenerator/blocks/regularBlock/Frame.java36
-rw-r--r--src/main/java/goodgenerator/blocks/regularBlock/TEBlock.java180
-rw-r--r--src/main/java/goodgenerator/blocks/tileEntity/EssentiaHatch.java225
-rw-r--r--src/main/java/goodgenerator/blocks/tileEntity/FuelRefineFactory.java368
-rw-r--r--src/main/java/goodgenerator/blocks/tileEntity/GTMetaTileEntity/NeutronAccelerator.java66
-rw-r--r--src/main/java/goodgenerator/blocks/tileEntity/GTMetaTileEntity/NeutronSensor.java168
-rw-r--r--src/main/java/goodgenerator/blocks/tileEntity/LargeEssentiaGenerator.java539
-rw-r--r--src/main/java/goodgenerator/blocks/tileEntity/MegaPlasmaTurbine.java50
-rw-r--r--src/main/java/goodgenerator/blocks/tileEntity/MetalVaporTurbine.java5
-rw-r--r--src/main/java/goodgenerator/blocks/tileEntity/MultiNqGenerator.java427
-rw-r--r--src/main/java/goodgenerator/blocks/tileEntity/NeutronActivator.java441
-rw-r--r--src/main/java/goodgenerator/blocks/tileEntity/UniversalChemicalFuelEngine.java348
-rw-r--r--src/main/java/goodgenerator/blocks/tileEntity/YottaFluidTank.java424
17 files changed, 3688 insertions, 0 deletions
diff --git a/src/main/java/goodgenerator/blocks/myFluids/BaseFluid.java b/src/main/java/goodgenerator/blocks/myFluids/BaseFluid.java
new file mode 100644
index 0000000000..9ccbd27e70
--- /dev/null
+++ b/src/main/java/goodgenerator/blocks/myFluids/BaseFluid.java
@@ -0,0 +1,54 @@
+package goodgenerator.blocks.myFluids;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.util.IIcon;
+import net.minecraftforge.fluids.BlockFluidClassic;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidRegistry;
+
+import static goodgenerator.main.GoodGenerator.MOD_ID;
+
+public class BaseFluid extends BlockFluidClassic{
+ @SideOnly( Side.CLIENT )
+ protected IIcon stillIcon;
+ @SideOnly( Side.CLIENT )
+ protected IIcon flowingIcon;
+ private String stillTexture;
+ private String flowingTexture;
+
+ public BaseFluid(Fluid fluid, Material material)
+ {
+ super( fluid, material );
+ }
+
+ public void SetTexture(String fluidName)
+ {
+ stillTexture = MOD_ID + ":fluids/" + fluidName + ".still";
+ flowingTexture = MOD_ID + ":fluids/" + fluidName + ".flowing";
+ }
+
+ public static Fluid BuildFluid(String fluidName){
+ Fluid tFluid = new Fluid(fluidName);
+ FluidRegistry.registerFluid(tFluid);
+ return tFluid;
+ }
+
+ @SideOnly( Side.CLIENT )
+ @Override
+ public void registerBlockIcons( IIconRegister register )
+ {
+ stillIcon = register.registerIcon(stillTexture);
+ flowingIcon = register.registerIcon(flowingTexture);
+
+ super.getFluid().setIcons( stillIcon, flowingIcon );
+ }
+
+ @Override
+ public IIcon getIcon( int side, int meta )
+ {
+ return ( side == 0 || side == 1 ) ? stillIcon : flowingIcon;
+ }
+}
diff --git a/src/main/java/goodgenerator/blocks/myFluids/FluidsBuilder.java b/src/main/java/goodgenerator/blocks/myFluids/FluidsBuilder.java
new file mode 100644
index 0000000000..94857b73f6
--- /dev/null
+++ b/src/main/java/goodgenerator/blocks/myFluids/FluidsBuilder.java
@@ -0,0 +1,176 @@
+package goodgenerator.blocks.myFluids;
+
+import goodgenerator.crossmod.nei.NEI_Config;
+import cpw.mods.fml.common.registry.GameRegistry;
+import net.minecraft.block.material.Material;
+import net.minecraftforge.fluids.Fluid;
+
+public class FluidsBuilder {
+ public FluidsBuilder(){
+ }
+
+ public static void Register() {
+ crackedNaquadahGas_Lightly();
+ crackedNaquadahGas_Moderately();
+ crackedNaquadahGas_Heavily();
+ crackedLightNaquadahFuel_Lightly();
+ crackedLightNaquadahFuel_Moderately();
+ crackedLightNaquadahFuel_Heavily();
+ crackedHeavyNaquadahFuel_Lightly();
+ crackedHeavyNaquadahFuel_Moderately();
+ crackedHeavyNaquadahFuel_Heavily();
+ crackedNaquadahAsphalt_Lightly();
+ crackedNaquadahAsphalt_Moderately();
+ crackedNaquadahAsphalt_Heavily();
+ combustionPromotor();
+ }
+
+ public static void crackedNaquadahGas_Lightly(){
+ Fluid tmp = BaseFluid.BuildFluid("lightlyCrackedNaquadahGas");
+ tmp.setGaseous(true)
+ .setTemperature(800);
+ BaseFluid tmp2 = new BaseFluid(tmp, Material.water);
+ tmp2.SetTexture("lightlyCrackedNaquadahGas");
+ tmp2.setBlockName("lightlyCrackedNaquadahGas");
+ GameRegistry.registerBlock(tmp2,"lightlyCrackedNaquadahGas");
+ NEI_Config.hide(tmp2);
+ }
+
+ public static void crackedNaquadahGas_Moderately(){
+ Fluid tmp = BaseFluid.BuildFluid("moderatelyCrackedNaquadahGas");
+ tmp.setGaseous(true)
+ .setTemperature(800);
+ BaseFluid tmp2 = new BaseFluid(tmp, Material.water);
+ tmp2.SetTexture("moderatelyCrackedNaquadahGas");
+ tmp2.setBlockName("moderatelyCrackedNaquadahGas");
+ GameRegistry.registerBlock(tmp2,"moderatelyCrackedNaquadahGas");
+ NEI_Config.hide(tmp2);
+ }
+
+ public static void crackedNaquadahGas_Heavily(){
+ Fluid tmp = BaseFluid.BuildFluid("heavilyCrackedNaquadahGas");
+ tmp.setGaseous(true)
+ .setTemperature(800);
+ BaseFluid tmp2 = new BaseFluid(tmp, Material.water);
+ tmp2.SetTexture("heavilyCrackedNaquadahGas");
+ tmp2.setBlockName("heavilyCrackedNaquadahGas");
+ GameRegistry.registerBlock(tmp2,"heavilyCrackedNaquadahGas");
+ NEI_Config.hide(tmp2);
+ }
+
+ public static void crackedLightNaquadahFuel_Lightly(){
+ Fluid tmp = BaseFluid.BuildFluid("lightlyCrackedLightNaquadahFuel");
+ tmp.setGaseous(false)
+ .setTemperature(1200);
+ BaseFluid tmp2 = new BaseFluid(tmp, Material.water);
+ tmp2.SetTexture("lightlyCrackedLightNaquadahFuel");
+ tmp2.setBlockName("lightlyCrackedLightNaquadahFuel");
+ GameRegistry.registerBlock(tmp2,"lightlyCrackedLightNaquadahFuel");
+ NEI_Config.hide(tmp2);
+ }
+
+ public static void crackedLightNaquadahFuel_Moderately(){
+ Fluid tmp = BaseFluid.BuildFluid("moderatelyCrackedLightNaquadahFuel");
+ tmp.setGaseous(false)
+ .setTemperature(1200);
+ BaseFluid tmp2 = new BaseFluid(tmp, Material.water);
+ tmp2.SetTexture("moderatelyCrackedLightNaquadahFuel");
+ tmp2.setBlockName("moderatelyCrackedLightNaquadahFuel");
+ GameRegistry.registerBlock(tmp2,"moderatelyCrackedLightNaquadahFuel");
+ NEI_Config.hide(tmp2);
+ }
+
+ public static void crackedLightNaquadahFuel_Heavily(){
+ Fluid tmp = BaseFluid.BuildFluid("heavilyCrackedLightNaquadahFuel");
+ tmp.setGaseous(false)
+ .setTemperature(1200);
+ BaseFluid tmp2 = new BaseFluid(tmp, Material.water);
+ tmp2.SetTexture("heavilyCrackedLightNaquadahFuel");
+ tmp2.setBlockName("heavilyCrackedLightNaquadahFuel");
+ GameRegistry.registerBlock(tmp2,"heavilyCrackedLightNaquadahFuel");
+ NEI_Config.hide(tmp2);
+ }
+
+ public static void crackedHeavyNaquadahFuel_Lightly(){
+ Fluid tmp = BaseFluid.BuildFluid("lightlyCrackedHeavyNaquadahFuel");
+ tmp.setGaseous(false)
+ .setTemperature(1200);
+ BaseFluid tmp2 = new BaseFluid(tmp, Material.water);
+ tmp2.SetTexture("lightlyCrackedHeavyNaquadahFuel");
+ tmp2.setBlockName("lightlyCrackedHeavyNaquadahFuel");
+ GameRegistry.registerBlock(tmp2,"lightlyCrackedHeavyNaquadahFuel");
+ NEI_Config.hide(tmp2);
+ }
+
+ public static void crackedHeavyNaquadahFuel_Moderately(){
+ Fluid tmp = BaseFluid.BuildFluid("moderatelyCrackedHeavyNaquadahFuel");
+ tmp.setGaseous(false)
+ .setTemperature(1200);
+ BaseFluid tmp2 = new BaseFluid(tmp, Material.water);
+ tmp2.SetTexture("moderatelyCrackedHeavyNaquadahFuel");
+ tmp2.setBlockName("moderatelyCrackedHeavyNaquadahFuel");
+ GameRegistry.registerBlock(tmp2,"moderatelyCrackedHeavyNaquadahFuel");
+ NEI_Config.hide(tmp2);
+ }
+
+ public static void crackedHeavyNaquadahFuel_Heavily(){
+ Fluid tmp = BaseFluid.BuildFluid("heavilyCrackedHeavyNaquadahFuel");
+ tmp.setGaseous(false)
+ .setTemperature(1200);
+ BaseFluid tmp2 = new BaseFluid(tmp, Material.water);
+ tmp2.SetTexture("heavilyCrackedHeavyNaquadahFuel");
+ tmp2.setBlockName("heavilyCrackedHeavyNaquadahFuel");
+ GameRegistry.registerBlock(tmp2,"heavilyCrackedHeavyNaquadahFuel");
+ NEI_Config.hide(tmp2);
+ }
+
+ public static void crackedNaquadahAsphalt_Lightly(){
+ Fluid tmp = BaseFluid.BuildFluid("lightlyCrackedNaquadahAsphalt");
+ tmp.setGaseous(false)
+ .setTemperature(1800)
+ .setDensity(20000)
+ .setViscosity(20000);
+ BaseFluid tmp2 = new BaseFluid(tmp, Material.water);
+ tmp2.SetTexture("lightlyCrackedNaquadahAsphalt");
+ tmp2.setBlockName("lightlyCrackedNaquadahAsphalt");
+ GameRegistry.registerBlock(tmp2,"lightlyCrackedNaquadahAsphalt");
+ NEI_Config.hide(tmp2);
+ }
+
+ public static void crackedNaquadahAsphalt_Moderately(){
+ Fluid tmp = BaseFluid.BuildFluid("moderatelyCrackedNaquadahAsphalt");
+ tmp.setGaseous(false)
+ .setTemperature(1800)
+ .setDensity(20000)
+ .setViscosity(20000);
+ BaseFluid tmp2 = new BaseFluid(tmp, Material.water);
+ tmp2.SetTexture("moderatelyCrackedNaquadahAsphalt");
+ tmp2.setBlockName("moderatelyCrackedNaquadahAsphalt");
+ GameRegistry.registerBlock(tmp2,"moderatelyCrackedNaquadahAsphalt");
+ NEI_Config.hide(tmp2);
+ }
+
+ public static void crackedNaquadahAsphalt_Heavily(){
+ Fluid tmp = BaseFluid.BuildFluid("heavilyCrackedNaquadahAsphalt");
+ tmp.setGaseous(false)
+ .setTemperature(1800)
+ .setDensity(20000)
+ .setViscosity(20000);
+ BaseFluid tmp2 = new BaseFluid(tmp, Material.water);
+ tmp2.SetTexture("heavilyCrackedNaquadahAsphalt");
+ tmp2.setBlockName("heavilyCrackedNaquadahAsphalt");
+ GameRegistry.registerBlock(tmp2,"heavilyCrackedNaquadahAsphalt");
+ NEI_Config.hide(tmp2);
+ }
+
+ public static void combustionPromotor(){
+ Fluid tmp = BaseFluid.BuildFluid("combustionPromotor");
+ tmp.setGaseous(false)
+ .setTemperature(300);
+ BaseFluid tmp2 = new BaseFluid(tmp, Material.water);
+ tmp2.SetTexture("combustionPromotor");
+ tmp2.setBlockName("combustionPromotor");
+ GameRegistry.registerBlock(tmp2,"combustionPromotor");
+ NEI_Config.hide(tmp2);
+ }
+}
diff --git a/src/main/java/goodgenerator/blocks/regularBlock/Casing.java b/src/main/java/goodgenerator/blocks/regularBlock/Casing.java
new file mode 100644
index 0000000000..7a1db3278d
--- /dev/null
+++ b/src/main/java/goodgenerator/blocks/regularBlock/Casing.java
@@ -0,0 +1,123 @@
+package goodgenerator.blocks.regularBlock;
+
+import goodgenerator.main.GoodGenerator;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import gregtech.api.GregTech_API;
+import net.minecraft.block.Block;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EnumCreatureType;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.IIcon;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+
+import java.util.List;
+
+public class Casing extends Block {
+
+ @SideOnly(Side.CLIENT)
+ protected IIcon[] texture;
+ String[] textureNames;
+ protected String name;
+
+ public Casing(String name) {
+ super(Material.iron);
+ this.setHardness(9.0F);
+ this.setResistance(5.0F);
+ this.name = name;
+ this.setHarvestLevel("wrench",2);
+ this.setCreativeTab(GoodGenerator.GG);
+ GregTech_API.registerMachineBlock(this, -1);
+ }
+
+ public Casing(String name, String[] texture){
+ super(Material.iron);
+ this.setHardness(9.0F);
+ this.setResistance(5.0F);
+ this.name = name;
+ this.textureNames = texture;
+ this.setHarvestLevel("wrench",2);
+ this.setCreativeTab(GoodGenerator.GG);
+ GregTech_API.registerMachineBlock(this, -1);
+ }
+
+ public Casing(String name, String[] texture, Material material){
+ super(material);
+ this.setHardness(9.0F);
+ this.setResistance(5.0F);
+ this.name = name;
+ this.textureNames = texture;
+ this.setHarvestLevel("wrench",2);
+ this.setCreativeTab(GoodGenerator.GG);
+ GregTech_API.registerMachineBlock(this, -1);
+ }
+
+ @Override
+ public int damageDropped(int meta) {
+ return meta;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(int side, int meta) {
+ return meta < this.texture.length ? this.texture[meta] : this.texture[0];
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerBlockIcons(IIconRegister par1IconRegister) {
+ this.texture = new IIcon[this.textureNames.length];
+ for (int i = 0; i < this.textureNames.length; i++) {
+ this.texture[i] = par1IconRegister.registerIcon(this.textureNames[i]);
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ @SuppressWarnings("unchecked")
+ public void getSubBlocks(Item item, CreativeTabs tab, List list) {
+ for (int i = 0; i < this.textureNames.length; i++) {
+ list.add(new ItemStack(item, 1, i));
+ }
+ }
+
+ @Override
+ public void onBlockAdded(World aWorld, int aX, int aY, int aZ) {
+ if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) {
+ GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ);
+ }
+ }
+
+ @Override
+ public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetaData) {
+ if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) {
+ GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ);
+ }
+ }
+
+ @Override
+ public String getUnlocalizedName() {
+ return this.name;
+ }
+
+ @Override
+ public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) {
+ return false;
+ }
+
+ @Override
+ public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) {
+ return false;
+ }
+
+ @Override
+ public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) {
+ return false;
+ }
+
+}
diff --git a/src/main/java/goodgenerator/blocks/regularBlock/ComplexTextureCasing.java b/src/main/java/goodgenerator/blocks/regularBlock/ComplexTextureCasing.java
new file mode 100644
index 0000000000..18a1629cbf
--- /dev/null
+++ b/src/main/java/goodgenerator/blocks/regularBlock/ComplexTextureCasing.java
@@ -0,0 +1,58 @@
+package goodgenerator.blocks.regularBlock;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.IIcon;
+
+import java.util.List;
+
+public class ComplexTextureCasing extends Casing{
+
+ @SideOnly(Side.CLIENT)
+ protected IIcon[] texture1, texture2;
+ String[] textureSide;
+ String[] textureTopAndDown;
+
+ public ComplexTextureCasing(String name, String[] textureSide, String[] textureTopAndDown){
+ super(name);
+ this.textureSide = textureSide;
+ this.textureTopAndDown = textureTopAndDown;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(int side, int meta) {
+ if (side < 2) {
+ return meta < this.texture2.length ? this.texture2[meta] : this.texture2[0];
+ }
+ else {
+ return meta < this.texture1.length ? this.texture1[meta] : this.texture1[0];
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerBlockIcons(IIconRegister par1IconRegister) {
+ this.texture1 = new IIcon[this.textureSide.length];
+ for (int i = 0; i < this.textureSide.length; i++) {
+ this.texture1[i] = par1IconRegister.registerIcon(this.textureSide[i]);
+ }
+ this.texture2 = new IIcon[this.textureTopAndDown.length];
+ for (int i = 0; i < this.textureTopAndDown.length; i++) {
+ this.texture2[i] = par1IconRegister.registerIcon(this.textureTopAndDown[i]);
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ @SuppressWarnings("unchecked")
+ public void getSubBlocks(Item item, CreativeTabs tab, List list) {
+ for (int i = 0; i < Math.max(this.textureSide.length, this.textureTopAndDown.length); i++) {
+ list.add(new ItemStack(item, 1, i));
+ }
+ }
+}
diff --git a/src/main/java/goodgenerator/blocks/regularBlock/Frame.java b/src/main/java/goodgenerator/blocks/regularBlock/Frame.java
new file mode 100644
index 0000000000..90c38c4cce
--- /dev/null
+++ b/src/main/java/goodgenerator/blocks/regularBlock/Frame.java
@@ -0,0 +1,36 @@
+package goodgenerator.blocks.regularBlock;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import net.minecraft.block.material.Material;
+import net.minecraft.world.IBlockAccess;
+
+public class Frame extends Casing{
+ public Frame(String name,String[] texture){
+ super(name,texture, Material.iron);
+ }
+
+ @Override
+ public boolean isOpaqueCube() {
+ return false;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public boolean shouldSideBeRendered(IBlockAccess worldClient, int xCoord, int yCoord, int zCoord, int aSide) {
+ if (worldClient.getBlock(xCoord, yCoord, zCoord) instanceof Frame)
+ return false;
+ return super.shouldSideBeRendered(worldClient, xCoord, yCoord, zCoord, aSide);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public int getRenderBlockPass() {
+ return 1;
+ }
+
+ @Override
+ public boolean renderAsNormalBlock() {
+ return false;
+ }
+}
diff --git a/src/main/java/goodgenerator/blocks/regularBlock/TEBlock.java b/src/main/java/goodgenerator/blocks/regularBlock/TEBlock.java
new file mode 100644
index 0000000000..b33dbffdec
--- /dev/null
+++ b/src/main/java/goodgenerator/blocks/regularBlock/TEBlock.java
@@ -0,0 +1,180 @@
+package goodgenerator.blocks.regularBlock;
+
+import goodgenerator.blocks.tileEntity.EssentiaHatch;
+import goodgenerator.main.GoodGenerator;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import gregtech.api.GregTech_API;
+import gregtech.api.util.GT_Utility;
+import net.minecraft.block.Block;
+import net.minecraft.block.BlockContainer;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EnumCreatureType;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.IEssentiaContainerItem;
+
+import java.util.List;
+
+public class TEBlock extends BlockContainer {
+
+ @SideOnly(Side.CLIENT)
+ protected IIcon[] texture;
+ String[] textureNames;
+ protected String name;
+ protected int index;
+
+ public TEBlock(String name, String[] texture, CreativeTabs Tab){
+ super(Material.iron);
+ this.setHardness(9.0F);
+ this.setResistance(5.0F);
+ this.name = name;
+ this.textureNames = texture;
+ this.setHarvestLevel("wrench",2);
+ this.setCreativeTab(GoodGenerator.GG);
+ GregTech_API.registerMachineBlock(this, -1);
+ }
+
+ public TEBlock(String name, String[] texture, int index){
+ super(Material.iron);
+ this.setHardness(9.0F);
+ this.setResistance(5.0F);
+ this.name = name;
+ this.textureNames = texture;
+ this.setHarvestLevel("wrench",2);
+ this.index = index;
+ this.setCreativeTab(GoodGenerator.GG);
+ GregTech_API.registerMachineBlock(this, -1);
+ }
+
+ public TEBlock(String name, String[] texture, Material material){
+ super(material);
+ this.setHardness(9.0F);
+ this.setResistance(5.0F);
+ this.name = name;
+ this.textureNames = texture;
+ this.setHarvestLevel("wrench",2);
+ this.setCreativeTab(GoodGenerator.GG);
+ GregTech_API.registerMachineBlock(this, -1);
+ }
+
+ public int getIndex() {
+ return this.index;
+ }
+
+ @Override
+ public int damageDropped(int meta) {
+ return meta;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(int side, int meta) {
+ return meta < this.texture.length ? this.texture[meta] : this.texture[0];
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerBlockIcons(IIconRegister par1IconRegister) {
+ this.texture = new IIcon[this.textureNames.length];
+ for (int i = 0; i < this.textureNames.length; i++) {
+ this.texture[i] = par1IconRegister.registerIcon(this.textureNames[i]);
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ @SuppressWarnings("unchecked")
+ public void getSubBlocks(Item item, CreativeTabs tab, List list) {
+ for (int i = 0; i < this.textureNames.length; i++) {
+ list.add(new ItemStack(item, 1, i));
+ }
+ }
+
+ @Override
+ public void onBlockAdded(World aWorld, int aX, int aY, int aZ) {
+ if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) {
+ GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ);
+ }
+ }
+
+ @Override
+ public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetaData) {
+ if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) {
+ GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ);
+ }
+ aWorld.removeTileEntity(aX, aY, aZ);
+ }
+
+ @Override
+ public String getUnlocalizedName() {
+ return this.name;
+ }
+
+ @Override
+ public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) {
+ return false;
+ }
+
+ @Override
+ public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) {
+ return false;
+ }
+
+ @Override
+ public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) {
+ return false;
+ }
+
+ @Override
+ public TileEntity createTileEntity(World world, int meta) {
+ if (index == 1)
+ return new EssentiaHatch();
+ return null;
+ }
+
+ @Override
+ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
+ if (world.isRemote) {
+ return false;
+ } else {
+ TileEntity tile = world.getTileEntity(x, y, z);
+ if (index == 1) {
+ if (tile instanceof EssentiaHatch) {
+ ItemStack tItemStack = player.getHeldItem();
+ if (tItemStack != null) {
+ Item tItem = tItemStack.getItem();
+ if (tItem instanceof IEssentiaContainerItem && ((IEssentiaContainerItem) tItem).getAspects(player.getHeldItem()) != null && ((IEssentiaContainerItem) tItem).getAspects(player.getHeldItem()).size() > 0) {
+ Aspect tLocked = ((IEssentiaContainerItem) tItem).getAspects(player.getHeldItem()).getAspects()[0];
+ ((EssentiaHatch) tile).setLockedAspect(tLocked);
+ GT_Utility.sendChatToPlayer(player, String.format(StatCollector.translateToLocal("essentiahatch.chat.0"), tLocked.getLocalizedDescription()));
+ }
+ }
+ else {
+ ((EssentiaHatch) tile).setLockedAspect(null);
+ GT_Utility.sendChatToPlayer(player, StatCollector.translateToLocal("essentiahatch.chat.1"));
+ }
+ world.markBlockForUpdate(x, y, z);
+ return true;
+ }
+ else return false;
+ }
+ else return false;
+ }
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
+ return null;
+ }
+}
diff --git a/src/main/java/goodgenerator/blocks/tileEntity/EssentiaHatch.java b/src/main/java/goodgenerator/blocks/tileEntity/EssentiaHatch.java
new file mode 100644
index 0000000000..c8a4b1c713
--- /dev/null
+++ b/src/main/java/goodgenerator/blocks/tileEntity/EssentiaHatch.java
@@ -0,0 +1,225 @@
+package goodgenerator.blocks.tileEntity;
+
+import goodgenerator.crossmod.thaumcraft.LargeEssentiaEnergyData;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.network.NetworkManager;
+import net.minecraft.network.Packet;
+import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.common.util.ForgeDirection;
+import thaumcraft.api.ThaumcraftApiHelper;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.api.aspects.IAspectContainer;
+import thaumcraft.api.aspects.IEssentiaTransport;
+
+import java.util.ArrayList;
+
+public class EssentiaHatch extends TileEntity implements IAspectContainer, IEssentiaTransport {
+
+ private Aspect mLocked;
+ private AspectList current = new AspectList();
+ public int mState = 0;
+
+ public void setLockedAspect(Aspect aAspect) {
+ this.mLocked = aAspect;
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound tagCompound) {
+ super.readFromNBT(tagCompound);
+
+ this.mLocked = Aspect.getAspect(tagCompound.getString("mLocked"));
+ this.mState = tagCompound.getInteger("mState");
+ current = new AspectList();
+ NBTTagList tlist = tagCompound.getTagList("Aspects", 10);
+ for (int j = 0; j < tlist.tagCount(); ++j) {
+ NBTTagCompound rs = tlist.getCompoundTagAt(j);
+ if (rs.hasKey("key")) {
+ current.add(Aspect.getAspect(rs.getString("key")), rs.getInteger("amount"));
+ }
+ }
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound tagCompound) {
+ super.writeToNBT(tagCompound);
+
+ tagCompound.setString("mLocked", this.mLocked == null ? "" : this.mLocked.getTag());
+ tagCompound.setInteger("mState", mState);
+ NBTTagList tlist = new NBTTagList();
+ Aspect[] aspectA = current.getAspects();
+ for (Aspect aspect : aspectA) {
+ if (aspect != null) {
+ NBTTagCompound f = new NBTTagCompound();
+ f.setString("key", aspect.getTag());
+ f.setInteger("amount", current.getAmount(aspect));
+ tlist.appendTag(f);
+ }
+ }
+ tagCompound.setTag("Aspects", tlist);
+ }
+
+ public final Packet getDescriptionPacket() {
+ NBTTagCompound nbt = new NBTTagCompound();
+ writeToNBT(nbt);
+ return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbt);
+ }
+
+ public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
+ NBTTagCompound nbt = pkt.func_148857_g();
+ readFromNBT(nbt);
+ }
+
+ public void markDirty() {
+ super.markDirty();
+ if (this.worldObj.isRemote) {
+ return;
+ }
+ this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
+ }
+
+ @Override
+ public void updateEntity() {
+ fillfrompipe();
+ }
+
+ public void fillfrompipe() {
+ if (getEssentiaAmount(null) > 1000)
+ return;
+ TileEntity[] te = new TileEntity[ForgeDirection.VALID_DIRECTIONS.length];
+ for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
+ te[i] = ThaumcraftApiHelper.getConnectableTile(this.worldObj, this.xCoord, this.yCoord, this.zCoord, ForgeDirection.VALID_DIRECTIONS[i]);
+ if (te[i] != null) {
+ IEssentiaTransport pipe = (IEssentiaTransport) te[i];
+ if (!pipe.canOutputTo(ForgeDirection.VALID_DIRECTIONS[i])) {
+ return;
+ }
+ if ((pipe.getEssentiaType(ForgeDirection.VALID_DIRECTIONS[i].getOpposite()) != null) && (pipe.getSuctionAmount(ForgeDirection.VALID_DIRECTIONS[i]) < getSuctionAmount(ForgeDirection.VALID_DIRECTIONS[i]))) {
+ Aspect readyInput = pipe.getEssentiaType(ForgeDirection.VALID_DIRECTIONS[i].getOpposite());
+ int type = LargeEssentiaEnergyData.getAspectTypeIndex(readyInput);
+ if (type != -1 && (mState & (1 << type)) == 0) continue;
+ if (readyInput.equals(mLocked)) {
+ addToContainer(mLocked, pipe.takeEssentia(mLocked, 1, ForgeDirection.VALID_DIRECTIONS[i]));
+ }
+ if (mLocked == null)
+ addToContainer(pipe.getEssentiaType(ForgeDirection.VALID_DIRECTIONS[i]), pipe.takeEssentia(pipe.getEssentiaType(ForgeDirection.VALID_DIRECTIONS[i]), 1, ForgeDirection.VALID_DIRECTIONS[i]));
+ }
+ }
+ }
+ }
+
+ @Override
+ public AspectList getAspects() {
+ return current;
+ }
+
+ @Override
+ public void setAspects(AspectList aspectList) {
+ this.current.add(aspectList);
+ }
+
+ @Override
+ public boolean doesContainerAccept(Aspect aspect) {
+ return mLocked == null || mLocked.equals(aspect);
+ }
+
+ @Override
+ public int addToContainer(Aspect aspect, int i) {
+ current.add(aspect, i);
+ this.markDirty();
+ return 0;
+ }
+
+ @Override
+ public boolean takeFromContainer(Aspect aspect, int i) {
+ return false;
+ }
+
+ @Override
+ public boolean takeFromContainer(AspectList aspectList) {
+ return false;
+ }
+
+ @Override
+ public boolean doesContainerContainAmount(Aspect aspect, int i) {
+ return current.aspects.containsKey(aspect) && i <= current.getAmount(aspect);
+ }
+
+ @Override
+ public boolean doesContainerContain(AspectList aspectList) {
+ ArrayList<Boolean> ret = new ArrayList<Boolean>();
+ for (Aspect a : aspectList.aspects.keySet())
+ ret.add(current.aspects.containsKey(a));
+ return !ret.contains(false);
+ }
+
+ @Override
+ public int containerContains(Aspect aspect) {
+ return current.aspects.containsKey(aspect) ? current.getAmount(aspect) : 0;
+ }
+
+ @Override
+ public boolean isConnectable(ForgeDirection forgeDirection) {
+ return true;
+ }
+
+ @Override
+ public boolean canInputFrom(ForgeDirection forgeDirection) {
+ return true;
+ }
+
+ @Override
+ public boolean canOutputTo(ForgeDirection forgeDirection) {
+ return false;
+ }
+
+ @Override
+ public void setSuction(Aspect aspect, int i) { }
+
+ @Override
+ public Aspect getSuctionType(ForgeDirection forgeDirection) {
+ return this.mLocked;
+ }
+
+ @Override
+ public int getSuctionAmount(ForgeDirection forgeDirection) {
+ return 256;
+ }
+
+ @Override
+ public int takeEssentia(Aspect aspect, int i, ForgeDirection forgeDirection) {
+ return 0;
+ }
+
+ @Override
+ public int addEssentia(Aspect aspect, int i, ForgeDirection forgeDirection) {
+ current.add(aspect, i);
+ return 0;
+ }
+
+ @Override
+ public Aspect getEssentiaType(ForgeDirection forgeDirection) {
+ return current.getAspects()[0];
+ }
+
+ @Override
+ public int getEssentiaAmount(ForgeDirection forgeDirection) {
+ int ret = 0;
+ for (final Aspect A : current.aspects.keySet()) {
+ ret += current.getAmount(A);
+ }
+ return ret;
+ }
+
+ @Override
+ public int getMinimumSuction() {
+ return Integer.MAX_VALUE;
+ }
+
+ @Override
+ public boolean renderExtendedTube() {
+ return true;
+ }
+}
diff --git a/src/main/java/goodgenerator/blocks/tileEntity/FuelRefineFactory.java b/src/main/java/goodgenerator/blocks/tileEntity/FuelRefineFactory.java
new file mode 100644
index 0000000000..e68c92f8e8
--- /dev/null
+++ b/src/main/java/goodgenerator/blocks/tileEntity/FuelRefineFactory.java
@@ -0,0 +1,368 @@
+package goodgenerator.blocks.tileEntity;
+
+import goodgenerator.loader.Loaders;
+import goodgenerator.util.DescTextLocalization;
+import goodgenerator.util.MyRecipeAdder;
+import com.github.bartimaeusnek.crossmod.tectech.TecTechEnabledMulti;
+import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti;
+import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyTunnel;
+import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM;
+import com.gtnewhorizon.structurelib.StructureLibAPI;
+import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable;
+import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
+import com.gtnewhorizon.structurelib.structure.IStructureElement;
+import com.gtnewhorizon.structurelib.structure.StructureDefinition;
+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.*;
+import gregtech.api.objects.GT_RenderedTexture;
+import gregtech.api.render.TextureFactory;
+import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
+import gregtech.api.util.GT_Recipe;
+import gregtech.api.util.GT_Utility;
+import net.minecraft.block.Block;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.World;
+import net.minecraftforge.fluids.FluidStack;
+import org.lwjgl.input.Keyboard;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static goodgenerator.util.DescTextLocalization.BLUE_PRINT_INFO;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.*;
+import static gregtech.api.util.GT_StructureUtility.*;
+import static gregtech.api.enums.GT_Values.V;
+
+public class FuelRefineFactory extends GT_MetaTileEntity_MultiblockBase_EM implements TecTechEnabledMulti, IConstructable {
+
+ private IStructureDefinition<FuelRefineFactory> multiDefinition = null;
+ private int Tier = -1;
+ private int[] cnt = new int[]{0,0,0};
+ private static final Block[] coils = new Block[]{Loaders.FRF_Coil_1,Loaders.FRF_Coil_2,Loaders.FRF_Coil_3};
+
+ public FuelRefineFactory(String name){super(name);}
+
+ public FuelRefineFactory(int id, String name, String nameRegional){
+ super(id,name,nameRegional);
+ }
+
+ @Override
+ public List<GT_MetaTileEntity_Hatch_Energy> getVanillaEnergyHatches() {
+ return this.mEnergyHatches;
+ }
+
+ @Override
+ public List<GT_MetaTileEntity_Hatch_EnergyTunnel> getTecTechEnergyTunnels() {
+ return new ArrayList<>();
+ }
+
+ @Override
+ public List<GT_MetaTileEntity_Hatch_EnergyMulti> getTecTechEnergyMultis() {
+ return new ArrayList<>();
+ }
+
+ @Override
+ public void construct(ItemStack itemStack, boolean hintsOnly) {
+ structureBuild_EM(mName, 7, 12, 1, hintsOnly, itemStack);
+ }
+
+ @Override
+ public IStructureDefinition<FuelRefineFactory> getStructure_EM() {
+ if(multiDefinition == null) {
+ multiDefinition = StructureDefinition
+ .<FuelRefineFactory>builder()
+ .addShape(mName,
+ transpose(new String[][]{
+ {" "," CCC "," "},
+ {" XGX "," CCFFFCC "," XGX "},
+ {" CC CC "," CFFCCCFFC "," CC CC "},
+ {" C C "," CFCC CCFC "," C C "},
+ {" C C "," CFC CFC "," C C "},
+ {" C C "," CFC CFC "," C C "},
+ {" X X ","CFC CFC"," X X "},
+ {" G G ","CFC CFC"," G G "},
+ {" X X ","CFC CFC"," X X "},
+ {" C C "," CFC CFC "," C C "},
+ {" C C "," CFC CFC "," C C "},
+ {" C C "," CFCC CCFC "," C C "},
+ {" CC CC "," CFFC~CFFC "," CC CC "},
+ {" XGX "," CCFFFCC "," XGX "},
+ {" "," CCC "," "}
+ })
+ ).addElement(
+ 'X',
+ ofChain(
+ ofHatchAdder(
+ FuelRefineFactory::addToFRFList,179,
+ Loaders.FRF_Casings,0
+ ),
+ ofBlock(
+ Loaders.FRF_Casings,0
+ )
+ )
+ ).addElement(
+ 'C',
+ ofBlock(
+ Loaders.FRF_Casings,0
+ )
+ ).addElement(
+ 'G',
+ ofBlock(
+ Loaders.fieldRestrictingGlass,0
+ )
+ ).addElement(
+ 'F',
+ ofChain(
+ onElementPass(
+ x -> ++x.cnt[0],
+ ofFieldCoil(0)
+ ),
+ onElementPass(
+ x -> ++x.cnt[1],
+ ofFieldCoil(1)
+ ),
+ onElementPass(
+ x -> ++x.cnt[2],
+ ofFieldCoil(2)
+ )
+ )
+ )
+ .build();
+ }
+ return multiDefinition;
+ }
+
+ public static <T> IStructureElement<T> ofFieldCoil(int aIndex) {
+ return new IStructureElement<T>() {
+ @Override
+ public boolean check(T t, World world, int x, int y, int z) {
+ Block block = world.getBlock(x, y, z);
+ return block.equals(coils[aIndex]);
+ }
+
+ @Override
+ public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
+ StructureLibAPI.hintParticle(world, x, y, z, coils[getIndex(trigger)], 0);
+ return true;
+ }
+
+ private int getIndex(ItemStack trigger) {
+ int s = trigger.stackSize;
+ if (s > 3 || s <= 0) s = 3;
+ return s - 1;
+ }
+
+ @Override
+ public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
+ return world.setBlock(x, y, z, coils[getIndex(trigger)], 0, 3);
+ }
+ };
+ }
+
+ @Override
+ public String[] getDescription(){
+ final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
+ tt.addMachineType("Naquadah Fuel Refinery")
+ .addInfo("Controller block for the Naquadah Fuel Refinery")
+ .addInfo("But at what cost?")
+ .addInfo("Produce the endgame naquadah fuel.")
+ .addInfo("Need field restriction coil to control the fatal radiation.")
+ .addInfo("Use higher tier coil to unlock more fuel and reduce the process time.")
+ .addInfo("The structure is too complex!")
+ .addInfo(BLUE_PRINT_INFO)
+ .addSeparator()
+ .beginStructureBlock(3, 15, 15, false)
+ .addInputHatch("The casings adjoin the field restriction glass.")
+ .addInputBus("The casings adjoin the field restriction glass.")
+ .addOutputHatch("The casings adjoin the field restriction glass.")
+ .addEnergyHatch("The casings adjoin the field restriction glass.")
+ .toolTipFinisher("Good Generator");
+ if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
+ return tt.getInformation();
+ } else {
+ return tt.getStructureInformation();
+ }
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT){
+ this.Tier = aNBT.getInteger("mTier");
+ super.loadNBTData(aNBT);
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT){
+ aNBT.setInteger("mTier", this.Tier);
+ super.saveNBTData(aNBT);
+ }
+
+ @Override
+ public String[] getStructureDescription(ItemStack itemStack){
+ return DescTextLocalization.addText("FuelRefineFactory.hint", 8);
+ }
+
+ @Override
+ public boolean checkMachine_EM(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
+ cnt[0] = 0;cnt[1] = 0;cnt[2] = 0;
+ mWrench = true;
+ mScrewdriver = true;
+ mSoftHammer = true;
+ mHardHammer = true;
+ mSolderingTool = true;
+ mCrowbar = true;
+ return structureCheck_EM(mName, 7,12,1) && getTier() != -1;
+ }
+
+ public int getTier(){
+ for (int i = 0; i < 3; i ++) {
+ if (cnt[i] == 32) {
+ Tier = i + 1;
+ return i;
+ }
+ }
+ Tier = -1;
+ return -1;
+ }
+
+ @Override
+ public boolean checkRecipe_EM(ItemStack aStack){
+
+ mWrench = true;
+ mScrewdriver = true;
+ mSoftHammer = true;
+ mHardHammer = true;
+ mSolderingTool = true;
+ mCrowbar = true;
+
+ ArrayList<FluidStack> tFluids = getStoredFluids();
+ ArrayList<ItemStack> tItems = getStoredInputs();
+ MyRecipeAdder.NaqFuelRefineMapper tRecipes = MyRecipeAdder.instance.FRF;
+
+ for (int i = 0; i < tFluids.size() - 1; i++) {
+ for (int j = i + 1; j < tFluids.size(); j++) {
+ if (GT_Utility.areFluidsEqual(tFluids.get(i), tFluids.get(j))) {
+ if ((tFluids.get(i)).amount >= (tFluids.get(j)).amount) {
+ tFluids.remove(j--);
+ } else {
+ tFluids.remove(i--);
+ break;
+ }
+ }
+ }
+ }
+
+ for (int i = 0; i < tItems.size() - 1; i++) {
+ for (int j = i + 1; j < tItems.size(); j++) {
+ if (GT_Utility.areStacksEqual(tItems.get(i), tItems.get(j))) {
+ if ((tItems.get(i)).stackSize >= (tItems.get(j)).stackSize) {
+ tItems.remove(j--);
+ } else {
+ tItems.remove(i--);
+ break;
+ }
+ }
+ }
+ }
+
+ FluidStack[] inFluids = tFluids.toArray(new FluidStack[0]);
+ ItemStack[] inItems = tItems.toArray(new ItemStack[0]);
+ this.mEfficiency = 10000;
+
+ long tPower = getMaxInputEnergy_EM();
+ byte tTier = (byte) Math.max(1, GT_Utility.getTier(tPower));
+ GT_Recipe recipe = tRecipes.findRecipe(this.getBaseMetaTileEntity(), false, V[tTier], inFluids, inItems);
+ if (recipe != null) {
+ if (recipe.mSpecialValue > Tier) return false;
+ if (recipe.isRecipeInputEqual(true, inFluids, inItems)){
+ mEUt = recipe.mEUt * (1 << (Tier - recipe.mSpecialValue));
+ mEUt = -Math.abs(mEUt);
+ mMaxProgresstime = recipe.mDuration / (1 << (Tier - recipe.mSpecialValue));
+ this.mOutputFluids = recipe.mFluidOutputs;
+ this.updateSlots();
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public final boolean addToFRFList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex){
+ if (aTileEntity == null) {
+ return false;
+ } else {
+ IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
+ if (aMetaTileEntity == null) {
+ return false;
+ } else {
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) {
+ ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex);
+ }
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) {
+ return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input)aMetaTileEntity);
+ } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) {
+ return this.mOutputHatches.add((GT_MetaTileEntity_Hatch_Output)aMetaTileEntity);
+ } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) {
+ return this.mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus)aMetaTileEntity);
+ } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) {
+ return this.mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy)aMetaTileEntity);
+ } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) {
+ return this.eEnergyMulti.add((GT_MetaTileEntity_Hatch_EnergyMulti)aMetaTileEntity);
+ } else {
+ return false;
+ }
+ }
+ }
+ }
+
+ @Override
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new FuelRefineFactory(this.mName);
+ }
+
+ @Override
+ public int getMaxEfficiency(ItemStack aStack) {
+ return 10000;
+ }
+
+ @Override
+ public int getPollutionPerTick(ItemStack aStack) {
+ return 0;
+ }
+
+ @Override
+ public int getDamageToComponent(ItemStack aStack) {
+ return 0;
+ }
+
+ @Override
+ public boolean explodesOnComponentBreak(ItemStack aStack) {
+ return true;
+ }
+
+ @Override
+ public boolean isCorrectMachinePart(ItemStack aStack) {
+ return true;
+ }
+
+ @Override
+ public String[] getInfoData() {
+ String[] infoData = new String[super.getInfoData().length + 1];
+ System.arraycopy(super.getInfoData(),0,infoData,0, super.getInfoData().length);
+ infoData[super.getInfoData().length] = StatCollector.translateToLocal("scanner.info.FRF") + " " + this.Tier;
+ return infoData;
+ }
+
+ @Override
+ @SuppressWarnings("ALL")
+ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
+ if(aSide == aFacing){
+ if(aActive) return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(179), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE), TextureFactory.builder().addIcon(Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE_GLOW).glow().build()};
+ return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(179), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE), TextureFactory.builder().addIcon(Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_GLOW).glow().build()};
+ }
+ return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(179)};
+ }
+}
diff --git a/src/main/java/goodgenerator/blocks/tileEntity/GTMetaTileEntity/NeutronAccelerator.java b/src/main/java/goodgenerator/blocks/tileEntity/GTMetaTileEntity/NeutronAccelerator.java
new file mode 100644
index 0000000000..1ee64e26c4
--- /dev/null
+++ b/src/main/java/goodgenerator/blocks/tileEntity/GTMetaTileEntity/NeutronAccelerator.java
@@ -0,0 +1,66 @@
+package goodgenerator.blocks.tileEntity.GTMetaTileEntity;
+
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.metatileentity.MetaTileEntity;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy;
+import net.minecraft.nbt.NBTTagCompound;
+
+import static gregtech.api.enums.GT_Values.V;
+
+public class NeutronAccelerator extends GT_MetaTileEntity_Hatch_Energy {
+
+ public boolean isRunning;
+
+ public NeutronAccelerator(int aID, String aName, String aNameRegional, int aTier) {
+ super(aID, aName, aNameRegional, aTier);
+ }
+
+ public NeutronAccelerator(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) {
+ super(aName, aTier, aDescription, aTextures);
+ }
+
+ public int getMaxEUConsume() {
+ return (int)(V[mTier] * 8 / 10);
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ super.loadNBTData(aNBT);
+ this.isRunning = aNBT.getBoolean("isRunning");
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ super.saveNBTData(aNBT);
+ aNBT.setBoolean("isRunning", this.isRunning);
+ }
+
+ @Override
+ public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new NeutronAccelerator(mName, mTier, this.getDescription(), mTextures);
+ }
+
+ @Override
+ public String[] getDescription() {
+ return new String[]{
+ "Input EU to Accelerate the Neutron!",
+ "Max EU input: " + this.maxEUInput(),
+ "Max EU consumption: " + this.getMaxEUConsume(),
+ "Every EU can be transformed into 10~20 eV Neutron Kinetic Energy."
+ };
+ }
+
+ @Override
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ if (this.getBaseMetaTileEntity().isServerSide()) {
+ if (aBaseMetaTileEntity.getStoredEU() >= getMaxEUConsume() && aBaseMetaTileEntity.isAllowedToWork()) {
+ setEUVar(aBaseMetaTileEntity.getStoredEU() - getMaxEUConsume());
+ isRunning = true;
+ } else {
+ isRunning = false;
+ }
+ }
+ super.onPostTick(aBaseMetaTileEntity, aTick);
+ }
+}
diff --git a/src/main/java/goodgenerator/blocks/tileEntity/GTMetaTileEntity/NeutronSensor.java b/src/main/java/goodgenerator/blocks/tileEntity/GTMetaTileEntity/NeutronSensor.java
new file mode 100644
index 0000000000..d69f0b75f8
--- /dev/null
+++ b/src/main/java/goodgenerator/blocks/tileEntity/GTMetaTileEntity/NeutronSensor.java
@@ -0,0 +1,168 @@
+package goodgenerator.blocks.tileEntity.GTMetaTileEntity;
+
+import goodgenerator.client.GUI.NeutronSensorGUIClient;
+import goodgenerator.common.container.NeutronSensorGUIContainer;
+import goodgenerator.main.GoodGenerator;
+import goodgenerator.network.MessageOpenNeutronSensorGUI;
+import gregtech.api.enums.Textures;
+import gregtech.api.interfaces.IIconContainer;
+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;
+import gregtech.api.render.TextureFactory;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+public class NeutronSensor extends GT_MetaTileEntity_Hatch {
+
+ private static final IIconContainer textureFont = new Textures.BlockIcons.CustomIcon("icons/NeutronSensorFont");
+ private static final IIconContainer textureFont_Glow = new Textures.BlockIcons.CustomIcon("icons/NeutronSensorFont_GLOW");
+
+ protected String texts = "";
+ boolean isOn = false;
+
+ public NeutronSensor(int aID, String aName, String aNameRegional, int aTier) {
+ super(aID, aName, aNameRegional, aTier, 0, "Detect Neutron Kinetic Energy.");
+ }
+
+ public NeutronSensor(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) {
+ super(aName, aTier, 0, aDescription, aTextures);
+ }
+
+ @Override
+ public String[] getDescription() {
+ return new String[]{
+ "Can be installed in Neutron Activator.",
+ "Output Redstone Signal according to the Neutron Kinetic Energy.",
+ "Right click to open the GUI and setting."
+ };
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ texts = aNBT.getString("mBoxContext");
+ super.loadNBTData(aNBT);
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ aNBT.setString("mBoxContext", texts);
+ super.saveNBTData(aNBT);
+ }
+
+ @Override
+ public void initDefaultModes(NBTTagCompound aNBT) {
+ getBaseMetaTileEntity().setActive(true);
+ }
+
+ @Override
+ public boolean isValidSlot(int aIndex) {
+ return false;
+ }
+
+ @Override
+ public boolean isSimpleMachine() {
+ return true;
+ }
+
+ @Override
+ public boolean isFacingValid(byte aFacing) {
+ return true;
+ }
+
+ @Override
+ public boolean isAccessAllowed(EntityPlayer aPlayer) {
+ return true;
+ }
+
+ @Override
+ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new NeutronSensorGUIClient(aPlayerInventory, aBaseMetaTileEntity, GoodGenerator.MOD_ID + ":textures/gui/NeutronSensorGUI.png", this.texts);
+ }
+
+ @Override
+ public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new NeutronSensorGUIContainer(aPlayerInventory, aBaseMetaTileEntity);
+ }
+
+ @Override
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) {
+ if (aBaseMetaTileEntity.isClientSide()) return true;
+ if (aSide == aBaseMetaTileEntity.getFrontFacing() && aPlayer instanceof EntityPlayerMP) {
+ GoodGenerator.CHANNEL.sendTo(new MessageOpenNeutronSensorGUI(aBaseMetaTileEntity, texts), (EntityPlayerMP) aPlayer);
+ return true;
+ }
+ return false;
+ }
+
+ public void setText(String text) {
+ texts = text == null ? "" : text;
+ }
+
+ public String getText() {
+ return texts == null ? "" : texts;
+ }
+
+ public void outputRedstoneSignal(){
+ isOn = true;
+ }
+
+ public void stopOutputRedstoneSignal(){
+ isOn = false;
+ }
+
+ @Override
+ public ITexture[] getTexturesActive(ITexture aBaseTexture) {
+ return new ITexture[] {
+ aBaseTexture,
+ TextureFactory.of(textureFont),
+ TextureFactory.builder().addIcon(textureFont_Glow).glow().build()
+ };
+ }
+
+ @Override
+ public ITexture[] getTexturesInactive(ITexture aBaseTexture) {
+ return new ITexture[] {
+ aBaseTexture,
+ TextureFactory.of(textureFont)
+ };
+ }
+
+ @Override
+ public boolean allowGeneralRedstoneOutput(){
+ return true;
+ }
+
+ @Override
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ if (isOn) {
+ for (byte i = 0; i < 6; i ++)
+ aBaseMetaTileEntity.setInternalOutputRedstoneSignal(i, (byte) 15);
+ }
+ else {
+ for (byte i = 0; i < 6; i ++)
+ aBaseMetaTileEntity.setInternalOutputRedstoneSignal(i, (byte) 0);
+ }
+ super.onPostTick(aBaseMetaTileEntity, aTick);
+ }
+
+ @Override
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new NeutronSensor(mName, mTier, mDescriptionArray, mTextures);
+ }
+
+ @Override
+ public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return false;
+ }
+
+ @Override
+ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return false;
+ }
+
+}
diff --git a/src/main/java/goodgenerator/blocks/tileEntity/LargeEssentiaGenerator.java b/src/main/java/goodgenerator/blocks/tileEntity/LargeEssentiaGenerator.java
new file mode 100644
index 0000000000..6acbb86ed1
--- /dev/null
+++ b/src/main/java/goodgenerator/blocks/tileEntity/LargeEssentiaGenerator.java
@@ -0,0 +1,539 @@
+package goodgenerator.blocks.tileEntity;
+
+import goodgenerator.crossmod.thaumcraft.LargeEssentiaEnergyData;
+import goodgenerator.items.MyMaterial;
+import goodgenerator.loader.Loaders;
+import goodgenerator.util.DescTextLocalization;
+import goodgenerator.util.ItemRefer;
+import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader;
+import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti;
+import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM;
+import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable;
+import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
+import com.gtnewhorizon.structurelib.structure.StructureDefinition;
+import gregtech.api.enums.Materials;
+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.*;
+import gregtech.api.objects.GT_RenderedTexture;
+import gregtech.api.objects.XSTR;
+import gregtech.api.render.TextureFactory;
+import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
+import gregtech.api.util.GT_Utility;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.World;
+import net.minecraftforge.fluids.FluidRegistry;
+import org.lwjgl.input.Keyboard;
+import thaumcraft.api.aspects.Aspect;
+import thaumcraft.api.aspects.AspectList;
+import thaumcraft.common.config.ConfigBlocks;
+
+import java.util.ArrayList;
+
+import static goodgenerator.util.DescTextLocalization.BLUE_PRINT_INFO;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.*;
+import static gregtech.api.util.GT_StructureUtility.ofHatchAdder;
+
+public class LargeEssentiaGenerator extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable {
+
+ private IStructureDefinition<LargeEssentiaGenerator> multiDefinition = null;
+ protected int mStableValue = 0;
+ protected int mTierLimit = -1;
+ protected long mLeftEnergy;
+ private int mUpgrade = 1;
+ final XSTR R = new XSTR();
+ protected ArrayList<EssentiaHatch> mEssentiaHatch = new ArrayList<>();
+
+ public LargeEssentiaGenerator(String name){
+ super(name);
+ }
+
+ public LargeEssentiaGenerator(int id, String name, String nameRegional){
+ super(id,name,nameRegional);
+ }
+
+ @Override
+ public void construct(ItemStack itemStack, boolean b) {
+ structureBuild_EM(mName, 4, 0, 4, b, itemStack);
+ }
+
+ @Override
+ public boolean checkMachine_EM(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
+ mStableValue = 0;
+ mEssentiaHatch.clear();
+ return structureCheck_EM(mName, 4, 0, 4) && (mDynamoHatches.size() + eDynamoMulti.size()) == 1
+ && checkHatchTier() && updateEssentiaHatchState();
+ }
+
+ public boolean checkHatchTier() {
+ for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) {
+ if (tHatch.mTier > mTierLimit) return false;
+ }
+ for (GT_MetaTileEntity_Hatch_Dynamo tHatch : mDynamoHatches) {
+ if (tHatch.mTier > mTierLimit) return false;
+ }
+ for (GT_MetaTileEntity_Hatch_DynamoMulti tHatch : eDynamoMulti) {
+ if (tHatch.mTier > mTierLimit) return false;
+ }
+ return true;
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ super.loadNBTData(aNBT);
+ this.mStableValue = aNBT.getInteger("mStableValue");
+ this.mLeftEnergy = aNBT.getLong("mLeftEnergy");
+ this.mUpgrade = aNBT.getInteger("mUpgrade");
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ super.saveNBTData(aNBT);
+ aNBT.setInteger("mStableValue", this.mStableValue);
+ aNBT.setLong("mLeftEnergy", this.mLeftEnergy);
+ aNBT.setInteger("mUpgrade", this.mUpgrade);
+ }
+
+ public boolean updateEssentiaHatchState() {
+ for (EssentiaHatch hatch : mEssentiaHatch) {
+ hatch.mState = mUpgrade;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ if (aWrenchingSide == 0 || aWrenchingSide == 1) return false;
+ if (getBaseMetaTileEntity().isValidFacing(aWrenchingSide)) {
+ getBaseMetaTileEntity().setFrontFacing(aWrenchingSide);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
+ if (this.getBaseMetaTileEntity().isServerSide()) {
+ ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem();
+ if (tCurrentItem != null && tCurrentItem.getItem().equals(ItemRefer.Essentia_Upgrade_Empty.get(1).getItem())) {
+ int tMeta = tCurrentItem.getItemDamage();
+ if ((mUpgrade & (1 << tMeta)) == 0 && tMeta != 0) {
+ tCurrentItem.stackSize --;
+ mUpgrade = mUpgrade | (1 << tMeta);
+ GT_Utility.sendChatToPlayer(aPlayer, tCurrentItem.getDisplayName() + StatCollector.translateToLocal("largeessentiagenerator.chat"));
+ }
+ updateEssentiaHatchState();
+ return true;
+ }
+ }
+ super.onRightclick(aBaseMetaTileEntity, aPlayer);
+ return true;
+ }
+
+ @Override
+ public IStructureDefinition<LargeEssentiaGenerator> getStructure_EM() {
+ if(multiDefinition == null) {
+ multiDefinition = StructureDefinition
+ .<LargeEssentiaGenerator>builder()
+ .addShape(mName,
+ transpose(new String[][]{
+ {"A A"," "," "," "," ~ "," "," "," ","A A"},
+ {"T C T"," CEC "," CEEEC "," CEEEEEC ","CEEEEEEEC"," CEEEEEC "," CEEEC "," CEC ","T C T"},
+ {"T TXT T"," TCCCT "," TCCCCCT ","TCCCCCCCT","XCCCCCCCX","TCCCCCCCT"," TCCCCCT "," TCCCT ","T TXT T"}
+ })
+ ).addElement(
+ 'A',
+ ofBlock(
+ ConfigBlocks.blockCosmeticOpaque, 1
+ )
+ ).addElement(
+ 'T',
+ ofBlock(
+ ConfigBlocks.blockCosmeticSolid, 7
+ )
+ ).addElement(
+ 'C',
+ ofBlock(
+ Loaders.magicCasing, 0
+ )
+ ).addElement(
+ 'E',
+ ofChain(
+ onElementPass(
+ x -> {++x.mStableValue; x.mTierLimit = Math.max(x.mTierLimit, 3);},
+ ofBlock(
+ Loaders.essentiaCell, 0
+ )
+ ),
+ onElementPass(
+ x -> {x.mStableValue += 2; x.mTierLimit = Math.max(x.mTierLimit, 4);},
+ ofBlock(
+ Loaders.essentiaCell, 1
+ )
+ ),
+ onElementPass(
+ x -> {x.mStableValue += 5; x.mTierLimit = Math.max(x.mTierLimit, 5);},
+ ofBlock(
+ Loaders.essentiaCell, 2
+ )
+ ),
+ onElementPass(
+ x -> {x.mStableValue += 10; x.mTierLimit = Math.max(x.mTierLimit, 6);},
+ ofBlock(
+ Loaders.essentiaCell, 3
+ )
+ )
+ )
+ ).addElement(
+ 'X',
+ ofChain(
+ ofHatchAdder(
+ LargeEssentiaGenerator::addLargeEssentiaGeneratorList,1536,
+ 1
+ ),
+ ofBlock(
+ Loaders.magicCasing, 0
+ ),
+ ofTileAdder(
+ LargeEssentiaGenerator::addEssentiaHatch, Loaders.magicCasing, 0
+ )
+ )
+ )
+ .build();
+ }
+ return multiDefinition;
+ }
+
+ public final boolean addEssentiaHatch(TileEntity aTileEntity) {
+ if (aTileEntity instanceof EssentiaHatch) {
+ return this.mEssentiaHatch.add((EssentiaHatch) aTileEntity);
+ }
+ return false;
+ }
+
+ public final boolean addLargeEssentiaGeneratorList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
+ if (aTileEntity == null) {
+ return false;
+ } else {
+ IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input){
+ ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex);
+ return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input)aMetaTileEntity);
+ } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){
+ ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex);
+ return this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance)aMetaTileEntity);
+ } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo){
+ ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex);
+ return this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo)aMetaTileEntity);
+ } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti){
+ ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex);
+ return this.eDynamoMulti.add((GT_MetaTileEntity_Hatch_DynamoMulti)aMetaTileEntity);
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean checkRecipe_EM(ItemStack aStack) {
+ this.mEfficiency = 10000;
+ this.mMaxProgresstime = 1;
+ setEssentiaToEUVoltageAndAmp(getVoltageLimit(), getAmpLimit());
+ return true;
+ }
+
+ public int getVoltageLimit() {
+ long voltage = 0;
+ for (GT_MetaTileEntity_Hatch tHatch : this.eDynamoMulti) {
+ voltage += tHatch.maxEUOutput();
+ }
+ for (GT_MetaTileEntity_Hatch tHatch : this.mDynamoHatches) {
+ voltage += tHatch.maxEUOutput();
+ }
+ if (voltage > Integer.MAX_VALUE) voltage = Integer.MAX_VALUE;
+ return (int)voltage;
+ }
+
+ public int getAmpLimit() {
+ long amp = 0;
+ for (GT_MetaTileEntity_Hatch tHatch : this.eDynamoMulti) {
+ amp += tHatch.maxAmperesOut();
+ }
+ for (GT_MetaTileEntity_Hatch tHatch : this.mDynamoHatches) {
+ amp += tHatch.maxAmperesOut();
+ }
+ if (amp > Integer.MAX_VALUE) amp = Integer.MAX_VALUE;
+ return (int)amp;
+ }
+
+ public long getPerAspectEnergy(Aspect aspect) {
+ int type = LargeEssentiaEnergyData.getAspectTypeIndex(aspect);
+ if (!isValidEssentia(aspect)) return 0;
+ switch (type) {
+ case 0: return normalEssentia(aspect);
+ case 1: return airEssentia(aspect);
+ case 2: return thermalEssentia(aspect);
+ case 3: return unstableEssentia(aspect);
+ case 4: return victusEssentia(aspect);
+ case 5: return taintedEssentia(aspect);
+ case 6: return mechanicEssentia(aspect);
+ case 7: return spiritEssentia(aspect);
+ case 8: return radiationEssentia(aspect);
+ case 9: return electricEssentia(aspect);
+ default: return 0;
+ }
+ }
+
+ public long normalEssentia(Aspect aspect) {
+ return LargeEssentiaEnergyData.getAspectFuelValue(aspect);
+ }
+
+ public long airEssentia(Aspect aspect) {
+ long baseValue = LargeEssentiaEnergyData.getAspectFuelValue(aspect);
+ double ceoOutput = 0;
+ int ceoInput = (int) LargeEssentiaEnergyData.getAspectCeo(aspect) * 8;
+ if (depleteInput(Materials.LiquidAir.getFluid(ceoInput))) {
+ ceoOutput = 1.5D;
+ }
+ else if (depleteInput(Materials.Air.getGas(ceoInput))){
+ ceoOutput = 1.0D;
+ }
+ return (long) (baseValue * ceoOutput);
+ }
+
+ public long thermalEssentia(Aspect aspect) {
+ long baseValue = LargeEssentiaEnergyData.getAspectFuelValue(aspect);
+ double ceoOutput = 0;
+ int ceoInput = (int) LargeEssentiaEnergyData.getAspectCeo(aspect) * 2;
+ if (depleteInput(FluidRegistry.getFluidStack("cryotheum", ceoInput))) {
+ ceoOutput = 9.0D;
+ }
+ else if (depleteInput(Materials.SuperCoolant.getFluid(ceoInput))) {
+ ceoOutput = 5.0D;
+ }
+ else if (depleteInput(FluidRegistry.getFluidStack("ic2coolant", ceoInput))) {
+ ceoOutput = 1.5D;
+ }
+ else if (depleteInput(Materials.Ice.getSolid(ceoInput))) {
+ ceoOutput = 1.2D;
+ }
+ else if (depleteInput(FluidRegistry.getFluidStack("ic2distilledwater", ceoInput))){
+ ceoOutput = 1.0D;
+ }
+ else if (depleteInput(Materials.Water.getFluid(ceoInput))) {
+ ceoOutput = 0.5D;
+ }
+
+ return (long) (baseValue * ceoOutput);
+ }
+
+ public long unstableEssentia(Aspect aspect) {
+ long baseValue = LargeEssentiaEnergyData.getAspectFuelValue(aspect);
+ double ceoOutput = 0;
+ int ceoInput = (int) LargeEssentiaEnergyData.getAspectCeo(aspect) * 4;
+ if (depleteInput(WerkstoffLoader.Xenon.getFluidOrGas(ceoInput))){
+ ceoOutput = 4.0D;
+ }
+ else if (depleteInput(WerkstoffLoader.Krypton.getFluidOrGas(ceoInput))){
+ ceoOutput = 3.0D;
+ }
+ else if (depleteInput(Materials.Argon.getFluid(ceoInput))){
+ ceoOutput = 2.5D;
+ }
+ else if (depleteInput(WerkstoffLoader.Neon.getFluidOrGas(ceoInput))){
+ ceoOutput = 2.2D;
+ }
+ else if (depleteInput(Materials.Helium.getFluid(ceoInput))){
+ ceoOutput = 2.0D;
+ }
+ else if (depleteInput(Materials.Nitrogen.getFluid(ceoInput))){
+ ceoOutput = 1.0D;
+ }
+ return (long) (baseValue * ceoOutput);
+ }
+
+ public long victusEssentia(Aspect aspect) {
+ long baseValue = LargeEssentiaEnergyData.getAspectFuelValue(aspect);
+ double ceoOutput = 1.0D;
+ int ceoInput = (int) LargeEssentiaEnergyData.getAspectCeo(aspect) * 18;
+ if (depleteInput(FluidRegistry.getFluidStack("xpjuice", ceoInput))) {
+ ceoOutput = 2.0D;
+ }
+ else if (depleteInput(FluidRegistry.getFluidStack("lifeessence", ceoInput))){
+ ceoOutput = 6.0D;
+ }
+ return (long) (baseValue * ceoOutput);
+ }
+
+ public long taintedEssentia(Aspect aspect) {
+ long baseValue = LargeEssentiaEnergyData.getAspectFuelValue(aspect);
+ double ceoOutput = 1.0D;
+ int ceoInput = (int) LargeEssentiaEnergyData.getAspectCeo(aspect) * 3;
+ int chance = 2000;
+ if (depleteInput(FluidRegistry.getFluidStack("fluidpure", ceoInput))) {
+ ceoOutput = 60.0D;
+ chance = 0;
+ }
+ else if (depleteInput(FluidRegistry.getFluidStack("fluiddeath", ceoInput))){
+ ceoOutput = Math.pow(25000D / baseValue, 4);
+ chance = 4000;
+ }
+
+ if (R.nextInt(10000) < chance) {
+ World world = getBaseMetaTileEntity().getWorld();
+ int tX = R.nextInt(4);
+ int tZ = R.nextInt(4);
+ if (world.isAirBlock(tX, 0, tZ))
+ world.setBlock(tX, 0, tZ, ConfigBlocks.blockFluxGas, R.nextInt(8), 3);
+ }
+
+ return (long) (baseValue * ceoOutput);
+ }
+
+ public long mechanicEssentia(Aspect aspect) {
+ long baseValue = LargeEssentiaEnergyData.getAspectFuelValue(aspect);
+ double ceoOutput = 0;
+ int ceoInput = (int) LargeEssentiaEnergyData.getAspectCeo(aspect) * 20;
+ if (depleteInput(Materials.Lubricant.getFluid(ceoInput))) {
+ ceoOutput = 1.0D;
+ }
+ return (long) (baseValue * ceoOutput);
+ }
+
+ public long spiritEssentia(Aspect aspect) {
+ long baseValue = LargeEssentiaEnergyData.getAspectFuelValue(aspect);
+ double ceoOutput = 1.0D;
+ int ceoInput = (int) LargeEssentiaEnergyData.getAspectCeo(aspect) * 2;
+ if (depleteInput(FluidRegistry.getFluidStack("witchery:fluidspirit", ceoInput))) {
+ ceoOutput = 10D * (1 + mStableValue / 100D);
+ }
+ else if (depleteInput(FluidRegistry.getFluidStack("witchery:hollowtears", ceoInput))) {
+ ceoOutput = 15D * (1 + 100D / mStableValue);
+ }
+ return (long) (baseValue * ceoOutput);
+ }
+
+ public long radiationEssentia(Aspect aspect) {
+ long baseValue = LargeEssentiaEnergyData.getAspectFuelValue(aspect);
+ double ceoOutput = 1.0D;
+ int ceoInput = (int) LargeEssentiaEnergyData.getAspectCeo(aspect) * 6;
+ if (depleteInput(Materials.Caesium.getMolten(ceoInput))) {
+ ceoOutput = 2.0D;
+ }
+ else if (depleteInput(Materials.Uranium235.getMolten(ceoInput))) {
+ ceoOutput = 3.0D;
+ }
+ else if (depleteInput(Materials.Naquadah.getMolten(ceoInput))) {
+ ceoOutput = 4.0D;
+ }
+ else if (depleteInput(MyMaterial.atomicSeparationCatalyst.getMolten(ceoInput))) {
+ ceoOutput = 16.0D;
+ }
+ return (long) (baseValue * ceoOutput);
+ }
+
+ public long electricEssentia(Aspect aspect) {
+ long baseValue = LargeEssentiaEnergyData.getAspectFuelValue(aspect);
+ double ceoOutput = Math.pow(3.0, GT_Utility.getTier(getVoltageLimit()));
+ return (long) (baseValue * ceoOutput);
+ }
+
+ public void setEssentiaToEUVoltageAndAmp(long voltageLimit, long ampLimit) {
+ long EUt = mLeftEnergy;
+ long EUVoltage = voltageLimit, EUAmp = 1;
+
+ for (EssentiaHatch hatch: this.mEssentiaHatch){
+ AspectList aspects = hatch.getAspects();
+ for (Aspect aspect: aspects.aspects.keySet()) {
+ if (!isValidEssentia(aspect) || getPerAspectEnergy(aspect) == 0) continue;
+ while (EUt <= (voltageLimit * ampLimit) && aspects.getAmount(aspect) > 0) {
+ EUt += getPerAspectEnergy(aspect);
+ aspects.reduce(aspect, 1);
+ if (aspects.getAmount(aspect) == 0)
+ aspects.remove(aspect);
+ }
+ }
+ if (EUt == 0 && aspects.size() != 0) {
+ if (!isValidEssentia(aspects.getAspects()[0]) || getPerAspectEnergy(aspects.getAspects()[0]) == 0) continue;
+ EUt += getPerAspectEnergy(aspects.getAspects()[0]);
+ aspects.reduce(aspects.getAspects()[0], 1);
+ if (aspects.getAmount(aspects.getAspects()[0]) == 0)
+ aspects.remove(aspects.getAspects()[0]);
+ }
+ }
+
+ if (EUt <= voltageLimit) {
+ EUVoltage = EUt;
+ EUAmp = 1;
+ mLeftEnergy = 0;
+ }
+ else {
+ while (EUVoltage * (EUAmp + 1) <= EUt && EUAmp + 1 <= ampLimit) {
+ EUAmp ++;
+ }
+ mLeftEnergy = EUt - (EUVoltage * EUAmp);
+ }
+
+ this.mEUt = (int)EUVoltage;
+ this.eAmpereFlow = (int)EUAmp;
+ }
+
+ @Override
+ public int getMaxEfficiency(ItemStack aStack) {
+ return 10000;
+ }
+
+ @Override
+ public String[] getStructureDescription(ItemStack itemStack) {
+ return DescTextLocalization.addText("LargeEssentiaGenerator.hint", 6);
+ }
+
+ @Override
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new LargeEssentiaGenerator(this.mName);
+ }
+
+ @Override
+ public String[] getDescription() {
+ final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
+ tt.addMachineType("Essentia Generator")
+ .addInfo("Controller block for the Large Essentia Generator")
+ .addInfo("Maybe some thaumaturages are upset by it. . .")
+ .addInfo("Transform essentia into energy!")
+ .addInfo("The the Diffusion Cell determines the highest hatch tier that LEG can accept.")
+ .addInfo("You can find more information about this generator in Thaumonomicon.")
+ .addInfo("The structure is too complex!")
+ .addInfo(BLUE_PRINT_INFO)
+ .addSeparator()
+ .addMaintenanceHatch("Hint block with dot 1")
+ .addInputHatch("Hint block with dot 1")
+ .addDynamoHatch("Hint block with dot 1")
+ .addOtherStructurePart("Essentia Input Hatch","Hint block with dot 1")
+ .toolTipFinisher("Good Generator");
+ if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
+ return tt.getInformation();
+ } else {
+ return tt.getStructureInformation();
+ }
+ }
+
+ @Override
+ @SuppressWarnings("ALL")
+ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
+ if(aSide == aFacing) {
+ if(aActive) return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(1536), new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_DRAGONEGG), TextureFactory.builder().addIcon(Textures.BlockIcons.MACHINE_CASING_DRAGONEGG_GLOW).glow().build()};
+ return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(1536), new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_DRAGONEGG)};
+ }
+ return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(1536)};
+ }
+
+ public boolean isValidEssentia(Aspect aspect) {
+ int type = LargeEssentiaEnergyData.getAspectTypeIndex(aspect);
+ return type != -1 && (mUpgrade & (1 << type)) != 0;
+ }
+}
diff --git a/src/main/java/goodgenerator/blocks/tileEntity/MegaPlasmaTurbine.java b/src/main/java/goodgenerator/blocks/tileEntity/MegaPlasmaTurbine.java
new file mode 100644
index 0000000000..0e2dda7389
--- /dev/null
+++ b/src/main/java/goodgenerator/blocks/tileEntity/MegaPlasmaTurbine.java
@@ -0,0 +1,50 @@
+package goodgenerator.blocks.tileEntity;
+
+
+import com.github.bartimaeusnek.crossmod.tectech.TecTechEnabledMulti;
+import com.github.technus.tectech.mechanics.constructable.IConstructable;
+import com.github.technus.tectech.mechanics.structure.IStructureDefinition;
+import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti;
+import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyTunnel;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy;
+import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_LargeTurbine_Plasma;
+import net.minecraft.item.ItemStack;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MegaPlasmaTurbine extends GT_MetaTileEntity_LargeTurbine_Plasma implements TecTechEnabledMulti, IConstructable {
+
+ private IStructureDefinition<MegaPlasmaTurbine> multiDefinition = null;
+
+ public MegaPlasmaTurbine(String name){super(name);}
+
+ public MegaPlasmaTurbine(int id, String name, String nameRegional){
+ super(id,name,nameRegional);
+ }
+
+ @Override
+ public void construct(ItemStack itemStack, boolean b) {
+
+ }
+
+ @Override
+ public String[] getStructureDescription(ItemStack itemStack) {
+ return new String[0];
+ }
+
+ @Override
+ public List<GT_MetaTileEntity_Hatch_Energy> getVanillaEnergyHatches() {
+ return this.mEnergyHatches;
+ }
+
+ @Override
+ public List<GT_MetaTileEntity_Hatch_EnergyTunnel> getTecTechEnergyTunnels() {
+ return new ArrayList<>();
+ }
+
+ @Override
+ public List<GT_MetaTileEntity_Hatch_EnergyMulti> getTecTechEnergyMultis() {
+ return new ArrayList<>();
+ }
+}
diff --git a/src/main/java/goodgenerator/blocks/tileEntity/MetalVaporTurbine.java b/src/main/java/goodgenerator/blocks/tileEntity/MetalVaporTurbine.java
new file mode 100644
index 0000000000..29aa1f3e1c
--- /dev/null
+++ b/src/main/java/goodgenerator/blocks/tileEntity/MetalVaporTurbine.java
@@ -0,0 +1,5 @@
+package goodgenerator.blocks.tileEntity;
+
+public class MetalVaporTurbine{
+
+}
diff --git a/src/main/java/goodgenerator/blocks/tileEntity/MultiNqGenerator.java b/src/main/java/goodgenerator/blocks/tileEntity/MultiNqGenerator.java
new file mode 100644
index 0000000000..3fd83472d8
--- /dev/null
+++ b/src/main/java/goodgenerator/blocks/tileEntity/MultiNqGenerator.java
@@ -0,0 +1,427 @@
+package goodgenerator.blocks.tileEntity;
+
+import goodgenerator.items.MyMaterial;
+import goodgenerator.loader.Loaders;
+import goodgenerator.util.CrackRecipeAdder;
+import goodgenerator.util.DescTextLocalization;
+import goodgenerator.util.MyRecipeAdder;
+import com.github.bartimaeusnek.bartworks.util.Pair;
+import com.github.bartimaeusnek.crossmod.tectech.TecTechEnabledMulti;
+import com.github.technus.tectech.thing.metaTileEntity.hatch.*;
+import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM;
+import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable;
+import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
+import com.gtnewhorizon.structurelib.structure.StructureDefinition;
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.Materials;
+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.*;
+import gregtech.api.objects.GT_RenderedTexture;
+import gregtech.api.render.TextureFactory;
+import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
+import gregtech.api.util.GT_Recipe;
+import gregtech.api.util.GT_Utility;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraftforge.fluids.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+import org.lwjgl.input.Keyboard;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import static goodgenerator.main.GG_Config_Loader.LiquidAirConsumptionPerSecond;
+import static goodgenerator.main.GG_Config_Loader.CoolantEfficiency;
+import static goodgenerator.main.GG_Config_Loader.ExcitedLiquidCoe;
+import static goodgenerator.util.DescTextLocalization.BLUE_PRINT_INFO;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.*;
+import static gregtech.api.util.GT_StructureUtility.ofHatchAdder;
+
+public class MultiNqGenerator extends GT_MetaTileEntity_MultiblockBase_EM implements TecTechEnabledMulti, IConstructable {
+
+ protected IStructureDefinition<MultiNqGenerator> multiDefinition = null;
+ protected long leftEnergy = 0;
+ protected long trueOutput = 0;
+ protected int trueEff = 0;
+ protected FluidStack lockedFluid = null;
+ protected int times = 1;
+ protected int basicOutput;
+
+ private static final List<Pair<FluidStack, Integer>> excitedLiquid;
+
+ private static final List<Pair<FluidStack, Integer>> coolant;
+
+ static {
+ excitedLiquid = Arrays.asList(
+ new Pair<>(MyMaterial.atomicSeparationCatalyst.getMolten(20), ExcitedLiquidCoe[0]),
+ new Pair<>(Materials.Naquadah.getMolten(20L), ExcitedLiquidCoe[1]),
+ new Pair<>(Materials.Uranium235.getMolten(180L), ExcitedLiquidCoe[2]),
+ new Pair<>(Materials.Caesium.getMolten(180L), ExcitedLiquidCoe[3])
+ );
+ coolant = Arrays.asList(
+ new Pair<>(FluidRegistry.getFluidStack("cryotheum", 1000), CoolantEfficiency[0]),
+ new Pair<>(Materials.SuperCoolant.getFluid(1000L), CoolantEfficiency[1]),
+ new Pair<>(FluidRegistry.getFluidStack("ic2coolant",1000), CoolantEfficiency[2])
+ );
+ }
+
+ @Override
+ public void construct(ItemStack itemStack, boolean hintsOnly) {
+ structureBuild_EM(mName, 3,7,0, hintsOnly, itemStack);
+ }
+
+ @Override
+ public String[] getStructureDescription(ItemStack itemStack) {
+ return DescTextLocalization.addText("MultiNqGenerator.hint", 8);
+ }
+
+ public final boolean addToGeneratorList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex){
+ if (aTileEntity == null) {
+ return false;
+ } else {
+ IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
+ if (aMetaTileEntity == null) {
+ return false;
+ } else {
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) {
+ ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex);
+ }
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) {
+ return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input)aMetaTileEntity);
+ } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) {
+ return this.mOutputHatches.add((GT_MetaTileEntity_Hatch_Output)aMetaTileEntity);
+ } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) {
+ return this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo)aMetaTileEntity);
+ } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) {
+ return this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance)aMetaTileEntity);
+ } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti) {
+ return this.eDynamoMulti.add((GT_MetaTileEntity_Hatch_DynamoMulti)aMetaTileEntity);
+ } else {
+ return false;
+ }
+ }
+ }
+ }
+
+ @Override
+ public IStructureDefinition<MultiNqGenerator> getStructure_EM() {
+ if(multiDefinition == null) {
+ multiDefinition = StructureDefinition
+ .<MultiNqGenerator>builder()
+ .addShape(mName,
+ transpose(new String[][]{
+ {"AAAAAAA","AAAAAAA","AAAAAAA","AAAAAAA","AAAAAAA","AAAAAAA","AAAAAAA"},
+ {"N N"," "," CCC "," CPC "," CCC "," ","N N"},
+ {"N N"," "," CCC "," CPC "," CCC "," ","N N"},
+ {"N N"," "," CCC "," CPC "," CCC "," ","N N"},
+ {"N N"," "," CCC "," CPC "," CCC "," ","N N"},
+ {"AAAAAAA","A A","A CCC A","A CPC A","A CCC A","A A","AAAAAAA"},
+ {"ANNNNNA","N N","N CCC N","N CPC N","N CCC N","N N","ANNNNNA"},
+ {"XXX~XXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX"},
+ })
+ ).addElement(
+ 'X',
+ ofChain(
+ ofHatchAdder(
+ MultiNqGenerator::addToGeneratorList, 44,
+ GregTech_API.sBlockCasings3, 12
+ ),
+ ofBlock(
+ GregTech_API.sBlockCasings3, 12
+ )
+ )
+ ).addElement(
+ 'A',
+ ofBlock(
+ GregTech_API.sBlockCasings3, 12
+ )
+ ).addElement(
+ 'N',
+ ofBlock(
+ Loaders.radiationProtectionSteelFrame, 0
+ )
+ ).addElement(
+ 'C',
+ ofBlock(
+ Loaders.MAR_Casing, 0
+ )
+ ).addElement(
+ 'P',
+ ofBlock(
+ GregTech_API.sBlockCasings2,15
+ )
+ )
+ .build();
+ }
+ return multiDefinition;
+ }
+
+ public MultiNqGenerator(String name) {
+ super(name);
+ }
+
+ public MultiNqGenerator(int id, String name, String nameRegional) {
+ super(id,name,nameRegional);
+ }
+
+ @Override
+ public boolean isCorrectMachinePart(ItemStack aStack) {
+ return true;
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT){
+ this.times = aNBT.getInteger("mTimes");
+ this.leftEnergy = aNBT.getLong("mLeftEnergy");
+ this.basicOutput = aNBT.getInteger("mbasicOutput");
+ if (FluidRegistry.getFluid(aNBT.getString("mLockedFluidName")) != null)
+ this.lockedFluid = new FluidStack(FluidRegistry.getFluid(aNBT.getString("mLockedFluidName")), aNBT.getInteger("mLockedFluidAmount"));
+ else this.lockedFluid = null;
+ super.loadNBTData(aNBT);
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT){
+ aNBT.setInteger("mTimes", this.times);
+ aNBT.setLong("mLeftEnergy", this.leftEnergy);
+ aNBT.setInteger("mbasicOutput", this.basicOutput);
+ if (lockedFluid != null){
+ aNBT.setString("mLockedFluidName", this.lockedFluid.getFluid().getName());
+ aNBT.setInteger("mLockedFluidAmount", this.lockedFluid.amount);
+ }
+ super.saveNBTData(aNBT);
+ }
+
+ @Override
+ public boolean checkRecipe_EM(ItemStack aStack) {
+
+ ArrayList<FluidStack> tFluids = getStoredFluids();
+
+ for (int i = 0; i < tFluids.size() - 1; i++) {
+ for (int j = i + 1; j < tFluids.size(); j++) {
+ if (GT_Utility.areFluidsEqual(tFluids.get(i), tFluids.get(j))) {
+ if ((tFluids.get(i)).amount >= (tFluids.get(j)).amount) {
+ tFluids.remove(j--);
+ } else {
+ tFluids.remove(i--);
+ break;
+ }
+ }
+ }
+ }
+
+ GT_Recipe tRecipe = MyRecipeAdder.instance.NqGFuels.findRecipe(this.getBaseMetaTileEntity(), true, 1 << 30, tFluids.toArray(new FluidStack[0]));
+ if (tRecipe != null) {
+ Pair<FluidStack, Integer> excitedInfo = getExcited(tFluids.toArray(new FluidStack[0]), false);
+ int pall = excitedInfo == null ? 1 : excitedInfo.getValue();
+ if (consumeFuel(CrackRecipeAdder.copyFluidWithAmount(tRecipe.mFluidInputs[0], pall), tFluids.toArray(new FluidStack[0]))) {
+ mOutputFluids = new FluidStack[]{CrackRecipeAdder.copyFluidWithAmount(tRecipe.mFluidOutputs[0], pall)};
+ basicOutput = tRecipe.mSpecialValue;
+ times = pall;
+ lockedFluid = excitedInfo == null ? null : excitedInfo.getKey();
+ mMaxProgresstime = tRecipe.mDuration;
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean onRunningTick(ItemStack stack) {
+ if (this.getBaseMetaTileEntity().isServerSide()) {
+ if (mMaxProgresstime != 0 && mProgresstime % 20 == 0) {
+ FluidStack[] input = getStoredFluids().toArray(new FluidStack[0]);
+ int eff = 100, time = 1;
+ if (LiquidAirConsumptionPerSecond != 0 && !consumeFuel(Materials.LiquidAir.getFluid(LiquidAirConsumptionPerSecond), input)) {
+ this.mEUt = 0;
+ this.trueEff = 0;
+ this.trueOutput = 0;
+ return true;
+ }
+ if (getCoolant(input, true) != null) eff = getCoolant(input, false).getValue();
+ if (consumeFuel(lockedFluid, input)) time = times;
+ this.mEUt = basicOutput * eff * time / 100;
+ this.trueEff = eff;
+ this.trueOutput = (long) basicOutput * (long) eff * (long) time / 100;
+ }
+ addAutoEnergy(trueOutput);
+ }
+ return true;
+ }
+
+ @Override
+ public String[] getInfoData() {
+ String[] info = super.getInfoData();
+ info[4] = "Probably makes: " + EnumChatFormatting.RED + Math.abs(this.trueOutput) + EnumChatFormatting.RESET + " EU/t";
+ info[6] = "Problems: " + EnumChatFormatting.RED + (this.getIdealStatus() - this.getRepairStatus()) + EnumChatFormatting.RESET + " Efficiency: " + EnumChatFormatting.YELLOW + trueEff + EnumChatFormatting.RESET + " %";
+ return info;
+ }
+
+ public boolean consumeFuel(FluidStack target, FluidStack[] input) {
+ if (target == null) return false;
+ for (FluidStack inFluid : input) {
+ if (inFluid != null && inFluid.isFluidEqual(target) && inFluid.amount >= target.amount){
+ inFluid.amount -= target.amount;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public Pair<FluidStack, Integer> getExcited(FluidStack[] input, boolean isConsume) {
+ for (Pair<FluidStack, Integer> fluidPair : excitedLiquid) {
+ FluidStack tFluid = fluidPair.getKey();
+ for (FluidStack inFluid : input) {
+ if (inFluid != null && inFluid.isFluidEqual(tFluid) && inFluid.amount >= tFluid.amount) {
+ if (isConsume) inFluid.amount -= tFluid.amount;
+ return fluidPair;
+ }
+ }
+ }
+ return null;
+ }
+
+ public Pair<FluidStack, Integer> getCoolant(FluidStack[] input, boolean isConsume) {
+ for (Pair<FluidStack, Integer> fluidPair : coolant) {
+ FluidStack tFluid = fluidPair.getKey();
+ for (FluidStack inFluid : input) {
+ if (inFluid != null && inFluid.isFluidEqual(tFluid) && inFluid.amount >= tFluid.amount) {
+ if (isConsume) inFluid.amount -= tFluid.amount;
+ return fluidPair;
+ }
+ }
+ }
+ return null;
+ }
+
+ public void addAutoEnergy(long outputPower){
+ if (this.eDynamoMulti.size() > 0)
+ for (GT_MetaTileEntity_Hatch tHatch : this.eDynamoMulti){
+ long voltage = tHatch.maxEUOutput();
+ long power = voltage * tHatch.maxAmperesOut();
+ long outputAmperes;
+ if (outputPower > power) doExplosion(8 * GT_Utility.getTier(power));
+ if (outputPower >= voltage){
+ leftEnergy += outputPower;
+ outputAmperes = leftEnergy / voltage;
+ leftEnergy -= outputAmperes * voltage;
+ addEnergyOutput_EM(voltage, outputAmperes);
+ }
+ else{
+ addEnergyOutput_EM(outputPower, 1);
+ }
+ }
+ if (this.mDynamoHatches.size() > 0)
+ for (GT_MetaTileEntity_Hatch tHatch : this.mDynamoHatches){
+ long voltage = tHatch.maxEUOutput();
+ long power = voltage * tHatch.maxAmperesOut();
+ long outputAmperes;
+ if (outputPower > power) doExplosion(8 * GT_Utility.getTier(power));
+ if (outputPower >= voltage){
+ leftEnergy += outputPower;
+ outputAmperes = leftEnergy / voltage;
+ leftEnergy -= outputAmperes * voltage;
+ addEnergyOutput_EM(voltage, outputAmperes);
+ }
+ else{
+ addEnergyOutput_EM(outputPower, 1);
+ }
+ }
+ }
+
+ @Override
+ public boolean checkMachine_EM(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
+ return structureCheck_EM(mName, 3, 7, 0) && mMaintenanceHatches.size() == 1 && mDynamoHatches.size() + eDynamoMulti.size() == 1;
+ }
+
+ @Override
+ public int getMaxEfficiency(ItemStack aStack) {
+ return 0;
+ }
+
+ @Override
+ public int getPollutionPerTick(ItemStack aStack) {
+ return 0;
+ }
+
+ @Override
+ public int getDamageToComponent(ItemStack aStack) {
+ return 0;
+ }
+
+ @Override
+ public boolean explodesOnComponentBreak(ItemStack aStack) {
+ return false;
+ }
+
+ @Override
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new MultiNqGenerator(this.mName);
+ }
+
+ @Override
+ public String[] getDescription() {
+ final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
+ tt.addMachineType("Naquadah Reactor")
+ .addInfo("Controller block for the Naquadah Reactor")
+ .addInfo("Environmental Friendly!")
+ .addInfo("Generate power with the High-energy liquid.")
+ .addInfo(String.format("Consume liquid air %d L/s to keep running, otherwise" + EnumChatFormatting.YELLOW + " it will void your fuel" + EnumChatFormatting.GRAY + ".", LiquidAirConsumptionPerSecond))
+ .addInfo("Input liquid nuclear fuel or liquid naquadah fuel.")
+ .addInfo("The reactor will explode when there are more than" + EnumChatFormatting.RED + " ONE" + EnumChatFormatting.GRAY + " types of fuel in the hatch!")
+ .addInfo("Consume coolant 1000 L/s to increase the efficiency:")
+ .addInfo(String.format("IC2 Coolant %d%%, Super Coolant %d%%, Cryotheum %d%%", CoolantEfficiency[2], CoolantEfficiency[1], CoolantEfficiency[0]))
+ .addInfo("Consume excited liquid to increase the output power:")
+ .addInfo(String.format("molten caesium | %dx power | 180 L/s ", ExcitedLiquidCoe[3]))
+ .addInfo(String.format("molten uranium-235 | %dx power | 180 L/s", ExcitedLiquidCoe[2]))
+ .addInfo(String.format("molten naquadah | %dx power | 20 L/s", ExcitedLiquidCoe[1]))
+ .addInfo(String.format("molten Atomic Separation Catalyst | %dx power | 20 L/s", ExcitedLiquidCoe[0]))
+ .addInfo("The structure is too complex!")
+ .addInfo(BLUE_PRINT_INFO)
+ .addSeparator()
+ .beginStructureBlock(7, 8, 7, true)
+ .addController("Front bottom")
+ .addDynamoHatch("Any bottom layer casing, only accept ONE!")
+ .addInputHatch("Any bottom layer casing")
+ .addOutputHatch("Any bottom layer casing")
+ .addMaintenanceHatch("Any bottom layer casing")
+ .toolTipFinisher("Good Generator");
+ if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
+ return tt.getInformation();
+ } else {
+ return tt.getStructureInformation();
+ }
+ }
+
+ @Override
+ @SuppressWarnings("ALL")
+ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
+ if(aSide == aFacing){
+ if(aActive) return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(44), new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_FRONT_ACTIVE), TextureFactory.builder().addIcon(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_FRONT_ACTIVE_GLOW).glow().build()};
+ return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(44), new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_FRONT)};
+ }
+ return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(44)};
+ }
+
+ @Override
+ public List<GT_MetaTileEntity_Hatch_Energy> getVanillaEnergyHatches() {
+ return this.mEnergyHatches;
+ }
+
+ @Override
+ public List<GT_MetaTileEntity_Hatch_EnergyTunnel> getTecTechEnergyTunnels() {
+ return new ArrayList<>();
+ }
+
+ @Override
+ public List<GT_MetaTileEntity_Hatch_EnergyMulti> getTecTechEnergyMultis() {
+ return new ArrayList<>();
+ }
+
+}
diff --git a/src/main/java/goodgenerator/blocks/tileEntity/NeutronActivator.java b/src/main/java/goodgenerator/blocks/tileEntity/NeutronActivator.java
new file mode 100644
index 0000000000..6c809bb676
--- /dev/null
+++ b/src/main/java/goodgenerator/blocks/tileEntity/NeutronActivator.java
@@ -0,0 +1,441 @@
+package goodgenerator.blocks.tileEntity;
+
+import goodgenerator.blocks.tileEntity.GTMetaTileEntity.NeutronAccelerator;
+import goodgenerator.blocks.tileEntity.GTMetaTileEntity.NeutronSensor;
+import goodgenerator.client.GUI.NeutronActivatorGUIClient;
+import goodgenerator.common.container.NeutronActivatorGUIContainer;
+import goodgenerator.loader.Loaders;
+import goodgenerator.util.CharExchanger;
+import goodgenerator.util.DescTextLocalization;
+import goodgenerator.util.ItemRefer;
+import goodgenerator.util.MyRecipeAdder;
+import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM;
+import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable;
+import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
+import com.gtnewhorizon.structurelib.structure.StructureDefinition;
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.Materials;
+import gregtech.api.enums.Textures;
+import gregtech.api.interfaces.IIconContainer;
+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;
+import gregtech.api.render.TextureFactory;
+import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
+import gregtech.api.util.GT_Recipe;
+import gregtech.api.util.GT_Utility;
+import ic2.core.Ic2Items;
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.StatCollector;
+import net.minecraftforge.fluids.FluidStack;
+import org.lwjgl.input.Keyboard;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import static goodgenerator.util.DescTextLocalization.BLUE_PRINT_INFO;
+import static goodgenerator.util.StructureHelper.addFrame;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.*;
+import static gregtech.api.util.GT_StructureUtility.ofHatchAdder;
+import static org.apache.commons.lang3.RandomUtils.nextInt;
+
+public class NeutronActivator extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable {
+
+ protected IStructureDefinition<NeutronActivator> multiDefinition = null;
+ protected final ArrayList<NeutronAccelerator> mNeutronAccelerator = new ArrayList<>();
+ protected final ArrayList<NeutronSensor> mNeutronSensor = new ArrayList<>();
+ protected int casingAmount = 0;
+ protected int height = 0;
+ protected int eV = 0, mCeil = 0, mFloor = 0;
+
+ private static final IIconContainer textureFontOn = new Textures.BlockIcons.CustomIcon("icons/NeutronActivator_On");
+ private static final IIconContainer textureFontOn_Glow = new Textures.BlockIcons.CustomIcon("icons/NeutronActivator_On_GLOW");
+ private static final IIconContainer textureFontOff = new Textures.BlockIcons.CustomIcon("icons/NeutronActivator_Off");
+ private static final IIconContainer textureFontOff_Glow = new Textures.BlockIcons.CustomIcon("icons/NeutronActivator_Off_GLOW");
+
+ protected final String NA_BOTTOM = mName + "buttom";
+ protected final String NA_MID = mName + "mid";
+ protected final String NA_TOP = mName + "top";
+
+ public NeutronActivator(String name) {
+ super(name);
+ }
+
+ public NeutronActivator(int id, String name, String nameRegional) {
+ super(id, name, nameRegional);
+ }
+
+ @Override
+ public boolean checkRecipe_EM(ItemStack aStack) {
+ this.mEfficiency = 10000;
+
+ ArrayList<FluidStack> tFluids = getStoredFluids();
+ ArrayList<ItemStack> tItems = getStoredInputs();
+ Collection<GT_Recipe> tRecipes = MyRecipeAdder.instance.NA.mRecipeList;
+
+ for (int i = 0; i < tFluids.size() - 1; i++) {
+ for (int j = i + 1; j < tFluids.size(); j++) {
+ if (GT_Utility.areFluidsEqual(tFluids.get(i), tFluids.get(j))) {
+ if ((tFluids.get(i)).amount >= (tFluids.get(j)).amount) {
+ tFluids.remove(j--);
+ } else {
+ tFluids.remove(i--);
+ break;
+ }
+ }
+ }
+ }
+
+ for (int i = 0; i < tItems.size() - 1; i++) {
+ for (int j = i + 1; j < tItems.size(); j++) {
+ if (GT_Utility.areStacksEqual(tItems.get(i), tItems.get(j))) {
+ if ((tItems.get(i)).stackSize >= (tItems.get(j)).stackSize) {
+ tItems.remove(j--);
+ } else {
+ tItems.remove(i--);
+ break;
+ }
+ }
+ }
+ }
+
+ FluidStack[] inFluids = tFluids.toArray(new FluidStack[0]);
+ ItemStack[] inItems = tItems.toArray(new ItemStack[0]);
+ int minNKE, maxNKE;
+
+ for (GT_Recipe recipe : tRecipes) {
+ minNKE = (recipe.mSpecialValue % 10000) * 1000000;
+ maxNKE = (recipe.mSpecialValue / 10000) * 1000000;
+ if (recipe.isRecipeInputEqual(true, inFluids, inItems)) {
+ mFloor = minNKE;
+ mCeil = maxNKE;
+ mMaxProgresstime = Math.max((int)(recipe.mDuration * Math.pow(0.9, height - 4)), 1);
+ if (eV <= maxNKE && eV >= minNKE) {
+ this.mOutputFluids = recipe.mFluidOutputs;
+ this.mOutputItems = recipe.mOutputs;
+ } else {
+ this.mOutputFluids = null;
+ this.mOutputItems = new ItemStack[]{ItemRefer.Radioactive_Waste.get(4)};
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int getMaxEfficiency(ItemStack aStack) {
+ return 10000;
+ }
+
+ @Override
+ public int getPollutionPerTick(ItemStack aStack) {
+ return 0;
+ }
+
+ @Override
+ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new NeutronActivatorGUIClient(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "EMDisplay.png");
+ }
+
+ @Override
+ public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new NeutronActivatorGUIContainer(aPlayerInventory, aBaseMetaTileEntity);
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ eV = aNBT.getInteger("mKeV");
+ mCeil = aNBT.getInteger("mCeil");
+ mFloor = aNBT.getInteger("mFloor");
+ height = aNBT.getInteger("height");
+ super.loadNBTData(aNBT);
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ aNBT.setInteger("mKeV", eV);
+ aNBT.setInteger("mCeil", mCeil);
+ aNBT.setInteger("mFloor", mFloor);
+ aNBT.setInteger("height", height);
+ super.saveNBTData(aNBT);
+ }
+
+ @Override
+ public String[] getDescription() {
+ final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
+ tt.addMachineType("Neutron Activator")
+ .addInfo("Controller block for the Neutron Activator")
+ .addInfo("Superluminal-velocity Motion.")
+ .addInfo("The minimum height of the Speeding Pipe Casing is 4.")
+ .addInfo("Per extra Speeding Pipe Casing will give time discount.")
+ .addInfo("But it will reduce the Neutron Accelerator efficiency.")
+ .addInfo("You need to input energy to the Neutron Accelerator to get it running.")
+ .addInfo("It will output correct products with Specific Neutron Kinetic Energy.")
+ .addInfo("Otherwise it will output trash.")
+ .addInfo("The Neutron Kinetic Energy will decrease 72KeV/s when no Neutron Accelerator is running.")
+ .addInfo("It will explode when the Neutron Kinetic Energy is over" + EnumChatFormatting.RED + " 1200MeV" + EnumChatFormatting.GRAY + ".")
+ .addInfo("The structure is too complex!")
+ .addInfo(BLUE_PRINT_INFO)
+ .addSeparator()
+ .addController("Front bottom")
+ .addInputHatch("Hint block with dot 1")
+ .addInputBus("Hint block with dot 1")
+ .addOutputHatch("Hint block with dot 2")
+ .addOutputBus("Hint block with dot 2")
+ .addMaintenanceHatch("Hint block with dot 2")
+ .addOtherStructurePart("Neutron Accelerator", "Hint block with dot 2")
+ .addOtherStructurePart("Neutron Sensor", "Hint block with dot 2")
+ .addCasingInfo("Clean Stainless Steel Machine Casing", 7)
+ .toolTipFinisher("Good Generator");
+ if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
+ return tt.getInformation();
+ } else {
+ return tt.getStructureInformation();
+ }
+ }
+
+ @Override
+ public IStructureDefinition<NeutronActivator> getStructure_EM() {
+ if (multiDefinition == null) {
+ multiDefinition = StructureDefinition
+ .<NeutronActivator>builder()
+ .addShape(NA_TOP,
+ transpose(new String[][]{
+ {"CCCCC", "CDDDC", "CDDDC", "CDDDC", "CCCCC"}
+ })
+ )
+ .addShape(NA_MID,
+ transpose(new String[][]{
+ {"F F", " GGG ", " GPG ", " GGG ", "F F"}
+ })
+ )
+ .addShape(NA_BOTTOM,
+ transpose(new String[][]{
+ {"XX~XX", "XDDDX", "XDDDX", "XDDDX", "XXXXX"}
+ })
+ )
+ .addElement(
+ 'C',
+ ofChain(
+ ofHatchAdder(
+ NeutronActivator::addClassicInputToMachineList, 49,
+ 1
+ ),
+ onElementPass(
+ x -> x.casingAmount++,
+ ofBlock(
+ GregTech_API.sBlockCasings4, 1
+ )
+ )
+ )
+ )
+ .addElement(
+ 'D',
+ ofBlock(
+ GregTech_API.sBlockCasings2, 6
+ )
+ )
+ .addElement(
+ 'F',
+ addFrame(
+ Materials.Steel
+ )
+ )
+ .addElement(
+ 'G',
+ ofBlock(
+ Block.getBlockFromItem(Ic2Items.reinforcedGlass.getItem()), 0
+ )
+ )
+ .addElement(
+ 'P',
+ ofBlock(
+ Loaders.speedingPipe, 0
+ )
+ )
+ .addElement(
+ 'X',
+ ofChain(
+ ofHatchAdder(
+ NeutronActivator::addClassicOutputToMachineList, 49,
+ 2
+ ),
+ ofHatchAdder(
+ NeutronActivator::addMaintenanceToMachineList, 49,
+ 2
+ ),
+ ofHatchAdder(
+ NeutronActivator::addAcceleratorAndSensor, 49,
+ 2
+ ),
+ onElementPass(
+ x -> x.casingAmount++,
+ ofBlock(
+ GregTech_API.sBlockCasings4, 1
+ )
+ )
+ )
+ )
+ .build();
+ }
+ return multiDefinition;
+ }
+
+ @Override
+ public boolean checkMachine_EM(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
+ this.casingAmount = 0;
+ this.mNeutronAccelerator.clear();
+ this.mNeutronSensor.clear();
+ if (!structureCheck_EM(NA_BOTTOM, 2, 0, 0)) return false;
+ height = 0;
+ while (structureCheck_EM(NA_MID, 2, height +1, 0)) {
+ height ++;
+ }
+ if (height < 4) return false;
+ return structureCheck_EM(NA_TOP, 2, height + 1, 0) && casingAmount >= 7;
+ }
+
+ public final boolean addAcceleratorAndSensor(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
+ if (aTileEntity == null) {
+ return false;
+ } else {
+ IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
+ if (aMetaTileEntity instanceof NeutronAccelerator) {
+ ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
+ return this.mNeutronAccelerator.add((NeutronAccelerator) aMetaTileEntity);
+ } else if (aMetaTileEntity instanceof NeutronSensor) {
+ ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
+ return this.mNeutronSensor.add((NeutronSensor) aMetaTileEntity);
+ }
+ }
+ return false;
+ }
+
+ public int maxNeutronKineticEnergy() {
+ return 1200000000;
+ }
+
+ public int getCurrentNeutronKineticEnergy() {
+ return eV;
+ }
+
+ @Override
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new NeutronActivator(this.mName);
+ }
+
+ @Override
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ super.onPostTick(aBaseMetaTileEntity, aTick);
+ boolean anyWorking = false;
+ if (this.getBaseMetaTileEntity().isServerSide()) {
+ for (NeutronAccelerator tHatch : mNeutronAccelerator) {
+ if (tHatch.isRunning && this.getRepairStatus() == this.getIdealStatus()) {
+ anyWorking = true;
+ this.eV += Math.max(nextInt(tHatch.getMaxEUConsume(), tHatch.getMaxEUConsume() * 2 + 1) * 10 * Math.pow(0.95, height - 4), 10);
+ }
+ }
+ if (!anyWorking) {
+ if (this.eV >= 72000 && aTick % 20 == 0) {
+ this.eV -= 72000;
+ } else if (this.eV > 0 && aTick % 20 == 0) {
+ this.eV = 0;
+ }
+ }
+ if (this.eV < 0) this.eV = 0;
+ if (this.eV > maxNeutronKineticEnergy()) doExplosion(4 * 32);
+
+ for (NeutronSensor tHatch : mNeutronSensor) {
+ String tText = tHatch.getText();
+ if (CharExchanger.isValidCompareExpress(rawProcessExp(tText))) {
+ if (CharExchanger.compareExpression(rawProcessExp(tText), eV)) {
+ tHatch.outputRedstoneSignal();
+ } else tHatch.stopOutputRedstoneSignal();
+ }
+ }
+
+ if (mProgresstime < mMaxProgresstime && (eV > mCeil || eV < mFloor)) {
+ this.mOutputFluids = null;
+ this.mOutputItems = new ItemStack[]{ItemRefer.Radioactive_Waste.get(4)};
+ }
+ }
+ }
+
+ protected String rawProcessExp(String exp) {
+ StringBuilder ret = new StringBuilder();
+ for (char c : exp.toCharArray()) {
+ if (exp.length() - ret.length() == 3) {
+ if (Character.isDigit(c)) ret.append(c);
+ else {
+ if (c == 'K' || c == 'k') {
+ ret.append("000");
+ }
+ if (c == 'M' || c == 'm') {
+ ret.append("000000");
+ }
+ }
+ break;
+ }
+ ret.append(c);
+ }
+ return ret.toString();
+ }
+
+ @Override
+ public void construct(ItemStack stackSize, boolean hintsOnly) {
+ structureBuild_EM(NA_BOTTOM, 2, 0, 0, hintsOnly, stackSize);
+ int heights = stackSize.stackSize + 3;
+ structureBuild_EM(NA_TOP, 2, heights + 1, 0, hintsOnly, stackSize);
+ while (heights > 0) {
+ structureBuild_EM(NA_MID, 2, heights, 0, hintsOnly, stackSize);
+ heights --;
+ }
+ }
+
+ @Override
+ public String[] getStructureDescription(ItemStack itemStack) {
+ return DescTextLocalization.addText("NeutronActivator.hint", 7);
+ }
+
+ @Override
+ public String[] getInfoData() {
+ int currentNKEInput = 0;
+ boolean anyWorking = false;
+ for (NeutronAccelerator tHatch : mNeutronAccelerator) {
+ if (tHatch.isRunning) {
+ currentNKEInput += nextInt(tHatch.getMaxEUConsume(), tHatch.getMaxEUConsume() * 2 + 1) * 10 * Math.pow(0.95, height - 4);
+ anyWorking = true;
+ }
+ }
+ if (!anyWorking) currentNKEInput = -72000;
+ return new String[] {
+ "Progress:",
+ EnumChatFormatting.GREEN + Integer.toString(this.mProgresstime / 20) + EnumChatFormatting.RESET + " s / " + EnumChatFormatting.YELLOW + this.mMaxProgresstime / 20 + EnumChatFormatting.RESET + " s",
+ "Current Neutron Kinetic Energy Input: " + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(currentNKEInput) + EnumChatFormatting.RESET + "eV",
+ StatCollector.translateToLocal("scanner.info.NA") + " " + EnumChatFormatting.LIGHT_PURPLE + GT_Utility.formatNumbers(getCurrentNeutronKineticEnergy()) + EnumChatFormatting.RESET + "eV"
+ };
+ }
+
+ @Override
+ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
+ if(aSide == aFacing) {
+ if(aActive) return new ITexture[]{
+ Textures.BlockIcons.getCasingTextureForId(49),
+ TextureFactory.of(textureFontOn),
+ TextureFactory.builder().addIcon(textureFontOn_Glow).glow().build()
+ };
+ else return new ITexture[]{
+ Textures.BlockIcons.getCasingTextureForId(49),
+ TextureFactory.of(textureFontOff),
+ TextureFactory.builder().addIcon(textureFontOff_Glow).glow().build()
+ };
+ }
+ return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(49)};
+ }
+}
diff --git a/src/main/java/goodgenerator/blocks/tileEntity/UniversalChemicalFuelEngine.java b/src/main/java/goodgenerator/blocks/tileEntity/UniversalChemicalFuelEngine.java
new file mode 100644
index 0000000000..4cd0476b4a
--- /dev/null
+++ b/src/main/java/goodgenerator/blocks/tileEntity/UniversalChemicalFuelEngine.java
@@ -0,0 +1,348 @@
+package goodgenerator.blocks.tileEntity;
+
+import goodgenerator.loader.Loaders;
+import goodgenerator.util.DescTextLocalization;
+import com.github.bartimaeusnek.crossmod.tectech.TecTechEnabledMulti;
+import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti;
+import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyTunnel;
+import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM;
+import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable;
+import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
+import com.gtnewhorizon.structurelib.structure.StructureDefinition;
+import gregtech.api.GregTech_API;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.metatileentity.implementations.*;
+import gregtech.api.render.TextureFactory;
+import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
+import gregtech.api.util.GT_Recipe;
+import gregtech.api.util.GT_Utility;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraftforge.fluids.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+import org.lwjgl.input.Keyboard;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import static goodgenerator.util.DescTextLocalization.BLUE_PRINT_INFO;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.*;
+import static gregtech.api.enums.Textures.BlockIcons.*;
+import static gregtech.api.util.GT_StructureUtility.ofHatchAdder;
+
+public class UniversalChemicalFuelEngine extends GT_MetaTileEntity_MultiblockBase_EM implements TecTechEnabledMulti, IConstructable {
+
+ protected final double DIESEL_EFFICIENCY_COEFFICIENT = 0.02D;
+ protected final double GAS_EFFICIENCY_COEFFICIENT = 0.01D;
+ protected final double EFFICIENCY_CEILING = 1.5D;
+
+ private IStructureDefinition<UniversalChemicalFuelEngine> multiDefinition = null;
+
+ public UniversalChemicalFuelEngine(String name){super(name);}
+
+ public UniversalChemicalFuelEngine(int id, String name, String nameRegional){
+ super(id,name,nameRegional);
+ }
+
+ public final boolean addMaintenance(IGregTechTileEntity aTileEntity, int aBaseCasingIndex){
+ if (aTileEntity == null) {
+ return false;
+ } else {
+ IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){
+ ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex);
+ return this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance)aMetaTileEntity);
+ }
+ }
+ return false;
+ }
+
+ public final boolean addMuffler(IGregTechTileEntity aTileEntity, int aBaseCasingIndex){
+ if (aTileEntity == null) {
+ return false;
+ } else {
+ IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler){
+ ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex);
+ return this.mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler)aMetaTileEntity);
+ }
+ }
+ return false;
+ }
+
+ public final boolean addInputHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex){
+ if (aTileEntity == null) {
+ return false;
+ } else {
+ IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input){
+ ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex);
+ return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input)aMetaTileEntity);
+ }
+ }
+ return false;
+ }
+
+ public final boolean addDynamoHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex){
+ if (aTileEntity == null) {
+ return false;
+ } else {
+ IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo){
+ ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex);
+ return this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo)aMetaTileEntity);
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public IStructureDefinition<UniversalChemicalFuelEngine> getStructure_EM(){
+ if (multiDefinition == null){
+ multiDefinition = StructureDefinition
+ .<UniversalChemicalFuelEngine>builder()
+ .addShape(mName,
+ transpose(new String[][]{
+ {"TTTTT","TTMMT","TTMMT","TTMMT","TTMMT","TTMMT","TTMMT","TTMMT","TTTTT"},
+ {"TTTTT","SPCCI-","SPCCI-","SPCCI-","SPCCI-","SPCCI-","SPCCI-","SPCCI-","TTTTT"},
+ {"TT~TT","SPGGI-","SPGGI-","SPGGI-","SPGGI-","SPGGI-","SPGGI-","SPGGI-","TTETT"},
+ {"TTWTT","TTTTT","TTTTT","TTTTT","TTTTT","TTTTT","TTTTT","TTTTT","TTTTT"}
+ })
+ ).addElement(
+ 'T',
+ ofBlock(
+ GregTech_API.sBlockCasings4, 2
+ )
+ ).addElement(
+ 'W',
+ ofHatchAdder(
+ UniversalChemicalFuelEngine::addMaintenance, 50,
+ 1
+ )
+ ).addElement(
+ 'M',
+ ofHatchAdder(
+ UniversalChemicalFuelEngine::addMuffler, 50,
+ 2
+ )
+ ).addElement(
+ 'S',
+ ofHatchAdder(
+ UniversalChemicalFuelEngine::addInputHatch, 50,
+ 3
+ )
+ ).addElement(
+ 'E',
+ ofHatchAdder(
+ UniversalChemicalFuelEngine::addDynamoHatch, 50,
+ 4
+ )
+ ).addElement(
+ 'P',
+ ofBlock(
+ GregTech_API.sBlockCasings2, 14
+ )
+ ).addElement(
+ 'C',
+ ofBlock(
+ Loaders.titaniumPlatedCylinder, 0
+ )
+ ).addElement(
+ 'G',
+ ofBlock(
+ GregTech_API.sBlockCasings2, 4
+ )
+ ).addElement(
+ 'I',
+ ofBlock(
+ GregTech_API.sBlockCasings4, 13
+ )
+ )
+ .build();
+ }
+ return multiDefinition;
+ }
+
+ @Override
+ public boolean checkMachine_EM(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
+ return structureCheck_EM(mName, 2, 2, 0);
+ }
+
+ @Override
+ public void construct(ItemStack itemStack, boolean b) {
+ structureBuild_EM(mName, 2, 2, 0, b, itemStack);
+ }
+
+ @Override
+ public String[] getStructureDescription(ItemStack itemStack) {
+ return DescTextLocalization.addText("UniversalChemicalFuelEngine.hint", 11);
+ }
+
+ @Override
+ public boolean isCorrectMachinePart(ItemStack aStack) {
+ return true;
+ }
+
+ @Override
+ public int getPollutionPerTick(ItemStack aStack) {
+ return (int)Math.sqrt(this.mEUt) / 20;
+ }
+
+ @Override
+ public String[] getDescription(){
+ final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
+ tt.addMachineType("Chemical Engine")
+ .addInfo("Controller block for the Chemical Engine")
+ .addInfo("BURNING BURNING BURNING")
+ .addInfo("Use combustible liquid to generate power.")
+ .addInfo("You need to supply Combustion Promoter to keep it running.")
+ .addInfo("This engine will consume all the fuel and combustion promoter in the hatch every second.")
+ .addInfo("The efficiency is determined by the proportion of Combustion Promoter to fuel.")
+ .addInfo("The proportion is bigger, and the efficiency will be higher.")
+ .addInfo("It creates sqrt(Current Output Power) pollution every second")
+ .addInfo("If you forget to supply Combustion Promoter, this engine will swallow all the fuel " + EnumChatFormatting.YELLOW + "without outputting energy" + EnumChatFormatting.GRAY + ".")
+ .addInfo("The efficiency is up to 150%.")
+ .addInfo("The structure is too complex!")
+ .addInfo(BLUE_PRINT_INFO)
+ .addSeparator()
+ .beginStructureBlock(5, 4, 9, false)
+ .addMaintenanceHatch("Hint block with dot 1")
+ .addMufflerHatch("Hint block with dot 2")
+ .addInputHatch("Hint block with dot 3")
+ .addDynamoHatch("Hint block with dot 4")
+ .toolTipFinisher("Good Generator");
+ if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
+ return tt.getInformation();
+ } else {
+ return tt.getStructureInformation();
+ }
+ }
+
+ @Override
+ public boolean checkRecipe_EM(ItemStack aStack) {
+
+ ArrayList<FluidStack> tFluids = getStoredFluids();
+
+ Collection<GT_Recipe> tDieselFuels = GT_Recipe.GT_Recipe_Map.sDieselFuels.mRecipeList;
+ Collection<GT_Recipe> tGasFuels = GT_Recipe.GT_Recipe_Map.sTurbineFuels.mRecipeList;
+
+ int PromoterAmount = findLiquidAmount(getPromoter(), tFluids);
+
+ for (GT_Recipe recipe : tDieselFuels) {
+ FluidStack tFuel = findFuel(recipe);
+ if (tFuel == null) continue;
+ int FuelAmount = findLiquidAmount(tFuel, tFluids);
+ if (FuelAmount == 0) continue;
+ calculateEfficiency(FuelAmount, PromoterAmount, DIESEL_EFFICIENCY_COEFFICIENT);
+
+ consumeAllLiquid(tFuel);
+ consumeAllLiquid(getPromoter());
+
+ this.mEUt = (int)(FuelAmount * recipe.mSpecialValue / 20.0D);
+ this.mMaxProgresstime = 20;
+ this.updateSlots();
+ return true;
+ }
+
+ for (GT_Recipe recipe : tGasFuels) {
+ FluidStack tFuel = findFuel(recipe);
+ if (tFuel == null) continue;
+ int FuelAmount = findLiquidAmount(tFuel, tFluids);
+ if (FuelAmount == 0) continue;
+ calculateEfficiency(FuelAmount, PromoterAmount, GAS_EFFICIENCY_COEFFICIENT);
+
+ consumeAllLiquid(tFuel);
+ consumeAllLiquid(getPromoter());
+
+ this.mEUt = (int)(FuelAmount * recipe.mSpecialValue / 20.0D);
+ this.mMaxProgresstime = 20;
+ this.updateSlots();
+ return true;
+ }
+
+ return false;
+ }
+
+ public FluidStack getPromoter() {
+ return FluidRegistry.getFluidStack("combustionpromotor", 1);
+ }
+
+ public FluidStack findFuel(GT_Recipe aFuel) {
+ return GT_Utility.getFluidForFilledItem(aFuel.mInputs[0], true);
+ }
+
+ public void calculateEfficiency(int aFuel, int aPromoter, double coefficient){
+ if (aPromoter == 0){
+ this.mEfficiency = 0;
+ return;
+ }
+ this.mEfficiency = (int)(Math.exp(-coefficient * (double)aFuel / (double)aPromoter) * EFFICIENCY_CEILING * 10000);
+ }
+
+ public int findLiquidAmount(FluidStack liquid, List<FluidStack> input) {
+ int cnt = 0;
+ for (FluidStack fluid : input){
+ if (fluid.isFluidEqual(liquid)) {
+ cnt += fluid.amount;
+ }
+ }
+ if (cnt < 0) cnt = 0;
+ return cnt;
+ }
+
+ public void consumeAllLiquid(FluidStack liquid) {
+ for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) {
+ if (isValidMetaTileEntity(tHatch)) {
+ FluidStack tLiquid = tHatch.getFluid();
+ if (tLiquid != null && tLiquid.isFluidEqual(liquid)) {
+ tHatch.drain(tLiquid.amount, true);
+ }
+ }
+ }
+ }
+
+ @Override
+ public int getMaxEfficiency(ItemStack aStack) {
+ return (int)(10000 * EFFICIENCY_CEILING);
+ }
+
+ @Override
+ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone){
+ if(aSide == aFacing){
+ if(aActive) return new ITexture[]{
+ casingTexturePages[0][50],
+ TextureFactory.of(OVERLAY_FRONT_DIESEL_ENGINE_ACTIVE),
+ TextureFactory.builder().addIcon(OVERLAY_FRONT_DIESEL_ENGINE_ACTIVE_GLOW).glow().build()
+ };
+ return new ITexture[]{
+ casingTexturePages[0][50],
+ TextureFactory.of(OVERLAY_FRONT_DIESEL_ENGINE),
+ TextureFactory.builder().addIcon(OVERLAY_FRONT_DIESEL_ENGINE_GLOW).glow().build()
+ };
+ }
+ return new ITexture[]{casingTexturePages[0][50]};
+ }
+
+ @Override
+ public List<GT_MetaTileEntity_Hatch_Energy> getVanillaEnergyHatches() {
+ return this.mEnergyHatches;
+ }
+
+ @Override
+ public List<GT_MetaTileEntity_Hatch_EnergyTunnel> getTecTechEnergyTunnels() {
+ return new ArrayList<>();
+ }
+
+ @Override
+ public List<GT_MetaTileEntity_Hatch_EnergyMulti> getTecTechEnergyMultis() {
+ return new ArrayList<>();
+ }
+
+ @Override
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new UniversalChemicalFuelEngine(this.mName);
+ }
+}
diff --git a/src/main/java/goodgenerator/blocks/tileEntity/YottaFluidTank.java b/src/main/java/goodgenerator/blocks/tileEntity/YottaFluidTank.java
new file mode 100644
index 0000000000..c2ac9ae885
--- /dev/null
+++ b/src/main/java/goodgenerator/blocks/tileEntity/YottaFluidTank.java
@@ -0,0 +1,424 @@
+package goodgenerator.blocks.tileEntity;
+
+import goodgenerator.client.GUI.YOTTankGUIClient;
+import goodgenerator.common.container.YOTTankGUIContainer;
+import goodgenerator.loader.Loaders;
+import goodgenerator.util.CharExchanger;
+import goodgenerator.util.DescTextLocalization;
+import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry;
+import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM;
+import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable;
+import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
+import com.gtnewhorizon.structurelib.structure.IStructureElement;
+import com.gtnewhorizon.structurelib.structure.StructureDefinition;
+import gregtech.api.enums.Materials;
+import gregtech.api.enums.Textures;
+import gregtech.api.interfaces.IIconContainer;
+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;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output;
+import gregtech.api.render.TextureFactory;
+import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.StatCollector;
+import net.minecraftforge.fluids.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+import org.lwjgl.input.Keyboard;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
+import static goodgenerator.util.DescTextLocalization.BLUE_PRINT_INFO;
+import static goodgenerator.util.StructureHelper.addFrame;
+import static goodgenerator.util.StructureHelper.addTieredBlock;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.*;
+import static gregtech.api.util.GT_StructureUtility.*;
+
+public class YottaFluidTank extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable {
+
+ private static final IIconContainer textureFontOn = new Textures.BlockIcons.CustomIcon("iconsets/OVERLAY_QTANK");
+ private static final IIconContainer textureFontOn_Glow = new Textures.BlockIcons.CustomIcon("iconsets/OVERLAY_QTANK_GLOW");
+ private static final IIconContainer textureFontOff = new Textures.BlockIcons.CustomIcon("iconsets/OVERLAY_QCHEST");
+ private static final IIconContainer textureFontOff_Glow = new Textures.BlockIcons.CustomIcon("iconsets/OVERLAY_QCHEST_GLOW");
+
+ protected IStructureDefinition<YottaFluidTank> multiDefinition = null;
+
+ protected BigInteger mStorage = new BigInteger("0", 10);
+ protected BigInteger mStorageCurrent = new BigInteger("0", 10);
+ protected String mFluidName = "";
+ protected int glassMeta;
+ protected int maxCell;
+ protected final String YOTTANK_BOTTOM = mName + "buttom";
+ protected final String YOTTANK_MID = mName + "mid";
+ protected final String YOTTANK_TOP = mName + "top";
+
+ public YottaFluidTank(int id, String name, String nameRegional) {
+ super(id, name, nameRegional);
+ }
+
+ public YottaFluidTank(String name) {
+ super(name);
+ }
+
+ public int getMeta() {
+ return glassMeta;
+ }
+
+ public void setMeta(int meta) {
+ glassMeta = meta;
+ }
+
+ public String getCap() {
+ return mStorage.toString(10);
+ }
+
+ public String getStored() {
+ return mStorageCurrent.toString(10);
+ }
+
+ public String getFluidName() {
+ if (mFluidName == null || mFluidName.equals("") || FluidRegistry.getFluidStack(mFluidName, 1) == null) return "Empty";
+ return FluidRegistry.getFluidStack(mFluidName, 1).getLocalizedName();
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ String tAmount = aNBT.getString("mStorage");
+ String tAmountCurrent = aNBT.getString("mStorageCurrent");
+ if (tAmount == null || tAmount.equals("")) tAmount = "0";
+ if (tAmountCurrent == null || tAmountCurrent.equals("")) tAmountCurrent = "0";
+ mStorage = new BigInteger(tAmount, 10);
+ mStorageCurrent = new BigInteger(tAmountCurrent, 10);
+ mFluidName = aNBT.getString("mFluidName");
+ super.loadNBTData(aNBT);
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ aNBT.setString("mStorage", mStorage.toString(10));
+ aNBT.setString("mStorageCurrent", mStorageCurrent.toString(10));
+ aNBT.setString("mFluidName", mFluidName);
+ super.saveNBTData(aNBT);
+ }
+
+ @Override
+ public boolean checkRecipe_EM(ItemStack aStack) {
+ this.mEUt = 0;
+ this.mMaxProgresstime = 20;
+ return true;
+ }
+
+ public boolean reduceFluid(int amount) {
+ BigInteger tmp = new BigInteger(amount + "");
+ if (mStorageCurrent.compareTo(tmp) < 0) {
+ return false;
+ }
+ else {
+ mStorageCurrent = mStorageCurrent.subtract(tmp);
+ return true;
+ }
+ }
+
+ private int calGlassTier(int meta) {
+ if (meta >= 1 && meta <= 6) return meta;
+ if (meta >= 7 && meta <= 12) return 1;
+ return 3;
+ }
+
+ @Override
+ public boolean checkMachine_EM(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
+ mStorage = BigInteger.ZERO;
+ glassMeta = 0;
+ if (!structureCheck_EM(YOTTANK_BOTTOM, 2, 0, 0)) return false;
+ int cnt = 0;
+ while (structureCheck_EM(YOTTANK_MID, 2, cnt + 1, 0)) {
+ cnt ++;
+ }
+ if (cnt > 15 || cnt < 1) return false;
+ if (!structureCheck_EM(YOTTANK_TOP, 2, cnt + 2, 0)) return false;
+ if (mMaintenanceHatches.size() == 1 && maxCell + 1 <= calGlassTier(glassMeta)) {
+ if (mStorage.compareTo(mStorageCurrent) < 0) mStorageCurrent = mStorage;
+ if (FluidRegistry.getFluidStack(mFluidName, 1) == null) {
+ mStorageCurrent = BigInteger.ZERO;
+ mFluidName = "";
+ }
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public IStructureDefinition<YottaFluidTank> getStructure_EM() {
+ if(multiDefinition == null) {
+ multiDefinition = StructureDefinition
+ .<YottaFluidTank>builder()
+ .addShape(YOTTANK_BOTTOM, transpose(new String[][]{
+ {"MM~MM","MCCCM","MCCCM","MCCCM","MMMMM"},
+ {" "," CCC "," COC "," CCC "," "}
+ }))
+ .addShape(YOTTANK_MID, transpose(new String[][]{
+ {"GGGGG","GRRRG","GRRRG","GRRRG","GGGGG"}
+ }))
+ .addShape(YOTTANK_TOP, transpose(new String[][]{
+ {"FFFFF","F F","F F","F F","FFFFF"},
+ {"CCCCC","CIIIC","CIIIC","CIIIC","CCCCC"}
+ }))
+ .addElement(
+ 'C',
+ ofBlock(
+ Loaders.yottaFluidTankCasing, 0
+ )
+ )
+ .addElement(
+ 'G',
+ addTieredBlock(
+ ItemRegistry.bw_realglas, YottaFluidTank::setMeta, YottaFluidTank::getMeta, 12
+ )
+ )
+ .addElement(
+ 'R',
+ ofChain(
+ cells(10)
+ )
+ )
+ .addElement(
+ 'F',
+ addFrame(Materials.Steel)
+ )
+ .addElement(
+ 'I',
+ ofHatchAdderOptional(
+ YottaFluidTank::addInput,
+ 1537,
+ 1,
+ Loaders.yottaFluidTankCasing,
+ 0
+ )
+ )
+ .addElement(
+ 'M',
+ ofHatchAdderOptional(
+ YottaFluidTank::addClassicMaintenanceToMachineList,
+ 1537,
+ 2,
+ Loaders.yottaFluidTankCasing,
+ 0
+ )
+ )
+ .addElement(
+ 'O',
+ ofHatchAdder(
+ YottaFluidTank::addOutput,
+ 1537,
+ 3
+ )
+ )
+ .build();
+ }
+ return multiDefinition;
+ }
+
+ public List<IStructureElement<YottaFluidTank>> cells(int num) {
+ List<IStructureElement<YottaFluidTank>> out = new ArrayList<>();
+ for (int i = 0; i < num; ++i) {
+ int finalI = i;
+ out.add(
+ onElementPass(
+ x -> {
+ x.mStorage = x.mStorage.add(calStorage(finalI));
+ x.maxCell = Math.max(x.maxCell, finalI);
+ },
+ ofBlock(Loaders.yottaFluidTankCell, i)
+ )
+ );
+ }
+ return out;
+ }
+
+ public final boolean addInput(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
+ if (aTileEntity == null) {
+ return false;
+ } else {
+ IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
+ if (aMetaTileEntity == null) {
+ return false;
+ } else {
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) {
+ ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex);
+ return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input)aMetaTileEntity);
+ }
+ }
+ }
+ return false;
+ }
+
+ public final boolean addOutput(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
+ if (aTileEntity == null) {
+ return false;
+ } else {
+ IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
+ if (aMetaTileEntity == null) {
+ return false;
+ } else {
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) {
+ ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex);
+ return this.mOutputHatches.add((GT_MetaTileEntity_Hatch_Output)aMetaTileEntity);
+ }
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public String[] getInfoData() {
+ return new String[] {
+ StatCollector.translateToLocal("scanner.info.YOTTank.0") + " " + EnumChatFormatting.GREEN + CharExchanger.formatNumber(getCap()) + EnumChatFormatting.RESET + " L",
+ StatCollector.translateToLocal("scanner.info.YOTTank.1") + " " + EnumChatFormatting.YELLOW + CharExchanger.formatNumber(getFluidName()) + EnumChatFormatting.RESET,
+ StatCollector.translateToLocal("scanner.info.YOTTank.2") + " " + EnumChatFormatting.BLUE + CharExchanger.formatNumber(getStored()) + EnumChatFormatting.RESET + " L",
+ };
+ }
+
+ @Override
+ public String[] getDescription() {
+ final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
+ tt.addMachineType("Fluid Tank")
+ .addInfo("Controller block for the YOTTank.")
+ .addInfo("The max output speed is decided by the amount of stored liquid and the output hatch's capacity.")
+ .addInfo("The max fluid cell tier is limited by the glass tier.")
+ .addInfo("HV glass for T1, EV glass for T2, IV glass for T3. . .")
+ .addInfo("The max height of the cell blocks is 15.")
+ .addInfo("The structure is too complex!")
+ .addInfo(BLUE_PRINT_INFO)
+ .addSeparator()
+ .beginVariableStructureBlock(5, 5, 1, 15, 5 ,5, false)
+ .addController("Front of the second layer")
+ .addInputHatch("Hint block with dot 1")
+ .addMaintenanceHatch("Hint block with dot 2")
+ .addOutputHatch("Hint block with dot 3")
+ .toolTipFinisher("Good Generator");
+ if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
+ return tt.getInformation();
+ } else {
+ return tt.getStructureInformation();
+ }
+ }
+
+ public BigInteger calStorage(int meta) {
+ StringBuilder cap = new StringBuilder();
+ cap.append("1000000");
+ for (int i = 0; i < meta; ++i)
+ cap.append("00");
+ return new BigInteger(cap.toString());
+ }
+
+ @Override
+ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new YOTTankGUIClient(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "EMDisplay.png");
+ }
+
+ @Override
+ public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new YOTTankGUIContainer(aPlayerInventory, aBaseMetaTileEntity);
+ }
+
+ @Override
+ public boolean onRunningTick(ItemStack aStack) {
+ super.onRunningTick(aStack);
+ if (this.getBaseMetaTileEntity().isServerSide()) {
+ List<FluidStack> tStore = getStoredFluids();
+ for (FluidStack tFluid : tStore) {
+ if (tFluid == null) continue;
+ if (mFluidName == null || mFluidName.equals("") || tFluid.getFluid().getName().equals(mFluidName)) {
+ if (mFluidName == null || mFluidName.equals("")) {
+ mFluidName = tFluid.getFluid().getName();
+ }
+ if (mStorageCurrent.add(new BigInteger(tFluid.amount + "")).compareTo(mStorage) < 0) {
+ mStorageCurrent = mStorageCurrent.add(new BigInteger(tFluid.amount + ""));
+ tFluid.amount = 0;
+ } else {
+ BigInteger delta = mStorage.subtract(mStorageCurrent);
+ mStorageCurrent = mStorageCurrent.add(delta);
+ tFluid.amount -= delta.intValue();
+ }
+ }
+ }
+ BigInteger outputAmount = mStorageCurrent.divide(new BigInteger("100", 10));
+ if (outputAmount.compareTo(new BigInteger(Integer.MAX_VALUE + "", 10)) > 0) outputAmount = new BigInteger(Integer.MAX_VALUE + "");
+ if (outputAmount.compareTo(BigInteger.ONE) <= 0) outputAmount = new BigInteger("1", 10);
+
+ if (mStorageCurrent.compareTo(BigInteger.ZERO) <= 0) mFluidName = "";
+
+ if (mFluidName != null && !mFluidName.equals("")) {
+ if (mOutputHatches.size() > 0) {
+ FluidStack tHatchFluid = mOutputHatches.get(0).mFluid;
+ FluidStack tOutput = FluidRegistry.getFluidStack(mFluidName, outputAmount.intValue());
+ if (tHatchFluid != null && tHatchFluid.isFluidEqual(tOutput)) {
+ int leftSpace = mOutputHatches.get(0).getCapacity() - tHatchFluid.amount;
+ if (leftSpace < tOutput.amount) {
+ if (reduceFluid(leftSpace)) tHatchFluid.amount += leftSpace;
+ }
+ else {
+ if (reduceFluid(tOutput.amount)) tHatchFluid.amount += tOutput.amount;
+ }
+ }
+ else if (tHatchFluid == null) {
+ int leftSpace = mOutputHatches.get(0).getCapacity();
+ if (leftSpace < tOutput.amount) {
+ if (reduceFluid(leftSpace)) mOutputHatches.get(0).fill(FluidRegistry.getFluidStack(mFluidName, leftSpace), true);
+ }
+ else {
+ if (reduceFluid(tOutput.amount)) mOutputHatches.get(0).fill(tOutput, true);
+ }
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public void construct(ItemStack stackSize, boolean hintsOnly) {
+ structureBuild_EM(YOTTANK_BOTTOM, 2, 0, 0, hintsOnly, stackSize);
+ int height = stackSize.stackSize;
+ if (height > 15) height = 15;
+ structureBuild_EM(YOTTANK_TOP, 2, height + 2, 0, hintsOnly, stackSize);
+ while (height > 0) {
+ structureBuild_EM(YOTTANK_MID, 2, height, 0, hintsOnly, stackSize);
+ height --;
+ }
+ }
+
+ @Override
+ public String[] getStructureDescription(ItemStack stackSize) {
+ return DescTextLocalization.addText("YOTTank.hint", 7);
+ }
+
+ @Override
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new YottaFluidTank(this.mName);
+ }
+
+ @Override
+ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone){
+ if (aSide == aFacing) {
+ if (aActive) return new ITexture[] {
+ Textures.BlockIcons.getCasingTextureForId(1537),
+ TextureFactory.of(textureFontOn),
+ TextureFactory.builder().addIcon(textureFontOn_Glow).glow().build()
+ };
+ else return new ITexture[] {
+ Textures.BlockIcons.getCasingTextureForId(1537),
+ TextureFactory.of(textureFontOff),
+ TextureFactory.builder().addIcon(textureFontOff_Glow).glow().build()
+ };
+ }
+ else return new ITexture[] {Textures.BlockIcons.getCasingTextureForId(1537)};
+ }
+}