aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java1
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_RadioHatch.java40
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RadioHatchMaterialLoader.java192
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java242
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_RadHatchHandler.java46
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/IMCForNEI.java13
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/NEI_BW_Config.java1
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_RadioHatch.java143
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java61
-rw-r--r--src/main/resources/assets/bartworks/lang/en_US.lang4
-rw-r--r--src/main/resources/assets/bartworks/sounds.json11
-rw-r--r--src/main/resources/assets/bartworks/sounds/radhatch.oggbin0 -> 236744 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/gui/basicmachines/BW.GUI.Radioactive.pngbin0 -> 2899 bytes
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);
+ }
+ }
}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_RadHatchHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_RadHatchHandler.java
new file mode 100644
index 0000000000..8c3a8f66f6
--- /dev/null
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_RadHatchHandler.java
@@ -0,0 +1,46 @@
+package com.github.bartimaeusnek.bartworks.neiHandler;
+
+import codechicken.nei.recipe.GuiCraftingRecipe;
+import codechicken.nei.recipe.GuiUsageRecipe;
+import codechicken.nei.recipe.TemplateRecipeHandler;
+import com.github.bartimaeusnek.bartworks.MainMod;
+import cpw.mods.fml.common.event.FMLInterModComms;
+import gregtech.api.util.GT_Recipe;
+import gregtech.nei.GT_NEI_DefaultHandler;
+import net.minecraft.util.StatCollector;
+
+public class BW_NEI_RadHatchHandler extends GT_NEI_DefaultHandler {
+
+ public BW_NEI_RadHatchHandler(GT_Recipe.GT_Recipe_Map aRecipeMap) {
+ super(aRecipeMap);
+ if (!NEI_BW_Config.sIsAdded) {
+ FMLInterModComms.sendRuntimeMessage(
+ MainMod.instance,
+ "NEIPlugins",
+ "register-crafting-handler",
+ "bartworks@" + this.getRecipeName() + "@" + this.getOverlayIdentifier());
+ GuiCraftingRecipe.craftinghandlers.add(this);
+ GuiUsageRecipe.usagehandlers.add(this);
+ }
+ }
+
+ @Override
+ public TemplateRecipeHandler newInstance() {
+ return new BW_NEI_RadHatchHandler(this.mRecipeMap);
+ }
+
+ @Override
+ public void drawExtras(int aRecipeIndex) {
+ GT_Recipe recipe = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe;
+ int radioLevel = recipe.mEUt;
+ int amount = recipe.mDuration;
+ long time = recipe.mSpecialValue;
+ drawText(10, 73, StatCollector.translateToLocalFormatted("BW.NEI.display.radhatch.0", radioLevel), -16777216);
+ drawText(10, 83, StatCollector.translateToLocalFormatted("BW.NEI.display.radhatch.1", amount), -16777216);
+ drawText(
+ 10,
+ 93,
+ StatCollector.translateToLocalFormatted("BW.NEI.display.radhatch.2", time * amount / 20.0),
+ -16777216);
+ }
+}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/IMCForNEI.java b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/IMCForNEI.java
index ff7fc3f1d1..3f5868a349 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/IMCForNEI.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/IMCForNEI.java
@@ -10,6 +10,19 @@ public class IMCForNEI {
sendCatalyst("gt.recipe.craker", "gregtech:gt.blockmachines:13367", -10);
sendHandler("bw.recipe.htgr", "gregtech:gt.blockmachines:12791");
sendCatalyst("bw.recipe.htgr", "gregtech:gt.blockmachines:12791");
+ sendHandler("bw.recipe.radhatch", "gregtech:gt.blockmachines:12713");
+ sendCatalyst("bw.recipe.radhatch", "gregtech:gt.blockmachines:12713");
+ sendCatalyst("bw.recipe.radhatch", "gregtech:gt.blockmachines:12714");
+ sendCatalyst("bw.recipe.radhatch", "gregtech:gt.blockmachines:12715");
+ sendCatalyst("bw.recipe.radhatch", "gregtech:gt.blockmachines:12716");
+ sendCatalyst("bw.recipe.radhatch", "gregtech:gt.blockmachines:12717");
+ sendCatalyst("bw.recipe.radhatch", "gregtech:gt.blockmachines:12718");
+ sendCatalyst("bw.recipe.radhatch", "gregtech:gt.blockmachines:12719");
+ sendCatalyst("bw.recipe.radhatch", "gregtech:gt.blockmachines:12720");
+ sendCatalyst("bw.recipe.radhatch", "gregtech:gt.blockmachines:12721");
+ sendCatalyst("bw.recipe.radhatch", "gregtech:gt.blockmachines:12722");
+ sendCatalyst("bw.recipe.radhatch", "gregtech:gt.blockmachines:12723");
+ sendCatalyst("bw.recipe.radhatch", "gregtech:gt.blockmachines:12724");
}
private static void sendHandler(String name, String block) {
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/NEI_BW_Config.java b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/NEI_BW_Config.java
index 55533b1c38..2fbb6a2d33 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/NEI_BW_Config.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/NEI_BW_Config.java
@@ -88,6 +88,7 @@ public class NEI_BW_Config implements IConfigureNEI {
new BW_NEI_OreHandler();
new BW_NEI_BioVatHandler(BWRecipes.instance.getMappingsFor(BWRecipes.BACTERIALVATBYTE));
new BW_NEI_BioLabHandler(BWRecipes.instance.getMappingsFor(BWRecipes.BIOLABBYTE));
+ new BW_NEI_RadHatchHandler(BWRecipes.instance.getMappingsFor(BWRecipes.RADHATCH));
new BW_NEI_HTGRHandler(GT_TileEntity_HTGR.fakeRecipeMap);
NEI_BW_Config.sIsAdded = true;
}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_RadioHatch.java b/src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_RadioHatch.java
index 855d73bb75..7d1f887200 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_RadioHatch.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_RadioHatch.java
@@ -23,12 +23,12 @@
package com.github.bartimaeusnek.bartworks.server.container;
import com.github.bartimaeusnek.bartworks.common.tileentities.tiered.GT_MetaTileEntity_RadioHatch;
+import com.github.bartimaeusnek.bartworks.util.BWRecipes;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gregtech.api.gui.GT_Container_1by1;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import java.nio.ByteBuffer;
-import java.util.Iterator;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
@@ -38,11 +38,14 @@ import net.minecraft.item.ItemStack;
public class GT_Container_RadioHatch extends GT_Container_1by1 {
- public byte mass, dmass;
- public short sv, dsv, sievert, r, g, b, dsievert, dr, dg, db;
- public byte[] teTimer = new byte[8], dteTimer = new byte[8];
+ public byte mass;
+ public short sv, sievert, r, g, b;
+ public long teTimer, decayTime;
GT_MetaTileEntity_RadioHatch TE;
private long timer;
+ private static final int packetSize = Byte.BYTES + Short.BYTES * 5 + Long.BYTES * 2;
+
+ private ByteBuffer buffer;
public GT_Container_RadioHatch(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) {
super(aInventoryPlayer, aTileEntity);
@@ -55,6 +58,9 @@ public class GT_Container_RadioHatch extends GT_Container_1by1 {
@SuppressWarnings("rawtypes")
public void detectAndSendChanges() {
super.detectAndSendChanges();
+ if (this.buffer == null) {
+ this.buffer = ByteBuffer.allocate(128);
+ }
if (!this.mTileEntity.isClientSide() && this.mTileEntity.getMetaTileEntity() != null) {
this.TE = (GT_MetaTileEntity_RadioHatch) this.mTileEntity.getMetaTileEntity();
this.mass = this.TE.getMass();
@@ -64,88 +70,60 @@ public class GT_Container_RadioHatch extends GT_Container_1by1 {
this.g = rgb[1];
this.b = rgb[2];
this.sv = (short) this.TE.getSievert();
- this.teTimer = ByteBuffer.allocate(8).putLong(this.TE.getTimer()).array();
+ this.teTimer = this.TE.getTimer();
+ this.decayTime = this.TE.getDecayTime();
++this.timer;
- Iterator var2 = this.crafters.iterator();
if (this.timer >= Long.MAX_VALUE - 1) this.timer = 0;
- while (true) {
- do {
- if (!var2.hasNext()) {
- this.dmass = this.mass;
- this.dsievert = this.sievert;
- this.dr = this.r;
- this.dg = this.g;
- this.db = this.b;
- this.dteTimer = this.teTimer;
- this.dsv = this.sv;
- return;
- }
- ICrafting var1 = (ICrafting) var2.next();
-
- if (this.timer % 500 == 10 || this.dmass != this.mass)
- var1.sendProgressBarUpdate(this, 21, this.mass);
- if (this.timer % 500 == 10 || this.dsievert != this.sievert)
- var1.sendProgressBarUpdate(this, 22, (this.sievert - 100));
- if (this.timer % 500 == 10 || this.dr != this.r) var1.sendProgressBarUpdate(this, 23, this.r);
- if (this.timer % 500 == 10 || this.dg != this.g) var1.sendProgressBarUpdate(this, 24, this.g);
- if (this.timer % 500 == 10 || this.db != this.b) var1.sendProgressBarUpdate(this, 25, this.b);
- if (this.timer % 500 == 10 || this.dteTimer != this.teTimer)
- for (int i = 0; i < this.teTimer.length; i++) {
- var1.sendProgressBarUpdate(this, 26 + i, this.teTimer[i]);
- }
- if (this.timer % 500 == 10 || this.dsv != this.sv) var1.sendProgressBarUpdate(this, 34, this.sv);
-
- } while (this.timer % 500 != 10 && this.dmass == this.mass);
+ this.buffer.put(0, mass);
+ this.buffer.putShort(Byte.BYTES, sv);
+ this.buffer.putShort(Byte.BYTES + Short.BYTES, sievert);
+ this.buffer.putShort(Byte.BYTES + Short.BYTES * 2, r);
+ this.buffer.putShort(Byte.BYTES + Short.BYTES * 3, g);
+ this.buffer.putShort(Byte.BYTES + Short.BYTES * 4, b);
+ this.buffer.putLong(Byte.BYTES + Short.BYTES * 5, teTimer);
+ this.buffer.putLong(Byte.BYTES + Short.BYTES * 5 + Long.BYTES, decayTime);
+ for (Object clientHandle : this.crafters) {
+ sendStateUpdate((ICrafting) clientHandle);
}
}
}
+ private void sendStateUpdate(ICrafting clientHandle) {
+ for (int i = 0; i < packetSize; i++) {
+ clientHandle.sendProgressBarUpdate(this, i + 300, buffer.get(i));
+ }
+ }
+
+ @Override
+ public void addCraftingToCrafters(ICrafting clientHandle) {
+ super.addCraftingToCrafters(clientHandle);
+ this.buffer.put(0, mass);
+ this.buffer.putShort(Byte.BYTES, sv);
+ this.buffer.putShort(Byte.BYTES + Short.BYTES, sievert);
+ this.buffer.putShort(Byte.BYTES + Short.BYTES * 2, r);
+ this.buffer.putShort(Byte.BYTES + Short.BYTES * 3, g);
+ this.buffer.putShort(Byte.BYTES + Short.BYTES * 4, b);
+ this.buffer.putLong(Byte.BYTES + Short.BYTES * 5, teTimer);
+ this.buffer.putLong(Byte.BYTES + Short.BYTES * 5 + Long.BYTES, decayTime);
+ sendStateUpdate(clientHandle);
+ }
+
@SideOnly(Side.CLIENT)
- public void updateProgressBar(int par1, int par2) {
- super.updateProgressBar(par1, par2);
- switch (par1) {
- case 21:
- this.mass = (byte) par2;
- break;
- case 22:
- this.sievert = (short) (par2 + 100);
- break;
- case 23:
- this.r = (short) par2;
- break;
- case 24:
- this.g = (short) par2;
- break;
- case 25:
- this.b = (short) par2;
- break;
- case 26:
- this.teTimer[0] = (byte) par2;
- break;
- case 27:
- this.teTimer[1] = (byte) par2;
- break;
- case 28:
- this.teTimer[2] = (byte) par2;
- break;
- case 29:
- this.teTimer[3] = (byte) par2;
- break;
- case 30:
- this.teTimer[4] = (byte) par2;
- break;
- case 31:
- this.teTimer[5] = (byte) par2;
- break;
- case 32:
- this.teTimer[6] = (byte) par2;
- break;
- case 33:
- this.teTimer[7] = (byte) par2;
- break;
- case 34:
- this.sv = (short) par2;
- break;
+ public void updateProgressBar(int index, int value) {
+ super.updateProgressBar(index, value);
+ index = index - 300;
+ if (index >= 0 && index < buffer.capacity()) {
+ this.buffer.put(index, (byte) value);
+ }
+ if (index >= packetSize - 1) {
+ this.mass = this.buffer.get(0);
+ this.sv = this.buffer.getShort(Byte.BYTES);
+ this.sievert = this.buffer.getShort(Byte.BYTES + Short.BYTES);
+ this.r = this.buffer.getShort(Byte.BYTES + Short.BYTES * 2);
+ this.g = this.buffer.getShort(Byte.BYTES + Short.BYTES * 3);
+ this.b = this.buffer.getShort(Byte.BYTES + Short.BYTES * 4);
+ this.teTimer = this.buffer.getLong(Byte.BYTES + Short.BYTES * 5);
+ this.decayTime = this.buffer.getLong(Byte.BYTES + Short.BYTES * 5 + Long.BYTES);
}
}
@@ -160,7 +138,7 @@ public class GT_Container_RadioHatch extends GT_Container_1by1 {
ItemStack stack = slot.getStack();
if (stack == null) return null;
if (slot instanceof RadioSlot) return super.transferStackInSlot(player, id);
- else if (((GT_MetaTileEntity_RadioHatch) this.mTileEntity.getMetaTileEntity()).isStackValidRadioMaterial(stack))
+ else if (BWRecipes.instance.getMappingsFor(BWRecipes.RADHATCH).containsInput(stack))
return super.transferStackInSlot(player, id);
else return null;
}
@@ -171,9 +149,8 @@ public class GT_Container_RadioHatch extends GT_Container_1by1 {
}
@Override
- public boolean isItemValid(ItemStack p_75214_1_) {
- return ((GT_MetaTileEntity_RadioHatch) ((IGregTechTileEntity) this.inventory).getMetaTileEntity())
- .isStackValidRadioMaterial(p_75214_1_);
+ public boolean isItemValid(ItemStack stack) {
+ return BWRecipes.instance.getMappingsFor(BWRecipes.RADHATCH).containsInput(stack);
}
}
}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java
index 7f9150f0dc..a0e2f1ae4b 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java
@@ -53,6 +53,7 @@ public class BWRecipes {
public static final byte BACTERIALVATBYTE = 1;
public static final byte ACIDGENMAPBYTE = 2;
public static final byte CIRCUITASSEMBLYLINE = 3;
+ public static final byte RADHATCH = 4;
private final GT_Recipe.GT_Recipe_Map sBiolab = new GT_Recipe.GT_Recipe_Map(
new HashSet<>(150),
@@ -121,6 +122,23 @@ public class BWRecipes {
true,
true // special handler
);
+ private final GT_Recipe.GT_Recipe_Map sRadHatch = new GT_Recipe.GT_Recipe_Map(
+ new HashSet<>(150),
+ "bw.recipe.radhatch",
+ "Radio Hatch Material List",
+ null,
+ "gregtech:textures/gui/basicmachines/BW.GUI.Radioactive",
+ 1,
+ 0,
+ 1,
+ 0,
+ 1,
+ "",
+ 0,
+ "",
+ false,
+ false // special handler
+ );
/**
* @param machine 0 = biolab; 1 = BacterialVat; 2 = sAcidGenFuels; 3 = circuitAssemblyLine
@@ -135,11 +153,52 @@ public class BWRecipes {
return sAcidGenFuels;
case 3:
return sCircuitAssemblyLineMap;
+ case 4:
+ return sRadHatch;
default:
return null;
}
}
+ public static long calcDecayTicks(int x) {
+ long 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)));
+ return ret;
+ }
+
+ public boolean addRadHatch(ItemStack item, int radioLevel, int amount, short[] rgba) {
+ return sRadHatch.addRecipe(new DynamicGTRecipe(
+ false,
+ new ItemStack[] {item},
+ null,
+ null,
+ new int[] {rgba[0], rgba[1], rgba[2]},
+ null,
+ null,
+ amount,
+ radioLevel,
+ (int) calcDecayTicks(radioLevel)))
+ != null;
+ }
+
+ public boolean addRadHatch(ItemStack item, int radioLevel, int amount, int time, short[] rgba) {
+ return sRadHatch.addRecipe(new DynamicGTRecipe(
+ false,
+ new ItemStack[] {item},
+ null,
+ null,
+ new int[] {rgba[0], rgba[1], rgba[2]},
+ null,
+ null,
+ amount,
+ radioLevel,
+ time))
+ != null;
+ }
+
public boolean addBioLabRecipe(
ItemStack[] aInputs,
ItemStack aOutput,
@@ -391,6 +450,7 @@ public class BWRecipes {
!= null;
}
+ @Deprecated
public boolean addBacterialVatRecipe(
ItemStack[] aInputs,
BioCulture aCulture,
@@ -456,6 +516,7 @@ public class BWRecipes {
!= null;
}
+ @Deprecated
public boolean addBacterialVatRecipe(
ItemStack[] aInputs,
BioCulture culture,
diff --git a/src/main/resources/assets/bartworks/lang/en_US.lang b/src/main/resources/assets/bartworks/lang/en_US.lang
index dca5ca5d25..951ceca7dd 100644
--- a/src/main/resources/assets/bartworks/lang/en_US.lang
+++ b/src/main/resources/assets/bartworks/lang/en_US.lang
@@ -165,4 +165,8 @@ itemGroup.bw.MetaItems.0=BartWorks Circuit Overhaul Items
BW.infoData.BioVat.expectedProduction=Expected Production
BW.infoData.BioVat.production=Production
+
+BW.NEI.display.radhatch.0=Sievert: %s Sv
+BW.NEI.display.radhatch.1=Mass: %s kg
+BW.NEI.display.radhatch.2=Time: %s s
#Liquids
diff --git a/src/main/resources/assets/bartworks/sounds.json b/src/main/resources/assets/bartworks/sounds.json
new file mode 100644
index 0000000000..0c1dea7fcc
--- /dev/null
+++ b/src/main/resources/assets/bartworks/sounds.json
@@ -0,0 +1,11 @@
+{
+ "hatch.RadOn": {
+ "category": "block",
+ "sounds": [
+ {
+ "name": "radhatch",
+ "stream": false
+ }
+ ]
+ }
+}
diff --git a/src/main/resources/assets/bartworks/sounds/radhatch.ogg b/src/main/resources/assets/bartworks/sounds/radhatch.ogg
new file mode 100644
index 0000000000..754711c999
--- /dev/null
+++ b/src/main/resources/assets/bartworks/sounds/radhatch.ogg
Binary files differ
diff --git a/src/main/resources/assets/gregtech/textures/gui/basicmachines/BW.GUI.Radioactive.png b/src/main/resources/assets/gregtech/textures/gui/basicmachines/BW.GUI.Radioactive.png
new file mode 100644
index 0000000000..9c6f03f8ed
--- /dev/null
+++ b/src/main/resources/assets/gregtech/textures/gui/basicmachines/BW.GUI.Radioactive.png
Binary files differ