Restructure mod

This commit is contained in:
Agatha Lovelace 2021-03-26 03:55:49 +02:00
parent 9c9e285acf
commit 1fe24edc96
No known key found for this signature in database
GPG Key ID: 2DB18BA2E0A80BC3
3 changed files with 107 additions and 88 deletions

View File

@ -1,10 +1,10 @@
package dev.agatharose.asbestos; package dev.agatharose.asbestos;
import static dev.agatharose.asbestos.AsbestosRegistry.*;
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;
import dev.agatharose.asbestos.item.ScraperItem;
import dev.agatharose.asbestos.item.ScraperToolMaterial;
import dev.agatharose.asbestos.scheduler.MesotheliomaSched; import dev.agatharose.asbestos.scheduler.MesotheliomaSched;
import dev.onyxstudios.cca.api.v3.component.ComponentKey; import dev.onyxstudios.cca.api.v3.component.ComponentKey;
import dev.onyxstudios.cca.api.v3.component.ComponentRegistryV3; import dev.onyxstudios.cca.api.v3.component.ComponentRegistryV3;
@ -14,111 +14,28 @@ import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer; import me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer;
import nerdhub.cardinal.components.api.util.RespawnCopyStrategy; import nerdhub.cardinal.components.api.util.RespawnCopyStrategy;
import net.fabricmc.api.ModInitializer; import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
import net.fabricmc.fabric.api.biome.v1.BiomeSelectors;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.Material;
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.effect.StatusEffects;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.item.BlockItem;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ToolItem;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.BuiltinRegistries;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.gen.decorator.Decorator;
import net.minecraft.world.gen.decorator.RangeDecoratorConfig;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.OreFeatureConfig;
import net.minecraft.world.gen.GenerationStep;
@SuppressWarnings("deprecation")
public class Asbestos implements ModInitializer, EntityComponentInitializer { public class Asbestos implements ModInitializer, EntityComponentInitializer {
// mesothelioma player component key // mesothelioma player component key
public static final ComponentKey<MesotheliomaComponent> MESOTHELIOMA = ComponentRegistryV3.INSTANCE public static final ComponentKey<MesotheliomaComponent> MESOTHELIOMA = ComponentRegistryV3.INSTANCE
.getOrCreate(new Identifier("asbestos:mesothelioma"), MesotheliomaComponent.class); .getOrCreate(new Identifier("asbestos:mesothelioma"), MesotheliomaComponent.class);
// block/item/effect definitions
public static final Item ASBESTOS_FIBERS = new Item(new FabricItemSettings().group(ItemGroup.MATERIALS).fireproof()
.food(new FoodComponent.Builder().alwaysEdible()
.statusEffect(new StatusEffectInstance(StatusEffects.WITHER, 30 * 20, 4, false, false), 1.0f)
.build()));
public static final CarcinogenicBlock ASBESTOS_BLOCK = new CarcinogenicBlock(
FabricBlockSettings.of(Material.WOOL).hardness(1.0f).sounds(BlockSoundGroup.WOOL), 40);
public static final CarcinogenicBlock SERPENTINITE_BLOCK = new CarcinogenicBlock(
FabricBlockSettings.of(Material.STONE).hardness(3.0f).breakByTool(FabricToolTags.PICKAXES).requiresTool(),
20);
public static final CarcinogenicBlock POPCORN_CEILING_BLOCK = new CarcinogenicBlock(FabricBlockSettings
.of(Material.WOOD).hardness(2.0f).breakByTool(FabricToolTags.AXES).sounds(BlockSoundGroup.WOOD), 20);
public static final CarcinogenicBlock ASBESTOS_TILE_BLOCK = new CarcinogenicBlock(
FabricBlockSettings.of(Material.STONE).hardness(3.0f).sounds(BlockSoundGroup.NETHER_BRICKS), 20);
public static ToolItem IRON_SCRAPER = new ScraperItem(ScraperToolMaterial.INSTANCE, 0.0f, -3.0f,
new Item.Settings().group(ItemGroup.TOOLS));
public static final StatusEffect MESOTHELIOMA_EFFECT = new MesotheliomaStatusEffect(); public static final StatusEffect MESOTHELIOMA_EFFECT = new MesotheliomaStatusEffect();
public static final DamageSource MESOTHELIOMA_DAMAGE = new MesotheliomaDamageSource(); public static final DamageSource MESOTHELIOMA_DAMAGE = new MesotheliomaDamageSource();
private static ConfiguredFeature<?, ?> SERPENTINITE_OVERWORLD = Feature.ORE
.configure(new OreFeatureConfig(OreFeatureConfig.Rules.BASE_STONE_OVERWORLD,
SERPENTINITE_BLOCK.getDefaultState(), 5))
.decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(0, 0, 32))).spreadHorizontally().repeat(10);
// 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 };
@Override @Override
public void onInitialize() { public void onInitialize() {
// asbestos fibers item AsbestosRegistry.register();
Registry.register(Registry.ITEM, new Identifier("asbestos", "asbestos_fibers"), ASBESTOS_FIBERS);
// asbestos block
Registry.register(Registry.BLOCK, new Identifier("asbestos", "asbestos_block"), ASBESTOS_BLOCK);
Registry.register(Registry.ITEM, new Identifier("asbestos", "asbestos_block"),
new BlockItem(ASBESTOS_BLOCK, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS).fireproof()));
// serpentinite block
Registry.register(Registry.BLOCK, new Identifier("asbestos", "serpentinite_block"), SERPENTINITE_BLOCK);
Registry.register(Registry.ITEM, new Identifier("asbestos", "serpentinite_block"),
new BlockItem(SERPENTINITE_BLOCK, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS)));
// popcorn ceiling block
Registry.register(Registry.BLOCK, new Identifier("asbestos", "popcorn_ceiling_block"), POPCORN_CEILING_BLOCK);
Registry.register(Registry.ITEM, new Identifier("asbestos", "popcorn_ceiling_block"),
new BlockItem(POPCORN_CEILING_BLOCK, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS).fireproof()));
// asbestos tile block
Registry.register(Registry.BLOCK, new Identifier("asbestos", "asbestos_tile_block"), ASBESTOS_TILE_BLOCK);
Registry.register(Registry.ITEM, new Identifier("asbestos", "asbestos_tile_block"),
new BlockItem(ASBESTOS_TILE_BLOCK, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS)));
// serpentinite worldgen
RegistryKey<ConfiguredFeature<?, ?>> serpentiniteOverworld = RegistryKey
.of(Registry.CONFIGURED_FEATURE_WORLDGEN, new Identifier("asbestos", "serpentinite_overworld"));
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, serpentiniteOverworld.getValue(),
SERPENTINITE_OVERWORLD);
BiomeModifications.addFeature(BiomeSelectors.foundInOverworld(), GenerationStep.Feature.UNDERGROUND_ORES,
serpentiniteOverworld);
// scraper tool
Registry.register(Registry.ITEM, new Identifier("asbestos", "iron_scraper"), IRON_SCRAPER);
// mesothelioma status effect // mesothelioma status effect
Registry.register(Registry.STATUS_EFFECT, new Identifier("asbestos", "mesothelioma"), MESOTHELIOMA_EFFECT); Registry.register(Registry.STATUS_EFFECT, new Identifier("asbestos", "mesothelioma"), MESOTHELIOMA_EFFECT);

