mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-22 05:02:30 +00:00
Created API - needs config loading, then implementation.
This commit is contained in:
7 files changed
+171
-5
No files matched your search
@@ -9,6 +9,7 @@ dependencies {
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.7.81-GTNH:dev')
|
||||
compileOnly('com.github.GTNewHorizons:Railcraft:9.16.33:api') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:StorageDrawers:2.1.7-GTNH:api') {transitive=false}
|
||||
compileOnly('ganymedes01.etfuturum:Et-Futurum-Requiem:2.6.2.21-GTNH-daily:dev') {transitive=false}
|
||||
compileOnly('curse.maven:cofh-lib-220333:2388748')
|
||||
compileOnly('curse.maven:minefactory-reloaded-66672:2366150')
|
||||
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
|
||||
|
||||
@@ -18,8 +18,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import cpw.mods.fml.common.registry.VillagerRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.passive.*;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
@@ -32,6 +34,8 @@ import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraftforge.common.util.EnumHelper;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import vazkii.botania.api.block.CatalyzedCocoonSpawn;
|
||||
import vazkii.botania.api.block.IEntityProvider;
|
||||
import vazkii.botania.api.brew.Brew;
|
||||
import vazkii.botania.api.internal.DummyMethodHandler;
|
||||
import vazkii.botania.api.internal.DummySubTile;
|
||||
@@ -78,6 +82,11 @@ public final class BotaniaAPI {
|
||||
public static List<RecipeBrew> brewRecipes = new ArrayList<>();
|
||||
public static List<RecipeManaInfusion> miniFlowerRecipes = new ArrayList<>();
|
||||
|
||||
public static final Map<String, IEntityProvider> cocoonSpawnOptions = new HashMap<>();
|
||||
public static final Map<String, Integer> defaultCommonCocoonSpawns = new HashMap<>();
|
||||
public static final Map<String, Integer> defaultRareCocoonSpawns = new HashMap<>();
|
||||
public static final List<CatalyzedCocoonSpawn> defaultCatalyzedCocoonSpawns = new ArrayList<>();
|
||||
|
||||
private static BiMap<String, Class<? extends SubTileEntity>> subTiles = HashBiMap.<String, Class<? extends SubTileEntity>> create();
|
||||
private static Map<Class<? extends SubTileEntity>, SubTileSignature> subTileSignatures = new HashMap<>();
|
||||
public static Set<String> subtilesForCreativeMenu = new LinkedHashSet<>();
|
||||
@@ -251,6 +260,65 @@ public final class BotaniaAPI {
|
||||
registerSemiDisposableBlock("stoneBasalt"); // Botania
|
||||
registerSemiDisposableBlock("stoneDiorite"); // Botania
|
||||
registerSemiDisposableBlock("stoneGranite"); // Botania
|
||||
|
||||
registerCocoonSpawnOption("minecraft:villager", world -> {
|
||||
final var villager = new EntityVillager(world);
|
||||
VillagerRegistry.applyRandomTrade(villager, world.rand);
|
||||
return villager;
|
||||
});
|
||||
registerCocoonSpawnOption("minecraft:horse", world -> {
|
||||
final var horse = new EntityHorse(world);
|
||||
horse.setGrowingAge(-24000);
|
||||
return horse;
|
||||
});
|
||||
registerCocoonSpawnOption("minecraft:wolf", world -> {
|
||||
final var wolf = new EntityWolf(world);
|
||||
wolf.setGrowingAge(-24000);
|
||||
return wolf;
|
||||
});
|
||||
registerCocoonSpawnOption("minecraft:ocelot", world -> {
|
||||
final var ocelot = new EntityOcelot(world);
|
||||
ocelot.setGrowingAge(-24000);
|
||||
return ocelot;
|
||||
});
|
||||
registerCocoonSpawnOption("minecraft:sheep", world -> {
|
||||
final var sheep = new EntitySheep(world);
|
||||
sheep.setGrowingAge(-24000);
|
||||
sheep.setFleeceColor(EntitySheep.getRandomFleeceColor(world.rand));
|
||||
return sheep;
|
||||
});
|
||||
registerCocoonSpawnOption("minecraft:cow", world -> {
|
||||
final var cow = new EntityCow(world);
|
||||
cow.setGrowingAge(-24000);
|
||||
return cow;
|
||||
});
|
||||
registerCocoonSpawnOption("minecraft:mooshroom", world -> {
|
||||
final var mooshroom = new EntityMooshroom(world);
|
||||
mooshroom.setGrowingAge(-24000);
|
||||
return mooshroom;
|
||||
});
|
||||
registerCocoonSpawnOption("minecraft:pig", world -> {
|
||||
final var pig = new EntityPig(world);
|
||||
pig.setGrowingAge(-24000);
|
||||
return pig;
|
||||
});
|
||||
registerCocoonSpawnOption("minecraft:chicken", world -> {
|
||||
final var chicken = new EntityChicken(world);
|
||||
chicken.setGrowingAge(-24000);
|
||||
return chicken;
|
||||
});
|
||||
|
||||
addDefaultCommonCocoonSpawn("minecraft:sheep", 100);
|
||||
addDefaultCommonCocoonSpawn("minecraft:cow", 99);
|
||||
addDefaultCommonCocoonSpawn("minecraft:mooshroom", 1);
|
||||
addDefaultCommonCocoonSpawn("minecraft:pig", 100);
|
||||
addDefaultCommonCocoonSpawn("minecraft:chicken", 100);
|
||||
|
||||
addDefaultRareCocoonSpawn("minecraft:horse", 100);
|
||||
addDefaultRareCocoonSpawn("minecraft:wolf", 100);
|
||||
addDefaultRareCocoonSpawn("minecraft:ocelot", 100);
|
||||
|
||||
addDefaultCatalyzedCocoonSpawn("minecraft:villager", new ItemStack(Items.emerald), 20);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -675,4 +743,40 @@ public final class BotaniaAPI {
|
||||
return "bm_" + block.getUnlocalizedName() + "@" + meta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a possible entity for the Cocoon of Caprice to be used in configs or assigned later.
|
||||
* @param id The ID of the entity spawn method - should be in the form `modid:entity`
|
||||
* @param entityProvider A method that will instantiate a new Entity & perform any spawning logic - setting age, etc.
|
||||
*/
|
||||
public static void registerCocoonSpawnOption(String id, IEntityProvider entityProvider) {
|
||||
cocoonSpawnOptions.put(id, entityProvider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an entity to the default common pool of the Cocoon of Caprice
|
||||
* @param id The ID of the entity spawn method previously registered with {@link BotaniaAPI#registerCocoonSpawnOption}
|
||||
* @param weight The chance of this entity getting chosen - 100 for the default options
|
||||
*/
|
||||
public static void addDefaultCommonCocoonSpawn(String id, int weight) {
|
||||
defaultCommonCocoonSpawns.put(id, weight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an entity to the default rare pool of the Cocoon of Caprice
|
||||
* @param id The ID of the entity spawn method previously registered with {@link BotaniaAPI#registerCocoonSpawnOption}
|
||||
* @param weight The chance of this entity getting chosen - 100 for the default options
|
||||
*/
|
||||
public static void addDefaultRareCocoonSpawn(String id, int weight) {
|
||||
defaultRareCocoonSpawns.put(id, weight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an entity to the default possible catalyzed spawns of the Cocoon of Caprice
|
||||
* @param id The ID of the entity spawn method previously registered with {@link BotaniaAPI#registerCocoonSpawnOption}
|
||||
* @param catalyst The item needed to increase the chance of this spawn being selected
|
||||
* @param maxCatalysts The amount of catalysts needed to guarantee that this entity gets chosen
|
||||
*/
|
||||
public static void addDefaultCatalyzedCocoonSpawn(String id, ItemStack catalyst, int maxCatalysts) {
|
||||
defaultCatalyzedCocoonSpawns.add(new CatalyzedCocoonSpawn(catalyst, maxCatalysts, id));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package vazkii.botania.api.block;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class CatalyzedCocoonSpawn {
|
||||
public final String id;
|
||||
public final ItemStack catalyst;
|
||||
public final int maxCatalyst;
|
||||
|
||||
public CatalyzedCocoonSpawn(ItemStack catalyst, int maxCatalyst, String id) {
|
||||
// TODO Add particles?
|
||||
this.id = id;
|
||||
this.catalyst = catalyst;
|
||||
this.maxCatalyst = maxCatalyst;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package vazkii.botania.api.block;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface IEntityProvider {
|
||||
Entity createEntity(World world);
|
||||
}
|
||||
@@ -23,11 +23,17 @@ import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.entity.passive.EntityWolf;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import cpw.mods.fml.common.registry.VillagerRegistry;
|
||||
import net.minecraft.util.WeightedRandom;
|
||||
import vazkii.botania.api.block.IEntityProvider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TileCocoon extends TileMod {
|
||||
|
||||
private static final String TAG_TIME_PASSED = "timePassed";
|
||||
private static final String TAG_EMERALDS_GIVEN = "emeraldsGiven";
|
||||
private static final String TAG_CATALYSED_ID = "catalyzedId";
|
||||
private static final String TAG_CATALYSTS_GIVEN = "catalystGiven";
|
||||
|
||||
public static final int TOTAL_TIME = 60; // TODO Undo this
|
||||
public static final int MAX_EMERALDS = 20;
|
||||
@@ -125,5 +131,4 @@ public class TileCocoon extends TileMod {
|
||||
timePassed = cmp.getInteger(TAG_TIME_PASSED);
|
||||
emeraldsGiven = cmp.getInteger(TAG_EMERALDS_GIVEN);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,12 +21,11 @@ import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.ChatStyle;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import vazkii.botania.api.block.CatalyzedCocoonSpawn;
|
||||
import vazkii.botania.api.block.IEntityProvider;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
import vazkii.botania.common.lib.LibPotionNames;
|
||||
import cpw.mods.fml.client.event.ConfigChangedEvent;
|
||||
@@ -124,6 +123,10 @@ public final class ConfigHandler {
|
||||
public static int potionIDAllure = 95;
|
||||
public static int potionIDClear = 96;
|
||||
|
||||
public static final ArrayList<CocoonSpawn> cocoonCommonPool = new ArrayList<>();
|
||||
public static final ArrayList<CocoonSpawn> cocoonRarePool = new ArrayList<>();
|
||||
public static final ArrayList<CatalyzedCocoonSpawn> cocoonCatalyzedSpawns = new ArrayList<>();
|
||||
|
||||
public static void loadConfig(File configFile) {
|
||||
config = new Configuration(configFile);
|
||||
|
||||
@@ -419,6 +422,12 @@ public final class ConfigHandler {
|
||||
verifiedPotionArray = true;
|
||||
}
|
||||
|
||||
private static void loadPropCocoonPool(ArrayList<CocoonSpawn> pool, String propName, String comment) {
|
||||
String[] propertyValue = config.getStringList(propName, Configuration.CATEGORY_GENERAL, new String[]{}, comment);
|
||||
|
||||
// TODO Figure out config loading...
|
||||
}
|
||||
|
||||
public static class ConfigAdaptor {
|
||||
|
||||
private boolean enabled;
|
||||
@@ -544,4 +553,13 @@ public final class ConfigHandler {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class CocoonSpawn extends WeightedRandom.Item {
|
||||
public final IEntityProvider entityProvider;
|
||||
|
||||
public CocoonSpawn(int weight, IEntityProvider entityProvider) {
|
||||
super(weight);
|
||||
this.entityProvider = entityProvider;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,11 @@
|
||||
*/
|
||||
package vazkii.botania.common.core.proxy;
|
||||
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import ganymedes01.etfuturum.configuration.configs.ConfigBlocksItems;
|
||||
import ganymedes01.etfuturum.configuration.configs.ConfigEntities;
|
||||
import ganymedes01.etfuturum.entities.EntityShulker;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.boss.EntityDragon;
|
||||
@@ -162,6 +167,14 @@ public class CommonProxy {
|
||||
ModBrewRecipes.initTC();
|
||||
}
|
||||
|
||||
if(Botania.etFuturumLoaded && ConfigEntities.enableShulker) {
|
||||
BotaniaAPI.registerCocoonSpawnOption("etfuturum:shulker", EntityShulker::new);
|
||||
|
||||
if (ConfigBlocksItems.enableChorusFruit) {
|
||||
BotaniaAPI.addDefaultCatalyzedCocoonSpawn("etfuturum:shulker", ganymedes01.etfuturum.ModItems.CHORUS_FRUIT.newItemStack(), 20);
|
||||
}
|
||||
}
|
||||
|
||||
ModBlocks.addDispenserBehaviours();
|
||||
ModBlocks.registerMultiparts();
|
||||
ConfigHandler.loadPostInit();
|
||||
|
||||
Reference in new issue
Block a user