mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-20 20:22:33 +00:00
Revert ore weight registration to API calls instead of IMC. Register netherite (though there's no forge ore tag for it yet)
This commit is contained in:
1 parent
1522d8bbb3
commit
0310cbd69e
6 files changed
+36
-98
No files matched your search
@@ -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<ResourceLocation, Function<DyeColor, Block>> getPaintableBlocks() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
@@ -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.<br />
|
||||
* The argument should be a {@link com.mojang.datafixers.util.Pair<net.minecraft.util.ResourceLocation, Integer>},
|
||||
* any other types are ignored.<br />
|
||||
* Check the Botania source to see default values.<br>
|
||||
*/
|
||||
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.<br />
|
||||
* The argument should be a {@link com.mojang.datafixers.util.Pair<net.minecraft.util.ResourceLocation, Integer>},
|
||||
* any other types are ignored.<br />
|
||||
* Check the Botania source to see default values.<br>
|
||||
*/
|
||||
public static final String REGISTER_NETHER_ORE_WEIGHT = "register_nether_ore_weight";
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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<ResourceLocation, Integer> handleOreWeights(Stream<InterModComms.IMCMessage> msgs) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<ResourceLocation, Integer> 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<ResourceLocation, Integer>) msg.getMessageSupplier().get())
|
||||
.collect(Collectors.toMap(Pair::getFirst, Pair::getSecond));
|
||||
return ImmutableMap.copyOf(map);
|
||||
}
|
||||
}
|
||||
@@ -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<Block> 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);
|
||||
}
|
||||
}
|
||||
@@ -278,8 +278,8 @@ public class BotaniaAPIImpl implements BotaniaAPI {
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public Map<ResourceLocation, Integer> oreWeights = Collections.emptyMap();
|
||||
public Map<ResourceLocation, Integer> netherOreWeights = Collections.emptyMap();
|
||||
private final Map<ResourceLocation, Integer> oreWeights = new ConcurrentHashMap<>();
|
||||
private final Map<ResourceLocation, Integer> netherOreWeights = new ConcurrentHashMap<>();
|
||||
private final Map<ResourceLocation, Function<DyeColor, Block>> 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<ResourceLocation, Function<DyeColor, Block>> getPaintableBlocks() {
|
||||
return Collections.unmodifiableMap(paintableBlocks);
|
||||
|
||||
Reference in new issue
Block a user