diff options
author | Bass <tudurap.com@gmail.com> | 2018-02-09 17:13:45 +0000 |
---|---|---|
committer | Bass <tudurap.com@gmail.com> | 2018-02-09 17:13:45 +0000 |
commit | 303fcfbf63497061333daeab731997a2fad3c265 (patch) | |
tree | 3ab9068841c921ebc4ff1f6867b45fab85158484 /src | |
parent | 7e6d8e92dfa5301a714e51a70db24dc842db6f71 (diff) | |
download | GT5-Unofficial-303fcfbf63497061333daeab731997a2fad3c265.tar.gz GT5-Unofficial-303fcfbf63497061333daeab731997a2fad3c265.tar.bz2 GT5-Unofficial-303fcfbf63497061333daeab731997a2fad3c265.zip |
Tesla being worked on.
Diffstat (limited to 'src')
8 files changed, 589 insertions, 101 deletions
diff --git a/src/main/java/com/github/technus/tectech/Util.java b/src/main/java/com/github/technus/tectech/Util.java index 25327e1369..08e48471fc 100644 --- a/src/main/java/com/github/technus/tectech/Util.java +++ b/src/main/java/com/github/technus/tectech/Util.java @@ -321,7 +321,7 @@ public final class Util { if (igt == null || !(boolean) adder.invoke(imt, addingMethods[pointer], igt, casingTextures[pointer])) { if (world.getBlock(x, y, z) != blockTypeFallback[pointer]) { if (DEBUG_MODE) { - TecTech.Logger.info("Fallback-struct-block-error " + x + ' ' + y + ' ' + z + " / " + a + ' ' + b + ' ' + c + " / " + world.getBlock(x, y, z).getUnlocalizedName() + ' ' + blockTypeFallback[pointer].getUnlocalizedName()); + TecTech.Logger.info("Fallback-struct-block-error " + x + ' ' + y + ' ' + z + " / " + a + ' ' + b + ' ' + c + " / " + world.getBlock(x, y, z).getUnlocalizedName() + ' ' + (blockTypeFallback[pointer] == null ? "null" : blockTypeFallback[pointer].getUnlocalizedName())); } return false; } diff --git a/src/main/java/com/github/technus/tectech/loader/MachineLoader.java b/src/main/java/com/github/technus/tectech/loader/MachineLoader.java index ac3d404816..c42332730f 100644 --- a/src/main/java/com/github/technus/tectech/loader/MachineLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/MachineLoader.java @@ -274,6 +274,8 @@ public class MachineLoader implements Runnable { rack_Hatch.set(new GT_MetaTileEntity_Hatch_Rack(15450, "hatch.rack.tier.08", "Computer Rack", 8, "4 Slot Rack").getStackForm(1L)); holder_Hatch.set(new GT_MetaTileEntity_Hatch_Holder(15451, "hatch.holder.tier.09", "Object Holder", 8, "For Research Station").getStackForm(1L)); + capacitor_Hatch.set(new GT_MetaTileEntity_Hatch_Capacitor(15452, "hatch.capacitor.tier.05", "Capacitor Hatch", 5, "For Tesla Coil").getStackForm(1L)); + // =================================================================================================== // Pipes // =================================================================================================== @@ -285,7 +287,7 @@ public class MachineLoader implements Runnable { // =================================================================================================== // Debug Stuff // =================================================================================================== - + hatch_CreativeMaitenance.set(new GT_MetaTileEntity_Hatch_CreativeMaintenance(15497, "debug.tt.maintenance", "Debug Maintenance Hatch", 15).getStackForm(1L)); Machine_DebugGenny.set(new GT_MetaTileEntity_DebugPowerGenerator(15498, "debug.tt.genny", "Debug Power Generator", 15).getStackForm(1L)); Machine_DebugWriter.set(new GT_MetaTileEntity_DebugStructureWriter(15499, "debug.tt.writer", "Debug Structure Writer", 15).getStackForm(1L)); @@ -297,5 +299,6 @@ public class MachineLoader implements Runnable { GT_MetaTileEntity_Hatch_Rack.run(); GT_MetaTileEntity_EM_computer.run(); GT_MetaTileEntity_EM_research.run(); + GT_MetaTileEntity_TM_teslaCoil.run(); } } diff --git a/src/main/java/com/github/technus/tectech/thing/CustomItemList.java b/src/main/java/com/github/technus/tectech/thing/CustomItemList.java index 49e186dfb5..be42c6a13e 100644 --- a/src/main/java/com/github/technus/tectech/thing/CustomItemList.java +++ b/src/main/java/com/github/technus/tectech/thing/CustomItemList.java @@ -11,8 +11,8 @@ import net.minecraft.item.ItemStack; import static gregtech.api.enums.GT_Values.W; public enum CustomItemList implements IItemContainer { - Machine_DebugWriter,Machine_DebugGenny, - EMpipe, DATApipe, rack_Hatch, holder_Hatch, + hatch_CreativeMaitenance, Machine_DebugWriter,Machine_DebugGenny, + EMpipe, DATApipe, rack_Hatch, holder_Hatch, capacitor_Hatch, eM_dynamomulti4_IV, eM_dynamomulti16_IV, eM_dynamomulti64_IV, eM_dynamomulti4_LuV, eM_dynamomulti16_LuV, eM_dynamomulti64_LuV, diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Capacitor.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Capacitor.java new file mode 100644 index 0000000000..a2b4057628 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Capacitor.java @@ -0,0 +1,127 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch; + +import com.github.technus.tectech.CommonValues; +import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_Container_Capacitor; +import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_GUIContainer_Capacitor; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.objects.GT_RenderedTexture; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +/** + * Created by Tec on 03.04.2017. + */ +public class GT_MetaTileEntity_Hatch_Capacitor extends GT_MetaTileEntity_Hatch { + private static Textures.BlockIcons.CustomIcon EM_H; + private static Textures.BlockIcons.CustomIcon EM_H_ACTIVE; + + public GT_MetaTileEntity_Hatch_Capacitor(int aID, String aName, String aNameRegional, int aTier, String descr) { + super(aID, aName, aNameRegional, aTier, 1, descr); + } + + public GT_MetaTileEntity_Hatch_Capacitor(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 1, aDescription, aTextures); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + EM_H_ACTIVE = new Textures.BlockIcons.CustomIcon("iconsets/EM_HOLDER_ACTIVE"); + EM_H = new Textures.BlockIcons.CustomIcon("iconsets/EM_HOLDER"); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(EM_H_ACTIVE)}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(EM_H)}; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_Capacitor(mName, mTier, mDescription, mTextures); + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing >= 2; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return true; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide == aBaseMetaTileEntity.getFrontFacing(); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide == aBaseMetaTileEntity.getFrontFacing(); + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_Capacitor(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_Capacitor(aPlayerInventory, aBaseMetaTileEntity, "Capacitor Hatch"); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + //if(aBaseMetaTileEntity.isActive()) + // aPlayer.addChatComponentMessage(new ChatComponentText("It is still active...")); + //else if(heat>0) + // aPlayer.addChatComponentMessage(new ChatComponentText("It is still warm...")); + //else + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public String[] getDescription() { + return new String[]{ + CommonValues.BASS_MARK, + mDescription, + EnumChatFormatting.AQUA + "Stores 'nergy! (for a while)" + }; + } +} + + diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_CreativeMaintenance.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_CreativeMaintenance.java new file mode 100644 index 0000000000..4a3914acfe --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_CreativeMaintenance.java @@ -0,0 +1,56 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; + +public class GT_MetaTileEntity_Hatch_CreativeMaintenance extends GT_MetaTileEntity_Hatch_Maintenance { + public GT_MetaTileEntity_Hatch_CreativeMaintenance(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public GT_MetaTileEntity_Hatch_CreativeMaintenance(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures, false); + } + + @Override + public String[] getDescription() { + String[] desc = new String[this.mDescriptionArray.length + 1]; + System.arraycopy(this.mDescriptionArray, 0, desc, 0, this.mDescriptionArray.length); + desc[this.mDescriptionArray.length] = "Fixing is for plebs!"; + return desc; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_CreativeMaintenance(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + this.mWrench = this.mScrewdriver = this.mSoftHammer = this.mHardHammer = this.mCrowbar = this.mSolderingTool = true; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return null; + } + + @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/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Capacitor.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Capacitor.java new file mode 100644 index 0000000000..f368867736 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Capacitor.java @@ -0,0 +1,80 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch.gui; + +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +/** + * Created by Tec on 09.04.2017. + */ +public class GT_Container_Capacitor extends GT_ContainerMetaTile_Machine { + public GT_Container_Capacitor(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new Slot(mTileEntity, 0, 80, 39)); + } + + @Override + public int getSlotCount() { + return 1; + } + + @Override + public int getShiftClickSlotCount() { + return 1; + } + + @Override + public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { + if (mActive != 0) { + return null; + } + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer aPlayer, int aSlotIndex) { + if (mActive != 0) { + return null; + } + return super.transferStackInSlot(aPlayer, aSlotIndex); + } + + @Override + public boolean canDragIntoSlot(Slot par1Slot) { + if (mActive != 0) { + return false; + } + return super.canDragIntoSlot(par1Slot); + } + + @Override + public void putStacksInSlots(ItemStack[] par1ArrayOfItemStack) { + if (mActive != 0) { + return; + } + super.putStacksInSlots(par1ArrayOfItemStack); + } + + @Override + protected boolean mergeItemStack(ItemStack aStack, int aStartIndex, int aSlotCount, boolean par4) { + if (mActive != 0) { + return false; + } + return super.mergeItemStack(aStack, aStartIndex, aSlotCount, par4); + } + + @Override + public void putStackInSlot(int par1, ItemStack par2ItemStack) { + if (mActive != 0) { + return; + } + super.putStackInSlot(par1, par2ItemStack); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Capacitor.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Capacitor.java new file mode 100644 index 0000000000..fbc34f1e29 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Capacitor.java @@ -0,0 +1,35 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch.gui; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; + +/** + * Created by Tec on 09.04.2017. + */ +public class GT_GUIContainer_Capacitor extends GT_GUIContainerMetaTile_Machine { + private final String mName; + + public GT_GUIContainer_Capacitor(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { + super(new GT_Container_Capacitor(aInventoryPlayer, aTileEntity), "gregtech:textures/gui/holder.png"); + mName = aName; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + fontRendererObj.drawString(mName, 8, 4, 4210752); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + if (mContainer != null) { + if (((GT_Container_Capacitor) mContainer).mActive == 1) { + drawTexturedModalRect(x + 151, y + 23, 183, 23, 18, 18); + } + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java index 7b63af5c88..ca58340bad 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java @@ -2,47 +2,101 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Capacitor; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; 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 net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; +import java.util.ArrayList; + import static com.github.technus.tectech.Util.StructureBuilder; -import static gregtech.api.GregTech_API.sBlockCasings2; -import static gregtech.api.GregTech_API.sBlockCasings5; +import static com.github.technus.tectech.Util.V; +import static com.github.technus.tectech.auxiliary.TecTechConfig.DEBUG_MODE; +import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; +import static gregtech.api.GregTech_API.*; import static gregtech.api.enums.GT_Values.E; /** * Created by danie_000 on 17.12.2016. + * edited by Bass on like 2018-02-05 */ -public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { - private int powerSetting = 1000; - private int timerSetting = 0; - private int timerValue = 0; - private boolean hasBeenPausedThiscycle=false; - - //region Structure - //use multi A energy inputs, use less power the longer it runs - private static final String[][] shape = new String[][]{ - {E,"00000",}, - {"A000","00000","A000","\u0003","A . ",}, - {"A000","00100","A010","B1","B1","B1","B1","A 1 ",}, - {"A000","00000","A000","\u0003","A ",}, - {E,"00000",} - }; - private static final Block[] blockType = new Block[]{sBlockCasings5,sBlockCasings2}; - private static final byte[] blockMeta = new byte[]{0,0}; +public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable {//TODO Add capacitors + private static Textures.BlockIcons.CustomIcon ScreenOFF; + private static Textures.BlockIcons.CustomIcon ScreenON; + private final ArrayList<GT_MetaTileEntity_Hatch_Capacitor> eCaps = new ArrayList<>(); + private int tier = 0; + private int orientation = 0; + private int scanTime = 0; + private int scanRadius = 64;//TODO Generate depending on power stored + private long euTOutMax = V[9] / 8;//TODO Generate depending on count and kind of capacitors + private ArrayList<GT_MetaTileEntity_TM_teslaCoil> eTeslaList = new ArrayList<>(); + + //region structure + private static final String[][] shape0 = new String[][]{//3 16 0 + {"\u000F", "A . ",}, + {E, "B000", "B000", "B000", "\u0001", "B000", E, "B000", E, "B000", E, "B000", "\u0001", "B111", " 22222 ",}, + {"B000", "A00000", "A00000", "A00000", "B000", E, "A0A!A0", E, "A0A!A0", E, "A0A!A0", E, "A0A!A0", "\u0001", "A1C1", " 21112 ",}, + {"B000", "A00000", "A00000", "A00000", "B030", "C3", "A0!3!0", "C3", "A0!3!0", "C3", "A0!3!0", "C3", "A0!3!0", "C3", "C3", "A1A3A1", " 21212 ",}, + {"B000", "A00000", "A00000", "A00000", "B000", E, "A0A!A0", E, "A0A!A0", E, "A0A!A0", E, "A0A!A0", "\u0001", "A1C1", " 21112 ",}, + {E, "B000", "B000", "B000", "\u0001", "B000", E, "B000", E, "B000", E, "B000", "\u0001", "B111", " 22222 ",}, + {"\u000F", "A ",}, + }; + private static final String[][] shape1 = new String[][]{//3 0 0 + {"A . ",}, + {" 22222 ","A11111","\u0001","B000",E,"B000",E,"B000",E,"B000","\u0001","B000","B000","B000",}, + {" 21112 ","A1C1","\u0001","A0A!A0",E,"A0A!A0",E,"A0A!A0",E,"A0A!A0",E,"B000","A00000","A00000","A00000","B000",}, + {" 21212 ","A1A3A1","C3","C3","A0!3!0","C3","A0!3!0","C3","A0!3!0","C3","A0!3!0","C3","B030","A00000","A00000","A00000","B000",}, + {" 21112 ","A1C1","\u0001","A0A!A0",E,"A0A!A0",E,"A0A!A0",E,"A0A!A0",E,"B000","A00000","A00000","A00000","B000",}, + {" 22222 ","A11111","\u0001","B000",E,"B000",E,"B000",E,"B000","\u0001","B000","B000","B000",}, + {"A ",}, + }; + private static final String[][] shape2 = new String[][]{//16 3 0 + {E,"P ","P ","P.","P ","P ",}, + {"P ","O12","A000B0A0A0A0B12","A000B0A0A0A0B12","A000B0A0A0A0B12","O12","P ",}, + {"P ","A000B0A0A0A0B12","00000K1","00000A!A!A!A!C1","00000K1","A000B0A0A0A0B12","P ",}, + {"P ","A000B0A0A0A0B12","00000A!A!A!A!C1","00003333333333332","00000A!A!A!A!C1","A000B0A0A0A0B12","P ",}, + {"P ","A000B0A0A0A0B12","00000K1","00000A!A!A!A!C1","00000K1","A000B0A0A0A0B12","P ",}, + {"P ","O12","A000B0A0A0A0B12","A000B0A0A0A0B12","A000B0A0A0A0B12","F0H12","P ",}, + {E,"P ","P ","P ","P ","P ",}, + }; + private static final String[][] shape3 = new String[][]{//0 3 0 + {E," "," ","."," "," ",}, + {" ","21","21B0A0A0A0B000","21B0A0A0A0B000","21B0A0A0A0B000","21H0"," ",}, + {" ","21B0A0A0A0B000","1K00000","1C!A!A!A!A00000","1K00000","21B0A0A0A0B000"," ",}, + {" ","21B0A0A0A0B000","1C!A!A!A!A00000","23333333333330000","1C!A!A!A!A00000","21B0A0A0A0B000"," ",}, + {" ","21B0A0A0A0B000","1K00000","1C!A!A!A!A00000","1K00000","21B0A0A0A0B000"," ",}, + {" ","21","21B0A0A0A0B000","21B0A0A0A0B000","21B0A0A0A0B000","21"," ",}, + {E," "," "," "," "," ",}, + }; - private static final String[] addingMethods = new String[]{"addClassicToMachineList"}; - private static final short[] casingTextures = new short[]{16}; - private static final Block[] blockTypeFallback = new Block[]{sBlockCasings5}; - private static final byte[] blockMetaFallback = new byte[]{0}; + private static final String[][][] shapes = new String[][][]{shape0,shape1,shape2,shape3}; + private static final Block[] blockType = new Block[]{sBlockCasings1, sBlockCasings5, sBlockCasings2, sBlockCasings5};//TODO Give it it's own casing type, add a primary coil type, add a secondary coil type and add toroid casing type + private static final byte[] blockMetaT0 = new byte[]{15, 0, 13, 0}; + private static final byte[] blockMetaT1 = new byte[]{15, 1, 13, 0}; + private static final byte[] blockMetaT2 = new byte[]{15, 2, 13, 0}; + private static final byte[][] blockMetas = new byte[][]{blockMetaT0,blockMetaT1,blockMetaT2}; + private static final String[] addingMethods = new String[]{"addCapacitorToMachineList", "addFrameToMachineList"}; + private static final short[] casingTextures = new short[]{29, 0}; + private static final Block[] blockTypeFallback = new Block[]{sBlockCasings2, null}; + private static final byte[] blockMetaFallback = new byte[]{13, 0}; + private static final String[] description = new String[]{ + EnumChatFormatting.AQUA + "Hint Details:", + "1 - Classic Hatches or Steel Pipe Casing", + "2 - Titanium Frames", + }; //endregion public GT_MetaTileEntity_TM_teslaCoil(int aID, String aName, String aNameRegional) { @@ -53,123 +107,256 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock super(aName); } + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_TM_teslaCoil(this.mName); + return new GT_MetaTileEntity_TM_teslaCoil(mName); } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[16], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE)}; - } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[16]}; + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + ScreenOFF = new Textures.BlockIcons.CustomIcon("iconsets/EM_WH"); + ScreenON = new Textures.BlockIcons.CustomIcon("iconsets/EM_WH_ACTIVE"); + super.registerIcons(aBlockIconRegister); } @Override - public boolean isFacingValid(byte aFacing) { - return aFacing >= 2; + public long maxEUStore() { + return V[9] * 2; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][4], new GT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; + } + return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][4]}; } @Override public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - return structureCheck_EM(shape, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 2, 7, 1); + eCaps.clear(); + int coilX0 = 0; + int coilX1 = 0; + int coilX2 = 0; + + int coilY0 = 1; + int coilY1 = 0; + int coilY2 = 0; + + int coilZ0 = 0; + int coilZ1 = 0; + int coilZ2 = 0; + + switch (iGregTechTileEntity.getFrontFacing()) { + case 2: + coilZ0 = 1; + coilZ1 = 1; + coilZ2 = 1; + coilX1 = 1; + coilX2 = -1; + break; + case 3: + coilZ0 = -1; + coilZ1 = -1; + coilZ2 = -1; + coilX1 = -1; + coilX2 = 1; + break; + case 4: + coilX0 = 1; + coilX1 = 1; + coilX2 = 1; + coilZ1 = -1; + coilZ2 = 1; + break; + case 5: + coilX0 = -1; + coilX1 = -1; + coilX2 = -1; + coilZ1 = 1; + coilZ2 = -1; + break; + default: + return false; + } + + Block coil0 = iGregTechTileEntity.getBlockOffset(coilX0, coilY0, coilZ0); + Block coil1 = iGregTechTileEntity.getBlockOffset(coilX0, -coilY0, coilZ0); + Block coil2 = iGregTechTileEntity.getBlockOffset(coilX1, coilY1, coilZ1); + Block coil3 = iGregTechTileEntity.getBlockOffset(coilX2, coilY2, coilZ2); + + int xOffset; + int yOffset; + int zOffset; + + if (coil0 == sBlockCasings5) { + xOffset = 3; + yOffset = 16; + zOffset = 0; + orientation = 0; + tier = iGregTechTileEntity.getMetaIDOffset(coilX0, coilY0, coilZ0); + } else if (coil1 == sBlockCasings5) { + xOffset = 3; + yOffset = 0; + zOffset = 0; + orientation = 1; + tier = iGregTechTileEntity.getMetaIDOffset(coilX0, -coilY0, coilZ0); + } else if (coil2 == sBlockCasings5) { + xOffset = 16; + yOffset = 3; + zOffset = 0; + orientation = 2; + tier = iGregTechTileEntity.getMetaIDOffset(coilX1, coilY1, coilZ1); + } else if (coil3 == sBlockCasings5) { + xOffset = 0; + yOffset = 3; + zOffset = 0; + orientation = 3; + tier = iGregTechTileEntity.getMetaIDOffset(coilX2, coilY2, coilZ2); + } else { + return false; + } + + return structureCheck_EM(shapes[orientation], blockType, blockMetas[tier], addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, xOffset, yOffset, zOffset); } @Override public void construct(int stackSize, boolean hintsOnly) { - StructureBuilder(shape, blockType, blockMeta,2, 7, 1, getBaseMetaTileEntity(),hintsOnly); + StructureBuilder(shapes[0], blockType, blockMetas[(stackSize-1)%3], 3, 16, 0, getBaseMetaTileEntity(), hintsOnly); } @Override public String[] getStructureDescription(int stackSize) { - return new String[0]; + return description; } @Override public String[] getDescription() { return new String[]{ - CommonValues.bassMark, - "High Frequency Oven", - EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + "From live to done in seconds!", - EnumChatFormatting.BLUE + "I said nuke the chinese, I meant teslaCoil supper!", + CommonValues.BASS_MARK, + "Tower of Wireless Power", + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + "Fewer pesky cables!", + EnumChatFormatting.BLUE + "Survival chances might be affected", }; } @Override public boolean checkRecipe_EM(ItemStack itemStack) { - hasBeenPausedThiscycle=false; - if(powerSetting<=300 || eParamsInStatus[0] == PARAM_TOO_HIGH || timerSetting<=0 || timerSetting>3000) return false; - if (timerValue <= 0) { - timerValue=timerSetting; - } - mEUt = -(powerSetting >> 1); - eAmpereFlow = 1; - mMaxProgresstime = 20; mEfficiencyIncrease = 10000; + mMaxProgresstime = 20; return true; } @Override - public void outputAfterRecipe_EM() { + public boolean onRunningTick(ItemStack aStack) { + IGregTechTileEntity mte = getBaseMetaTileEntity(); - } + if (mte.isClientSide()) { + return true; + } + if (!ePowerPass && getEUVar() > maxEUStore() / 2 * 0.8) { + ePowerPass = true; + } else if (ePowerPass && getEUVar() < maxEUStore() / 2 * 0.2) { + ePowerPass = false; + } - @Override - public void updateParameters_EM() { - if (eParamsIn[0] <= 300) - eParamsInStatus[0] = PARAM_TOO_LOW; - else if (eParamsIn[0] < 1000) - eParamsInStatus[0] = PARAM_LOW; - else if (eParamsIn[0] == 1000) - eParamsInStatus[0] = PARAM_OK; - else if (eParamsIn[0] <= Integer.MAX_VALUE) - eParamsInStatus[0] = PARAM_HIGH; - else eParamsInStatus[0] = PARAM_TOO_HIGH; - - if (eParamsIn[10] <= 1) - eParamsInStatus[10] = PARAM_TOO_LOW; - else if (eParamsIn[10] <= 3000) - eParamsInStatus[10] = PARAM_OK; - else eParamsInStatus[10] = PARAM_TOO_HIGH; - - powerSetting = (int)eParamsIn[0]; - timerSetting = (int)eParamsIn[10]; - - eParamsOut[0] = timerValue; - } + if (ePowerPass) { + scanTime++; + if (scanTime == 100) { + scanTime = 0; + eTeslaList.clear(); - @Override - public boolean onRunningTick(ItemStack aStack) { - if(eSafeVoid) hasBeenPausedThiscycle=true; - return hasBeenPausedThiscycle || super.onRunningTick(aStack);//consume eu and other resources if not paused - } + for (int xPosOffset = -scanRadius; xPosOffset <= scanRadius; xPosOffset++) { + for (int yPosOffset = -scanRadius; yPosOffset <= scanRadius; yPosOffset++) { + for (int zPosOffset = -scanRadius; zPosOffset <= scanRadius; zPosOffset++) { + IGregTechTileEntity node = mte.getIGregTechTileEntityOffset(xPosOffset, yPosOffset, zPosOffset); + if (node == null) { + continue; + } + IMetaTileEntity nodeInside = node.getMetaTileEntity(); + if (nodeInside instanceof GT_MetaTileEntity_TM_teslaCoil && node.isActive()) { + eTeslaList.add((GT_MetaTileEntity_TM_teslaCoil) nodeInside); + } + } + } + } + } - @Override - public void stopMachine() { - super.stopMachine(); - timerValue=0; - } + float xPos = mte.getXCoord() + 0.5f; + float yPos = mte.getYCoord() + 0.5f; + float zPos = mte.getZCoord() + 0.5f; + long reqSum = 0; + for (GT_MetaTileEntity_TM_teslaCoil Rx : eTeslaList.toArray(new GT_MetaTileEntity_TM_teslaCoil[eTeslaList.size()])) { + try { + reqSum += Rx.maxEUStore() - Rx.getEUVar(); + } catch (Exception e) { + eTeslaList.remove(Rx); + } + } - @Override - protected void workGotDisabled_EM() { - timerValue=0; + for (GT_MetaTileEntity_TM_teslaCoil Rx : eTeslaList) { + if (!Rx.ePowerPass) { + long euTran = (euTOutMax * (Rx.maxEUStore() - Rx.getEUVar())) / reqSum; + if (Rx.getEUVar() + euTran <= Rx.maxEUStore() && getEUVar() - euTran >= 0) { + setEUVar(getEUVar() - euTran); + Rx.getBaseMetaTileEntity().increaseStoredEnergyUnits(euTran, true);//might work QUESTION POINT; + //mte.getWorld().playSoundEffect(xPos, yPos, zPos, Reference.MODID + ":microwave_ding", 1, 1); + } + } + } + } + return true; } - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setInteger("eTimerVal", timerValue); + public final boolean addFrameToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + return aTileEntity != null && aTileEntity.getMetaTileEntity() instanceof GT_MetaPipeEntity_Frame; } - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - timerValue = aNBT.getInteger("eTimerVal"); + public final boolean addCapacitorToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Capacitor) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eCaps.add((GT_MetaTileEntity_Hatch_Capacitor) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eEnergyMulti.add((GT_MetaTileEntity_Hatch_EnergyMulti) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eDynamoMulti.add((GT_MetaTileEntity_Hatch_DynamoMulti) aMetaTileEntity); + } + return false; } - @Override - public void doExplosion(long aExplosionPower) { - explodeMultiblock(); - }//Redirecting to explodemultiblock + public static void run() { + try { + adderMethodMap.put("addFrameToMachineList", GT_MetaTileEntity_TM_teslaCoil.class.getMethod("addFrameToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addCapacitorToMachineList", GT_MetaTileEntity_TM_teslaCoil.class.getMethod("addCapacitorToMachineList", IGregTechTileEntity.class, int.class)); + } catch (NoSuchMethodException e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + } } |