Skip to content

Commit

Permalink
Add rannuncarpus blacklist, blacklist storage drawers by default
Browse files Browse the repository at this point in the history
Closes #3253
  • Loading branch information
Hubry committed Nov 10, 2020
1 parent b1f3253 commit bfdebe4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/vazkii/botania/common/Botania.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ public Botania() {
modBus.addGenericListener(TileEntityType.class, ModSubtiles::registerTEs);
modBus.addGenericListener(GlobalLootModifierSerializer.class, DisposeModifier::register);
modBus.addGenericListener(Attribute.class, PixieHandler::registerAttribute);
modBus.addListener((ModConfig.Loading e) -> ConfigHandler.onConfigLoad());
modBus.addListener((ModConfig.Reloading e) -> ConfigHandler.onConfigLoad());

IEventBus forgeBus = MinecraftForge.EVENT_BUS;
forgeBus.addListener(this::serverAboutToStart);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
Expand Down Expand Up @@ -83,6 +85,12 @@ public void tickFlower() {

ItemStack stack = item.getItem();
Item stackItem = stack.getItem();
ResourceLocation id = Registry.ITEM.getKey(stackItem);
if (ConfigHandler.blacklistedRannuncarpusModIds.contains(id.getNamespace())
|| ConfigHandler.blacklistedRannuncarpusItems.contains(id)) {
continue;
}

if (stackItem instanceof BlockItem || stackItem instanceof IFlowerPlaceable) {
if (!validPositions.isEmpty()) {
BlockPos coords = validPositions.get(getWorld().rand.nextInt(validPositions.size()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
import org.apache.commons.lang3.tuple.Pair;

import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

public final class ConfigHandler {

Expand Down Expand Up @@ -139,6 +142,9 @@ public static class Common {

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

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

public final ForgeConfigSpec.BooleanValue worldgenEnabled;

public Common(ForgeConfigSpec.Builder builder) {
Expand Down Expand Up @@ -207,6 +213,13 @@ public Common(ForgeConfigSpec.Builder builder) {
worldgenEnabled = builder
.comment("Set this to false to disable mystical flower and mushroom worldgen. More fine-tuned customization should be done with datapacks.")
.define("worldgen", true);
rannuncarpusItemBlacklist = builder
.comment("List of item registry names that will be ignored by rannuncarpuses when placing blocks.")
.defineList("rannuncarpus.itemBlacklist", Collections.emptyList(), s -> s instanceof String && ResourceLocation.tryCreate((String) s) != null);
rannuncarpusModBlacklist = 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"), s -> s instanceof String && ResourceLocation.tryCreate(s + ":test") != null);
}
}

Expand All @@ -217,4 +230,12 @@ public Common(ForgeConfigSpec.Builder builder) {
COMMON_SPEC = specPair.getRight();
COMMON = specPair.getLeft();
}

public static Set<ResourceLocation> blacklistedRannuncarpusItems;
public static Set<String> blacklistedRannuncarpusModIds;

public static void onConfigLoad() {
blacklistedRannuncarpusItems = COMMON.rannuncarpusItemBlacklist.get().stream().map(ResourceLocation::new).collect(Collectors.toSet());
blacklistedRannuncarpusModIds = new HashSet<>(COMMON.rannuncarpusModBlacklist.get());
}
}

0 comments on commit bfdebe4

Please sign in to comment.