Add asbestos removal PPE
This commit is contained in:
parent
1fe24edc96
commit
1f2927358e
|
@ -2,6 +2,8 @@ package dev.agatharose.asbestos;
|
||||||
|
|
||||||
import static dev.agatharose.asbestos.AsbestosRegistry.*;
|
import static dev.agatharose.asbestos.AsbestosRegistry.*;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import dev.agatharose.asbestos.component.MesotheliomaComponent;
|
import dev.agatharose.asbestos.component.MesotheliomaComponent;
|
||||||
import dev.agatharose.asbestos.component.PlayerMesotheliomaComponent;
|
import dev.agatharose.asbestos.component.PlayerMesotheliomaComponent;
|
||||||
import dev.agatharose.asbestos.config.AsbestosConfig;
|
import dev.agatharose.asbestos.config.AsbestosConfig;
|
||||||
|
@ -17,6 +19,9 @@ import net.fabricmc.api.ModInitializer;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.entity.damage.DamageSource;
|
import net.minecraft.entity.damage.DamageSource;
|
||||||
import net.minecraft.entity.effect.StatusEffect;
|
import net.minecraft.entity.effect.StatusEffect;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
|
|
||||||
|
@ -33,6 +38,26 @@ public class Asbestos implements ModInitializer, EntityComponentInitializer {
|
||||||
// blocks that will contribute to mesothelioma levels without being broken
|
// blocks that will contribute to mesothelioma levels without being broken
|
||||||
public static Block[] HARMFUL_PASSIVE_BLOCKS = { ASBESTOS_BLOCK };
|
public static Block[] HARMFUL_PASSIVE_BLOCKS = { ASBESTOS_BLOCK };
|
||||||
|
|
||||||
|
// any armor that protects the player from asbestos exposure
|
||||||
|
public static Item[] PPE_ARMOR = { PPE_HELMET, PPE_CHESTPLATE, PPE_LEGGINGS, PPE_BOOTS };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the player is safe from asbestos exposure
|
||||||
|
*
|
||||||
|
* @param player
|
||||||
|
*/
|
||||||
|
public static boolean isProtectedFromAsbestos(PlayerEntity player) {
|
||||||
|
// iterate over the player's armor items
|
||||||
|
for (ItemStack item : player.getArmorItems()) {
|
||||||
|
// if they have at least one non-protective piece of armor, they are not immune
|
||||||
|
if (!Arrays.asList(PPE_ARMOR).contains(item.getItem())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// otherwise, they're safe
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
AsbestosRegistry.register();
|
AsbestosRegistry.register();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package dev.agatharose.asbestos;
|
package dev.agatharose.asbestos;
|
||||||
|
|
||||||
|
import dev.agatharose.asbestos.item.PpeArmorMaterial;
|
||||||
import dev.agatharose.asbestos.item.ScraperItem;
|
import dev.agatharose.asbestos.item.ScraperItem;
|
||||||
import dev.agatharose.asbestos.item.ScraperToolMaterial;
|
import dev.agatharose.asbestos.item.ScraperToolMaterial;
|
||||||
import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
|
import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
|
||||||
|
@ -8,8 +9,11 @@ import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.block.Material;
|
||||||
|
import net.minecraft.entity.EquipmentSlot;
|
||||||
import net.minecraft.entity.effect.StatusEffectInstance;
|
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||||
import net.minecraft.entity.effect.StatusEffects;
|
import net.minecraft.entity.effect.StatusEffects;
|
||||||
|
import net.minecraft.item.ArmorItem;
|
||||||
|
import net.minecraft.item.ArmorMaterial;
|
||||||
import net.minecraft.item.BlockItem;
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.FoodComponent;
|
import net.minecraft.item.FoodComponent;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
@ -29,7 +33,7 @@ import net.minecraft.world.gen.feature.OreFeatureConfig;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class AsbestosRegistry {
|
public class AsbestosRegistry {
|
||||||
// block/item/effect definitions
|
// block/item definitions
|
||||||
public static final Item ASBESTOS_FIBERS = new Item(new FabricItemSettings().group(ItemGroup.MATERIALS)
|
public static final Item ASBESTOS_FIBERS = new Item(new FabricItemSettings().group(ItemGroup.MATERIALS)
|
||||||
.fireproof()
|
.fireproof()
|
||||||
.food(new FoodComponent.Builder().alwaysEdible().statusEffect(
|
.food(new FoodComponent.Builder().alwaysEdible().statusEffect(
|
||||||
|
@ -53,6 +57,20 @@ public class AsbestosRegistry {
|
||||||
public static ToolItem IRON_SCRAPER = new ScraperItem(ScraperToolMaterial.INSTANCE, 0.0f, -3.0f,
|
public static ToolItem IRON_SCRAPER = new ScraperItem(ScraperToolMaterial.INSTANCE, 0.0f, -3.0f,
|
||||||
new Item.Settings().group(ItemGroup.TOOLS));
|
new Item.Settings().group(ItemGroup.TOOLS));
|
||||||
|
|
||||||
|
// asbestos removal ppe
|
||||||
|
|
||||||
|
public static final ArmorMaterial PPE_ARMOR_MATERIAL = new PpeArmorMaterial();
|
||||||
|
public static final Item PPE_HELMET = new ArmorItem(PPE_ARMOR_MATERIAL, EquipmentSlot.HEAD,
|
||||||
|
new Item.Settings().group(ItemGroup.COMBAT));
|
||||||
|
public static final Item PPE_CHESTPLATE = new ArmorItem(PPE_ARMOR_MATERIAL, EquipmentSlot.CHEST,
|
||||||
|
new Item.Settings().group(ItemGroup.COMBAT));
|
||||||
|
public static final Item PPE_LEGGINGS = new ArmorItem(PPE_ARMOR_MATERIAL, EquipmentSlot.LEGS,
|
||||||
|
new Item.Settings().group(ItemGroup.COMBAT));
|
||||||
|
public static final Item PPE_BOOTS = new ArmorItem(PPE_ARMOR_MATERIAL, EquipmentSlot.FEET,
|
||||||
|
new Item.Settings().group(ItemGroup.COMBAT));
|
||||||
|
|
||||||
|
// serpentinite worldgen
|
||||||
|
|
||||||
private static ConfiguredFeature<?, ?> SERPENTINITE_OVERWORLD = Feature.ORE
|
private static ConfiguredFeature<?, ?> SERPENTINITE_OVERWORLD = Feature.ORE
|
||||||
.configure(new OreFeatureConfig(OreFeatureConfig.Rules.BASE_STONE_OVERWORLD,
|
.configure(new OreFeatureConfig(OreFeatureConfig.Rules.BASE_STONE_OVERWORLD,
|
||||||
SERPENTINITE_BLOCK.getDefaultState(), 5))
|
SERPENTINITE_BLOCK.getDefaultState(), 5))
|
||||||
|
@ -98,5 +116,11 @@ public class AsbestosRegistry {
|
||||||
|
|
||||||
// scraper tool
|
// scraper tool
|
||||||
Registry.register(Registry.ITEM, new Identifier("asbestos", "iron_scraper"), IRON_SCRAPER);
|
Registry.register(Registry.ITEM, new Identifier("asbestos", "iron_scraper"), IRON_SCRAPER);
|
||||||
|
|
||||||
|
// asbestos removal ppe
|
||||||
|
Registry.register(Registry.ITEM, new Identifier("asbestos", "ppe_helmet"), PPE_HELMET);
|
||||||
|
Registry.register(Registry.ITEM, new Identifier("asbestos", "ppe_chestplate"), PPE_CHESTPLATE);
|
||||||
|
Registry.register(Registry.ITEM, new Identifier("asbestos", "ppe_leggings"), PPE_LEGGINGS);
|
||||||
|
Registry.register(Registry.ITEM, new Identifier("asbestos", "ppe_boots"), PPE_BOOTS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,10 +27,13 @@ public class CarcinogenicBlock extends Block {
|
||||||
// call the original method
|
// call the original method
|
||||||
super.onBreak(world, pos, state, player);
|
super.onBreak(world, pos, state, player);
|
||||||
|
|
||||||
// get the player's initial mesothelioma progress
|
// check if player is capable of safely removing asbestos
|
||||||
int exposure = Asbestos.MESOTHELIOMA.get(player).getMesothelioma();
|
if (!Asbestos.isProtectedFromAsbestos(player)) {
|
||||||
|
// get the player's initial mesothelioma progress
|
||||||
|
int exposure = Asbestos.MESOTHELIOMA.get(player).getMesothelioma();
|
||||||
|
|
||||||
// increase it by the block's dangerousness level
|
// increase it by the block's dangerousness level
|
||||||
Asbestos.MESOTHELIOMA.get(player).setMesothelioma(exposure + dangerousness);
|
Asbestos.MESOTHELIOMA.get(player).setMesothelioma(exposure + dangerousness);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
package dev.agatharose.asbestos.item;
|
||||||
|
|
||||||
|
import net.minecraft.entity.EquipmentSlot;
|
||||||
|
import net.minecraft.item.ArmorMaterial;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
|
import net.minecraft.recipe.Ingredient;
|
||||||
|
import net.minecraft.sound.SoundEvent;
|
||||||
|
import net.minecraft.sound.SoundEvents;
|
||||||
|
|
||||||
|
public class PpeArmorMaterial implements ArmorMaterial {
|
||||||
|
private static final int[] BASE_DURABILITY = new int[] { 13, 15, 16, 11 };
|
||||||
|
private static final int[] PROTECTION_VALUES = new int[] { 1, 1, 2, 1 };
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDurability(EquipmentSlot slot) {
|
||||||
|
return BASE_DURABILITY[slot.getEntitySlotId()] * 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getProtectionAmount(EquipmentSlot slot) {
|
||||||
|
return PROTECTION_VALUES[slot.getEntitySlotId()];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getEnchantability() {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SoundEvent getEquipSound() {
|
||||||
|
return SoundEvents.BLOCK_WOOL_HIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Ingredient getRepairIngredient() {
|
||||||
|
return Ingredient.ofItems(Items.STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "asbestos_ppe";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getToughness() {
|
||||||
|
return 0.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getKnockbackResistance() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,6 +31,11 @@ public class MesotheliomaSched {
|
||||||
player.addStatusEffect(new StatusEffectInstance(Asbestos.MESOTHELIOMA_EFFECT, 32767));
|
player.addStatusEffect(new StatusEffectInstance(Asbestos.MESOTHELIOMA_EFFECT, 32767));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// don't have to check for asbestos if the player is safe from it
|
||||||
|
if (Asbestos.isProtectedFromAsbestos(player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int offset = config.mesothelioma.offset;
|
int offset = config.mesothelioma.offset;
|
||||||
|
|
||||||
// iterate over every block in the cuboid
|
// iterate over every block in the cuboid
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
"block.asbestos.asbestos_tile_block": "Asbestos Tiles",
|
"block.asbestos.asbestos_tile_block": "Asbestos Tiles",
|
||||||
"item.asbestos.asbestos_fibers": "Asbests Fibers",
|
"item.asbestos.asbestos_fibers": "Asbests Fibers",
|
||||||
"item.asbestos.iron_scraper": "Asbestos Scraper",
|
"item.asbestos.iron_scraper": "Asbestos Scraper",
|
||||||
|
"item.asbestos.ppe_helmet": "Asbestos Removal PPE Helmet",
|
||||||
|
"item.asbestos.ppe_chestplate": "Asbestos Removal PPE Chestplate",
|
||||||
|
"item.asbestos.ppe_leggings": "Asbestos Removal PPE Leggings",
|
||||||
|
"item.asbestos.ppe_boots": "Asbestos Removal PPE Boots",
|
||||||
"effect.asbestos.mesothelioma": "Mesothelioma",
|
"effect.asbestos.mesothelioma": "Mesothelioma",
|
||||||
"death.attack.mesotheliomaDamage": "%1$s was entitled to financial compensation",
|
"death.attack.mesotheliomaDamage": "%1$s was entitled to financial compensation",
|
||||||
"text.autoconfig.asbestos.title": "Asbestos Removal",
|
"text.autoconfig.asbestos.title": "Asbestos Removal",
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "asbestos:item/ppe_boots"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "asbestos:item/ppe_chestplate"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "asbestos:item/ppe_helmet"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "asbestos:item/ppe_leggings"
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 260 B |
Binary file not shown.
After Width: | Height: | Size: 367 B |
Binary file not shown.
After Width: | Height: | Size: 330 B |
Binary file not shown.
After Width: | Height: | Size: 260 B |
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 578 B |
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"type": "minecraft:crafting_shaped",
|
||||||
|
"pattern": [
|
||||||
|
" ",
|
||||||
|
"S S",
|
||||||
|
"S S"
|
||||||
|
],
|
||||||
|
"key": {
|
||||||
|
"S": {
|
||||||
|
"item": "minecraft:string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"result": {
|
||||||
|
"item": "asbestos:ppe_boots"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"type": "minecraft:crafting_shaped",
|
||||||
|
"pattern": [
|
||||||
|
"S S",
|
||||||
|
"SSS",
|
||||||
|
"SSS"
|
||||||
|
],
|
||||||
|
"key": {
|
||||||
|
"S": {
|
||||||
|
"item": "minecraft:string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"result": {
|
||||||
|
"item": "asbestos:ppe_chestplate"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
"type": "minecraft:crafting_shaped",
|
||||||
|
"pattern": [
|
||||||
|
"SSS",
|
||||||
|
"SGS",
|
||||||
|
"S S"
|
||||||
|
],
|
||||||
|
"key": {
|
||||||
|
"S": {
|
||||||
|
"item": "minecraft:string"
|
||||||
|
},
|
||||||
|
"G": {
|
||||||
|
"item": "minecraft:black_stained_glass_pane"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"result": {
|
||||||
|
"item": "asbestos:ppe_helmet"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"type": "minecraft:crafting_shaped",
|
||||||
|
"pattern": [
|
||||||
|
"SSS",
|
||||||
|
"S S",
|
||||||
|
"S S"
|
||||||
|
],
|
||||||
|
"key": {
|
||||||
|
"S": {
|
||||||
|
"item": "minecraft:string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"result": {
|
||||||
|
"item": "asbestos:ppe_leggings"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue