* add asbestos tiles and popcorn ceilings

* add mod config
* add blocks that are dangerous to break
This commit is contained in:
Agatha Lovelace 2021-03-16 20:57:20 +02:00
parent 718bd1528a
commit 9c9e285acf
No known key found for this signature in database
GPG Key ID: 2DB18BA2E0A80BC3
25 changed files with 270 additions and 22 deletions

View File

@ -17,6 +17,9 @@ repositories {
maven {
name = "Ladysnake Libs"
url = "https://dl.bintray.com/ladysnake/libs"
}
maven {
url "https://maven.shedaniel.me/"
}
maven {
url "https://jitpack.io"
@ -38,6 +41,11 @@ dependencies {
exclude(group: "net.fabricmc.fabric-api")
}
// Cloth Config
modApi("me.shedaniel.cloth:cloth-config-fabric:${cloth_version}") {
exclude(group: "net.fabricmc.fabric-api")
}
// CardinalComponentsAPI
modApi "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-base:${cca_version}"
modApi "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-entity:${cca_version}"

View File

@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.10.7
# Mod Properties
mod_version = 1.0.1
mod_version = 1.1
maven_group = dev.agatharose
archives_base_name = asbestos
@ -17,3 +17,4 @@ org.gradle.jvmargs=-Xmx1G
fabric_version=0.25.1+build.416-1.16
modmenu_version=1.14.6+build.31
cca_version=2.7.9
cloth_version=4.10.13

View File

@ -2,6 +2,7 @@ package dev.agatharose.asbestos;
import dev.agatharose.asbestos.component.MesotheliomaComponent;
import dev.agatharose.asbestos.component.PlayerMesotheliomaComponent;
import dev.agatharose.asbestos.config.AsbestosConfig;
import dev.agatharose.asbestos.item.ScraperItem;
import dev.agatharose.asbestos.item.ScraperToolMaterial;
import dev.agatharose.asbestos.scheduler.MesotheliomaSched;
@ -9,6 +10,8 @@ import dev.onyxstudios.cca.api.v3.component.ComponentKey;
import dev.onyxstudios.cca.api.v3.component.ComponentRegistryV3;
import dev.onyxstudios.cca.api.v3.entity.EntityComponentFactoryRegistry;
import dev.onyxstudios.cca.api.v3.entity.EntityComponentInitializer;
import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer;
import nerdhub.cardinal.components.api.util.RespawnCopyStrategy;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
@ -52,11 +55,18 @@ public class Asbestos implements ModInitializer, EntityComponentInitializer {
.statusEffect(new StatusEffectInstance(StatusEffects.WITHER, 30 * 20, 4, false, false), 1.0f)
.build()));
public static final Block ASBESTOS_BLOCK = new Block(
FabricBlockSettings.of(Material.WOOL).hardness(1.0f).sounds(BlockSoundGroup.WOOL));
public static final CarcinogenicBlock ASBESTOS_BLOCK = new CarcinogenicBlock(
FabricBlockSettings.of(Material.WOOL).hardness(1.0f).sounds(BlockSoundGroup.WOOL), 40);
public static final Block SERPENTINITE_BLOCK = new Block(
FabricBlockSettings.of(Material.STONE).hardness(2.0f).breakByTool(FabricToolTags.PICKAXES).requiresTool());
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));
@ -70,6 +80,9 @@ public class Asbestos implements ModInitializer, EntityComponentInitializer {
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
public static Block[] HARMFUL_PASSIVE_BLOCKS = { ASBESTOS_BLOCK };
@Override
public void onInitialize() {
// asbestos fibers item
@ -85,6 +98,16 @@ public class Asbestos implements ModInitializer, EntityComponentInitializer {
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"));
@ -100,6 +123,8 @@ public class Asbestos implements ModInitializer, EntityComponentInitializer {
// mesothelioma status effect
Registry.register(Registry.STATUS_EFFECT, new Identifier("asbestos", "mesothelioma"), MESOTHELIOMA_EFFECT);
AutoConfig.register(AsbestosConfig.class, Toml4jConfigSerializer::new);
// Mesothelioma tick scheduler
MesotheliomaSched.init();
}

View File

@ -0,0 +1,36 @@
package dev.agatharose.asbestos;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class CarcinogenicBlock extends Block {
private int dangerousness;
/**
* A type of a block that is cancerous and makes the player more sick when
* broken
*
* @param settings inherited block settings
* @param dangerousness how many mesothelioma points will be added on block
* break
*/
public CarcinogenicBlock(Settings settings, int dangerousness) {
super(settings);
this.dangerousness = dangerousness;
}
@Override
public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) {
// call the original method
super.onBreak(world, pos, state, player);
// get the player's initial mesothelioma progress
int exposure = Asbestos.MESOTHELIOMA.get(player).getMesothelioma();
// increase it by the block's dangerousness level
Asbestos.MESOTHELIOMA.get(player).setMesothelioma(exposure + dangerousness);
}
}

View File

@ -1,5 +1,7 @@
package dev.agatharose.asbestos;
import dev.agatharose.asbestos.config.AsbestosConfig;
import me.shedaniel.autoconfig.AutoConfig;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectInstance;
@ -19,8 +21,7 @@ public class MesotheliomaStatusEffect extends StatusEffect {
@Override
public void applyUpdateEffect(LivingEntity entity, int amplifier) {
// TODO: move into mod config
int threshold = 180;
AsbestosConfig config = AutoConfig.getConfigHolder(AsbestosConfig.class).getConfig();
// for the sake of performance, non-players are immune to mesothelioma
// and will not receive financial compensation
@ -29,11 +30,11 @@ public class MesotheliomaStatusEffect extends StatusEffect {
int exposure = Asbestos.MESOTHELIOMA.get(player).getMesothelioma();
// slows you down because breathing is hard
if (exposure >= (threshold / 1.5)) {
if (exposure >= (config.mesothelioma.threshold / 1.5)) {
player.addStatusEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 32767, 1));
}
if (exposure >= threshold) {
if (exposure >= config.mesothelioma.threshold) {
player.damage(Asbestos.MESOTHELIOMA_DAMAGE, 1 << amplifier);
}
}

View File

@ -0,0 +1,28 @@
package dev.agatharose.asbestos.config;
import me.shedaniel.autoconfig.ConfigData;
import me.shedaniel.autoconfig.annotation.Config;
import me.shedaniel.autoconfig.annotation.*;
@Config(name = "asbestos")
@Config.Gui.Background("asbestos:textures/block/serpentinite_block.png")
public class AsbestosConfig implements ConfigData {
@ConfigEntry.Gui.CollapsibleObject
public Mesothelioma mesothelioma = new Mesothelioma();
// options related to the mesothelioma status effect
public static class Mesothelioma {
// how many blocks around the player will be checked
@ConfigEntry.BoundedDiscrete(min = 0, max = 32)
@ConfigEntry.Gui.Tooltip
public int offset = 3;
// how many seconds will pass between each check
@ConfigEntry.Gui.Tooltip(count = 2)
public int period = 5;
// how many mesothelioma points must the player have to die
@ConfigEntry.Gui.Tooltip
public int threshold = 180;
}
}

View File

@ -0,0 +1,16 @@
package dev.agatharose.asbestos.config;
import io.github.prospector.modmenu.api.ConfigScreenFactory;
import io.github.prospector.modmenu.api.ModMenuApi;
import me.shedaniel.autoconfig.AutoConfig;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
@Environment(EnvType.CLIENT)
public class ModMenuIntegration implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return parent -> AutoConfig.getConfigScreen(AsbestosConfig.class, parent).get();
}
}

View File

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

View File

@ -3,6 +3,8 @@ package dev.agatharose.asbestos.scheduler;
import java.util.Arrays;
import dev.agatharose.asbestos.Asbestos;
import dev.agatharose.asbestos.config.AsbestosConfig;
import me.shedaniel.autoconfig.AutoConfig;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.minecraft.block.Block;
import net.minecraft.entity.effect.StatusEffectInstance;
@ -11,15 +13,12 @@ import net.minecraft.util.math.Vec3d;
public class MesotheliomaSched {
public static void init() {
// how many blocks around the player will be checked
// TODO: move into mod config
int offset = 3;
int period = 5;
int threshold = 180;
ServerTickEvents.END_SERVER_TICK.register(server -> {
// run every 5 seconds
if (server.getTicks() % (period * 20) == 0) {
// load mod config from the toml file
AsbestosConfig config = AutoConfig.getConfigHolder(AsbestosConfig.class).getConfig();
// run every 5 seconds by default
if (server.getTicks() % (config.mesothelioma.period * 20) == 0) {
server.getWorlds().forEach(world -> {
world.getPlayers().forEach(player -> {
// get the player's asbestos exposure level
@ -27,11 +26,13 @@ public class MesotheliomaSched {
// let the player know that they may be entitled to financial compensation...
// before it's too late
if (exposure >= (threshold / 2)) {
if (exposure >= (config.mesothelioma.threshold / 2)) {
// give the player infinite mesothelioma effect
player.addStatusEffect(new StatusEffectInstance(Asbestos.MESOTHELIOMA_EFFECT, 32767));
}
int offset = config.mesothelioma.offset;
// iterate over every block in the cuboid
findasbestos: for (int i = -offset; i < offset; i++) {
for (int j = -offset; j < offset; j++) {
@ -42,7 +43,7 @@ public class MesotheliomaSched {
Block block = world.getBlockState(pos).getBlock();
if (Arrays.asList(Asbestos.DANGEROUS_BLOCKS).contains(block)) {
if (Arrays.asList(Asbestos.HARMFUL_PASSIVE_BLOCKS).contains(block)) {
Asbestos.MESOTHELIOMA.get(player).setMesothelioma(exposure + 1);
break findasbestos;

View File

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "asbestos:block/asbestos_tile_block"
}
}
}

View File

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "asbestos:block/popcorn_ceiling_block"
}
}
}

View File

@ -1,8 +1,19 @@
{
"block.asbestos.asbestos_block": "Asbestos Block",
"block.asbestos.serpentinite_block": "Serpentinite",
"block.asbestos.popcorn_ceiling_block": "Popcorn Ceiling",
"block.asbestos.asbestos_tile_block": "Asbestos Tiles",
"item.asbestos.asbestos_fibers": "Asbests Fibers",
"item.asbestos.iron_scraper": "Asbestos Scraper",
"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.option.mesothelioma": "Mesothelioma settings",
"text.autoconfig.asbestos.option.mesothelioma.offset": "Offset (blocks)",
"text.autoconfig.asbestos.option.mesothelioma.offset.@Tooltip": "How many blocks around the player will be checked",
"text.autoconfig.asbestos.option.mesothelioma.period": "Period (seconds)",
"text.autoconfig.asbestos.option.mesothelioma.period.@Tooltip[0]": "How many seconds will pass between",
"text.autoconfig.asbestos.option.mesothelioma.period.@Tooltip[1]": "each check for asbestos around the player",
"text.autoconfig.asbestos.option.mesothelioma.threshold": "Mesothelioma threshold",
"text.autoconfig.asbestos.option.mesothelioma.threshold.@Tooltip": "How many mesothelioma points must the player have to die"
}

View File

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "asbestos:block/asbestos_tiles"
}
}

View File

@ -0,0 +1,8 @@
{
"parent": "block/cube_bottom_top",
"textures": {
"top": "asbestos:block/popcorn_top",
"bottom": "asbestos:block/popcorn_bottom",
"side": "asbestos:block/popcorn_side"
}
}

View File

@ -0,0 +1,3 @@
{
"parent": "asbestos:block/asbestos_tile_block"
}

View File

@ -0,0 +1,3 @@
{
"parent": "asbestos:block/popcorn_ceiling_block"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 319 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

View File

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "asbestos:asbestos_tile_block"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "asbestos:popcorn_ceiling_block"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,19 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"AB",
"BA"
],
"key": {
"A": {
"item": "asbestos:asbestos_fibers"
},
"B": {
"item": "minecraft:polished_andesite"
}
},
"result": {
"item": "asbestos:asbestos_tile_block",
"count": 4
}
}

View File

@ -0,0 +1,22 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"PP",
"AD"
],
"key": {
"P": {
"tag": "minecraft:planks"
},
"A": {
"item": "asbestos:asbestos_block"
},
"D": {
"item": "minecraft:white_dye"
}
},
"result": {
"item": "asbestos:popcorn_ceiling_block",
"count": 4
}
}

View File

@ -20,6 +20,9 @@
],
"cardinal-components-entity": [
"dev.agatharose.asbestos.Asbestos"
],
"modmenu": [
"dev.agatharose.asbestos.config.ModMenuIntegration"
]
},
"custom": {