Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config for agricarnation white list #4446

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ private static class Common implements BotaniaConfig.ConfigAccess {
public final PropertyMirror<Integer> gogIslandScaleMultiplier = PropertyMirror.create(INTEGER);
public final PropertyMirror<List<String>> rannuncarpusItemBlacklist = PropertyMirror.create(ConfigTypes.makeList(STRING));
public final PropertyMirror<List<String>> rannuncarpusModBlacklist = PropertyMirror.create(ConfigTypes.makeList(STRING));
public final PropertyMirror<List<String>> agricarnationWhitelist = PropertyMirror.create(ConfigTypes.makeList(STRING));

public ConfigTree configure(ConfigTreeBuilder builder) {
builder.fork("blockBreakingParticles")
Expand Down Expand Up @@ -346,7 +347,11 @@ public ConfigTree configure(ConfigTreeBuilder builder) {
.beginValue("rannuncarpusModBlacklist", ConfigTypes.makeList(STRING), Collections.singletonList("storagedrawers"))
.withComment("List of mod names for rannuncarpuses to ignore.\n" +
"Ignores Storage Drawers by default due to crashes with placing drawer blocks without player involvement.")
.finishValue(rannuncarpusModBlacklist::mirror);
.finishValue(rannuncarpusModBlacklist::mirror)

.beginValue("agricarnationWhitelist", ConfigTypes.makeList(STRING), Collections.emptyList())
.withComment("List of item registry names that will be speeded up growth by agricarnations.")
.finishValue(agricarnationWhitelist::mirror);

return builder.build();
}
Expand Down Expand Up @@ -425,6 +430,11 @@ public List<String> rannuncarpusItemBlacklist() {
public List<String> rannuncarpusModBlacklist() {
return rannuncarpusModBlacklist.getValue();
}

@Override
public List<String> agricarnationWhitelist() {
return agricarnationWhitelist.getValue();
}
}

private static final Common COMMON = new Common();
Expand Down
11 changes: 11 additions & 0 deletions Forge/src/main/java/vazkii/botania/forge/ForgeBotaniaConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ private static class Common implements BotaniaConfig.ConfigAccess {
public final ForgeConfigSpec.ConfigValue<List<? extends String>> rannuncarpusItemBlacklist;
public final ForgeConfigSpec.ConfigValue<List<? extends String>> rannuncarpusModBlacklist;

public final ForgeConfigSpec.ConfigValue<List<? extends String>> agricarnationWhitelist;

public Common(ForgeConfigSpec.Builder builder) {
builder.push("blockBreakingParticles");
blockBreakParticles = builder
Expand Down Expand Up @@ -302,6 +304,9 @@ public Common(ForgeConfigSpec.Builder builder) {
.comment("List of mod names for rannuncarpuses to ignore.\n" +
"Ignores Storage Drawers by default due to crashes with placing drawer blocks without player involvement.")
.defineList("rannuncarpus.modBlacklist", Collections.singletonList("storagedrawers"), o -> o instanceof String s && ResourceLocation.tryParse(s + ":test") != null);
agricarnationWhitelist = builder
.comment("List of item registry names that will be speeded up growth by agricarnations.")
.defineList("argicarnation.whiteList", Collections.emptyList(), o -> o instanceof String s && ResourceLocation.tryParse(s) != null);
}

@Override
Expand Down Expand Up @@ -380,6 +385,12 @@ public List<String> rannuncarpusItemBlacklist() {
public List<String> rannuncarpusModBlacklist() {
return (List<String>) rannuncarpusModBlacklist.get();
}

@SuppressWarnings("unchecked") // NightConfig's types are weird
@Override
public List<String> agricarnationWhitelist() {
return (List<String>) agricarnationWhitelist.get();
}
}

private static final Common COMMON;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
package vazkii.botania.common.block.flower.functional;

import net.minecraft.core.BlockPos;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.level.block.*;
Expand Down Expand Up @@ -87,6 +89,11 @@ private boolean isPlant(BlockPos pos) {
BlockState state = getLevel().getBlockState(pos);
Block block = state.getBlock();

ResourceLocation id = BuiltInRegistries.BLOCK.getKey(block);
if (BotaniaConfig.common().agricarnationWhitelist().contains(id.toString())) {
return !(block instanceof BonemealableBlock mealable) || mealable.isValidBonemealTarget(getLevel(), pos, state, getLevel().isClientSide);
}

// Spreads when ticked
if (block instanceof SpreadingSnowyDirtBlock) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,9 @@ public List<String> rannuncarpusItemBlacklist() {
public List<String> rannuncarpusModBlacklist() {
return inner.rannuncarpusModBlacklist();
}

@Override
public List<String> agricarnationWhitelist() {
return inner.agricarnationWhitelist();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public interface ConfigAccess {
int gogIslandScaleMultiplier();
List<String> rannuncarpusItemBlacklist();
List<String> rannuncarpusModBlacklist();
List<String> agricarnationWhitelist();
}

public interface ClientConfigAccess {
Expand Down
Loading