Skip to content

Commit

Permalink
feat: start on half life
Browse files Browse the repository at this point in the history
  • Loading branch information
bruberu committed Jun 9, 2024
1 parent a7d798c commit bba511e
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public void onUpdate(@NotNull ItemStack itemStack, @NotNull World worldIn, @NotN
if (prefix.radiationDamageFunction != null) {
Material material = getMaterial(itemStack);
if (material != null) {
float radiationDamage = prefix.radiationDamageFunction.apply(material.getNeutrons());
double radiationDamage = prefix.radiationDamageFunction.apply(material.getDecaysPerSecond());
ItemStack armor = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
if (!armor.isEmpty() && armor.getItem() instanceof ArmorMetaItem<?>) {
ArmorMetaItem<?>.ArmorMetaValueItem metaValueItem = ((ArmorMetaItem<?>) armor.getItem())
Expand All @@ -198,7 +198,7 @@ public void onUpdate(@NotNull ItemStack itemStack, @NotNull World worldIn, @NotN
}
if (radiationDamage > 0.0) {
entity.attackEntityFrom(DamageSources.getRadioactiveDamage().setDamageBypassesArmor(),
radiationDamage);
(float) radiationDamage);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/gregtech/api/unification/Element.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class Element {
@ZenProperty("isotope")
public final boolean isIsotope;
@ZenProperty("halfLifeSeconds")
public final long halfLifeSeconds;
public final double halfLifeSeconds;
@ZenProperty("decayTo")
public final String decayTo;

Expand All @@ -34,7 +34,7 @@ public class Element {
* @param name Name of the Element
* @param symbol Symbol of the Element
*/
public Element(long protons, long neutrons, long halfLifeSeconds, String decayTo, String name, String symbol,
public Element(long protons, long neutrons, double halfLifeSeconds, String decayTo, String name, String symbol,
boolean isIsotope) {
this.protons = protons;
this.neutrons = neutrons;
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/gregtech/api/unification/Elements.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,22 @@ private Elements() {}
public static final Element Ac = add(89, 136, -1, null, "Actinium", "Ac", false);
public static final Element Th = add(90, 140, -1, null, "Thorium", "Th", false);
public static final Element Pa = add(91, 138, -1, null, "Protactinium", "Pa", false);
public static final Element U = add(92, 146, -1, null, "Uranium", "U", false);
public static final Element U238 = add(92, 146, -1, null, "Uranium-238", "U-238", false);
public static final Element U235 = add(92, 143, -1, null, "Uranium-235", "U-235", true);
public static final Element U239 = add(92, 147, -1, null, "Uranium-239", "U-239", true);
public static final Element U = add(92, 146, 1.4090285e+17, null, "Uranium", "U", false);
public static final Element U238 = add(92, 146, 1.4090285e+17, null, "Uranium-238", "U-238", false);
public static final Element U235 = add(92, 143, 2.2195037e+16, null, "Uranium-235", "U-235", true);
public static final Element U239 = add(92, 147, 1407, null, "Uranium-239", "U-239", true);
public static final Element Np = add(93, 144, -1, null, "Neptunium", "Np", false);
public static final Element Np235 = add(93, 142, -1, null, "Neptunium-235", "Np-235", true);
public static final Element Np236 = add(93, 143, -1, null, "Neptunium-236", "Np-236", true);
public static final Element Np237 = add(93, 144, -1, null, "Neptunium-237", "Np-237", true);
public static final Element Np239 = add(93, 146, -1, null, "Neptunium-239", "Np-239", true);
public static final Element Pu = add(94, 152, -1, null, "Plutonium", "Pu", false);
public static final Element Pu238 = add(94, 144, -1, null, "Plutonium-238", "Pu-238", true);
public static final Element Pu239 = add(94, 145, -1, null, "Plutonium-239", "Pu-239", true);
public static final Element Pu240 = add(94, 146, -1, null, "Plutonium-240", "Pu-240", true);
public static final Element Pu241 = add(94, 147, -1, null, "Plutonium-241", "Pu-241", true);
public static final Element Pu242 = add(94, 148, -1, null, "Plutonium-242", "Pu-242", true);
public static final Element Pu244 = add(94, 150, -1, null, "Plutonium-244", "Pu-244", true);
public static final Element Pu238 = add(94, 144, 2765707200d, null, "Plutonium-238", "Pu-238", true);
public static final Element Pu239 = add(94, 145, 760332960000d, null, "Plutonium-239", "Pu-239", true);
public static final Element Pu240 = add(94, 146, 206907696000d, null, "Plutonium-240", "Pu-240", true);
public static final Element Pu241 = add(94, 147, 450649440d, null, "Plutonium-241", "Pu-241", true);
public static final Element Pu242 = add(94, 148, 1.1826e+13, null, "Plutonium-242", "Pu-242", true);
public static final Element Pu244 = add(94, 150, 2.52288e+15, null, "Plutonium-244", "Pu-244", true);
public static final Element Am = add(95, 150, -1, null, "Americium", "Am", false);
public static final Element Cm = add(96, 153, -1, null, "Curium", "Cm", false);
public static final Element Bk = add(97, 152, -1, null, "Berkelium", "Bk", false);
Expand Down Expand Up @@ -164,7 +164,7 @@ private Elements() {}
// TODO Cosmic Neutronium, other Gregicality Elements

@ZenMethod
public static Element add(long protons, long neutrons, long halfLifeSeconds, String decayTo, String name,
public static Element add(long protons, long neutrons, double halfLifeSeconds, String decayTo, String name,
String symbol, boolean isIsotope) {
Element element = new Element(protons, neutrons, halfLifeSeconds, decayTo, name, symbol, isIsotope);
elements.put(name, element);
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/gregtech/api/unification/material/Material.java
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,22 @@ public boolean isRadioactive() {
return false;
}

// Assumes one mole per item and that it's always "starting to decay"
@ZenGetter("decaysPerSecond")
public double getDecaysPerSecond() {
if (!this.isRadioactive()) {
return 0;
}
if (materialInfo.element != null) {
return 6e23 * (Math.log(2) * Math.exp(-Math.log(2) / materialInfo.element.halfLifeSeconds));
}
double decaysPerSecond = 0;
for (MaterialStack material : materialInfo.componentList)
decaysPerSecond += material.material.getDecaysPerSecond();
return decaysPerSecond;
}


@ZenGetter("protons")
public long getProtons() {
if (materialInfo.element != null)
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/gregtech/api/unification/ore/OrePrefix.java
Original file line number Diff line number Diff line change
Expand Up @@ -505,13 +505,13 @@ public static void init() {
stick.modifyMaterialAmount(Materials.Blaze, 4);
stick.modifyMaterialAmount(Materials.Bone, 5);

fuelRod.radiationDamageFunction = (neutrons) -> neutrons / 1.5f;
fuelPellet.radiationDamageFunction = (neutrons) -> neutrons / 24f;
fuelRod.radiationDamageFunction = (neutrons) -> neutrons / 1.5e23;
fuelPellet.radiationDamageFunction = (neutrons) -> neutrons / 24e23;

fuelRodDepleted.radiationDamageFunction = (neutrons) -> neutrons / 2.f;
fuelRodHotDepleted.radiationDamageFunction = (neutrons) -> neutrons / 1.5f;
fuelRodHotDepleted.heatDamageFunction = (x) -> 2.0f;
fuelPelletDepleted.radiationDamageFunction = (neutrons) -> neutrons / 32f;
fuelRodDepleted.radiationDamageFunction = (neutrons) -> neutrons / 20e23;
fuelRodHotDepleted.radiationDamageFunction = (neutrons) -> neutrons / 15e23;
fuelRodHotDepleted.heatDamageFunction = (x) -> 2f;
fuelPelletDepleted.radiationDamageFunction = (neutrons) -> neutrons / 32e23;
}

private static void excludeAllGems(Material material) {
Expand Down Expand Up @@ -554,7 +554,7 @@ private static void excludeAllGemsButNormal(Material material) {
public byte maxStackSize = 64;
public final List<MaterialStack> secondaryMaterials = new ArrayList<>();
public Function<Integer, Float> heatDamageFunction = null; // Negative for Frost Damage
public Function<Long, Float> radiationDamageFunction = null;
public Function<Double, Double> radiationDamageFunction = null;
public Function<Material, List<String>> tooltipFunc;

private String alternativeOreName = null;
Expand Down

0 comments on commit bba511e

Please sign in to comment.