View File

@ -0,0 +1,102 @@
package dev.agatharose.asbestos;
import dev.agatharose.asbestos.item.ScraperItem;
import dev.agatharose.asbestos.item.ScraperToolMaterial;
import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
import net.fabricmc.fabric.api.biome.v1.BiomeSelectors;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.Material;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.item.BlockItem;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ToolItem;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.BuiltinRegistries;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.decorator.Decorator;
import net.minecraft.world.gen.decorator.RangeDecoratorConfig;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.OreFeatureConfig;
@SuppressWarnings("deprecation")
public class AsbestosRegistry {
// block/item/effect definitions
public static final Item ASBESTOS_FIBERS = new Item(new FabricItemSettings().group(ItemGroup.MATERIALS)
.fireproof()
.food(new FoodComponent.Builder().alwaysEdible().statusEffect(
new StatusEffectInstance(StatusEffects.WITHER, 30 * 20, 4, false, false), 1.0f)
.build()));
public static final CarcinogenicBlock ASBESTOS_BLOCK = new CarcinogenicBlock(
FabricBlockSettings.of(Material.WOOL).hardness(1.0f).sounds(BlockSoundGroup.WOOL), 40);
public static final CarcinogenicBlock SERPENTINITE_BLOCK = new CarcinogenicBlock(FabricBlockSettings
.of(Material.STONE).hardness(3.0f).breakByTool(FabricToolTags.PICKAXES).requiresTool(), 20);
public static final CarcinogenicBlock POPCORN_CEILING_BLOCK = new CarcinogenicBlock(FabricBlockSettings
.of(Material.WOOD).hardness(2.0f).breakByTool(FabricToolTags.AXES).sounds(BlockSoundGroup.WOOD),
20);
public static final CarcinogenicBlock ASBESTOS_TILE_BLOCK = new CarcinogenicBlock(
FabricBlockSettings.of(Material.STONE).hardness(3.0f).sounds(BlockSoundGroup.NETHER_BRICKS),
20);
public static ToolItem IRON_SCRAPER = new ScraperItem(ScraperToolMaterial.INSTANCE, 0.0f, -3.0f,
new Item.Settings().group(ItemGroup.TOOLS));
private static ConfiguredFeature<?, ?> SERPENTINITE_OVERWORLD = Feature.ORE
.configure(new OreFeatureConfig(OreFeatureConfig.Rules.BASE_STONE_OVERWORLD,
SERPENTINITE_BLOCK.getDefaultState(), 5))
.decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(0, 0, 32))).spreadHorizontally()
.repeat(10);
public static void register() {
// asbestos fibers item
Registry.register(Registry.ITEM, new Identifier("asbestos", "asbestos_fibers"), ASBESTOS_FIBERS);
// asbestos block
Registry.register(Registry.BLOCK, new Identifier("asbestos", "asbestos_block"), ASBESTOS_BLOCK);
Registry.register(Registry.ITEM, new Identifier("asbestos", "asbestos_block"), new BlockItem(
ASBESTOS_BLOCK, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS).fireproof()));
// serpentinite block
Registry.register(Registry.BLOCK, new Identifier("asbestos", "serpentinite_block"), SERPENTINITE_BLOCK);
Registry.register(Registry.ITEM, new Identifier("asbestos", "serpentinite_block"), new BlockItem(
SERPENTINITE_BLOCK, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS)));
// popcorn ceiling block
Registry.register(Registry.BLOCK, new Identifier("asbestos", "popcorn_ceiling_block"),
POPCORN_CEILING_BLOCK);
Registry.register(Registry.ITEM, new Identifier("asbestos", "popcorn_ceiling_block"),
new BlockItem(POPCORN_CEILING_BLOCK,
new Item.Settings().group(ItemGroup.BUILDING_BLOCKS).fireproof()));
// asbestos tile block
Registry.register(Registry.BLOCK, new Identifier("asbestos", "asbestos_tile_block"),
ASBESTOS_TILE_BLOCK);
Registry.register(Registry.ITEM, new Identifier("asbestos", "asbestos_tile_block"), new BlockItem(
ASBESTOS_TILE_BLOCK, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS)));
// serpentinite worldgen
RegistryKey<ConfiguredFeature<?, ?>> serpentiniteOverworld = RegistryKey.of(
Registry.CONFIGURED_FEATURE_WORLDGEN,
new Identifier("asbestos", "serpentinite_overworld"));
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, serpentiniteOverworld.getValue(),
SERPENTINITE_OVERWORLD);
BiomeModifications.addFeature(BiomeSelectors.foundInOverworld(),
GenerationStep.Feature.UNDERGROUND_ORES, serpentiniteOverworld);
// scraper tool
Registry.register(Registry.ITEM, new Identifier("asbestos", "iron_scraper"), IRON_SCRAPER);
}
}

