Skip to content

Commit

Permalink
Radiation damage from items and fuel rods
Browse files Browse the repository at this point in the history
  • Loading branch information
Zalgo239 committed Dec 28, 2023
1 parent c9300f6 commit 7471f5d
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 16 deletions.
8 changes: 8 additions & 0 deletions src/main/java/gregtech/api/items/armor/IArmorLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,12 @@ default ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemSt
default float getHeatResistance() {
return 1.0f;
}

/**
*
* @return the value to multiply radiation damage by
*/
default float getRadiationResistance() {
return 1.0f;
}
}
54 changes: 40 additions & 14 deletions src/main/java/gregtech/api/items/materialitem/MetaPrefixItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,23 +157,49 @@ public void onUpdate(@NotNull ItemStack itemStack, @NotNull World worldIn, @NotN
super.onUpdate(itemStack, worldIn, entityIn, itemSlot, isSelected);
if (metaItems.containsKey((short) itemStack.getItemDamage()) && entityIn instanceof EntityLivingBase entity) {
if (entityIn.ticksExisted % 20 == 0) {
if (prefix.heatDamageFunction == null) return;

Material material = getMaterial(itemStack);
if (material == null || !material.hasProperty(PropertyKey.BLAST)) return;

float heatDamage = prefix.heatDamageFunction.apply(material.getBlastTemperature());
ItemStack armor = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
if (!armor.isEmpty() && armor.getItem() instanceof ArmorMetaItem<?>) {
ArmorMetaItem<?>.ArmorMetaValueItem metaValueItem = ((ArmorMetaItem<?>) armor.getItem())
.getItem(armor);
if (metaValueItem != null) heatDamage *= metaValueItem.getArmorLogic().getHeatResistance();
//Handle heat damage
if (prefix.heatDamageFunction != null) {
Material material = getMaterial(itemStack);
if (material != null) {
float heatDamage = 0.f;
if (material.hasProperty(PropertyKey.BLAST)) {
heatDamage = prefix.heatDamageFunction.apply(material.getBlastTemperature());
} else if (material.hasProperty(PropertyKey.FISSION_FUEL)) {
heatDamage = prefix.heatDamageFunction.apply(0);
}
ItemStack armor = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
if (!armor.isEmpty() && armor.getItem() instanceof ArmorMetaItem<?>) {
ArmorMetaItem<?>.ArmorMetaValueItem metaValueItem = ((ArmorMetaItem<?>) armor.getItem())
.getItem(armor);
if (metaValueItem != null) heatDamage *= metaValueItem.getArmorLogic().getHeatResistance();
}
if (heatDamage > 0.0) {
entity.attackEntityFrom(DamageSources.getHeatDamage().setDamageBypassesArmor(), heatDamage);
} else if (heatDamage < 0.0) {
entity.attackEntityFrom(DamageSources.getFrostDamage().setDamageBypassesArmor(),
-heatDamage);
}
}
}

if (heatDamage > 0.0) {
entity.attackEntityFrom(DamageSources.getHeatDamage().setDamageBypassesArmor(), heatDamage);
} else if (heatDamage < 0.0) {
entity.attackEntityFrom(DamageSources.getFrostDamage().setDamageBypassesArmor(), -heatDamage);
//Handle radiation damage
if (prefix.radiationDamageFunction != null) {
Material material = getMaterial(itemStack);
if (material != null) {
float radiationDamage = prefix.radiationDamageFunction.apply(material.getNeutrons());
ItemStack armor = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
if (!armor.isEmpty() && armor.getItem() instanceof ArmorMetaItem<?>) {
ArmorMetaItem<?>.ArmorMetaValueItem metaValueItem = ((ArmorMetaItem<?>) armor.getItem())
.getItem(armor);
if (metaValueItem != null) {
radiationDamage *= metaValueItem.getArmorLogic().getRadiationResistance();
}
}
if (radiationDamage > 0.0) {
entity.attackEntityFrom(DamageSources.getRadioactiveDamage().setDamageBypassesArmor(), radiationDamage);
}
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/gregtech/api/unification/Elements.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ private Elements() {}
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 Np = add(93, 144, -1, null, "Neptunium", "Np", false);
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 Pu239 = add(94, 145, -1, null, "Plutonium-239", "Pu-239", false);
public static final Element Pu241 = add(94, 149, -1, null, "Plutonium-241", "Pu-241", true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ public static void register() {
public static Material Neodymium;
public static Material Neon;
public static Material Neptunium;
public static Material Neptunium239;
public static Material Nickel;
public static Material Nihonium;
public static Material Niobium;
Expand Down Expand Up @@ -249,6 +250,7 @@ public static void register() {
public static Material Tungsten;
public static Material Uranium238;
public static Material Uranium235;
public static Material Uranium239;
public static Material Vanadium;
public static Material Xenon;
public static Material Ytterbium;
Expand Down Expand Up @@ -682,8 +684,9 @@ public static void register() {
public static Material Lapotron;
public static Material UUMatter;
public static Material PCBCoolant;

public static Material Corium;
public static Material EnrichedUraniumDioxide;
public static Material DepletedUraniumDioxide;

/**
* Second Degree Compounds
Expand Down Expand Up @@ -741,6 +744,8 @@ public static void register() {
public static Material SaltWater;
public static Material Clay;
public static Material Redstone;
public static Material LEU235;
public static Material HEU235;

/**
* Third Degree Materials
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ public class MaterialIconType {

public static final MaterialIconType turbineBlade = new MaterialIconType("turbineBlade");

public static final MaterialIconType fuelRod = new MaterialIconType("fuelRod");
public static final MaterialIconType fuelRodDepleted = new MaterialIconType("fuelRodDepleted");
public static final MaterialIconType fuelRodHotDepleted = new MaterialIconType("fuelRodHotDepleted");

// BLOCK TEXTURES
public static final MaterialIconType liquid = new MaterialIconType("liquid");
public static final MaterialIconType gas = new MaterialIconType("gas");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1006,5 +1006,18 @@ public static void register() {
.blastStats(VA[LuV], 1500)
.vacuumStats(VA[IV], 300))
.build();

Uranium239 = new Material.Builder(131, gregtechId("uranium_239"))
.ingot(3)
.liquid(new FluidBuilder().temperature(1405))
.color(0x46FA46).iconSet(SHINY)
.flags(EXT_METAL)
.element(Elements.U239)
.build();

Neptunium239 = new Material.Builder(132, gregtechId("neptunium_239"))
.color(0x284D7B).iconSet(METALLIC)
.element(Elements.Np239)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1553,5 +1553,21 @@ public static void register() {
.blastStats(VA[EV], 1400)
.vacuumStats(VA[HV], 250))
.build();

EnrichedUraniumDioxide = new Material.Builder(452, gregtechId("enriched_uranium_dioxide"))
.dust(3)
.color(0x232323).iconSet(METALLIC)
.flags(DISABLE_DECOMPOSITION)
.components(Uranium235, 1, Oxygen, 2)
.build()
.setFormula("UO2", true);

DepletedUraniumDioxide = new Material.Builder(453, gregtechId("depleted_uranium_dioxide"))
.dust(3)
.color(0x232323).iconSet(METALLIC)
.flags(DISABLE_DECOMPOSITION)
.components(Uranium238, 1, Oxygen, 2)
.build()
.setFormula("UO2", true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -503,5 +503,23 @@ public static void register() {
EXCLUDE_PLATE_COMPRESSOR_RECIPE, DECOMPOSITION_BY_CENTRIFUGING)
.components(Silicon, 1, Pyrite, 5, Ruby, 1, Mercury, 3)
.build();

LEU235 = new Material.Builder(2065, gregtechId("leu_235"))
.dust(3)
.color(0x232323).iconSet(METALLIC)
.flags(DISABLE_DECOMPOSITION)
.components(EnrichedUraniumDioxide, 1, DepletedUraniumDioxide, 20)
.fissionFuelProperties(2000, 1000, 100., 0., 1000., 0.)
.build()
.setFormula("UO2", true);

HEU235 = new Material.Builder(2066, gregtechId("heu_235"))
.dust(3)
.color(0x232323).iconSet(METALLIC)
.flags(DISABLE_DECOMPOSITION)
.components(EnrichedUraniumDioxide, 1, DepletedUraniumDioxide, 5)
.fissionFuelProperties(2000, 1000, 10., 0., 2000., 0.)
.build()
.setFormula("UO2", true);
}
}
10 changes: 10 additions & 0 deletions src/main/java/gregtech/api/unification/ore/OrePrefix.java
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,11 @@ public class OrePrefix {
public static final OrePrefix circuit = new OrePrefix("circuit", -1, null, null, ENABLE_UNIFICATION, null);
public static final OrePrefix component = new OrePrefix("component", -1, null, null, ENABLE_UNIFICATION, null);

// Nuclear stuff
public static final OrePrefix fuelRod = new OrePrefix("fuelRod", -1, null, MaterialIconType.fuelRod, 0, material -> material.hasProperty(PropertyKey.FISSION_FUEL));
public static final OrePrefix fuelRodDepleted = new OrePrefix("fuelRodDepleted", -1, null, MaterialIconType.fuelRodDepleted, 0, material -> material.hasProperty(PropertyKey.FISSION_FUEL));
public static final OrePrefix fuelRodHotDepleted = new OrePrefix("fuelRodHotDepleted", -1, null, MaterialIconType.fuelRodHotDepleted, 0, material -> material.hasProperty(PropertyKey.FISSION_FUEL));

public static class Flags {

public static final long ENABLE_UNIFICATION = 1;
Expand Down Expand Up @@ -476,6 +481,10 @@ public static void init() {

stick.modifyMaterialAmount(Materials.Blaze, 4);
stick.modifyMaterialAmount(Materials.Bone, 5);

fuelRodDepleted.radiationDamageFunction = (neutrons) -> neutrons/2.f;
fuelRodHotDepleted.radiationDamageFunction = (neutrons) -> neutrons/1.5f;
fuelRodHotDepleted.heatDamageFunction = (x) -> 2.0f;
}

private static void excludeAllGems(Material material) {
Expand Down Expand Up @@ -518,6 +527,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<Material, List<String>> tooltipFunc;

private String alternativeOreName = null;
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/gregtech/common/items/MetaItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,9 @@ private MetaItems() {}
orePrefixes.add(OrePrefix.toolHeadWrench);
orePrefixes.add(OrePrefix.toolHeadBuzzSaw);
orePrefixes.add(OrePrefix.toolHeadScrewdriver);
orePrefixes.add(OrePrefix.fuelRod);
orePrefixes.add(OrePrefix.fuelRodDepleted);
orePrefixes.add(OrePrefix.fuelRodHotDepleted);
}

public static void init() {
Expand Down
6 changes: 5 additions & 1 deletion src/main/resources/assets/gregtech/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,9 @@ item.material.oreprefix.polymer.dustTiny=Tiny Pile of %s Pulp
item.material.oreprefix.polymer.dustSmall=Small Pile of %s Pulp
item.material.oreprefix.polymer.dust=%s Pulp
item.material.oreprefix.polymer.ingot=%s Bar
item.material.oreprefix.fuelRod=%s Fuel Rod
item.material.oreprefix.fuelRodDepleted=%s Exhausted Fuel Rod
item.material.oreprefix.fuelRodHotDepleted=%s Hot Exhausted Fuel Rod


# Direct Element Materials
Expand Down Expand Up @@ -2069,7 +2072,8 @@ gregtech.material.aqua_regia=Aqua Regia
gregtech.material.salt_water=Salt Water
gregtech.material.clay=Clay
gregtech.material.redstone=Redstone

gregtech.material.leu_235=LEU-235
gregtech.material.heu_235=HEU-235

# Third Degree Materials
gregtech.material.electrotine=Electrotine
Expand Down

0 comments on commit 7471f5d

Please sign in to comment.