diff --git a/src/main/java/vazkii/botania/api/BotaniaAPI.java b/src/main/java/vazkii/botania/api/BotaniaAPI.java index d27aae0fd..1a47c6940 100644 --- a/src/main/java/vazkii/botania/api/BotaniaAPI.java +++ b/src/main/java/vazkii/botania/api/BotaniaAPI.java @@ -78,6 +78,25 @@ public interface BotaniaAPI { return Collections.emptyMap(); } + /** + * Register ore to be produced by the Orechid + * + * @param tag Block tag ID containing the ores to register + * @param weight Relative weight of tis entry + */ + default void registerOreWeight(ResourceLocation tag, int weight) { + + } + + /** + * Register ore to be produced by the Orechid Ignem + * + * @see #registerOreWeight + */ + default void registerNetherOreWeight(ResourceLocation tag, int weight) { + + } + default Map> getPaintableBlocks() { return Collections.emptyMap(); } diff --git a/src/main/java/vazkii/botania/api/imc/IMC.java b/src/main/java/vazkii/botania/api/imc/IMC.java deleted file mode 100644 index cb4f20892..000000000 --- a/src/main/java/vazkii/botania/api/imc/IMC.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This class is distributed as part of the Botania Mod. - * Get the Source Code in github: - * https://github.com/Vazkii/Botania - * - * Botania is Open Source and distributed under the - * Botania License: http://botaniamod.net/license.php - */ -package vazkii.botania.api.imc; - -/** - * This class defines the IMC methods accepted by Botania and their expected argument types. - * This is just for documentation purposes, IMC is meant to be sent when you don't want to depend on the Botania API - * classes. - * - * @see net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent - * @see net.minecraftforge.fml.event.lifecycle.InterModProcessEvent - * @see net.minecraftforge.fml.InterModComms - */ -public class IMC { - /** - * Maps a block tag to its weight in world generation. This is used for the Orechid flower.
- * The argument should be a {@link com.mojang.datafixers.util.Pair}, - * any other types are ignored.
- * Check the Botania source to see default values.
- */ - public static final String REGISTER_ORE_WEIGHT = "register_ore_weight"; - - /** - * Maps a block tag to its weight in nether world generation. This is used for the Orechid Ignem flower.
- * The argument should be a {@link com.mojang.datafixers.util.Pair}, - * any other types are ignored.
- * Check the Botania source to see default values.
- */ - public static final String REGISTER_NETHER_ORE_WEIGHT = "register_nether_ore_weight"; -} diff --git a/src/main/java/vazkii/botania/common/Botania.java b/src/main/java/vazkii/botania/common/Botania.java index 426e944b3..ec0295f41 100644 --- a/src/main/java/vazkii/botania/common/Botania.java +++ b/src/main/java/vazkii/botania/common/Botania.java @@ -135,7 +135,6 @@ public class Botania { IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus(); modBus.addListener(this::commonSetup); modBus.addListener(IMCSender::enqueue); - modBus.addListener(IMCHandler::handle); modBus.addListener(this::loadComplete); modBus.addListener(DataGenerators::gatherData); modBus.addGenericListener(Feature.class, ModFeatures::registerFeatures); diff --git a/src/main/java/vazkii/botania/common/core/handler/IMCHandler.java b/src/main/java/vazkii/botania/common/core/handler/IMCHandler.java deleted file mode 100644 index 7616afd4b..000000000 --- a/src/main/java/vazkii/botania/common/core/handler/IMCHandler.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This class is distributed as part of the Botania Mod. - * Get the Source Code in github: - * https://github.com/Vazkii/Botania - * - * Botania is Open Source and distributed under the - * Botania License: http://botaniamod.net/license.php - */ -package vazkii.botania.common.core.handler; - -import com.google.common.collect.ImmutableMap; -import com.mojang.datafixers.util.Pair; - -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.InterModComms; -import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; - -import vazkii.botania.api.BotaniaAPI; -import vazkii.botania.api.imc.IMC; -import vazkii.botania.common.impl.BotaniaAPIImpl; - -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public final class IMCHandler { - public static void handle(InterModProcessEvent evt) { - ((BotaniaAPIImpl) BotaniaAPI.instance()).oreWeights = handleOreWeights(evt.getIMCStream(IMC.REGISTER_ORE_WEIGHT::equals)); - ((BotaniaAPIImpl) BotaniaAPI.instance()).netherOreWeights = handleOreWeights(evt.getIMCStream(IMC.REGISTER_NETHER_ORE_WEIGHT::equals)); - } - - private static Map handleOreWeights(Stream msgs) { - @SuppressWarnings("unchecked") - Map map = msgs - .filter(msg -> { - Object thing = msg.getMessageSupplier().get(); - if (thing instanceof Pair) { - return ((Pair) thing).getFirst() instanceof ResourceLocation - && ((Pair) thing).getSecond() instanceof Integer; - } - return false; - }) - .map(msg -> (Pair) msg.getMessageSupplier().get()) - .collect(Collectors.toMap(Pair::getFirst, Pair::getSecond)); - return ImmutableMap.copyOf(map); - } -} diff --git a/src/main/java/vazkii/botania/common/core/handler/IMCSender.java b/src/main/java/vazkii/botania/common/core/handler/IMCSender.java index 40a43350e..8c70b537f 100644 --- a/src/main/java/vazkii/botania/common/core/handler/IMCSender.java +++ b/src/main/java/vazkii/botania/common/core/handler/IMCSender.java @@ -81,6 +81,7 @@ public class IMCSender { // Vanilla addOreWeightNether("quartz", 19600); + addOreWeightNether("netherite", 148); // Mystical Agriculture addOreWeight("nether/inferium", 10000); addOreWeight("nether/prosperity", 7420); @@ -111,12 +112,6 @@ public class IMCSender { addOreWeightNether("ardite", 500); addOreWeightNether("cobalt", 500); - /* Ore weights TODO 1.14 / 1.15 - addOreWeight("oreCertusQuartz", 3975); // Applied Energistics certusQuartz, certus/quartz or quartz/certus? - addOreWeight("oreQuartzBlack", 5535); // Actually Additions quartzBlock, quartz/black or black/quartz? - addOreWeightNether("oreHaditeCoal", 500); // Hadite haditeCoal, hadite/coal or coal/hadite? - */ - BotaniaAPI.instance().registerPaintableBlock(Blocks.GLASS, color -> ColorHelper.STAINED_GLASS_MAP.get(color).get()); for (IRegistryDelegate b : ColorHelper.STAINED_GLASS_MAP.values()) { BotaniaAPI.instance().registerPaintableBlock(b.get(), color -> ColorHelper.STAINED_GLASS_MAP.get(color).get()); @@ -153,15 +148,13 @@ public class IMCSender { } } - public static void sendToSelf(String method, Object thing) { - InterModComms.sendTo(LibMisc.MOD_ID, method, () -> thing); - } - private static void addOreWeight(String oreTag, int weight) { - sendToSelf(IMC.REGISTER_ORE_WEIGHT, new Pair<>(new ResourceLocation("forge", "ores/" + oreTag), weight)); + ResourceLocation tag = new ResourceLocation("forge", "ores/" + oreTag); + BotaniaAPI.instance().registerOreWeight(tag, weight); } private static void addOreWeightNether(String oreTag, int weight) { - sendToSelf(IMC.REGISTER_NETHER_ORE_WEIGHT, new Pair<>(new ResourceLocation("forge", "ores/" + oreTag), weight)); + ResourceLocation tag = new ResourceLocation("forge", "ores/" + oreTag); + BotaniaAPI.instance().registerNetherOreWeight(tag, weight); } } diff --git a/src/main/java/vazkii/botania/common/impl/BotaniaAPIImpl.java b/src/main/java/vazkii/botania/common/impl/BotaniaAPIImpl.java index d35da3bfe..1735ce53b 100644 --- a/src/main/java/vazkii/botania/common/impl/BotaniaAPIImpl.java +++ b/src/main/java/vazkii/botania/common/impl/BotaniaAPIImpl.java @@ -278,8 +278,8 @@ public class BotaniaAPIImpl implements BotaniaAPI { return arrayList; } - public Map oreWeights = Collections.emptyMap(); - public Map netherOreWeights = Collections.emptyMap(); + private final Map oreWeights = new ConcurrentHashMap<>(); + private final Map netherOreWeights = new ConcurrentHashMap<>(); private final Map> paintableBlocks = new ConcurrentHashMap<>(); @Override @@ -292,6 +292,16 @@ public class BotaniaAPIImpl implements BotaniaAPI { return Collections.unmodifiableMap(netherOreWeights); } + @Override + public void registerOreWeight(ResourceLocation tag, int weight) { + oreWeights.put(tag, weight); + } + + @Override + public void registerNetherOreWeight(ResourceLocation tag, int weight) { + netherOreWeights.put(tag, weight); + } + @Override public Map> getPaintableBlocks() { return Collections.unmodifiableMap(paintableBlocks);