diff options
author | GlodBlock <1356392126@qq.com> | 2021-08-16 22:46:40 +0800 |
---|---|---|
committer | GlodBlock <1356392126@qq.com> | 2021-08-16 22:46:40 +0800 |
commit | c6daf6b4d70ccde55c2a944036cb13656966e991 (patch) | |
tree | fe57ed6b65ed9e4c601445eff0627e19fdb0a586 /src/main/java | |
parent | 845cce81a82e1cfd9d404fa1b13490acff96bf35 (diff) | |
download | GT5-Unofficial-c6daf6b4d70ccde55c2a944036cb13656966e991.tar.gz GT5-Unofficial-c6daf6b4d70ccde55c2a944036cb13656966e991.tar.bz2 GT5-Unofficial-c6daf6b4d70ccde55c2a944036cb13656966e991.zip |
add Neutron Activator related blocks
Diffstat (limited to 'src/main/java')
12 files changed, 668 insertions, 13 deletions
diff --git a/src/main/java/GoodGenerator/Blocks/TEs/FuelRefineFactory.java b/src/main/java/GoodGenerator/Blocks/TEs/FuelRefineFactory.java index 856828d2d7..b046866409 100644 --- a/src/main/java/GoodGenerator/Blocks/TEs/FuelRefineFactory.java +++ b/src/main/java/GoodGenerator/Blocks/TEs/FuelRefineFactory.java @@ -190,14 +190,14 @@ public class FuelRefineFactory extends GT_MetaTileEntity_MultiblockBase_EM imple @Override public void loadNBTData(NBTTagCompound aNBT){ - super.loadNBTData(aNBT); this.Tier = aNBT.getInteger("mTier"); + super.loadNBTData(aNBT); } @Override public void saveNBTData(NBTTagCompound aNBT){ - super.saveNBTData(aNBT); aNBT.setInteger("mTier", this.Tier); + super.saveNBTData(aNBT); } @Override diff --git a/src/main/java/GoodGenerator/Blocks/TEs/MetaTE/NeutronAccelerator.java b/src/main/java/GoodGenerator/Blocks/TEs/MetaTE/NeutronAccelerator.java new file mode 100644 index 0000000000..b6f087eba7 --- /dev/null +++ b/src/main/java/GoodGenerator/Blocks/TEs/MetaTE/NeutronAccelerator.java @@ -0,0 +1,66 @@ +package GoodGenerator.Blocks.TEs.MetaTE; + +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] * 10 / 8); + } + + @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 0.1~0.2 KeV Neutron Kinetic Energy." + }; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (this.getBaseMetaTileEntity().isServerSide()) { + if (aBaseMetaTileEntity.getStoredEU() >= getMaxEUConsume()) { + setEUVar(aBaseMetaTileEntity.getStoredEU() - getMaxEUConsume()); + isRunning = true; + } else { + isRunning = false; + } + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } +} diff --git a/src/main/java/GoodGenerator/Blocks/TEs/MetaTE/NeutronSensor.java b/src/main/java/GoodGenerator/Blocks/TEs/MetaTE/NeutronSensor.java new file mode 100644 index 0000000000..0c9071671e --- /dev/null +++ b/src/main/java/GoodGenerator/Blocks/TEs/MetaTE/NeutronSensor.java @@ -0,0 +1,141 @@ +package GoodGenerator.Blocks.TEs.MetaTE; + +import GoodGenerator.Client.GUI.NeutronSensorGUIClient; +import GoodGenerator.Common.Container.NeutronSensorGUIContainer; +import GoodGenerator.Main.GoodGenerator; +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_Log; +import net.minecraft.entity.player.EntityPlayer; +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 = ""; + + 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"); + GT_Log.out.print(texts + "\n"); + 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); + texts = aNBT.getString("mBoxContext"); + } + + @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) { + GT_Log.out.print(texts + "\n"); + 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()) aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + public void setText(String text) { + texts = text; + } + + @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 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; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + //if (aTick % 100 == 0) GT_Log.out.print(texts + "\n"); + } +} diff --git a/src/main/java/GoodGenerator/Blocks/TEs/MultiNqGenerator.java b/src/main/java/GoodGenerator/Blocks/TEs/MultiNqGenerator.java index 769f4fefc6..4fc44e9469 100644 --- a/src/main/java/GoodGenerator/Blocks/TEs/MultiNqGenerator.java +++ b/src/main/java/GoodGenerator/Blocks/TEs/MultiNqGenerator.java @@ -135,9 +135,11 @@ public class MultiNqGenerator extends GT_MetaTileEntity_MultiblockBase_EM implem return multiDefinition; } - public MultiNqGenerator(String name){super(name);} + public MultiNqGenerator(String name) { + super(name); + } - public MultiNqGenerator(int id, String name, String nameRegional){ + public MultiNqGenerator(int id, String name, String nameRegional) { super(id,name,nameRegional); } @@ -148,7 +150,6 @@ public class MultiNqGenerator extends GT_MetaTileEntity_MultiblockBase_EM implem @Override public void loadNBTData(NBTTagCompound aNBT){ - super.loadNBTData(aNBT); this.ticker = aNBT.getInteger("mTicker"); this.fluidLocker = aNBT.getBoolean("mIsLocked"); this.times = aNBT.getInteger("mTimes"); @@ -156,11 +157,11 @@ public class MultiNqGenerator extends GT_MetaTileEntity_MultiblockBase_EM implem 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){ - super.saveNBTData(aNBT); aNBT.setInteger("mTicker", this.ticker); aNBT.setBoolean("mIsLocked", this.fluidLocker); aNBT.setInteger("mTimes", this.times); @@ -169,6 +170,7 @@ public class MultiNqGenerator extends GT_MetaTileEntity_MultiblockBase_EM implem aNBT.setString("mLockedFluidName", this.lockedFluid.getFluid().getName()); aNBT.setInteger("mLockedFluidAmount", this.lockedFluid.amount); } + super.saveNBTData(aNBT); } @Override diff --git a/src/main/java/GoodGenerator/Blocks/TEs/NeutronActivator.java b/src/main/java/GoodGenerator/Blocks/TEs/NeutronActivator.java new file mode 100644 index 0000000000..2498f81d2a --- /dev/null +++ b/src/main/java/GoodGenerator/Blocks/TEs/NeutronActivator.java @@ -0,0 +1,177 @@ +package GoodGenerator.Blocks.TEs; + +import GoodGenerator.Blocks.TEs.MetaTE.NeutronAccelerator; +import GoodGenerator.Blocks.TEs.MetaTE.NeutronSensor; +import com.github.technus.tectech.mechanics.structure.IStructureDefinition; +import com.github.technus.tectech.mechanics.structure.StructureDefinition; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import ic2.core.Ic2Items; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; + +import java.util.ArrayList; + +import static GoodGenerator.util.StructureHelper.addFrame; +import static com.github.technus.tectech.mechanics.structure.StructureUtility.*; +import static org.apache.commons.lang3.RandomUtils.nextInt; + +public class NeutronActivator extends GT_MetaTileEntity_MultiblockBase_EM { + + 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 KeV; + + public NeutronActivator(String name) { + super(name); + } + + public NeutronActivator(int id, String name, String nameRegional) { + super(id,name,nameRegional); + } + + @Override + public IStructureDefinition<NeutronActivator> getStructure_EM() { + if(multiDefinition == null) { + multiDefinition = StructureDefinition + .<NeutronActivator>builder() + .addShape(mName, + transpose(new String[][]{ + {"CCCCC","CDDDC","CDDDC","CDDDC","CCCCC"}, + {"F F"," GGG "," GPG "," GGG ","F F"}, + {"F F"," GGG "," GPG "," GGG ","F F"}, + {"F F"," GGG "," GPG "," GGG ","F F"}, + {"F F"," GGG "," GPG "," GGG ","F F"}, + {"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( + GregTech_API.sBlockCasings2, 13 + ) + ) + .addElement( + 'X', + ofChain( + ofHatchAdder( + NeutronActivator::addClassicOutputToMachineList, 49, + 2 + ), + ofHatchAdder( + NeutronActivator::addMaintenanceToMachineList, 49, + 2 + ), + ofHatchAdder( + NeutronActivator::addAccelerator, 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(); + return structureCheck_EM(mName, 2, 5, 0) && casingAmount >= 7; + } + + public final boolean addAccelerator(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 10000000; + } + + @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) { + anyWorking = true; + this.KeV += nextInt(tHatch.getMaxEUConsume(), tHatch.getMaxEUConsume() * 2 + 1) / 10; + } + } + if (!anyWorking) { + if (this.KeV >= 80 && aTick % 20 == 0) { + this.KeV -= 80; + } + else if (this.KeV > 0 && aTick % 20 == 0) { + this.KeV = 0; + } + } + if (this.KeV < 0) this.KeV = 0; + if (this.KeV > maxNeutronKineticEnergy()) doExplosion(4 * 32); + } + } +} diff --git a/src/main/java/GoodGenerator/Client/GUI/NeutronSensorGUIClient.java b/src/main/java/GoodGenerator/Client/GUI/NeutronSensorGUIClient.java new file mode 100644 index 0000000000..b80f1d7d90 --- /dev/null +++ b/src/main/java/GoodGenerator/Client/GUI/NeutronSensorGUIClient.java @@ -0,0 +1,111 @@ +package GoodGenerator.Client.GUI; + +import GoodGenerator.Blocks.TEs.MetaTE.NeutronSensor; +import GoodGenerator.Main.GoodGenerator; +import GoodGenerator.util.CharExchanger; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import net.minecraft.client.gui.GuiTextField; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +@SideOnly(Side.CLIENT) +public class NeutronSensorGUIClient extends GT_GUIContainerMetaTile_Machine { + + protected final String mName; + + private GuiTextField TextBox; + private String context; + private GT_MetaTileEntity_Hatch mTile; + + public NeutronSensorGUIClient(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aTexture, String text) { + super(aInventoryPlayer, aTileEntity, aTexture); + this.mName = "Neutron Sensor"; + this.mTile = (GT_MetaTileEntity_Hatch) aTileEntity.getMetaTileEntity(); + this.mContainer.detectAndSendChanges(); + if (text == null) this.context = ""; + else this.context = text; + } + + public void initGui(){ + super.initGui(); + this.TextBox = new GuiTextField(this.fontRendererObj, 8, 48, 100, 18); + TextBox.setMaxStringLength(20); + TextBox.setText(context); + this.TextBox.setFocused(true); + } + + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + this.fontRendererObj.drawString(this.mName, 8, 4, 4210752); + this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.NeutronSensor.0"), 8, 16, 0x000000); + this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.NeutronSensor.1"), 8, 28, 0x000000); + this.TextBox.drawTextBox(); + if (TextBox.getText() != null) { + if (isValidSuffix(TextBox.getText())) { + if (CharExchanger.isValidCompareExpress(rawProcessExp(TextBox.getText()))) + this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.NeutronSensor.2"), 120, 53, 0x077d02); + else this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.NeutronSensor.3"), 120, 53, 0xff0000); + } + else this.fontRendererObj.drawString(StatCollector.translateToLocal("gui.NeutronSensor.3"), 120, 53, 0xff0000); + } + this.mc.getTextureManager().bindTexture(new ResourceLocation(GoodGenerator.MOD_ID + ":textures/gui/NeutronSensorGUI.png")); + } + + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (this.width - this.xSize) / 2; + int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } + + protected void keyTyped(char par1, int par2) { + if (!this.TextBox.isFocused()) + super.keyTyped(par1, par2); + if (par2 == 1) this.mc.thePlayer.closeScreen(); + this.TextBox.textboxKeyTyped(par1, par2); + } + + public void updateScreen() { + super.updateScreen(); + this.TextBox.updateCursorCounter(); + } + + protected void mouseClicked(int x, int y, int btn) { + super.mouseClicked(x, y, btn); + this.TextBox.mouseClicked(x - this.getLeft(), y - this.getTop(), btn); + } + + public void onGuiClosed() { + ((NeutronSensor) mTile).setText(context); + super.onGuiClosed(); + } + + 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); + break; + } + ret.append(c); + } + return ret.toString(); + } + + protected boolean isValidSuffix(String exp) { + int index; + index = exp.length() - 1; + if (index < 0) return false; + if (exp.charAt(index) != 'V' && exp.charAt(index) != 'v') return false; + index = exp.length() - 2; + if (index < 0) return false; + if (exp.charAt(index) != 'E' && exp.charAt(index) != 'e') return false; + index = exp.length() - 3; + if (index < 0) return false; + return exp.charAt(index) == 'M' || exp.charAt(index) == 'm' || exp.charAt(index) == 'K' || exp.charAt(index) == 'k' || Character.isDigit(exp.charAt(index)); + } +} diff --git a/src/main/java/GoodGenerator/Common/Container/NeutronSensorGUIContainer.java b/src/main/java/GoodGenerator/Common/Container/NeutronSensorGUIContainer.java new file mode 100644 index 0000000000..0c243b0a69 --- /dev/null +++ b/src/main/java/GoodGenerator/Common/Container/NeutronSensorGUIContainer.java @@ -0,0 +1,12 @@ +package GoodGenerator.Common.Container; + +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; + +public class NeutronSensorGUIContainer extends GT_ContainerMetaTile_Machine { + + public NeutronSensorGUIContainer(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } +} diff --git a/src/main/java/GoodGenerator/Items/MyMaterial.java b/src/main/java/GoodGenerator/Items/MyMaterial.java index 47ed7df2b7..65913501ba 100644 --- a/src/main/java/GoodGenerator/Items/MyMaterial.java +++ b/src/main/java/GoodGenerator/Items/MyMaterial.java @@ -257,10 +257,10 @@ public class MyMaterial implements Runnable { new Pair<> (Fluorine,4) ); - //Naquadria Catalyst + //Atomic Separation Catalyst public static final Werkstoff atomicSeparationCatalyst = new Werkstoff( new short[]{0xe8,0x5e,0x0c}, - "Naquadria Catalyst", + "Atomic Separation Catalyst", "the melting core...", new Werkstoff.Stats().setMeltingPoint(5000).setBlastFurnace(true), Werkstoff.Types.COMPOUND, @@ -338,7 +338,7 @@ public class MyMaterial implements Runnable { public static final Werkstoff ether = new Werkstoff( new short[]{0xeb,0xbc,0x2f}, - "Diethyl Ether", + "Ether", subscriptNumbers("CH3CH2OCH2CH3"), new Werkstoff.Stats(), Werkstoff.Types.COMPOUND, diff --git a/src/main/java/GoodGenerator/Loader/Loaders.java b/src/main/java/GoodGenerator/Loader/Loaders.java index a69651c38b..88ea24b226 100644 --- a/src/main/java/GoodGenerator/Loader/Loaders.java +++ b/src/main/java/GoodGenerator/Loader/Loaders.java @@ -4,11 +4,14 @@ import GoodGenerator.Blocks.RegularBlock.Casing; import GoodGenerator.Blocks.RegularBlock.Frame; import GoodGenerator.Blocks.RegularBlock.TEBlock; import GoodGenerator.Blocks.TEs.*; +import GoodGenerator.Blocks.TEs.MetaTE.NeutronAccelerator; +import GoodGenerator.Blocks.TEs.MetaTE.NeutronSensor; import GoodGenerator.Items.MyItemBlocks; import GoodGenerator.Items.MyItems; import GoodGenerator.Main.GoodGenerator; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.GT_Values; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.render.TextureFactory; @@ -57,6 +60,9 @@ public class Loaders { public static ItemStack FRF; public static ItemStack UCFE; public static ItemStack LEG; + public static ItemStack NS; + + public static ItemStack[] NeutronAccelerators = new ItemStack[9]; public static void Register(){ GameRegistry.registerBlock(MAR_Casing, MyItemBlocks.class, "MAR_Casing"); @@ -93,6 +99,10 @@ public class Loaders { GameRegistry.registerTileEntity(EssentiaHatch.class, "EssentiaHatch"); Loaders.LEG = new LargeEssentiaGenerator(IDOffset + 1, "LargeEssentiaGenerator", "Large Essentia Generator").getStackForm(1L); } + for (int i = 0; i < 9; i ++) { + Loaders.NeutronAccelerators[i] = new NeutronAccelerator(IDOffset + 2 + i, "Neutron Accelerator " + GT_Values.VN[i], "Neutron Accelerator " + GT_Values.VN[i], i).getStackForm(1L); + } + Loaders.NS = new NeutronSensor(IDOffset + 11, "Neutron Sensor", "Neutron Sensor", 5).getStackForm(1L); } public static void addOreDic(){ diff --git a/src/main/java/GoodGenerator/Loader/RecipeLoader.java b/src/main/java/GoodGenerator/Loader/RecipeLoader.java index c68624d244..94f52b8ec5 100644 --- a/src/main/java/GoodGenerator/Loader/RecipeLoader.java +++ b/src/main/java/GoodGenerator/Loader/RecipeLoader.java @@ -1088,7 +1088,7 @@ public class RecipeLoader { FluidRegistry.getFluidStack("refinedglue",1000), null, new ItemStack(Loaders.specialCeramics,9), - 1000, + 100, 1980 ); @@ -1100,7 +1100,7 @@ public class RecipeLoader { FluidRegistry.getFluidStack("refinedglue",1000), null, new ItemStack(Loaders.specialCeramics,9), - 1000, + 100, 1980 ); diff --git a/src/main/java/GoodGenerator/util/CharExchanger.java b/src/main/java/GoodGenerator/util/CharExchanger.java index afd5a49999..e2b95c040b 100644 --- a/src/main/java/GoodGenerator/util/CharExchanger.java +++ b/src/main/java/GoodGenerator/util/CharExchanger.java @@ -1,8 +1,83 @@ package GoodGenerator.util; public class CharExchanger { + public static char shifter(int unicode){ - char c = (char)unicode; - return c; + return (char)unicode; + } + + public static boolean isValidCompareExpressChar(char c) { + return Character.isDigit(c) || c == '<' || c == '>' || c == '=' || c == '!'; + } + + public static boolean isValidCompareExpress(String exp) { + if (exp.length() < 2) return false; + for (char c: exp.toCharArray()) + if (!isValidCompareExpressChar(c)) return false; + char c1 = exp.charAt(0), c2 = exp.charAt(1); + String subExp = "" + c1; + if (!Character.isDigit(c2)) subExp = subExp + c2; + switch (subExp) { + case ">": + case "<": + case ">=": + case "<=": + case "==": + case "!=": + break; + default: return false; + } + if (exp.length() == subExp.length()) return false; + for (int i = subExp.length(); i < exp.length(); i ++) { + if (!Character.isDigit(exp.charAt(i))) return false; + } + return true; + } + + /** + * ">" : 1 <BR> + * "<" : 2 <BR> + * "==" : 13 <BR> + * "!=" : 14 <BR> + * ">=" : 11 <BR> + * "<=" : 12 <BR> + * INVALID : -1 + */ + public static int getOperator(String exp){ + char c1, c2; + int ret; + if (exp.length() < 1) return -1; + c1 = exp.charAt(0); + switch (c1) { + case '>': ret = 1;break; + case '<': ret = 2;break; + case '=': ret = 3;break; + case '!': ret = 4;break; + default: return -1; + } + if (exp.length() > 1) c2 = exp.charAt(1); + else return ret; + if (c2 == '=') { + ret += 10; + } + return ret; + } + + public static boolean compareExpression(String exp, int num) { + int op = getOperator(exp); + String NumExp = exp; + String[] opChar = new String[]{">", "<", "<=", ">=", "==", "!="}; + if (op == -1) throw new IllegalArgumentException(); + for (String re: opChar) NumExp = NumExp.replace(re, ""); + int num2 = Integer.getInteger(NumExp); + switch (op) { + case 1: return num > num2; + case 2: return num < num2; + case 13: return num == num2; + case 14: return num != num2; + case 11: return num >= num2; + case 12: return num <= num2; + default: return false; + } } } diff --git a/src/main/java/GoodGenerator/util/StructureHelper.java b/src/main/java/GoodGenerator/util/StructureHelper.java new file mode 100644 index 0000000000..2c5feadab8 --- /dev/null +++ b/src/main/java/GoodGenerator/util/StructureHelper.java @@ -0,0 +1,61 @@ +package GoodGenerator.util; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.mechanics.structure.IStructureElement; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.metatileentity.BaseMetaPipeEntity; +import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Frame; +import gregtech.api.util.GT_OreDictUnificator; +import net.minecraft.init.Items; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import java.util.Arrays; + +public class StructureHelper { + + public static <T>IStructureElement<T> addFrame(Materials aMaterials) { + return new IStructureElement<T>() { + + private IIcon[] mIcons; + + @Override + public boolean check(T t, World world, int x, int y, int z) { + TileEntity tBlock = world.getTileEntity(x, y, z); + if (tBlock instanceof BaseMetaPipeEntity) { + BaseMetaPipeEntity tFrame = (BaseMetaPipeEntity) tBlock; + if (tFrame.isInvalidTileEntity()) return false; + if (tFrame.getMetaTileEntity() instanceof GT_MetaPipeEntity_Frame) { + return ((GT_MetaPipeEntity_Frame) tFrame.getMetaTileEntity()).mMaterial == aMaterials; + } + } + return false; + } + + @Override + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + if (mIcons == null) { + mIcons = new IIcon[6]; + Arrays.fill(mIcons, aMaterials.mIconSet.mTextures[OrePrefixes.frameGt.mTextureIndex].getIcon()); + } + TecTech.proxy.hint_particle_tinted(world, x, y, z, mIcons, aMaterials.mRGBa); + return true; + } + + @Override + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + ItemStack tFrame = GT_OreDictUnificator.get(OrePrefixes.frameGt, aMaterials, 1); + if (tFrame.getItem() instanceof ItemBlock) { + ItemBlock tFrameStackItem = (ItemBlock) tFrame.getItem(); + return tFrameStackItem.placeBlockAt(tFrame, null, world, x, y, z, 6, 0, 0, 0, Items.feather.getDamage(tFrame)); + } + return false; + } + }; + } + +} |