Skip to content

Commit

Permalink
agricarnation white list
Browse files Browse the repository at this point in the history
  • Loading branch information
rqy2002 committed Aug 27, 2023
1 parent fdec906 commit 986b8c0
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
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,10 @@ 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 true;

// 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,7 @@ 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

0 comments on commit 986b8c0

Please sign in to comment.