mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-14 01:04:12 +00:00
Move inventory code to their own files, refactor, cleanup.
Register items and blocks before the rest of preInit.
This commit is contained in:
1 parent
f1afca664b
commit
411b4959f2
229 files changed
+4628
-5271
No files matched your search
@@ -24,6 +24,7 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -55,6 +56,7 @@ import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.api.apiculture.FlowerManager;
|
||||
import forestry.api.apiculture.IBeekeepingMode;
|
||||
import forestry.api.apiculture.hives.HiveManager;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IClassification;
|
||||
@@ -86,12 +88,10 @@ import forestry.apiculture.genetics.JubilanceFactory;
|
||||
import forestry.apiculture.genetics.alleles.AlleleEffect;
|
||||
import forestry.apiculture.items.ItemArmorApiarist;
|
||||
import forestry.apiculture.items.ItemBeeGE;
|
||||
import forestry.apiculture.items.ItemBeealyzer;
|
||||
import forestry.apiculture.items.ItemBlockCandle;
|
||||
import forestry.apiculture.items.ItemHabitatLocator;
|
||||
import forestry.apiculture.items.ItemHiveFrame;
|
||||
import forestry.apiculture.items.ItemHoneycomb;
|
||||
import forestry.apiculture.items.ItemImprinter;
|
||||
import forestry.apiculture.items.ItemMinecartBeehouse;
|
||||
import forestry.apiculture.items.ItemWaxCast;
|
||||
import forestry.apiculture.multiblock.TileAlveary;
|
||||
@@ -126,7 +126,6 @@ import forestry.core.config.Config;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.config.ForestryBlock;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.config.GameMode;
|
||||
import forestry.core.config.LocalizedConfiguration;
|
||||
import forestry.core.entities.EntityFXSnow;
|
||||
import forestry.core.fluids.Fluids;
|
||||
@@ -135,6 +134,8 @@ import forestry.core.items.ItemForestry;
|
||||
import forestry.core.items.ItemOverlay;
|
||||
import forestry.core.items.ItemOverlay.OverlayInfo;
|
||||
import forestry.core.items.ItemScoop;
|
||||
import forestry.core.items.ItemWithGui;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.network.PacketIdClient;
|
||||
import forestry.core.network.PacketIdServer;
|
||||
import forestry.core.proxy.Proxies;
|
||||
@@ -200,10 +201,68 @@ public class PluginApiculture extends ForestryPlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
super.preInit();
|
||||
protected void registerItemsAndBlocks() {
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
// / BEES
|
||||
ForestryItem.beeQueenGE.registerItem(new ItemBeeGE(EnumBeeType.QUEEN), "beeQueenGE");
|
||||
ForestryItem.beeDroneGE.registerItem(new ItemBeeGE(EnumBeeType.DRONE), "beeDroneGE");
|
||||
ForestryItem.beePrincessGE.registerItem(new ItemBeeGE(EnumBeeType.PRINCESS), "beePrincessGE");
|
||||
ForestryItem.beeLarvaeGE.registerItem(new ItemBeeGE(EnumBeeType.LARVAE), "beeLarvaeGE");
|
||||
|
||||
Item beealyzer = new ItemWithGui(GuiId.BeealyzerGUI).setCreativeTab(Tabs.tabApiculture);
|
||||
ForestryItem.beealyzer.registerItem(beealyzer, "beealyzer");
|
||||
ForestryItem.habitatLocator.registerItem(new ItemHabitatLocator(), "habitatLocator");
|
||||
Item imprinter = new ItemWithGui(GuiId.ImprinterGUI).setCreativeTab(Tabs.tabApiculture).setMaxStackSize(1);
|
||||
ForestryItem.imprinter.registerItem(imprinter, "imprinter");
|
||||
|
||||
ForestryItem.minecartBeehouse.registerItem(new ItemMinecartBeehouse(), "cart.beehouse");
|
||||
|
||||
// / COMB FRAMES
|
||||
ForestryItem.frameUntreated.registerItem(new ItemHiveFrame(80, 0.9f), "frameUntreated");
|
||||
ForestryItem.frameImpregnated.registerItem(new ItemHiveFrame(240, 0.4f), "frameImpregnated");
|
||||
ForestryItem.frameProven.registerItem(new ItemHiveFrame(720, 0.3f), "frameProven");
|
||||
|
||||
// / BEE RESOURCES
|
||||
ForestryItem.honeyDrop.registerItem(new ItemOverlay(Tabs.tabApiculture,
|
||||
new OverlayInfo("honey", 0xecb42d, 0xe8c814),
|
||||
new OverlayInfo("charged", 0x800505, 0x9c0707).setIsSecret(),
|
||||
new OverlayInfo("omega", 0x191919, 0x4a8ca7).setIsSecret()), "honeyDrop");
|
||||
OreDictionary.registerOre("dropHoney", ForestryItem.honeyDrop.getItemStack());
|
||||
|
||||
ForestryItem.pollenCluster.registerItem(new ItemOverlay(Tabs.tabApiculture,
|
||||
new OverlayInfo("normal", 0xa28a25, 0xa28a25),
|
||||
new OverlayInfo("crystalline", 0xffffff, 0xc5feff)),
|
||||
"pollen");
|
||||
OreDictionary.registerOre("itemPollen", ForestryItem.pollenCluster.getItemStack());
|
||||
|
||||
ForestryItem.propolis.registerItem(new ItemOverlay(Tabs.tabApiculture,
|
||||
new OverlayInfo("normal", 0xc5b24e),
|
||||
new OverlayInfo("sticky", 0xc68e57),
|
||||
new OverlayInfo("pulsating", 0x2ccdb1).setIsSecret(),
|
||||
new OverlayInfo("silky", 0xddff00)),
|
||||
"propolis");
|
||||
|
||||
ForestryItem.honeydew.registerItem(new ItemForestry().setCreativeTab(Tabs.tabApiculture), "honeydew");
|
||||
OreDictionary.registerOre("dropHoneydew", ForestryItem.honeydew.getItemStack());
|
||||
|
||||
ForestryItem.royalJelly.registerItem(new ItemForestry().setCreativeTab(Tabs.tabApiculture), "royalJelly");
|
||||
OreDictionary.registerOre("dropRoyalJelly", ForestryItem.royalJelly.getItemStack());
|
||||
|
||||
ForestryItem.waxCast.registerItem(new ItemWaxCast().setCreativeTab(Tabs.tabApiculture), "waxCast");
|
||||
|
||||
// / BEE COMBS
|
||||
ForestryItem.beeComb.registerItem(new ItemHoneycomb(), "beeCombs");
|
||||
OreDictionary.registerOre("beeComb", ForestryItem.beeComb.getWildcard());
|
||||
|
||||
// / APIARIST'S CLOTHES
|
||||
ForestryItem.apiaristHat.registerItem(new ItemArmorApiarist(0), "apiaristHelmet");
|
||||
ForestryItem.apiaristChest.registerItem(new ItemArmorApiarist(1), "apiaristChest");
|
||||
ForestryItem.apiaristLegs.registerItem(new ItemArmorApiarist(2), "apiaristLegs");
|
||||
ForestryItem.apiaristBoots.registerItem(new ItemArmorApiarist(3), "apiaristBoots");
|
||||
|
||||
// TOOLS
|
||||
ForestryItem.scoop.registerItem(new ItemScoop(), "scoop");
|
||||
ForestryItem.scoop.item().setHarvestLevel("scoop", 3);
|
||||
|
||||
ForestryBlock.apiculture.registerBlock(new BlockBase(Material.iron), ItemBlockForestry.class, "apiculture");
|
||||
ForestryBlock.apiculture.block().setCreativeTab(Tabs.tabApiculture);
|
||||
@@ -213,6 +272,23 @@ public class PluginApiculture extends ForestryPlugin {
|
||||
ForestryBlock.apicultureChest.block().setCreativeTab(Tabs.tabApiculture);
|
||||
ForestryBlock.apicultureChest.block().setHarvestLevel("axe", 0);
|
||||
|
||||
ForestryBlock.beehives.registerBlock(new BlockBeehives(), ItemBlockForestry.class, "beehives");
|
||||
|
||||
// Candles
|
||||
ForestryBlock.candle.registerBlock(new BlockCandle(), ItemBlockCandle.class, "candle");
|
||||
ForestryBlock.stump.registerBlock(new BlockStump(), ItemBlockForestry.class, "stump");
|
||||
|
||||
// Alveary and Components
|
||||
ForestryBlock.alveary.registerBlock(new BlockAlveary(), ItemBlockForestry.class, "alveary");
|
||||
ForestryBlock.alveary.block().setHarvestLevel("axe", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
super.preInit();
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
definitionApiary = ((BlockBase) ForestryBlock.apiculture.block()).addDefinition(new MachineDefinition(Constants.DEFINITION_APIARY_META, "forestry.Apiary", TileApiary.class,
|
||||
ShapedRecipeCustom.createShapedRecipe(ForestryBlock.apiculture.getItemStack(1, Constants.DEFINITION_APIARY_META),
|
||||
"XXX",
|
||||
@@ -248,16 +324,6 @@ public class PluginApiculture extends ForestryPlugin {
|
||||
definitionAnalyzer = ((BlockBase) ForestryBlock.core.block()).addDefinition(new MachineDefinition(Constants.DEFINITION_ANALYZER_META, "forestry.Analyzer", TileAnalyzer.class,
|
||||
PluginApiculture.proxy.getRendererAnalyzer(Constants.TEXTURE_PATH_BLOCKS + "/analyzer_")));
|
||||
|
||||
ForestryBlock.beehives.registerBlock(new BlockBeehives(), ItemBlockForestry.class, "beehives");
|
||||
|
||||
// Candles
|
||||
ForestryBlock.candle.registerBlock(new BlockCandle(), ItemBlockCandle.class, "candle");
|
||||
ForestryBlock.stump.registerBlock(new BlockStump(), ItemBlockForestry.class, "stump");
|
||||
|
||||
// Alveary and Components
|
||||
ForestryBlock.alveary.registerBlock(new BlockAlveary(), ItemBlockForestry.class, "alveary");
|
||||
ForestryBlock.alveary.block().setHarvestLevel("axe", 0);
|
||||
|
||||
// Add triggers
|
||||
if (PluginManager.Module.BUILDCRAFT_STATEMENTS.isEnabled()) {
|
||||
ApicultureTriggers.initialize();
|
||||
@@ -274,25 +340,11 @@ public class PluginApiculture extends ForestryPlugin {
|
||||
|
||||
@Override
|
||||
public void doInit() {
|
||||
final String oldConfig = CONFIG_CATEGORY + ".conf";
|
||||
final String newConfig = CONFIG_CATEGORY + ".cfg";
|
||||
|
||||
File configFile = new File(Forestry.instance.getConfigFolder(), newConfig);
|
||||
File configFile = new File(Forestry.instance.getConfigFolder(), CONFIG_CATEGORY + ".cfg");
|
||||
if (!configFile.exists()) {
|
||||
setDefaultsForConfig();
|
||||
}
|
||||
|
||||
File oldConfigFile = new File(Forestry.instance.getConfigFolder(), oldConfig);
|
||||
if (oldConfigFile.exists()) {
|
||||
loadOldConfig();
|
||||
|
||||
final String oldConfigRenamed = CONFIG_CATEGORY + ".conf.old";
|
||||
File oldConfigFileRenamed = new File(Forestry.instance.getConfigFolder(), oldConfigRenamed);
|
||||
if (oldConfigFile.renameTo(oldConfigFileRenamed)) {
|
||||
Log.info("Migrated " + CONFIG_CATEGORY + " settings to the new file '" + newConfig + "' and renamed '" + oldConfig + "' to '" + oldConfigRenamed + "'.");
|
||||
}
|
||||
}
|
||||
|
||||
LocalizedConfiguration config = new LocalizedConfiguration(configFile, "2.0.0");
|
||||
if (!config.getLoadedConfigVersion().equals(config.getDefinedConfigVersion())) {
|
||||
boolean deleted = configFile.delete();
|
||||
@@ -460,28 +512,6 @@ public class PluginApiculture extends ForestryPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
private static void loadOldConfig() {
|
||||
// Config
|
||||
forestry.core.config.deprecated.Configuration apicultureConfig = new forestry.core.config.deprecated.Configuration();
|
||||
|
||||
forestry.core.config.deprecated.Property property = apicultureConfig.get("render.bees.fancy", CONFIG_CATEGORY, fancyRenderedBees);
|
||||
property.comment = "set to true to enable a fancy butterfly-like renderer for bees. (experimental!)";
|
||||
fancyRenderedBees = Boolean.parseBoolean(property.value);
|
||||
|
||||
property = apicultureConfig.get("beekeeping.mode", CONFIG_CATEGORY, "NORMAL");
|
||||
property.comment = "change beekeeping modes here. possible values EASY, NORMAL, HARD, HARDCORE, INSANE. mods may add additional modes.";
|
||||
beekeepingMode = property.value.trim();
|
||||
Log.finer("Beekeeping mode read from config: " + beekeepingMode);
|
||||
|
||||
property = apicultureConfig.get("beekeeping.secondprincess", CONFIG_CATEGORY, secondPrincessChance);
|
||||
property.comment = "percent chance of second princess drop, for limited/skyblock maps. Acceptable values up to 2 decimals.";
|
||||
secondPrincessChance = Float.parseFloat(property.value);
|
||||
|
||||
property = apicultureConfig.get("species.blacklist", CONFIG_CATEGORY, "");
|
||||
property.comment = "add species to blacklist identified by their uid and seperated with ';'.";
|
||||
parseBeeBlacklist(property.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGuiHandler getGuiHandler() {
|
||||
return new GuiHandlerApiculture();
|
||||
@@ -499,69 +529,6 @@ public class PluginApiculture extends ForestryPlugin {
|
||||
PacketIdServer.BEE_LOGIC_ACTIVE_ENTITY_REQUEST.setPacketHandler(new PacketBeeLogicEntityRequest());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerItems() {
|
||||
|
||||
// / BEES
|
||||
ForestryItem.beeQueenGE.registerItem((new ItemBeeGE(EnumBeeType.QUEEN)), "beeQueenGE");
|
||||
ForestryItem.beeDroneGE.registerItem((new ItemBeeGE(EnumBeeType.DRONE)), "beeDroneGE");
|
||||
ForestryItem.beePrincessGE.registerItem((new ItemBeeGE(EnumBeeType.PRINCESS)), "beePrincessGE");
|
||||
ForestryItem.beeLarvaeGE.registerItem((new ItemBeeGE(EnumBeeType.LARVAE)), "beeLarvaeGE");
|
||||
|
||||
ForestryItem.beealyzer.registerItem((new ItemBeealyzer()), "beealyzer");
|
||||
ForestryItem.habitatLocator.registerItem(new ItemHabitatLocator(), "habitatLocator");
|
||||
ForestryItem.imprinter.registerItem((new ItemImprinter()), "imprinter");
|
||||
|
||||
ForestryItem.minecartBeehouse.registerItem(new ItemMinecartBeehouse(), "cart.beehouse");
|
||||
|
||||
// / COMB FRAMES
|
||||
ForestryItem.frameUntreated.registerItem(new ItemHiveFrame(80, 0.9f), "frameUntreated");
|
||||
ForestryItem.frameImpregnated.registerItem(new ItemHiveFrame(240, 0.4f), "frameImpregnated");
|
||||
ForestryItem.frameProven.registerItem(new ItemHiveFrame(720, 0.3f), "frameProven");
|
||||
|
||||
// / BEE RESOURCES
|
||||
ForestryItem.honeyDrop.registerItem(new ItemOverlay(Tabs.tabApiculture,
|
||||
new OverlayInfo("honey", 0xecb42d, 0xe8c814),
|
||||
new OverlayInfo("charged", 0x800505, 0x9c0707).setIsSecret(),
|
||||
new OverlayInfo("omega", 0x191919, 0x4a8ca7).setIsSecret()), "honeyDrop");
|
||||
OreDictionary.registerOre("dropHoney", ForestryItem.honeyDrop.getItemStack());
|
||||
|
||||
ForestryItem.pollenCluster.registerItem(new ItemOverlay(Tabs.tabApiculture,
|
||||
new OverlayInfo("normal", 0xa28a25, 0xa28a25),
|
||||
new OverlayInfo("crystalline", 0xffffff, 0xc5feff)),
|
||||
"pollen");
|
||||
OreDictionary.registerOre("itemPollen", ForestryItem.pollenCluster.getItemStack());
|
||||
|
||||
ForestryItem.propolis.registerItem(new ItemOverlay(Tabs.tabApiculture,
|
||||
new OverlayInfo("normal", 0xc5b24e),
|
||||
new OverlayInfo("sticky", 0xc68e57),
|
||||
new OverlayInfo("pulsating", 0x2ccdb1).setIsSecret(),
|
||||
new OverlayInfo("silky", 0xddff00)),
|
||||
"propolis");
|
||||
|
||||
ForestryItem.honeydew.registerItem(new ItemForestry().setCreativeTab(Tabs.tabApiculture), "honeydew");
|
||||
OreDictionary.registerOre("dropHoneydew", ForestryItem.honeydew.getItemStack());
|
||||
|
||||
ForestryItem.royalJelly.registerItem(new ItemForestry().setCreativeTab(Tabs.tabApiculture), "royalJelly");
|
||||
OreDictionary.registerOre("dropRoyalJelly", ForestryItem.royalJelly.getItemStack());
|
||||
|
||||
ForestryItem.waxCast.registerItem(new ItemWaxCast().setCreativeTab(Tabs.tabApiculture), "waxCast");
|
||||
|
||||
// / BEE COMBS
|
||||
ForestryItem.beeComb.registerItem(new ItemHoneycomb(), "beeCombs");
|
||||
OreDictionary.registerOre("beeComb", ForestryItem.beeComb.getWildcard());
|
||||
|
||||
// / APIARIST'S CLOTHES
|
||||
ForestryItem.apiaristHat.registerItem(new ItemArmorApiarist(0), "apiaristHelmet");
|
||||
ForestryItem.apiaristChest.registerItem(new ItemArmorApiarist(1), "apiaristChest");
|
||||
ForestryItem.apiaristLegs.registerItem(new ItemArmorApiarist(2), "apiaristLegs");
|
||||
ForestryItem.apiaristBoots.registerItem(new ItemArmorApiarist(3), "apiaristBoots");
|
||||
|
||||
// TOOLS
|
||||
ForestryItem.scoop.registerItem(new ItemScoop(), "scoop");
|
||||
ForestryItem.scoop.item().setHarvestLevel("scoop", 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerCrates() {
|
||||
ICrateRegistry crateRegistry = StorageManager.crateRegistry;
|
||||
@@ -662,8 +629,8 @@ public class PluginApiculture extends ForestryPlugin {
|
||||
}
|
||||
|
||||
// / CAPSULES
|
||||
RecipeUtil.addRecipe(GameMode.getGameMode().getStackSetting("recipe.output.capsule"), "###", '#', ForestryItem.beeswax);
|
||||
RecipeUtil.addRecipe(GameMode.getGameMode().getStackSetting("recipe.output.refractory"), "###", '#', ForestryItem.refractoryWax);
|
||||
RecipeUtil.addRecipe(ForestryAPI.activeMode.getStackSetting("recipe.output.capsule"), "###", '#', ForestryItem.beeswax);
|
||||
RecipeUtil.addRecipe(ForestryAPI.activeMode.getStackSetting("recipe.output.refractory"), "###", '#', ForestryItem.refractoryWax);
|
||||
|
||||
// / BITUMINOUS PEAT
|
||||
RecipeUtil.addRecipe(ForestryItem.bituminousPeat.getItemStack(),
|
||||
|
||||
Reference in new issue
Block a user