View File

@ -4,7 +4,7 @@ import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import dev.agatharose.asbestos.Asbestos; import static dev.agatharose.asbestos.AsbestosRegistry.*;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.item.MiningToolItem; import net.minecraft.item.MiningToolItem;
import net.minecraft.item.ToolMaterial; import net.minecraft.item.ToolMaterial;
@ -12,7 +12,7 @@ import net.minecraft.item.ToolMaterial;
public class ScraperItem extends MiningToolItem { public class ScraperItem extends MiningToolItem {
private static Set<Block> affectedBlocks = new HashSet<Block>( private static Set<Block> affectedBlocks = new HashSet<Block>(
Arrays.asList(Asbestos.ASBESTOS_BLOCK, Asbestos.POPCORN_CEILING_BLOCK, Asbestos.ASBESTOS_TILE_BLOCK)); Arrays.asList(ASBESTOS_BLOCK, POPCORN_CEILING_BLOCK, ASBESTOS_TILE_BLOCK));
public ScraperItem(ToolMaterial material, float attackDamage, float attackSpeed, Settings settings) { public ScraperItem(ToolMaterial material, float attackDamage, float attackSpeed, Settings settings) {
super(attackDamage, attackSpeed, material, affectedBlocks, settings); super(attackDamage, attackSpeed, material, affectedBlocks, settings);