mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 11:53:29 +01:00
disallow some more blocks from being plant boosted, and added the ablility to add more
This commit is contained in:
parent
bf757248d2
commit
778e64282f
2 changed files with 21 additions and 5 deletions
|
@ -4,6 +4,7 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.aura.type.BasicAuraType;
|
import de.ellpeck.naturesaura.api.aura.type.BasicAuraType;
|
||||||
import de.ellpeck.naturesaura.api.misc.WeightedOre;
|
import de.ellpeck.naturesaura.api.misc.WeightedOre;
|
||||||
import de.ellpeck.naturesaura.chunk.effect.OreSpawnEffect;
|
import de.ellpeck.naturesaura.chunk.effect.OreSpawnEffect;
|
||||||
|
import de.ellpeck.naturesaura.chunk.effect.PlantBoostEffect;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraftforge.common.ForgeConfigSpec;
|
import net.minecraftforge.common.ForgeConfigSpec;
|
||||||
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
|
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
|
||||||
|
@ -20,6 +21,7 @@ public final class ModConfig {
|
||||||
public ConfigValue<List<? extends String>> auraTypeOverrides;
|
public ConfigValue<List<? extends String>> auraTypeOverrides;
|
||||||
public ConfigValue<List<? extends String>> additionalOres;
|
public ConfigValue<List<? extends String>> additionalOres;
|
||||||
public ConfigValue<List<? extends String>> oreExceptions;
|
public ConfigValue<List<? extends String>> oreExceptions;
|
||||||
|
public ConfigValue<List<? extends String>> plantBoostExceptions;
|
||||||
public ConfigValue<List<? extends String>> additionalProjectiles;
|
public ConfigValue<List<? extends String>> additionalProjectiles;
|
||||||
public ConfigValue<Integer> fieldCreatorRange;
|
public ConfigValue<Integer> fieldCreatorRange;
|
||||||
public ConfigValue<Double> auraToRFRatio;
|
public ConfigValue<Double> auraToRFRatio;
|
||||||
|
@ -66,6 +68,10 @@ public final class ModConfig {
|
||||||
.comment("Blocks that are exempt from being recognized as generatable ores for the passive ore generation effect. Each entry needs to be formatted as modid:block[prop1=value1,...] where block state properties are optional")
|
.comment("Blocks that are exempt from being recognized as generatable ores for the passive ore generation effect. Each entry needs to be formatted as modid:block[prop1=value1,...] where block state properties are optional")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".oreExceptions")
|
.translation("config." + NaturesAura.MOD_ID + ".oreExceptions")
|
||||||
.defineList("oreExceptions", Collections.emptyList(), s -> true);
|
.defineList("oreExceptions", Collections.emptyList(), s -> true);
|
||||||
|
this.plantBoostExceptions = builder
|
||||||
|
.comment("Blocks that are exept from being fertilized by the plant boost effect. Each entry needs to be formatted as modid:block")
|
||||||
|
.translation("config." + NaturesAura.MOD_ID + ".plantBoostExceptions")
|
||||||
|
.defineList("plantBoostExceptions", Collections.emptyList(), s -> true);
|
||||||
this.additionalProjectiles = builder
|
this.additionalProjectiles = builder
|
||||||
.comment("Additional projectile types that are allowed to be consumed by the projectile generator. Each entry needs to be formatted as entity_registry_name->aura_amount")
|
.comment("Additional projectile types that are allowed to be consumed by the projectile generator. Each entry needs to be formatted as entity_registry_name->aura_amount")
|
||||||
.translation("config." + NaturesAura.MOD_ID + ".additionalProjectiles")
|
.translation("config." + NaturesAura.MOD_ID + ".additionalProjectiles")
|
||||||
|
@ -227,6 +233,14 @@ public final class ModConfig {
|
||||||
NaturesAura.LOGGER.warn("Error parsing oreExceptions", e);
|
NaturesAura.LOGGER.warn("Error parsing oreExceptions", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (String s : this.plantBoostExceptions.get())
|
||||||
|
PlantBoostEffect.EXCEPTIONS.add(Objects.requireNonNull(ForgeRegistries.BLOCKS.getValue(new ResourceLocation(s))));
|
||||||
|
} catch (Exception e) {
|
||||||
|
NaturesAura.LOGGER.warn("Error parsing plantBoostExceptions", e);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (String s : this.additionalProjectiles.get()) {
|
for (String s : this.additionalProjectiles.get()) {
|
||||||
var split = s.split("->");
|
var split = s.split("->");
|
||||||
|
|
|
@ -17,14 +17,16 @@ import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.*;
|
||||||
import net.minecraft.world.level.block.BonemealableBlock;
|
|
||||||
import net.minecraft.world.level.block.DoublePlantBlock;
|
|
||||||
import net.minecraft.world.level.block.TallGrassBlock;
|
|
||||||
import net.minecraft.world.level.chunk.LevelChunk;
|
import net.minecraft.world.level.chunk.LevelChunk;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class PlantBoostEffect implements IDrainSpotEffect {
|
public class PlantBoostEffect implements IDrainSpotEffect {
|
||||||
|
|
||||||
|
public static final Set<Block> EXCEPTIONS = new HashSet<>(List.of(Blocks.GRASS_BLOCK, Blocks.MOSS_BLOCK, Blocks.GLOW_LICHEN, Blocks.SMALL_DRIPLEAF, Blocks.BIG_DRIPLEAF, Blocks.BIG_DRIPLEAF_STEM));
|
||||||
public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "plant_boost");
|
public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "plant_boost");
|
||||||
|
|
||||||
private int amount;
|
private int amount;
|
||||||
|
@ -75,7 +77,7 @@ public class PlantBoostEffect implements IDrainSpotEffect {
|
||||||
|
|
||||||
var state = level.getBlockState(plantPos);
|
var state = level.getBlockState(plantPos);
|
||||||
var block = state.getBlock();
|
var block = state.getBlock();
|
||||||
if (block instanceof BonemealableBlock growable && !(block instanceof DoublePlantBlock) && !(block instanceof TallGrassBlock) && block != Blocks.GRASS_BLOCK && block != Blocks.MOSS_BLOCK) {
|
if (block instanceof BonemealableBlock growable && !PlantBoostEffect.EXCEPTIONS.contains(block) && !(block instanceof DoublePlantBlock) && !(block instanceof TallGrassBlock)) {
|
||||||
if (growable.isValidBonemealTarget(level, plantPos, state, false)) {
|
if (growable.isValidBonemealTarget(level, plantPos, state, false)) {
|
||||||
try {
|
try {
|
||||||
growable.performBonemeal((ServerLevel) level, level.random, plantPos, state);
|
growable.performBonemeal((ServerLevel) level, level.random, plantPos, state);
|
||||||
|
|
Loading…
Reference in a new issue