diff options
| author | Yang Xizhi <60341015+GlodBlock@users.noreply.github.com> | 2022-09-06 21:59:09 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-06 15:59:09 +0200 |
| commit | dec7edc32cfe606580a859ba111ea33085518bfd (patch) | |
| tree | 32d421aacce14c79839df1c945eab508289cc432 /src | |
| parent | 0f34afff08436727ecd1cb8eb682f2c82871de87 (diff) | |
| download | GT5-Unofficial-dec7edc32cfe606580a859ba111ea33085518bfd.tar.gz GT5-Unofficial-dec7edc32cfe606580a859ba111ea33085518bfd.tar.bz2 GT5-Unofficial-dec7edc32cfe606580a859ba111ea33085518bfd.zip | |
add nei page and code rewrite for radhatch (#195)
* add neihandler for radhatch
* spotlessApply (#196)
Co-authored-by: Yang Xizhi <60341015+GlodBlock@users.noreply.github.com>
Co-authored-by: GitHub GTNH Actions <>
* gui container and recipe logic rewrite
* clean up
* spotlessApply (#197)
Co-authored-by: Yang Xizhi <60341015+GlodBlock@users.noreply.github.com>
Co-authored-by: GitHub GTNH Actions <>
* request change
* add sievert display and sound effect
* Spotless apply for branch radhatch for #195 (#199)
* fix DT construct and survivalConstruct having wrong offset (#198)
* spotlessApply
Co-authored-by: Glease <4586901+Glease@users.noreply.github.com>
Co-authored-by: Yang Xizhi <60341015+GlodBlock@users.noreply.github.com>
Co-authored-by: GitHub GTNH Actions <>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Glease <4586901+Glease@users.noreply.github.com>
Former-commit-id: bac12a5f712ca340284bdb6f3be4bb26a43f9594
Diffstat (limited to 'src')
13 files changed, 501 insertions, 253 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java index 78fafff410..13bff6e0d6 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java @@ -170,6 +170,7 @@ public final class MainMod { WerkstoffLoader.run(); LocalisationLoader.localiseAll(); } + RadioHatchMaterialLoader.run(); } @Mod.EventHandler diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_RadioHatch.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_RadioHatch.java index 13dd85c5c4..b77417131c 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_RadioHatch.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_RadioHatch.java @@ -24,16 +24,15 @@ package com.github.bartimaeusnek.bartworks.client.gui; import com.github.bartimaeusnek.bartworks.API.BioVatLogicAdder; import com.github.bartimaeusnek.bartworks.MainMod; -import com.github.bartimaeusnek.bartworks.common.tileentities.tiered.GT_MetaTileEntity_RadioHatch; import com.github.bartimaeusnek.bartworks.server.container.GT_Container_RadioHatch; import com.github.bartimaeusnek.bartworks.util.MathUtils; 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 java.nio.ByteBuffer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) @@ -51,13 +50,12 @@ public class GT_GUIContainer_RadioHatch extends GT_GUIContainerMetaTile_Machine } protected void drawGuiContainerForegroundLayer(int par1, int par2) { - long timer = ByteBuffer.wrap(((GT_Container_RadioHatch) this.mContainer).teTimer) - .getLong(); - double maxT = ((GT_Container_RadioHatch) this.mContainer).mass - * (GT_MetaTileEntity_RadioHatch.calcDecayTicks(((GT_Container_RadioHatch) this.mContainer).sievert)); + + long timer = ((GT_Container_RadioHatch) this.mContainer).teTimer; + double maxT = ((GT_Container_RadioHatch) this.mContainer).decayTime; double rem = maxT - timer % maxT; - this.fontRendererObj.drawString(this.mName, 8, 4, 4210752); + this.fontRendererObj.drawString(this.mName, 5, 4, 4210752); this.mc.getTextureManager().bindTexture(new ResourceLocation(MainMod.MOD_ID + ":textures/GUI/RadHatch.png")); if (((GT_Container_RadioHatch) this.mContainer).mass > 0) { GL11.glColor3f( @@ -67,7 +65,11 @@ public class GT_GUIContainer_RadioHatch extends GT_GUIContainerMetaTile_Machine this.drawTexturedModalRect(124, 18, 124, 18, 16, 48); } GL11.glColor3f(1f, 1f, 1f); - this.drawTexturedModalRect(124, 18, 176, 0, 16, 48 - MathUtils.ceilInt(48 * (rem / maxT))); + if (((GT_Container_RadioHatch) this.mContainer).mass <= 0) { + this.drawTexturedModalRect(124, 18, 176, 0, 16, 48); + } else { + this.drawTexturedModalRect(124, 18, 176, 0, 16, 48 - MathUtils.ceilInt(48 * (rem / maxT))); + } this.drawTexturedModalRect( 65, 13, @@ -76,16 +78,18 @@ public class GT_GUIContainer_RadioHatch extends GT_GUIContainerMetaTile_Machine (48 * (((GT_Container_RadioHatch) this.mContainer).sv)) / (GT_GUIContainer_RadioHatch.maxSv), 16); - // this.fontRendererObj.drawString("Sv: " + ((GT_Container_RadioHatch) mContainer).sievert, 8, 50, - // BW_ColorUtil.getColorFromRGBArray(new short[]{((GT_Container_RadioHatch) mContainer).r, - // ((GT_Container_RadioHatch) mContainer).g, ((GT_Container_RadioHatch) mContainer).b})); - // this.fontRendererObj.drawString("Kg: " + ((GT_Container_RadioHatch) mContainer).mass, 8, 68, - // BW_ColorUtil.getColorFromRGBArray(new short[]{((GT_Container_RadioHatch) mContainer).r, - // ((GT_Container_RadioHatch) mContainer).g, ((GT_Container_RadioHatch) mContainer).b})); - // this.fontRendererObj.drawString("Time: " + timer, 8, 76, BW_ColorUtil.getColorFromRGBArray(new - // short[]{((GT_Container_RadioHatch) mContainer).r, ((GT_Container_RadioHatch) mContainer).g, - // ((GT_Container_RadioHatch) mContainer).b})); - + this.fontRendererObj.drawString( + StatCollector.translateToLocalFormatted( + "BW.NEI.display.radhatch.1", ((GT_Container_RadioHatch) this.mContainer).mass), + 65, + 62, + 4210752); + this.fontRendererObj.drawString( + StatCollector.translateToLocalFormatted( + "BW.NEI.display.radhatch.0", ((GT_Container_RadioHatch) this.mContainer).sv), + 60, + 72, + 4210752); } protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RadioHatchMaterialLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RadioHatchMaterialLoader.java new file mode 100644 index 0000000000..8d0bdd1b48 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RadioHatchMaterialLoader.java @@ -0,0 +1,192 @@ +package com.github.bartimaeusnek.bartworks.common.loaders; + +import com.github.bartimaeusnek.bartworks.system.material.BW_NonMeta_MaterialItems; +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.util.BWRecipes; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; + +public class RadioHatchMaterialLoader { + + public static void run() { + + for (Werkstoff material : Werkstoff.werkstoffHashSet) { + if (material != null && material.getStats().isRadioactive()) { + int level = (int) material.getStats().getProtons(); + short[] rgba = material.getRGBA(); + if (material.hasItemType(OrePrefixes.stick)) + BWRecipes.instance.addRadHatch(material.get(OrePrefixes.stick), level, 1, rgba); + if (material.hasItemType(OrePrefixes.stickLong)) + BWRecipes.instance.addRadHatch(material.get(OrePrefixes.stickLong), level, 2, rgba); + } + } + + for (Materials material : Materials.getAll()) { + if (material == null || material.mElement == null) continue; + boolean validProton = material.getProtons() >= 83 + && !material.equals(Materials.Tritanium) // No Tritanium + && !material.equals(Materials.Naquadah); // Naquadah needs spacial value + if (validProton) { + int level = (int) material.getProtons(); + short[] rgba = material.getRGBA(); + if (GT_OreDictUnificator.get(OrePrefixes.stick, material, 1) != null) + BWRecipes.instance.addRadHatch( + GT_OreDictUnificator.get(OrePrefixes.stick, material, 1), level, 1, rgba); + if (GT_OreDictUnificator.get(OrePrefixes.stickLong, material, 1) != null) + BWRecipes.instance.addRadHatch( + GT_OreDictUnificator.get(OrePrefixes.stickLong, material, 1), level, 2, rgba); + } + } + + Materials[] spacialMaterial = + new Materials[] {Materials.Naquadah, Materials.NaquadahEnriched, Materials.Naquadria}; + int[] spacialValue = new int[] {130, 140, 150}; + + for (int i = 0; i < spacialMaterial.length; i++) { + if (GT_OreDictUnificator.get(OrePrefixes.stick, spacialMaterial[i], 1) != null) + BWRecipes.instance.addRadHatch( + GT_OreDictUnificator.get(OrePrefixes.stick, spacialMaterial[i], 1), + spacialValue[i], + 1, + spacialMaterial[i].mRGBa); + if (GT_OreDictUnificator.get(OrePrefixes.stickLong, spacialMaterial[i], 1) != null) + BWRecipes.instance.addRadHatch( + GT_OreDictUnificator.get(OrePrefixes.stickLong, spacialMaterial[i], 1), + spacialValue[i], + 2, + spacialMaterial[i].mRGBa); + } + + BWRecipes.instance.addRadHatch( + ItemList.ThoriumCell_1.get(1), (int) Materials.Thorium.getProtons(), 3, Materials.Thorium.mRGBa); + BWRecipes.instance.addRadHatch( + ItemList.ThoriumCell_2.get(1), (int) Materials.Thorium.getProtons(), 6, Materials.Thorium.mRGBa); + BWRecipes.instance.addRadHatch( + ItemList.ThoriumCell_4.get(1), (int) Materials.Thorium.getProtons(), 12, Materials.Thorium.mRGBa); + + BWRecipes.instance.addRadHatch(ItemList.NaquadahCell_1.get(1), 140, 3, Materials.NaquadahEnriched.mRGBa); + BWRecipes.instance.addRadHatch(ItemList.NaquadahCell_2.get(1), 140, 6, Materials.NaquadahEnriched.mRGBa); + BWRecipes.instance.addRadHatch(ItemList.NaquadahCell_4.get(1), 140, 12, Materials.NaquadahEnriched.mRGBa); + + BWRecipes.instance.addRadHatch( + ItemList.Moxcell_1.get(1), (int) Materials.Plutonium.getProtons(), 3, Materials.Plutonium.mRGBa); + BWRecipes.instance.addRadHatch( + ItemList.Moxcell_2.get(1), (int) Materials.Plutonium.getProtons(), 6, Materials.Plutonium.mRGBa); + BWRecipes.instance.addRadHatch( + ItemList.Moxcell_4.get(1), (int) Materials.Plutonium.getProtons(), 12, Materials.Plutonium.mRGBa); + + BWRecipes.instance.addRadHatch( + ItemList.Uraniumcell_1.get(1), (int) Materials.Uranium.getProtons(), 3, Materials.Uranium.mRGBa); + BWRecipes.instance.addRadHatch( + ItemList.Uraniumcell_2.get(1), (int) Materials.Uranium.getProtons(), 6, Materials.Uranium.mRGBa); + BWRecipes.instance.addRadHatch( + ItemList.Uraniumcell_4.get(1), (int) Materials.Uranium.getProtons(), 12, Materials.Uranium.mRGBa); + + BWRecipes.instance.addRadHatch( + BW_NonMeta_MaterialItems.TiberiumCell_1.get(1), + (int) WerkstoffLoader.Tiberium.getBridgeMaterial().getProtons(), + 3, + WerkstoffLoader.Tiberium.getRGBA()); + BWRecipes.instance.addRadHatch( + BW_NonMeta_MaterialItems.TiberiumCell_2.get(1), + (int) WerkstoffLoader.Tiberium.getBridgeMaterial().getProtons(), + 6, + WerkstoffLoader.Tiberium.getRGBA()); + BWRecipes.instance.addRadHatch( + BW_NonMeta_MaterialItems.TiberiumCell_4.get(1), + (int) WerkstoffLoader.Tiberium.getBridgeMaterial().getProtons(), + 12, + WerkstoffLoader.Tiberium.getRGBA()); + + BWRecipes.instance.addRadHatch( + BW_NonMeta_MaterialItems.TheCoreCell.get(1), 140, 96, Materials.NaquadahEnriched.mRGBa); + + BWRecipes.instance.addRadHatch( + ItemList.Depleted_Thorium_1.get(1), + (int) Materials.Thorium.getProtons() / 10, + 3, + Materials.Thorium.mRGBa); + BWRecipes.instance.addRadHatch( + ItemList.Depleted_Thorium_2.get(1), + (int) Materials.Thorium.getProtons() / 10, + 6, + Materials.Thorium.mRGBa); + BWRecipes.instance.addRadHatch( + ItemList.Depleted_Thorium_4.get(1), + (int) Materials.Thorium.getProtons() / 10, + 12, + Materials.Thorium.mRGBa); + + BWRecipes.instance.addRadHatch( + ItemList.Depleted_Naquadah_1.get(1), 140 / 10, 3, Materials.NaquadahEnriched.mRGBa); + BWRecipes.instance.addRadHatch( + ItemList.Depleted_Naquadah_2.get(1), 140 / 10, 6, Materials.NaquadahEnriched.mRGBa); + BWRecipes.instance.addRadHatch( + ItemList.Depleted_Naquadah_4.get(1), 140 / 10, 12, Materials.NaquadahEnriched.mRGBa); + + BWRecipes.instance.addRadHatch( + GT_ModHandler.getModItem("IC2", "reactorMOXSimpledepleted", 1), + (int) Materials.Plutonium.getProtons() / 10, + 3, + Materials.Plutonium.mRGBa); + BWRecipes.instance.addRadHatch( + GT_ModHandler.getModItem("IC2", "reactorMOXDualdepleted", 1), + (int) Materials.Plutonium.getProtons() / 10, + 6, + Materials.Plutonium.mRGBa); + BWRecipes.instance.addRadHatch( + GT_ModHandler.getModItem("IC2", "reactorMOXQuaddepleted", 1), + (int) Materials.Plutonium.getProtons() / 10, + 12, + Materials.Plutonium.mRGBa); + + BWRecipes.instance.addRadHatch( + GT_ModHandler.getModItem("IC2", "reactorUraniumSimpledepleted", 1), + (int) Materials.Uranium.getProtons() / 10, + 3, + Materials.Uranium.mRGBa); + BWRecipes.instance.addRadHatch( + GT_ModHandler.getModItem("IC2", "reactorUraniumDualdepleted", 1), + (int) Materials.Uranium.getProtons() / 10, + 6, + Materials.Uranium.mRGBa); + BWRecipes.instance.addRadHatch( + GT_ModHandler.getModItem("IC2", "reactorUraniumQuaddepleted", 1), + (int) Materials.Uranium.getProtons() / 10, + 12, + Materials.Uranium.mRGBa); + + BWRecipes.instance.addRadHatch( + BW_NonMeta_MaterialItems.Depleted_Tiberium_1.get(1), + (int) WerkstoffLoader.Tiberium.getBridgeMaterial().getProtons() / 10, + 3, + WerkstoffLoader.Tiberium.getRGBA()); + BWRecipes.instance.addRadHatch( + BW_NonMeta_MaterialItems.Depleted_Tiberium_2.get(1), + (int) WerkstoffLoader.Tiberium.getBridgeMaterial().getProtons() / 10, + 6, + WerkstoffLoader.Tiberium.getRGBA()); + BWRecipes.instance.addRadHatch( + BW_NonMeta_MaterialItems.Depleted_Tiberium_4.get(1), + (int) WerkstoffLoader.Tiberium.getBridgeMaterial().getProtons() / 10, + 12, + WerkstoffLoader.Tiberium.getRGBA()); + + BWRecipes.instance.addRadHatch( + BW_NonMeta_MaterialItems.Depleted_TheCoreCell.get(1), 130 / 10, 96, Materials.Naquadah.mRGBa); + + if (WerkstoffLoader.gtnhGT) { + BWRecipes.instance.addRadHatch(ItemList.MNqCell_1.get(1), 150, 3, Materials.Naquadria.mRGBa); + BWRecipes.instance.addRadHatch(ItemList.MNqCell_2.get(1), 150, 6, Materials.Naquadria.mRGBa); + BWRecipes.instance.addRadHatch(ItemList.MNqCell_4.get(1), 150, 12, Materials.Naquadria.mRGBa); + + BWRecipes.instance.addRadHatch(ItemList.Depleted_MNq_1.get(1), 150 / 10, 3, Materials.Naquadria.mRGBa); + BWRecipes.instance.addRadHatch(ItemList.Depleted_MNq_2.get(1), 150 / 10, 6, Materials.Naquadria.mRGBa); + BWRecipes.instance.addRadHatch(ItemList.Depleted_MNq_4.get(1), 150 / 10, 12, Materials.Naquadria.mRGBa); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java index d82181ea08..28fa80e963 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java @@ -22,33 +22,29 @@ package com.github.bartimaeusnek.bartworks.common.tileentities.tiered; -import static com.github.bartimaeusnek.bartworks.util.BW_Util.calculateSv; +import static gregtech.api.enums.GT_Values.ticksBetweenSounds; -import com.github.bartimaeusnek.bartworks.API.BioVatLogicAdder; -import com.github.bartimaeusnek.bartworks.API.IRadMaterial; -import com.github.bartimaeusnek.bartworks.API.LoaderReference; import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.bartworks.client.gui.GT_GUIContainer_RadioHatch; import com.github.bartimaeusnek.bartworks.server.container.GT_Container_RadioHatch; +import com.github.bartimaeusnek.bartworks.util.BWRecipes; import com.github.bartimaeusnek.bartworks.util.BW_ColorUtil; import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; import com.github.bartimaeusnek.bartworks.util.MathUtils; -import com.github.bartimaeusnek.crossmod.GTpp.loader.RadioHatchCompat; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; 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.BaseMetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.render.TextureFactory; -import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import java.util.HashMap; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch { @@ -56,11 +52,14 @@ public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch { private final int cap; public int sievert; private long timer = 1; + private long decayTime = 1; private short[] colorForGUI; private byte mass; private String material; private byte coverage; - private static HashMap<Integer, Long> sievertDecayCache = new HashMap<>(); + private ItemStack lastUsedItem = null; + private boolean lastFail = false; + private GT_Recipe lastRecipe = null; public GT_MetaTileEntity_RadioHatch(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 1, new String[] { @@ -85,19 +84,6 @@ public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch { this.cap = aTier - 2; } - public static long calcDecayTicks(int x) { - long ret = GT_MetaTileEntity_RadioHatch.sievertDecayCache.getOrDefault(x, 0L); - if (ret != 0) return ret; - - if (x == 43) ret = 5000; - else if (x == 61) ret = 4500; - else if (x <= 100) ret = MathUtils.ceilLong((8000D * Math.tanh(-x / 20D) + 8000D) * 1000D); - else ret = MathUtils.ceilLong(((8000D * Math.tanh(-x / 65D) + 8000D))); - - GT_MetaTileEntity_RadioHatch.sievertDecayCache.put(x, ret); - return ret; // *20; - } - public int getSievert() { return this.sievert - MathUtils.ceilInt((float) this.sievert / 100f * (float) this.coverage); } @@ -115,6 +101,10 @@ public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch { return this.coverage; } + public long getDecayTime() { + return this.decayTime; + } + public void setCoverage(short coverage) { byte nu; if (coverage > 100) nu = 100; @@ -145,16 +135,13 @@ public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch { this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()); - // super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); } public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } else { + if (!aBaseMetaTileEntity.isClientSide()) { aBaseMetaTileEntity.openGUI(aPlayer); - return true; } + return true; } public void updateSlots() { @@ -162,13 +149,15 @@ public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch { } public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - if (this.getBaseMetaTileEntity().isServerSide()) { + BaseMetaTileEntity myMetaTileEntity = ((BaseMetaTileEntity) this.getBaseMetaTileEntity()); + if (myMetaTileEntity.isServerSide()) { - if (this.mass > 0) ++this.timer; + if (this.mass > 0) { + ++this.timer; + } - if (this.mass > 0 && this.sievert > 0) { - float decayTicks = GT_MetaTileEntity_RadioHatch.calcDecayTicks(this.sievert); - if (decayTicks > 0 && this.timer % decayTicks == 0) { + if (this.mass > 0) { + if (this.decayTime == 0 || (this.decayTime > 0 && this.timer % this.decayTime == 0)) { this.mass--; if (this.mass == 0) { this.material = StatCollector.translateToLocal("tooltip.bw.empty.name"); @@ -178,122 +167,68 @@ public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch { } } - if (this.mass >= this.cap) return; + if (myMetaTileEntity.mTickTimer > (myMetaTileEntity.mLastSoundTick + ticksBetweenSounds)) { + if (this.sievert > 0) { + sendLoopStart((byte) 1); + myMetaTileEntity.mLastSoundTick = myMetaTileEntity.mTickTimer; + } + } - ItemStack lStack = this.mInventory[0]; + if (this.mass == 0) { + ItemStack lStack = this.mInventory[0]; - isStackValidRadioMaterial(lStack, true); - } - } - - public boolean isStackValidRadioMaterial(ItemStack lStack) { - return isStackValidRadioMaterial(lStack, false); - } + if (lStack == null) { + return; + } - public boolean isStackValidRadioMaterial(ItemStack lStack, boolean use) { - if (lStack == null) return false; - - IRadMaterial radmat = null; - // gt++ compat - if (LoaderReference.miscutils) radmat = RadioHatchCompat.GTppRadChecker(lStack); - - // GT++ and BW Materials check - - if (lStack.getItem() instanceof IRadMaterial || radmat != null) { - if (radmat == null) radmat = ((IRadMaterial) lStack.getItem()); - int sv = radmat.getRadiationLevel(lStack); - int amount = radmat.getAmountOfMaterial(lStack); - if (sv > BioVatLogicAdder.RadioHatch.getMaxSv()) BioVatLogicAdder.RadioHatch.MaxSV = sv; - if ((this.mass == 0 || this.sievert == sv) && sv > 0 && amount > 0) { - if (use) { - if (this.mass + amount <= this.cap) { - String name = radmat.getNameForGUI(lStack); - if (this.mass == 0 || this.material.equals(name)) { - this.mass += amount; - this.sievert = sv; - this.mInventory[0].stackSize--; - this.updateSlots(); - this.colorForGUI = radmat.getColorForGUI(lStack); - this.material = name; - return true; - } - } - return false; + if (this.lastFail && GT_Utility.areStacksEqual(this.lastUsedItem, lStack, true)) { + return; } - return true; - } - } - // Predefined materials check - - for (ItemStack varStack : BioVatLogicAdder.RadioHatch.getIsSv().keySet()) { - if (GT_Utility.areStacksEqual(varStack, lStack, true)) { - int amount = BioVatLogicAdder.RadioHatch.getIsKg().getOrDefault(varStack, 0); - int sv = BioVatLogicAdder.RadioHatch.getIsSv().get(varStack); - if ((this.mass == 0 || this.sievert == sv) && sv > 0 && amount > 0) { - if (use) { - if (this.mass + amount <= this.cap) { - String name = StatCollector.translateToLocal(varStack.getUnlocalizedName()); - if (this.mass == 0 || this.material.equals(name)) { - this.mass += amount; - this.sievert = - BioVatLogicAdder.RadioHatch.getIsSv().get(varStack); - this.mInventory[0].stackSize--; - this.updateSlots(); - this.colorForGUI = - BioVatLogicAdder.RadioHatch.getIsColor().get(varStack); - this.material = name; - return true; - } - } - return false; + if (!this.lastFail && this.lastUsedItem != null && this.lastRecipe != null) { + if (GT_Utility.areStacksEqual(this.lastUsedItem, lStack, true)) { + this.mass = (byte) this.lastRecipe.mDuration; + this.decayTime = this.lastRecipe.mSpecialValue; + this.sievert = this.lastRecipe.mEUt; + this.material = this.lastUsedItem.getDisplayName(); + lStack.stackSize--; + updateSlots(); + } else { + this.lastRecipe = null; } - return true; } - } - } - // Rest - - // check material for general validity - if (GT_OreDictUnificator.getAssociation(lStack) != null - && GT_OreDictUnificator.getAssociation(lStack).mMaterial != null - && GT_OreDictUnificator.getAssociation(lStack).mMaterial.mMaterial != null) { - // check orePrefix for general validity - if (GT_OreDictUnificator.getAssociation(lStack).mPrefix != null) { - OrePrefixes orePrefixes = GT_OreDictUnificator.getAssociation(lStack).mPrefix; - // check orePrefix for specialised validity - if (orePrefixes.equals(OrePrefixes.stickLong) || orePrefixes.equals(OrePrefixes.stick)) { - Materials materials = GT_OreDictUnificator.getAssociation(lStack).mMaterial.mMaterial; - // check material for specialised validity - if (materials.getProtons() >= 83 && materials.getProtons() != 125 - || materials.getProtons() == 61 - || materials.getProtons() == 43) { - if (use) { - int sv = calculateSv(materials); - int amount = (orePrefixes.equals(OrePrefixes.stickLong) ? 2 : 1); - if (this.mass == 0 || this.sievert == sv) { - if ((this.mass + amount) <= this.cap) { - String name = materials.mName; - if (this.mass == 0 || this.material.equals(name)) { - this.sievert = sv; - this.mass += orePrefixes.equals(OrePrefixes.stickLong) ? 2 : 1; - this.mInventory[0].stackSize--; - this.updateSlots(); - this.colorForGUI = materials.mColor.mRGBa; - this.material = materials.mName; - return true; - } - } - } - return false; + if (this.lastRecipe == null || this.lastFail) { + this.lastRecipe = BWRecipes.instance + .getMappingsFor(BWRecipes.RADHATCH) + .findRecipe( + this.getBaseMetaTileEntity(), false, Integer.MAX_VALUE - 7, null, mInventory[0]); + if (this.lastRecipe == null) { + this.lastFail = true; + this.lastUsedItem = this.mInventory[0] == null ? null : this.mInventory[0].copy(); + } else { + if (this.lastRecipe.mDuration > this.cap) { + this.lastFail = true; + this.lastUsedItem = this.mInventory[0].copy(); + return; } - return true; + this.lastFail = false; + this.lastUsedItem = this.mInventory[0].copy(); + this.mass = (byte) this.lastRecipe.mDuration; + this.decayTime = this.lastRecipe.mSpecialValue; + this.sievert = this.lastRecipe.mEUt; + this.colorForGUI = new short[] { + (short) this.lastRecipe.mChances[0], + (short) this.lastRecipe.mChances[1], + (short) this.lastRecipe.mChances[2] + }; + this.material = lStack.getDisplayName(); + lStack.stackSize--; + updateSlots(); } } } } - return false; } @Override @@ -305,30 +240,21 @@ public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch { public String[] getInfoData() { if (this.sievert != 0) return new String[] { - StatCollector.translateToLocal("tooltip.tile.radhatch.2.name") + " " + this.material, + StatCollector.translateToLocal("tooltip.tile.radhatch.2.name") + " " + + StatCollector.translateToLocal(this.material), StatCollector.translateToLocal("tooltip.tile.radhatch.3.name") + " " + this.sievert, StatCollector.translateToLocal("tooltip.tile.radhatch.4.name") + " " + this.mass, StatCollector.translateToLocal("tooltip.tile.radhatch.5.name") + " " - + ((GT_MetaTileEntity_RadioHatch.calcDecayTicks(this.sievert)) - - this.timer % (GT_MetaTileEntity_RadioHatch.calcDecayTicks(this.sievert) * 60)) + + (this.decayTime - this.timer % (this.decayTime * 60)) + StatCollector.translateToLocal("tooltip.tile.radhatch.6.name") + "/" - + ((GT_MetaTileEntity_RadioHatch.calcDecayTicks(this.sievert)) - - this.timer % (GT_MetaTileEntity_RadioHatch.calcDecayTicks(this.sievert))) - / 20 + + (this.decayTime - this.timer % this.decayTime) / 20 + StatCollector.translateToLocal("tooltip.tile.radhatch.7.name") + "/" - + ((GT_MetaTileEntity_RadioHatch.calcDecayTicks(this.sievert)) - - this.timer % (GT_MetaTileEntity_RadioHatch.calcDecayTicks(this.sievert))) - / 20 - / 60 + + (this.decayTime - this.timer % this.decayTime) / 20 / 60 + StatCollector.translateToLocal("tooltip.tile.radhatch.8.name") + "/" - + ((GT_MetaTileEntity_RadioHatch.calcDecayTicks(this.sievert)) - - this.timer % (GT_MetaTileEntity_RadioHatch.calcDecayTicks(this.sievert))) - / 20 - / 60 - / 60 + + (this.decayTime - this.timer % this.decayTime) / 20 / 60 / 60 + StatCollector.translateToLocal("tooltip.tile.radhatch.9.name") }; else @@ -361,7 +287,8 @@ public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch { } public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return (aSide == this.getBaseMetaTileEntity().getFrontFacing() && isStackValidRadioMaterial(aStack)); + return aSide == this.getBaseMetaTileEntity().getFrontFacing() + && BWRecipes.instance.getMappingsFor(BWRecipes.RADHATCH).containsInput(aStack); } public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { @@ -380,6 +307,7 @@ public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch { aNBT.setInteger("mTextColor", BW_ColorUtil.getColorFromRGBArray(this.getColorForGUI())); if (this.material != null && !this.material.isEmpty()) aNBT.setString("mMaterial", this.material); aNBT.setLong("timer", this.timer); + aNBT.setLong("decay", this.decayTime); super.saveNBTData(aNBT); } @@ -395,6 +323,16 @@ public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch { this.coverage = aNBT.getByte("mCoverage"); this.colorForGUI = BW_ColorUtil.splitColorToRBGArray(aNBT.getInteger("mTextColor")); this.material = aNBT.getString("mMaterial"); + this.decayTime = aNBT.getLong("decay"); super.loadNBTData(aNBT); } + + @Override + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + ResourceLocation rl = new ResourceLocation(MainMod.MOD_ID, "hatch.RadOn"); + if (aIndex == 1) { + GT_Utility.doSoundAtClient(rl, 10, 1.0F, aX, aY, aZ); + } + } } |
