diff --git a/lang b/lang index ab16b1a2e..05bee96e8 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit ab16b1a2efc80aa48e70d81c8859fd83e143a98f +Subproject commit 05bee96e8aa617756ab7445cf32163a901c82028 diff --git a/src/main/java/forestry/Forestry.java b/src/main/java/forestry/Forestry.java index 9661e460e..9d42c573b 100755 --- a/src/main/java/forestry/Forestry.java +++ b/src/main/java/forestry/Forestry.java @@ -39,6 +39,9 @@ import forestry.core.utils.FluidMap; import forestry.core.utils.ItemStackMap; import forestry.core.utils.StringUtil; import java.io.File; +import java.util.HashMap; +import java.util.Map; + import net.minecraft.block.Block; import net.minecraft.item.Item; @@ -63,6 +66,22 @@ public class Forestry { public static Forestry instance; private File configFolder; + private static final Map mappedItems = new HashMap(); + + static { + mappedItems.put("Forestry:builderBackpack", ForestryItem.builderBackpack); + mappedItems.put("Forestry:builderBackpackT2", ForestryItem.builderBackpackT2); + mappedItems.put("Forestry:adventurerBackpack", ForestryItem.adventurerBackpack); + mappedItems.put("Forestry:adventurerBackpackT2", ForestryItem.adventurerBackpackT2); + mappedItems.put("Forestry:shortMead", ForestryItem.beverage); + mappedItems.put("Forestry:waterCan", ForestryItem.canWater); + mappedItems.put("Forestry:biofuelCan", ForestryItem.canEthanol); + mappedItems.put("Forestry:biomassCan", ForestryItem.canBiomass); + mappedItems.put("Forestry:bucketBiofuel", ForestryItem.bucketEthanol); + mappedItems.put("Forestry:refractoryBiofuel", ForestryItem.refractoryEthanol); + mappedItems.put("Forestry:waxCapsuleBiofuel", ForestryItem.waxCapsuleEthanol); + } + public Forestry() { FuelManager.fermenterFuel = new ItemStackMap(); FuelManager.moistenerResource = new ItemStackMap(); @@ -129,21 +148,12 @@ public class Forestry { if (block != null) { mapping.remap(Item.getItemFromBlock(block)); Proxies.log.warning("Remapping item " + mapping.name + " to " + StringUtil.cleanBlockName(block)); - } else if (mapping.name.equals("Forestry:builderBackpack")) { - mapping.remap(ForestryItem.builderBackpack.item()); - Proxies.log.warning("Remapping item " + mapping.name + " to " + ForestryItem.builderBackpack.name()); - } else if (mapping.name.equals("Forestry:builderBackpackT2")) { - mapping.remap(ForestryItem.builderBackpackT2.item()); - Proxies.log.warning("Remapping item " + mapping.name + " to " + ForestryItem.builderBackpackT2.name()); - } else if (mapping.name.equals("Forestry:adventurerBackpack")) { - mapping.remap(ForestryItem.adventurerBackpack.item()); - Proxies.log.warning("Remapping item " + mapping.name + " to " + ForestryItem.adventurerBackpack.name()); - } else if (mapping.name.equals("Forestry:adventurerBackpackT2")) { - mapping.remap(ForestryItem.adventurerBackpackT2.item()); - Proxies.log.warning("Remapping item " + mapping.name + " to " + ForestryItem.adventurerBackpackT2.name()); - } else if (mapping.name.equals("Forestry:shortMead")) { - mapping.remap(ForestryItem.beverage.item()); - Proxies.log.warning("Remapping item " + mapping.name + " to " + ForestryItem.beverage.name()); + } else { + ForestryItem mappedItem = mappedItems.get(mapping.name); + if (mappedItem != null) { + mapping.remap(mappedItem.item()); + Proxies.log.warning("Remapping item " + mapping.name + " to " + mappedItem.name()); + } } } } diff --git a/src/main/java/forestry/core/EventHandlerCore.java b/src/main/java/forestry/core/EventHandlerCore.java index dd5caadce..465fb4752 100755 --- a/src/main/java/forestry/core/EventHandlerCore.java +++ b/src/main/java/forestry/core/EventHandlerCore.java @@ -10,22 +10,25 @@ ******************************************************************************/ package forestry.core; +import net.minecraft.item.ItemStack; + +import net.minecraftforge.client.event.TextureStitchEvent; +import net.minecraftforge.event.entity.player.EntityItemPickupEvent; +import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.oredict.OreDictionary; + import cpw.mods.fml.common.eventhandler.Event.Result; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.core.ErrorStateRegistry; -import forestry.core.fluids.Fluids; +import forestry.core.fluids.ForestryFluids; import forestry.core.interfaces.IOreDictionaryHandler; import forestry.core.interfaces.IPickupHandler; import forestry.core.interfaces.ISaveEventHandler; import forestry.core.render.TextureManager; import forestry.plugins.PluginManager; -import net.minecraft.item.ItemStack; -import net.minecraftforge.client.event.TextureStitchEvent; -import net.minecraftforge.event.entity.player.EntityItemPickupEvent; -import net.minecraftforge.event.world.WorldEvent; -import net.minecraftforge.oredict.OreDictionary; public class EventHandlerCore { @@ -86,8 +89,9 @@ public class EventHandlerCore { if(event.map.getTextureType() == 1) { ErrorStateRegistry.initIcons(event.map); TextureManager.getInstance().initDefaultIcons(event.map); - } else if(event.map.getTextureType() == 0) - Fluids.resetFluidIcons(event.map); + } else if(event.map.getTextureType() == 0) { + ForestryFluids.resetFluidIcons(event.map); + } } @SubscribeEvent diff --git a/src/main/java/forestry/core/ForestryCore.java b/src/main/java/forestry/core/ForestryCore.java index 12da31df3..bec6868b0 100755 --- a/src/main/java/forestry/core/ForestryCore.java +++ b/src/main/java/forestry/core/ForestryCore.java @@ -11,10 +11,21 @@ package forestry.core; import com.google.common.collect.ImmutableList; + +import java.io.File; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.server.MinecraftServer; + +import net.minecraftforge.common.MinecraftForge; + import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.GameRegistry; + import forestry.api.apiculture.FlowerManager; import forestry.api.core.ForestryAPI; import forestry.api.fuels.EngineBronzeFuel; @@ -34,12 +45,6 @@ import forestry.core.gadgets.TileMill; import forestry.core.proxy.Proxies; import forestry.core.utils.LiquidHelper; import forestry.plugins.PluginManager; -import java.io.File; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.server.MinecraftServer; -import net.minecraftforge.common.MinecraftForge; public class ForestryCore { @@ -61,7 +66,6 @@ public class ForestryCore { public void init(Object basemod) { - // Register Liquids & Containers registerLiquidContainers(); // Register world generator @@ -123,7 +127,6 @@ public class ForestryCore { } public void postInit() { - PluginManager.runPostInit(); Proxies.common.registerTickHandlers(); @@ -144,61 +147,14 @@ public class ForestryCore { return "after:mod_IC2;after:mod_BuildCraftCore;after:mod_BuildCraftEnergy;after:mod_BuildCraftFactory;after:mod_BuildCraftSilicon;after:mod_BuildCraftTransport;after:mod_RedPowerWorld"; } + /** Set containers for vanilla liquids */ private void registerLiquidContainers() { - // Add lava and water buckets to the API in case this has not been done yet. - if (LiquidHelper.isEmptyLiquidData()) { - LiquidHelper.injectLiquidContainer(Fluids.LAVA, Defaults.BUCKET_VOLUME, new ItemStack(Items.lava_bucket), new ItemStack(Items.bucket)); - LiquidHelper.injectLiquidContainer(Fluids.WATER, Defaults.BUCKET_VOLUME, new ItemStack(Items.water_bucket), new ItemStack(Items.bucket)); - } - - // Glass - Fluids.GLASS.register(); - - // Set default lava, water and biofuel buckets - Fluids.MILK.register(); - LiquidHelper.injectLiquidContainer(Fluids.MILK, Defaults.BUCKET_VOLUME, new ItemStack(Items.milk_bucket), new ItemStack(Items.bucket)); - - // Lava - LiquidHelper.injectTinContainer(Fluids.LAVA, Defaults.BUCKET_VOLUME, ForestryItem.canLava.getItemStack(), ForestryItem.canEmpty.getItemStack()); - LiquidHelper.injectRefractoryContainer(Fluids.LAVA, Defaults.BUCKET_VOLUME, ForestryItem.refractoryLava.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); - - // Water - LiquidHelper.injectLiquidContainer(Fluids.WATER, Defaults.BUCKET_VOLUME, new ItemStack(Items.potionitem, 1, 0), new ItemStack(Items.glass_bottle)); - LiquidHelper.injectTinContainer(Fluids.WATER, Defaults.BUCKET_VOLUME, ForestryItem.canWater.getItemStack(), ForestryItem.canEmpty.getItemStack()); - LiquidHelper.injectWaxContainer(Fluids.WATER, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleWater.getItemStack(), ForestryItem.waxCapsule.getItemStack()); - LiquidHelper.injectRefractoryContainer(Fluids.WATER, Defaults.BUCKET_VOLUME, ForestryItem.refractoryWater.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); - - Fluids.BIOMASS.register(); - LiquidHelper.injectLiquidContainer(Fluids.BIOMASS, Defaults.BUCKET_VOLUME, ForestryItem.bucketBiomass.getItemStack(), new ItemStack(Items.bucket)); - LiquidHelper.injectTinContainer(Fluids.BIOMASS, Defaults.BUCKET_VOLUME, ForestryItem.canBiomass.getItemStack(), ForestryItem.canEmpty.getItemStack()); - LiquidHelper.injectWaxContainer(Fluids.BIOMASS, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleBiomass.getItemStack(), ForestryItem.waxCapsule.getItemStack()); - LiquidHelper.injectRefractoryContainer(Fluids.BIOMASS, Defaults.BUCKET_VOLUME, ForestryItem.refractoryBiomass.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); - - Fluids.BIOETHANOL.register(); - LiquidHelper.injectLiquidContainer(Fluids.BIOETHANOL, Defaults.BUCKET_VOLUME, ForestryItem.bucketBiofuel.getItemStack(), new ItemStack(Items.bucket)); - LiquidHelper.injectTinContainer(Fluids.BIOETHANOL, Defaults.BUCKET_VOLUME, ForestryItem.canBiofuel.getItemStack(), ForestryItem.canEmpty.getItemStack()); - LiquidHelper.injectWaxContainer(Fluids.BIOETHANOL, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleBiofuel.getItemStack(), ForestryItem.waxCapsule.getItemStack()); - LiquidHelper.injectRefractoryContainer(Fluids.BIOETHANOL, Defaults.BUCKET_VOLUME, ForestryItem.refractoryBiofuel.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); - - Fluids.SEEDOIL.register(); - LiquidHelper.injectTinContainer(Fluids.SEEDOIL, Defaults.BUCKET_VOLUME, ForestryItem.canSeedOil.getItemStack(), ForestryItem.canEmpty.getItemStack()); - LiquidHelper.injectWaxContainer(Fluids.SEEDOIL, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleSeedOil.getItemStack(), ForestryItem.waxCapsule.getItemStack()); - LiquidHelper.injectRefractoryContainer(Fluids.SEEDOIL, Defaults.BUCKET_VOLUME, ForestryItem.refractorySeedOil.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); - - Fluids.HONEY.register(); - LiquidHelper.injectTinContainer(Fluids.HONEY, Defaults.BUCKET_VOLUME, ForestryItem.canHoney.getItemStack(), ForestryItem.canEmpty.getItemStack()); - LiquidHelper.injectWaxContainer(Fluids.HONEY, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleHoney.getItemStack(), ForestryItem.waxCapsule.getItemStack()); - LiquidHelper.injectRefractoryContainer(Fluids.HONEY, Defaults.BUCKET_VOLUME, ForestryItem.refractoryHoney.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); - - Fluids.JUICE.register(); - LiquidHelper.injectTinContainer(Fluids.JUICE, Defaults.BUCKET_VOLUME, ForestryItem.canJuice.getItemStack(), ForestryItem.canEmpty.getItemStack()); - LiquidHelper.injectWaxContainer(Fluids.JUICE, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleJuice.getItemStack(), ForestryItem.waxCapsule.getItemStack()); - LiquidHelper.injectRefractoryContainer(Fluids.JUICE, Defaults.BUCKET_VOLUME, ForestryItem.refractoryJuice.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); - - Fluids.ICE.register(); - LiquidHelper.injectTinContainer(Fluids.ICE, Defaults.BUCKET_VOLUME, ForestryItem.canIce.getItemStack(), ForestryItem.canEmpty.getItemStack()); - LiquidHelper.injectWaxContainer(Fluids.ICE, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleIce.getItemStack(), ForestryItem.waxCapsule.getItemStack()); - LiquidHelper.injectRefractoryContainer(Fluids.ICE, Defaults.BUCKET_VOLUME, ForestryItem.refractoryIce.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); + LiquidHelper.injectLiquidContainer(Fluids.LAVA, ForestryItem.canLava.getItemStack()); + LiquidHelper.injectLiquidContainer(Fluids.LAVA, ForestryItem.refractoryLava.getItemStack()); + LiquidHelper.injectLiquidContainer(Fluids.WATER, Defaults.BUCKET_VOLUME, new ItemStack(Items.potionitem), new ItemStack(Items.glass_bottle)); + LiquidHelper.injectLiquidContainer(Fluids.WATER, ForestryItem.canWater.getItemStack()); + LiquidHelper.injectLiquidContainer(Fluids.WATER, ForestryItem.waxCapsuleWater.getItemStack()); + LiquidHelper.injectLiquidContainer(Fluids.WATER, ForestryItem.refractoryWater.getItemStack()); } } diff --git a/src/main/java/forestry/core/config/Config.java b/src/main/java/forestry/core/config/Config.java index b022d4804..e66da0a98 100755 --- a/src/main/java/forestry/core/config/Config.java +++ b/src/main/java/forestry/core/config/Config.java @@ -19,20 +19,26 @@ import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Locale; +import java.util.Map; import java.util.Properties; +import java.util.Set; +import forestry.core.fluids.ForestryFluids; import forestry.core.proxy.Proxies; public class Config { public static final String CATEGORY_COMMON = "common"; + public static final String CATEGORY_FLUIDS = "fluids"; public static final String CATEGORY_DEBUG = "debug"; public static Configuration config; public static String gameMode; - public static final HashSet disabledStructures = new HashSet(); + private static final Set disabledStructures = new HashSet(); + private static final Set disabledFluids = new HashSet(); + private static final Set disabledBlocks = new HashSet(); public static boolean isDebug = false; @@ -65,10 +71,6 @@ public class Config { private static boolean craftingBronzeEnabled = true; - public static boolean getCraftingBronzeEnabled() { - return craftingBronzeEnabled; - } - public static boolean craftingStampsEnabled = true; public static final ArrayList collectorStamps = new ArrayList(); @@ -82,6 +84,22 @@ public class Config { public static final HashMap hints = new HashMap(); public static boolean disableEnergyStat = false; + public static boolean isStructureEnabled(String uid) { + return !Config.disabledStructures.contains(uid); + } + + public static boolean isFluidEnabled(ForestryFluids fluids) { + return !Config.disabledFluids.contains(fluids.tag); + } + + public static boolean isBlockEnabled(String tag) { + return !Config.disabledBlocks.contains(tag); + } + + public static boolean isCraftingBronzeEnabled() { + return craftingBronzeEnabled; + } + public static void load() { setDebugMode(); @@ -96,35 +114,10 @@ public class Config { config.addPurge("buildcraft.ignore"); config.addPurge("power.framework"); - Property property = config.get("difficulty.gamemode", CATEGORY_COMMON, "EASY"); - property.comment = "set to your preferred game mode. available modes are OP, EASY, NORMAL, HARD. mismatch with the server may cause visual glitches with recipes. setting an unavailable mode will create a new mode definition file."; - gameMode = property.value; + loadModes(); + loadFluids(); - property = config.get("difficulty.recreate.definitions", CATEGORY_COMMON, true); - property.comment = "set to true to force recreation of the game mode definitions in config/forestry/gamemodes"; - boolean recreate = Boolean.parseBoolean(property.value); - - if (recreate) - Proxies.log.info("Recreating all gamemode definitions from the defaults. This may be caused by an upgrade"); - - // Make sure the default mode files are there. - File easyMode = config.getCategoryFile("gamemodes/EASY"); - if (recreate) - CopyFileToFS(easyMode, "/config/forestry/gamemodes/EASY.conf"); - - File opMode = config.getCategoryFile("gamemodes/OP"); - if (!opMode.exists() || recreate) - CopyFileToFS(opMode, "/config/forestry/gamemodes/OP.conf"); - - File normalMode = config.getCategoryFile("gamemodes/NORMAL"); - if (!normalMode.exists() || recreate) - CopyFileToFS(normalMode, "/config/forestry/gamemodes/NORMAL.conf"); - - File hardMode = config.getCategoryFile("gamemodes/HARD"); - if (!hardMode.exists() || recreate) - CopyFileToFS(hardMode, "/config/forestry/gamemodes/HARD.conf"); - - config.set("difficulty.recreate.definitions", CATEGORY_COMMON, false); + Property property; Property particleFX = config.get("performance.particleFX.enabled", CATEGORY_COMMON, true); particleFX.comment = "set to false to disable particle fx on slower machines"; @@ -217,6 +210,53 @@ public class Config { loadHints(); } + private static void loadModes() { + Property property = config.get("difficulty.gamemode", CATEGORY_COMMON, "EASY"); + property.comment = "set to your preferred game mode. available modes are OP, EASY, NORMAL, HARD. mismatch with the server may cause visual glitches with recipes. setting an unavailable mode will create a new mode definition file."; + gameMode = property.value; + + property = config.get("difficulty.recreate.definitions", CATEGORY_COMMON, true); + property.comment = "set to true to force recreation of the game mode definitions in config/forestry/gamemodes"; + boolean recreate = Boolean.parseBoolean(property.value); + + if (recreate) + Proxies.log.info("Recreating all gamemode definitions from the defaults. This may be caused by an upgrade"); + + // Make sure the default mode files are there. + File easyMode = config.getCategoryFile("gamemodes/EASY"); + if (recreate) + CopyFileToFS(easyMode, "/config/forestry/gamemodes/EASY.conf"); + + File opMode = config.getCategoryFile("gamemodes/OP"); + if (!opMode.exists() || recreate) + CopyFileToFS(opMode, "/config/forestry/gamemodes/OP.conf"); + + File normalMode = config.getCategoryFile("gamemodes/NORMAL"); + if (!normalMode.exists() || recreate) + CopyFileToFS(normalMode, "/config/forestry/gamemodes/NORMAL.conf"); + + File hardMode = config.getCategoryFile("gamemodes/HARD"); + if (!hardMode.exists() || recreate) + CopyFileToFS(hardMode, "/config/forestry/gamemodes/HARD.conf"); + + config.set("difficulty.recreate.definitions", CATEGORY_COMMON, false); + } + + private static void loadFluids() { + Property property; + for (ForestryFluids fluid : ForestryFluids.values()) { + property = config.get("disable.fluid." + fluid.tag, CATEGORY_FLUIDS, false); + property.comment = "set to true to disable the fluid for " + fluid.tag; + if (Boolean.parseBoolean(property.value)) + Config.disabledFluids.add(fluid.tag); + + property = config.get("disable.fluidBlock." + fluid.tag, CATEGORY_FLUIDS, false); + property.comment = "set to true to disable the in-world FluidBlock for " + fluid.tag; + if (Boolean.parseBoolean(property.value)) + Config.disabledBlocks.add(fluid.tag); + } + } + private static void setDebugMode() { File debug = new File(Proxies.common.getForestryRoot(), "config/" + Defaults.MOD.toLowerCase(Locale.ENGLISH) + "/DEBUG.ON"); isDebug = debug.exists(); @@ -279,9 +319,4 @@ public class Config { else return list.split("[;]+"); } - - public static boolean getOrCreateBooleanProperty(String key, String kind, boolean defaults) { - return Boolean.parseBoolean(config.get(key, kind, defaults).value); - } - } diff --git a/src/main/java/forestry/core/config/Configuration.java b/src/main/java/forestry/core/config/Configuration.java index e9e6269e3..40d60d5b1 100755 --- a/src/main/java/forestry/core/config/Configuration.java +++ b/src/main/java/forestry/core/config/Configuration.java @@ -237,8 +237,8 @@ public class Configuration { writer.write("# " + Defaults.MOD + newLine + "# " + Version.getVersion() + newLine); writer.write("#" + newLine + "# Config files:" + newLine); - writer.write("# base.conf\t\t-\t Contains Forge configuration for block and item ids" + newLine); writer.write("# common.conf\t\t-\t Contains all options common to Forestry" + newLine); + writer.write("# fluids.conf\t\t-\t Contains all options for fluids" + newLine); writer.write("# apiculture.conf\t-\t Contains all options for bee breeding" + newLine); writer.write("# backpacks.conf\t-\t Contains custom configurations for backpacks" + newLine); writer.write("# pipes.conf\t\t-\t Configures item id for the apiarist's pipe" + newLine); diff --git a/src/main/java/forestry/core/config/ForestryItem.java b/src/main/java/forestry/core/config/ForestryItem.java index 46465d42c..4e839aae8 100755 --- a/src/main/java/forestry/core/config/ForestryItem.java +++ b/src/main/java/forestry/core/config/ForestryItem.java @@ -10,10 +10,16 @@ ******************************************************************************/ package forestry.core.config; +import forestry.core.fluids.ForestryFluids; +import forestry.core.items.ItemLiquidContainer; import forestry.core.proxy.Proxies; import forestry.plugins.PluginManager; import forestry.plugins.PluginManager.Stage; + +import java.awt.Color; import java.util.EnumSet; + +import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; @@ -42,7 +48,13 @@ public enum ForestryItem { wrench, pipette, bucketBiomass, - bucketBiofuel, + bucketEthanol, + bucketGlass, + bucketHoney, + bucketIce, + bucketJuice, + bucketSeedoil, + bucketShortMead, // Crafting impregnatedCasing, sturdyCasing, @@ -156,7 +168,7 @@ public enum ForestryItem { waxCapsule, waxCapsuleWater, waxCapsuleBiomass, - waxCapsuleBiofuel, + waxCapsuleEthanol, waxCapsuleOil, waxCapsuleFuel, waxCapsuleSeedOil, @@ -167,7 +179,7 @@ public enum ForestryItem { refractoryEmpty, refractoryWater, refractoryBiomass, - refractoryBiofuel, + refractoryEthanol, refractoryOil, refractoryFuel, refractoryLava, @@ -179,7 +191,7 @@ public enum ForestryItem { canWater, canEmpty, canBiomass, - canBiofuel, + canEthanol, canOil, canFuel, canLava, @@ -283,4 +295,18 @@ public enum ForestryItem { return null; return new ItemStack(item, qty, meta); } + + public void registerContainer(ItemLiquidContainer.EnumContainerType type, ForestryFluids fluid, int healAmount, float saturationModifier) { + ItemLiquidContainer liquidContainer = new ItemLiquidContainer(type, fluid.getBlock(), fluid.getColor()); + liquidContainer.setDrink(healAmount, saturationModifier); + registerItem(liquidContainer, toString()); + } + + public void registerContainer(ItemLiquidContainer.EnumContainerType type, ForestryFluids fluid) { + registerItem(new ItemLiquidContainer(type, fluid.getBlock(), fluid.getColor()), toString()); + } + + public void registerContainer(ItemLiquidContainer.EnumContainerType type, Block block, Color color) { + registerItem(new ItemLiquidContainer(type, block, color), toString()); + } } diff --git a/src/main/java/forestry/core/fluids/BlockForestryFluid.java b/src/main/java/forestry/core/fluids/BlockForestryFluid.java new file mode 100644 index 000000000..794459ff3 --- /dev/null +++ b/src/main/java/forestry/core/fluids/BlockForestryFluid.java @@ -0,0 +1,250 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.fluids; + +import java.awt.Color; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.Minecraft; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.init.Blocks; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.BlockFluidClassic; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; + +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.config.Defaults; +import forestry.core.render.EntityColoredDropParticleFX; +import forestry.core.render.TextureManager; + +public class BlockForestryFluid extends BlockFluidClassic { + + private final boolean flammable; + private final int flammability; + private final Color color; + + @SideOnly(Side.CLIENT) + private List icons; + + public BlockForestryFluid(ForestryFluids forestryFluid) { + this(forestryFluid, 0, false); + } + + public BlockForestryFluid(ForestryFluids forestryFluid, int flammability, boolean flammable) { + this(forestryFluid.standardFluid.get(), flammability, flammable, forestryFluid.getColor()); + } + + private BlockForestryFluid(Fluid fluid, int flammability, boolean flammable, Color color) { + super(fluid, Material.water); + + setDensity(fluid.getDensity()); + + this.flammability = flammability; + this.flammable = flammable; + + this.color = color; + } + + @Override + public boolean canDrain(World world, int x, int y, int z) { + return true; + } + + @Override + public Fluid getFluid() { + return FluidRegistry.getFluid(fluidName); + } + + @Override + public IIcon getIcon(int side, int meta) { + if (side == 0 || side == 1 || this.icons.size() == 1) { + return this.icons.get(0); + } else { + return this.icons.get(1); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + + this.icons = new ArrayList(2); + + String still = "liquid/" + fluidName + "_still"; + this.icons.add(TextureManager.getInstance().registerTex(iconRegister, still)); + + if(flowTextureExists()) { + String flow = "liquid/" + fluidName + "_flow"; + this.icons.add(TextureManager.getInstance().registerTex(iconRegister, flow)); + } + } + + @SideOnly(Side.CLIENT) + public boolean flowTextureExists() { + try { + ResourceLocation resourceLocation = new ResourceLocation(Defaults.ID, "textures/blocks/liquid/" + fluidName + "_flow.png"); + IResourceManager resourceManager = Minecraft.getMinecraft().getResourceManager(); + return resourceManager.getResource(resourceLocation) != null; + } catch (java.lang.Exception e) { + return false; + } + } + + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World world, int x, int y, int z, Random rand) { + if (rand.nextInt(10) == 0 && World.doesBlockHaveSolidTopSurface(world, x, y - 1, z) && !world.getBlock(x, y - 2, z).getMaterial().blocksMovement()) { + double px = (double) ((float) x + rand.nextFloat()); + double py = (double) y - 1.05D; + double pz = (double) ((float) z + rand.nextFloat()); + + EntityFX fx = new EntityColoredDropParticleFX(world, px, py, pz, color.getRed(), color.getGreen(), color.getBlue()); + FMLClientHandler.instance().getClient().effectRenderer.addEffect(fx); + } + } + + @Override + public boolean canDisplace(IBlockAccess world, int x, int y, int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) { + return false; + } + return super.canDisplace(world, x, y, z); + } + + @Override + public boolean displaceIfPossible(World world, int x, int y, int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) { + return false; + } + return super.displaceIfPossible(world, x, y, z); + } + + @Override + public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + return flammable ? 30 : 0; + } + + @Override + public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + return flammability; + } + + public boolean isFlammable(IBlockAccess world, int x, int y, int z) { + return flammable; + } + + @Override + public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + return flammable; + } + + @Override + public boolean isFireSource(World world, int x, int y, int z, ForgeDirection side) { + return flammable && flammability == 0; + } + + public Color getColor() { + return color; + } + + @Override + public Material getMaterial() { + // Fahrenheit 451 = 505.928 Kelvin + // The temperature at which book-paper catches fire, and burns. + if (temperature > 505) + return Material.lava; + else + return super.getMaterial(); + } + + @Override + public void updateTick(World world, int x, int y, int z, Random rand) { + super.updateTick(world, x, y, z, rand); + + // Start fires if the fluid is lava-like + if (getMaterial() == Material.lava) { + int rangeUp = rand.nextInt(3); + + for (int i = 0; i < rangeUp; ++i) { + x += rand.nextInt(3) - 1; + ++y; + z += rand.nextInt(3) - 1; + Block block = world.getBlock(x, y, z); + + if (block.getMaterial() == Material.air) { + if (isNeighborFlammable(world, x, y, z)) { + world.setBlock(x, y, z, Blocks.fire); + return; + } + } else if (block.getMaterial().blocksMovement()) { + return; + } + } + + if (rangeUp == 0) { + int startX = x; + int startZ = z; + + for (int i = 0; i < 3; ++i) { + x = startX + rand.nextInt(3) - 1; + z = startZ + rand.nextInt(3) - 1; + + if (world.isAirBlock(x, y + 1, z) && this.isFlammable(world, x, y, z)) { + world.setBlock(x, y + 1, z, Blocks.fire); + } + } + } + } + + // explode if very flammable and near fire + int flammability = getFlammability(world, x, y, z, ForgeDirection.UNKNOWN); + if (flammability > 0) { + // Explosion size is determined by flammability, up to size 4. + float explosionSize = 4F * flammability / 300F; + if (explosionSize > 1.0 && isNearFire(world, x, y, z)) { + world.setBlock(x, y, z, Blocks.fire); + world.newExplosion(null, x, y, z, explosionSize, true, true); + } + } + } + + private boolean isNeighborFlammable(World world, int x, int y, int z) { + return isFlammable(world, x - 1, y, z) || + isFlammable(world, x + 1, y, z) || + isFlammable(world, x, y, z - 1) || + isFlammable(world, x, y, z + 1) || + isFlammable(world, x, y - 1, z) || + isFlammable(world, x, y + 1, z); + } + + private boolean isNearFire(World world, int x, int y, int z) { + AxisAlignedBB boundingBox = AxisAlignedBB.getBoundingBox(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1); + return world.func_147470_e(boundingBox); + } +} diff --git a/src/main/java/forestry/core/fluids/Fluids.java b/src/main/java/forestry/core/fluids/Fluids.java index 12040b03a..dcf17563a 100644 --- a/src/main/java/forestry/core/fluids/Fluids.java +++ b/src/main/java/forestry/core/fluids/Fluids.java @@ -10,13 +10,10 @@ ******************************************************************************/ package forestry.core.fluids; -import forestry.core.render.TextureManager; -import java.util.ArrayList; -import java.util.List; import java.util.Locale; -import net.minecraft.client.renderer.texture.IIconRegister; + import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; + import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; @@ -28,9 +25,7 @@ import net.minecraftforge.fluids.FluidStack; public enum Fluids { WATER, LAVA, FUEL, BIOMASS, BIOFUEL, CREOSOTE, STEAM, BIOETHANOL, - COAL, PYROTHEUM, HONEY, MILK, JUICE, ICE, GLASS, OIL, SEEDOIL, SHORT_MEAD("short.mead"); - - private static final List myLiquids = new ArrayList(values().length); + COAL, PYROTHEUM, HONEY("for.honey"), MILK, JUICE, ICE, GLASS, OIL, SEEDOIL, SHORT_MEAD("short.mead"); private final String tag; @@ -50,15 +45,6 @@ public enum Fluids { return FluidRegistry.getFluid(tag); } - public void register() { - Fluid fluid = get(); - if (fluid == null) { - fluid = new Fluid(tag); - FluidRegistry.registerFluid(fluid); - myLiquids.add(tag); - } - } - /** * Gets a FluidStack filled with mb milliBuckets worth of Fluid. */ @@ -84,12 +70,5 @@ public enum Fluids { return fluid == null && fluidStack == null; } - public static void resetFluidIcons(IIconRegister register) { - for (String fluidString : myLiquids) { - Fluid fluid = FluidRegistry.getFluid(fluidString); - IIcon icon = TextureManager.getInstance().registerTex(register, "liquid/" + fluid.getName()); - fluid.setIcons(icon); - } - } } diff --git a/src/main/java/forestry/core/fluids/ForestryFluids.java b/src/main/java/forestry/core/fluids/ForestryFluids.java new file mode 100644 index 000000000..aa0c0d31e --- /dev/null +++ b/src/main/java/forestry/core/fluids/ForestryFluids.java @@ -0,0 +1,317 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.fluids; + +import java.awt.Color; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; + +import net.minecraftforge.client.event.TextureStitchEvent; +import net.minecraftforge.event.entity.player.FillBucketEvent; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; + +import cpw.mods.fml.common.eventhandler.Event; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.config.Config; +import forestry.core.config.ForestryItem; +import forestry.core.items.ItemLiquidContainer; +import forestry.core.proxy.Proxies; +import forestry.core.utils.LiquidHelper; + +public enum ForestryFluids { + + ETHANOL(Fluids.BIOETHANOL, new Color(255, 111, 0), 790, 1000) { + @Override + public Block makeBlock() { + return new BlockForestryFluid(this, 300, true); + } + @Override + List getFilledContainers() { + return Arrays.asList( + ForestryItem.bucketEthanol.getItemStack(), + ForestryItem.canEthanol.getItemStack(), + ForestryItem.waxCapsuleEthanol.getItemStack(), + ForestryItem.refractoryEthanol.getItemStack() + ); + } + }, + BIOMASS(Fluids.BIOMASS, new Color(100, 132, 41), 400, 6560) { + @Override + public Block makeBlock() { + return new BlockForestryFluid(this, 100, true); + } + @Override + List getFilledContainers() { + return Arrays.asList( + ForestryItem.bucketBiomass.getItemStack(), + ForestryItem.canBiomass.getItemStack(), + ForestryItem.waxCapsuleBiomass.getItemStack(), + ForestryItem.refractoryBiomass.getItemStack() + ); + } + }, + LIQUID_GLASS(Fluids.GLASS, new Color(164, 164, 164), 2400, 10000, 1200) { + @Override + public Block makeBlock() { + return new BlockForestryFluid(this, 0, true); + } + @Override + List getFilledContainers() { + return Arrays.asList( + ForestryItem.bucketGlass.getItemStack() + ); + } + }, + HONEY(Fluids.HONEY, new Color(255, 173, 31), 1420, 73600) { + @Override + public Block makeBlock() { + return new BlockForestryFluid(this); + } + @Override + List getFilledContainers() { + return Arrays.asList( + ForestryItem.bucketHoney.getItemStack(), + ForestryItem.canHoney.getItemStack(), + ForestryItem.waxCapsuleHoney.getItemStack(), + ForestryItem.refractoryHoney.getItemStack() + ); + } + }, + ICE(Fluids.ICE, new Color(175, 242, 255), 920, 1000, 265) { + @Override + public Block makeBlock() { + return new BlockForestryFluid(this); + } + @Override + List getFilledContainers() { + return Arrays.asList( + ForestryItem.bucketIce.getItemStack(), + ForestryItem.canIce.getItemStack(), + ForestryItem.waxCapsuleIce.getItemStack(), + ForestryItem.refractoryIce.getItemStack() + ); + } + }, + JUICE(Fluids.JUICE, new Color(168, 201, 114), 1000, 1000) { + @Override + public Block makeBlock() { + return new BlockForestryFluid(this); + } + @Override + List getFilledContainers() { + return Arrays.asList( + ForestryItem.bucketJuice.getItemStack(), + ForestryItem.canJuice.getItemStack(), + ForestryItem.waxCapsuleJuice.getItemStack(), + ForestryItem.refractoryJuice.getItemStack() + ); + } + }, + MILK(Fluids.MILK, new Color(255, 255, 255), 1030, 3000) { + @Override + public Block makeBlock() { + return new BlockForestryFluid(this); + } + @Override + List getFilledContainers() { + return Arrays.asList( + new ItemStack(Items.milk_bucket) + ); + } + }, + SEEDOIL(Fluids.SEEDOIL, new Color(255, 255, 168), 885, 5000) { + @Override + public Block makeBlock() { + return new BlockForestryFluid(this, 2, true); + } + @Override + List getFilledContainers() { + return Arrays.asList( + ForestryItem.bucketSeedoil.getItemStack(), + ForestryItem.canSeedOil.getItemStack(), + ForestryItem.waxCapsuleSeedOil.getItemStack(), + ForestryItem.refractorySeedOil.getItemStack() + ); + } + }, + SHORT_MEAD(Fluids.SHORT_MEAD, new Color(239, 153, 0), 1000, 1200) { + @Override + public Block makeBlock() { + return new BlockForestryFluid(this); + } + @Override + List getFilledContainers() { + return Arrays.asList( + ForestryItem.bucketShortMead.getItemStack() + ); + } + }; + + public static final ForestryFluids[] VALUES = values(); + public final String tag; + public final Fluids standardFluid; + public final int density, viscosity, temperature; + private final Color color; + protected Fluid fluid; + protected Block fluidBlock; + + private ForestryFluids(Fluids standardFluid, Color color, int density, int viscosity) { + this(standardFluid, color, density, viscosity, 295); + } + + private ForestryFluids(Fluids standardFluid, Color color, int density, int viscosity, int temperature) { + this.tag = "fluid." + standardFluid.getTag(); + this.standardFluid = standardFluid; + this.color = color; + this.density = density; + this.viscosity = viscosity; + this.temperature = temperature; + } + + private void initFluid() { + if (fluid == null && Config.isFluidEnabled(this)) { + fluid = new Fluid(standardFluid.getTag()).setDensity(density).setViscosity(viscosity).setTemperature(temperature); + FluidRegistry.registerFluid(fluid); + initBlock(); + } + } + + List getFilledContainers() { + return Collections.emptyList(); + } + + abstract Block makeBlock(); + + private void initBlock() { + if (fluidBlock != null) + return; + + Fluid fluid = standardFluid.get(); + if (fluid == null) + return; + + fluidBlock = fluid.getBlock(); + + if (Config.isBlockEnabled(tag)) + if (fluidBlock == null) { + fluidBlock = makeBlock(); + fluidBlock.setBlockName("forestry." + tag); + Proxies.common.registerBlock(fluidBlock, ItemBlock.class); + } else { + GameRegistry.UniqueIdentifier blockID = GameRegistry.findUniqueIdentifierFor(fluidBlock); + Proxies.log.severe("Pre-existing {0} fluid block detected, deferring to {1}:{2}, " + + "this may cause issues if the server/client have different mod load orders, " + + "recommended that you disable all but one instance of {0} fluid blocks via your configs.", fluid.getName(), blockID.modId, blockID.name); + } + } + + public static void resetFluidIcons(IIconRegister register) { + for (ForestryFluids fluid : VALUES) { + fluid.getBlock().registerBlockIcons(register); + } + } + + public Block getBlock() { + return fluidBlock; + } + + public Color getColor() { + return color; + } + + public static class MissingFluidException extends RuntimeException { + + public MissingFluidException(String tag) { + super("Fluid '" + tag + "' was not found. Please check your configs."); + } + + } + + public static void preInit() { + for (ForestryFluids fluidType : VALUES) { + fluidType.initFluid(); + } + } + + public static void init() { + for (ForestryFluids fluidType : VALUES) { + if (fluidType.standardFluid.get() == null) + continue; + + for (ItemStack filledContainer : fluidType.getFilledContainers()) { + LiquidHelper.injectLiquidContainer(fluidType.standardFluid, filledContainer); + } + } + } + + public static void postInit() { + for (ForestryFluids fluidType : VALUES) { + fluidType.initBlock(); + if (fluidType.standardFluid.get() == null) + throw new MissingFluidException(fluidType.standardFluid.getTag()); + } + } + + public static class TextureHook { + + @SubscribeEvent + @SideOnly(Side.CLIENT) + public void textureHook(TextureStitchEvent.Post event) { + if (event.map.getTextureType() == 0) { + for (ForestryFluids fluidType : VALUES) { + if (fluidType.fluid != null) + fluidType.fluid.setIcons(fluidType.fluidBlock.getBlockTextureFromSide(1), fluidType.fluidBlock.getBlockTextureFromSide(2)); + } + } + } + + } + + public static Object getTextureHook() { + return new TextureHook(); + } + + public static class FillBucketHook { + @SubscribeEvent + public void fillBucket(FillBucketEvent event) { + MovingObjectPosition movingObjectPosition = event.target; + int x = movingObjectPosition.blockX; + int y = movingObjectPosition.blockY; + int z = movingObjectPosition.blockZ; + Block targetedBlock = event.world.getBlock(x, y, z); + if (targetedBlock instanceof BlockForestryFluid) { + Item filledBucket = ItemLiquidContainer.getExistingBucket(targetedBlock); + if (filledBucket != null) { + event.result = new ItemStack(filledBucket); + event.setResult(Event.Result.ALLOW); + } + } + } + } + + public static Object getFillBucketHook() { + return new FillBucketHook(); + } +} \ No newline at end of file diff --git a/src/main/java/forestry/core/items/ItemLiquidContainer.java b/src/main/java/forestry/core/items/ItemLiquidContainer.java index 0b2056840..9007cb4e0 100755 --- a/src/main/java/forestry/core/items/ItemLiquidContainer.java +++ b/src/main/java/forestry/core/items/ItemLiquidContainer.java @@ -10,17 +10,18 @@ ******************************************************************************/ package forestry.core.items; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.core.CreativeTabForestry; -import forestry.core.fluids.FluidHelper; -import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; +import java.awt.Color; +import java.util.HashMap; import java.util.Locale; +import java.util.Map; +import java.util.Random; + import net.minecraft.block.Block; +import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; +import net.minecraft.init.Items; import net.minecraft.item.EnumAction; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -28,17 +29,29 @@ import net.minecraft.util.IIcon; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition.MovingObjectType; import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidBlock; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.CreativeTabForestry; +import forestry.core.fluids.BlockForestryFluid; +import forestry.core.fluids.FluidHelper; +import forestry.core.proxy.Proxies; +import forestry.core.render.TextureManager; + public class ItemLiquidContainer extends Item { public static enum EnumContainerType { - - GLASS, JAR, CAN, CAPSULE, REFRACTORY + GLASS, JAR, CAN, CAPSULE, REFRACTORY, BUCKET } + private static final Map buckets = new HashMap(); + private boolean isDrink = false; private boolean isAlwaysEdible = false; @@ -46,14 +59,25 @@ public class ItemLiquidContainer extends Item { private float saturationModifier = 0.0f; private final EnumContainerType type; - private final int colour; + private final Block contents; + private final Color color; - public ItemLiquidContainer(EnumContainerType type, int colour) { + public ItemLiquidContainer(EnumContainerType type, Block contents, Color color) { super(); this.type = type; - this.colour = colour; + this.contents = contents; + this.color = color; setCreativeTab(CreativeTabForestry.tabForestry); setMaxStackSize(16); + if (type == EnumContainerType.BUCKET) { + setContainerItem(Items.bucket); + this.maxStackSize = 1; + buckets.put(contents, this); + } + } + + public static ItemLiquidContainer getExistingBucket(Block contents) { + return buckets.get(contents); } private int getMatchingSlot(EntityPlayer player, ItemStack stack) { @@ -141,8 +165,8 @@ public class ItemLiquidContainer extends Item { } } - if (fluid == null || fluid.amount <= 0) - return itemstack; + if (fluid == null || fluid.amount <= 0 && this.type == EnumContainerType.BUCKET) + return tryPlaceLiquid(itemstack, world, entityplayer, movingobjectposition); ItemStack filledContainer = FluidHelper.getFilledContainer(fluid.getFluid(), itemstack); if (filledContainer == null) @@ -179,6 +203,81 @@ public class ItemLiquidContainer extends Item { } + private ItemStack tryPlaceLiquid(ItemStack itemstack, World world, EntityPlayer player, MovingObjectPosition movingobjectposition) { + + if (this.type != EnumContainerType.BUCKET) { + return itemstack; + } + + if (this.contents == Blocks.air) { + return new ItemStack(Items.bucket); + } + + int x = movingobjectposition.blockX; + int y = movingobjectposition.blockY; + int z = movingobjectposition.blockZ; + + switch (movingobjectposition.sideHit) { + case 0: --y; break; + case 1: ++y; break; + case 2: --z; break; + case 3: ++z; break; + case 4: --x; break; + case 5: ++x; break; + } + + if (!player.canPlayerEdit(x, y, z, movingobjectposition.sideHit, itemstack)) { + return itemstack; + } + + if (this.tryPlaceLiquidAtPosition(world, x, y, z) && !player.capabilities.isCreativeMode) { + return new ItemStack(Items.bucket); + } + + return itemstack; + } + + private boolean tryPlaceLiquidAtPosition(World world, int x, int y, int z) { + if (this.contents == Blocks.air) { + return false; + } else { + Material material = world.getBlock(x, y, z).getMaterial(); + boolean isLiquid = !material.isSolid(); + + if (!world.isAirBlock(x, y, z) && !isLiquid) { + return false; + } else { + // Can't put down liquids in the nether. + // Explode if it's flammable, evaporate otherwise. + if (world.provider.isHellWorld && this.contents != Blocks.flowing_lava) { + int flammability = contents.getFlammability(world, x, y, z, ForgeDirection.UNKNOWN); + if (contents instanceof BlockForestryFluid && flammability > 0) { + // Explosion size is determined by flammability, up to size 4. + float explosionSize = 4F * flammability / 300F; + world.newExplosion(null, x, y, z, explosionSize, true, true); + return true; + } else { + Random random = world.rand; + world.playSoundEffect(x + 0.5, y + 0.5F, z + 0.5F, "random.fizz", 0.5F, 2.6F + (random.nextFloat() - random.nextFloat()) * 0.8F); + + for (int l = 0; l < 8; ++l) { + world.spawnParticle("largesmoke", x + random.nextDouble(), y + random.nextDouble(), z + random.nextDouble(), 0.0, 0.0, 0.0); + } + } + } else { + if (!world.isRemote && isLiquid && !material.isLiquid()) { + world.func_147480_a(x, y, z, true); + } + + world.setBlock(x, y, z, this.contents, 0, 3); + } + + return true; + } + } + } + + public int getHealAmount() { return healAmount; } @@ -218,7 +317,7 @@ public class ItemLiquidContainer extends Item { @SideOnly(Side.CLIENT) @Override public IIcon getIconFromDamageForRenderPass(int i, int j) { - if (j > 0 && colour >= 0) + if (j > 0 && color != null) return icons[1]; else return icons[0]; @@ -232,9 +331,13 @@ public class ItemLiquidContainer extends Item { @Override public int getColorFromItemStack(ItemStack itemstack, int j) { - if (j > 0 && colour >= 0) - return colour; + if (j > 0 && color != null) + return color.getRGB() & 0xffffff; // remove alpha else return 0xffffff; } + + public EnumContainerType getType() { + return type; + } } diff --git a/src/main/java/forestry/core/proxy/ProxyCommon.java b/src/main/java/forestry/core/proxy/ProxyCommon.java index cfad6e3ac..e41783504 100755 --- a/src/main/java/forestry/core/proxy/ProxyCommon.java +++ b/src/main/java/forestry/core/proxy/ProxyCommon.java @@ -31,7 +31,11 @@ import forestry.core.network.PacketFXSignal; import forestry.core.network.PacketIds; import forestry.core.render.SpriteSheet; import forestry.core.utils.StringUtil; +import forestry.plugins.PluginManager; + import java.io.File; +import java.util.EnumSet; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.IResourceManager; @@ -62,6 +66,8 @@ public class ProxyCommon { } public void registerBlock(Block block, Class itemClass) { + if (!EnumSet.of(PluginManager.Stage.PRE_INIT).contains(PluginManager.getStage())) + throw new RuntimeException("Tried to register Block outside of Pre-Init"); GameRegistry.registerBlock(block, itemClass, StringUtil.cleanBlockName(block)); } diff --git a/src/main/java/forestry/core/render/EntityColoredDropParticleFX.java b/src/main/java/forestry/core/render/EntityColoredDropParticleFX.java new file mode 100644 index 000000000..bccc400b6 --- /dev/null +++ b/src/main/java/forestry/core/render/EntityColoredDropParticleFX.java @@ -0,0 +1,84 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.render; + +import net.minecraft.block.BlockLiquid; +import net.minecraft.block.material.Material; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class EntityColoredDropParticleFX extends EntityFX { + + /** + * The height of the current bob + */ + private int bobTimer; + + public EntityColoredDropParticleFX(World world, double x, double y, double z, float red, float green, float blue) { + super(world, x, y, z); + this.particleRed = red; + this.particleGreen = green; + this.particleBlue = blue; + + this.setParticleTextureIndex(113); + this.setSize(0.01F, 0.01F); + this.particleGravity = 0.06F; + this.bobTimer = 40; + this.particleMaxAge = (int) (64.0D / (Math.random() * 0.8D + 0.2D)); + } + + /** + * Called to update the entity's position/logic. + */ + public void onUpdate() { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + this.motionY -= (double) this.particleGravity; + + if (this.bobTimer-- > 0) { + this.motionX *= 0.02D; + this.motionY *= 0.02D; + this.motionZ *= 0.02D; + this.setParticleTextureIndex(113); + } else { + this.setParticleTextureIndex(112); + } + + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9800000190734863D; + this.motionY *= 0.9800000190734863D; + this.motionZ *= 0.9800000190734863D; + + if (this.particleMaxAge-- <= 0) { + this.setDead(); + } + + if (this.onGround) { + this.setParticleTextureIndex(114); + + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + } + + Material material = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)).getMaterial(); + + if (material.isLiquid() || material.isSolid()) { + double d0 = (double) ((float) (MathHelper.floor_double(this.posY) + 1) - BlockLiquid.getLiquidHeightPercent(this.worldObj.getBlockMetadata(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)))); + + if (this.posY < d0) { + this.setDead(); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/forestry/core/render/TextureManager.java b/src/main/java/forestry/core/render/TextureManager.java index a47334ddf..66b5e09dc 100755 --- a/src/main/java/forestry/core/render/TextureManager.java +++ b/src/main/java/forestry/core/render/TextureManager.java @@ -10,15 +10,18 @@ ******************************************************************************/ package forestry.core.render; +import java.util.ArrayList; +import java.util.HashMap; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.core.ForestryAPI; import forestry.api.core.IIconProvider; import forestry.api.core.ITextureManager; -import java.util.ArrayList; -import java.util.HashMap; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.util.IIcon; @SideOnly(Side.CLIENT) public class TextureManager implements ITextureManager { diff --git a/src/main/java/forestry/core/utils/LiquidHelper.java b/src/main/java/forestry/core/utils/LiquidHelper.java index fda0feff9..56d42c337 100755 --- a/src/main/java/forestry/core/utils/LiquidHelper.java +++ b/src/main/java/forestry/core/utils/LiquidHelper.java @@ -10,18 +10,44 @@ ******************************************************************************/ package forestry.core.utils; -import forestry.api.recipes.RecipeManagers; -import forestry.core.config.ForestryItem; -import forestry.core.fluids.Fluids; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBucket; import net.minecraft.item.ItemStack; + import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; import net.minecraftforge.fluids.FluidStack; +import forestry.api.recipes.RecipeManagers; +import forestry.core.config.Defaults; +import forestry.core.config.ForestryItem; +import forestry.core.fluids.Fluids; +import forestry.core.items.ItemLiquidContainer; +import forestry.core.proxy.Proxies; + public class LiquidHelper { - public static boolean isEmptyLiquidData() { - return FluidContainerRegistry.getRegisteredFluidContainerData().length <= 0; + public static void injectLiquidContainer(Fluids fluid, ItemStack filled) { + Item item = filled.getItem(); + if (item.getContainerItem() instanceof ItemBucket) { + LiquidHelper.injectLiquidContainer(fluid, Defaults.BUCKET_VOLUME, filled, new ItemStack(Items.bucket)); + return; + } else if (item instanceof ItemLiquidContainer) { + ItemLiquidContainer liquidContainer = (ItemLiquidContainer)item; + switch (liquidContainer.getType()) { + case CAN: + LiquidHelper.injectTinContainer(fluid, Defaults.BUCKET_VOLUME, filled, ForestryItem.canEmpty.getItemStack()); + return; + case CAPSULE: + LiquidHelper.injectWaxContainer(fluid, Defaults.BUCKET_VOLUME, filled, ForestryItem.waxCapsule.getItemStack()); + return; + case REFRACTORY: + LiquidHelper.injectRefractoryContainer(fluid, Defaults.BUCKET_VOLUME, filled, ForestryItem.refractoryEmpty.getItemStack()); + return; + } + } + Proxies.log.warning("Unable to inject liquid container: " + filled); } public static void injectLiquidContainer(Fluids fluid, int volume, ItemStack filled, ItemStack empty) { diff --git a/src/main/java/forestry/core/utils/Schemata.java b/src/main/java/forestry/core/utils/Schemata.java index b0adbee8f..f36670e38 100755 --- a/src/main/java/forestry/core/utils/Schemata.java +++ b/src/main/java/forestry/core/utils/Schemata.java @@ -97,7 +97,7 @@ public class Schemata { } public boolean isEnabled() { - return !Config.disabledStructures.contains(uid); + return Config.isStructureEnabled(uid); } /** diff --git a/src/main/java/forestry/plugins/PluginBuildCraftFuels.java b/src/main/java/forestry/plugins/PluginBuildCraftFuels.java index eacab05c8..87798e991 100644 --- a/src/main/java/forestry/plugins/PluginBuildCraftFuels.java +++ b/src/main/java/forestry/plugins/PluginBuildCraftFuels.java @@ -10,15 +10,23 @@ ******************************************************************************/ package forestry.plugins; -import buildcraft.api.fuels.BuildcraftFuelRegistry; +import java.awt.Color; + +import net.minecraft.block.Block; + +import net.minecraftforge.fluids.Fluid; + import cpw.mods.fml.common.Optional; + import forestry.core.GameMode; import forestry.core.config.Defaults; import forestry.core.config.ForestryItem; import forestry.core.fluids.Fluids; import forestry.core.proxy.Proxies; import forestry.core.utils.LiquidHelper; -import net.minecraftforge.fluids.Fluid; + +import buildcraft.api.fuels.BuildcraftFuelRegistry; +import forestry.core.items.ItemLiquidContainer.EnumContainerType; @Plugin(pluginID = "BC6|Fuels", name = "BuildCraft 6 Fuels", author = "mezz", url = Defaults.URL, unlocalizedDescription = "for.plugin.buildcraft6.description") public class PluginBuildCraftFuels extends ForestryPlugin { @@ -39,16 +47,41 @@ public class PluginBuildCraftFuels extends ForestryPlugin { BuildcraftFuelRegistry.coolant.addCoolant(Fluids.ICE.get(), 10.0f); Fluid ethanol = Fluids.BIOETHANOL.get(); - int ethanolPower = 40; - int ethanolBurnTime = Math.round(Defaults.ENGINE_CYCLE_DURATION_ETHANOL * GameMode.getGameMode().getFloatSetting("fuel.ethanol.combustion")); - BuildcraftFuelRegistry.fuel.addFuel(ethanol, ethanolPower, ethanolBurnTime); + if (ethanol != null) { + int ethanolPower = 40; + int ethanolBurnTime = Math.round(Defaults.ENGINE_CYCLE_DURATION_ETHANOL * GameMode.getGameMode().getFloatSetting("fuel.ethanol.combustion")); + BuildcraftFuelRegistry.fuel.addFuel(ethanol, ethanolPower, ethanolBurnTime); + } - LiquidHelper.injectWaxContainer(Fluids.OIL, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleOil.getItemStack(), ForestryItem.waxCapsule.getItemStack()); - LiquidHelper.injectWaxContainer(Fluids.FUEL, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleFuel.getItemStack(), ForestryItem.waxCapsule.getItemStack()); - LiquidHelper.injectRefractoryContainer(Fluids.OIL, Defaults.BUCKET_VOLUME, ForestryItem.refractoryOil.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); - LiquidHelper.injectRefractoryContainer(Fluids.FUEL, Defaults.BUCKET_VOLUME, ForestryItem.refractoryFuel.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); - LiquidHelper.injectTinContainer(Fluids.OIL, Defaults.BUCKET_VOLUME, ForestryItem.canOil.getItemStack(), ForestryItem.canEmpty.getItemStack()); - LiquidHelper.injectTinContainer(Fluids.FUEL, Defaults.BUCKET_VOLUME, ForestryItem.canFuel.getItemStack(), ForestryItem.canEmpty.getItemStack()); + Fluid oil = Fluids.OIL.get(); + if (oil != null) { + Block oilBlock = oil.getBlock(); + if (oilBlock != null) { + Color oilColor = new Color(0x404040); + ForestryItem.waxCapsuleOil.registerContainer(EnumContainerType.CAPSULE, oilBlock, oilColor); + ForestryItem.canOil.registerContainer(EnumContainerType.CAN, oilBlock, oilColor); + ForestryItem.refractoryOil.registerContainer(EnumContainerType.REFRACTORY, oilBlock, oilColor); + + LiquidHelper.injectLiquidContainer(Fluids.OIL, ForestryItem.waxCapsuleOil.getItemStack()); + LiquidHelper.injectLiquidContainer(Fluids.OIL, ForestryItem.refractoryOil.getItemStack()); + LiquidHelper.injectLiquidContainer(Fluids.OIL, ForestryItem.canOil.getItemStack()); + } + } + + Fluid fuel = Fluids.FUEL.get(); + if (fuel != null) { + Block fuelBlock = fuel.getBlock(); + if (fuelBlock != null) { + Color fuelColor = new Color(0xffff00); + ForestryItem.waxCapsuleFuel.registerContainer(EnumContainerType.CAPSULE, fuelBlock, fuelColor); + ForestryItem.canFuel.registerContainer(EnumContainerType.CAN, fuelBlock, fuelColor); + ForestryItem.refractoryFuel.registerContainer(EnumContainerType.REFRACTORY, fuelBlock, fuelColor); + + LiquidHelper.injectLiquidContainer(Fluids.FUEL, ForestryItem.waxCapsuleFuel.getItemStack()); + LiquidHelper.injectLiquidContainer(Fluids.FUEL, ForestryItem.refractoryFuel.getItemStack()); + LiquidHelper.injectLiquidContainer(Fluids.FUEL, ForestryItem.canFuel.getItemStack()); + } + } } } diff --git a/src/main/java/forestry/plugins/PluginCore.java b/src/main/java/forestry/plugins/PluginCore.java index ba033a27e..30a62f5af 100755 --- a/src/main/java/forestry/plugins/PluginCore.java +++ b/src/main/java/forestry/plugins/PluginCore.java @@ -10,8 +10,22 @@ ******************************************************************************/ package forestry.plugins; +import java.awt.Color; +import java.util.ArrayList; + +import net.minecraft.block.material.Material; +import net.minecraft.command.ICommand; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.oredict.OreDictionary; +import net.minecraftforge.oredict.RecipeSorter; + import cpw.mods.fml.common.IFuelHandler; import cpw.mods.fml.common.network.IGuiHandler; + import forestry.api.circuits.ChipsetManager; import forestry.api.core.Tabs; import forestry.api.genetics.AlleleManager; @@ -29,6 +43,7 @@ import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; +import forestry.core.fluids.ForestryFluids; import forestry.core.gadgets.BlockBase; import forestry.core.gadgets.BlockResource; import forestry.core.gadgets.BlockResourceStorageBlock; @@ -51,7 +66,6 @@ import forestry.core.items.ItemForestryPickaxe; import forestry.core.items.ItemForestryShovel; import forestry.core.items.ItemFruit; import forestry.core.items.ItemLiquidContainer; -import forestry.core.items.ItemLiquidContainer.EnumContainerType; import forestry.core.items.ItemMisc; import forestry.core.items.ItemOverlay; import forestry.core.items.ItemOverlay.OverlayInfo; @@ -61,15 +75,11 @@ import forestry.core.items.ItemWrench; import forestry.core.proxy.Proxies; import forestry.core.utils.ForestryModEnvWarningCallable; import forestry.core.utils.ShapedRecipeCustom; -import java.util.ArrayList; -import net.minecraft.block.material.Material; -import net.minecraft.command.ICommand; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.oredict.OreDictionary; -import net.minecraftforge.oredict.RecipeSorter; + +import static forestry.core.items.ItemLiquidContainer.EnumContainerType.BUCKET; +import static forestry.core.items.ItemLiquidContainer.EnumContainerType.CAN; +import static forestry.core.items.ItemLiquidContainer.EnumContainerType.CAPSULE; +import static forestry.core.items.ItemLiquidContainer.EnumContainerType.REFRACTORY; @Plugin(pluginID = "Core", name = "Core", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.core.description") public class PluginCore extends ForestryPlugin { @@ -86,6 +96,10 @@ public class PluginCore extends ForestryPlugin { rootCommand.addChildCommand(new CommandVersion()); rootCommand.addChildCommand(new CommandPlugins()); + ForestryFluids.preInit(); + MinecraftForge.EVENT_BUS.register(ForestryFluids.getTextureHook()); + MinecraftForge.EVENT_BUS.register(ForestryFluids.getFillBucketHook()); + ChipsetManager.solderManager = new ItemSolderingIron.SolderManager(); CircuitRegistry circuitRegistry = new CircuitRegistry(); @@ -135,6 +149,8 @@ public class PluginCore extends ForestryPlugin { public void doInit() { super.doInit(); + ForestryFluids.init(); + definitionEscritoire.register(); crashCallable = new ForestryModEnvWarningCallable(); @@ -264,49 +280,56 @@ public class PluginCore extends ForestryPlugin { ForestryItem.fruits.registerItem(new ItemFruit(), "fruits"); // / EMPTY LIQUID CONTAINERS - ForestryItem.waxCapsule.registerItem(new ItemLiquidContainer(EnumContainerType.CAPSULE, -1).setMaxStackSize(64), "waxCapsule"); - ForestryItem.canEmpty.registerItem(new ItemLiquidContainer(EnumContainerType.CAN, -1).setMaxStackSize(64), "canEmpty"); - ForestryItem.refractoryEmpty.registerItem(new ItemLiquidContainer(EnumContainerType.REFRACTORY, -1).setMaxStackSize(64), "refractoryEmpty"); + ForestryItem.waxCapsule.registerItem(new ItemLiquidContainer(CAPSULE, Blocks.air, null).setMaxStackSize(64), "waxCapsule"); + ForestryItem.canEmpty.registerItem(new ItemLiquidContainer(CAN, Blocks.air, null).setMaxStackSize(64), "canEmpty"); + ForestryItem.refractoryEmpty.registerItem(new ItemLiquidContainer(REFRACTORY, Blocks.air, null).setMaxStackSize(64), "refractoryEmpty"); // / BUCKETS - ForestryItem.bucketBiomass.registerItem(new ItemForestry().setContainerItem(Items.bucket).setMaxStackSize(1), "bucketBiomass"); - ForestryItem.bucketBiofuel.registerItem(new ItemForestry().setContainerItem(Items.bucket).setMaxStackSize(1), "bucketBiofuel"); + ForestryItem.bucketBiomass.registerContainer(BUCKET, ForestryFluids.BIOMASS); + ForestryItem.bucketEthanol.registerContainer(BUCKET, ForestryFluids.ETHANOL); + ForestryItem.bucketGlass.registerContainer(BUCKET, ForestryFluids.LIQUID_GLASS); + ForestryItem.bucketHoney.registerContainer(BUCKET, ForestryFluids.HONEY); + ForestryItem.bucketIce.registerContainer(BUCKET, ForestryFluids.ICE); + ForestryItem.bucketJuice.registerContainer(BUCKET, ForestryFluids.JUICE); + ForestryItem.bucketSeedoil.registerContainer(BUCKET, ForestryFluids.SEEDOIL); + ForestryItem.bucketShortMead.registerContainer(BUCKET, ForestryFluids.SHORT_MEAD); + + Color colorWater = new Color(0x2432ec); + Color colorLava = new Color(0xfd461f); // / WAX CAPSULES - ForestryItem.waxCapsuleWater.registerItem((new ItemLiquidContainer(EnumContainerType.CAPSULE, 0x2432ec)), "waxCapsuleWater"); - ForestryItem.waxCapsuleBiomass.registerItem((new ItemLiquidContainer(EnumContainerType.CAPSULE, 0x83d41c)), "waxCapsuleBiomass"); - ForestryItem.waxCapsuleBiofuel.registerItem((new ItemLiquidContainer(EnumContainerType.CAPSULE, 0xff7909)), "waxCapsuleBiofuel"); - ForestryItem.waxCapsuleOil.registerItem((new ItemLiquidContainer(EnumContainerType.CAPSULE, 0x404040)), "waxCapsuleOil"); - ForestryItem.waxCapsuleFuel.registerItem((new ItemLiquidContainer(EnumContainerType.CAPSULE, 0xffff00)), "waxCapsuleFuel"); - ForestryItem.waxCapsuleSeedOil.registerItem((new ItemLiquidContainer(EnumContainerType.CAPSULE, 0xffffa9)), "waxCapsuleSeedOil"); - ForestryItem.waxCapsuleHoney.registerItem((new ItemLiquidContainer(EnumContainerType.CAPSULE, 0xffda47)).setDrink(Defaults.FOOD_HONEY_HEAL, Defaults.FOOD_HONEY_SATURATION), "waxCapsuleHoney"); - ForestryItem.waxCapsuleJuice.registerItem((new ItemLiquidContainer(EnumContainerType.CAPSULE, 0x99d04e)).setDrink(Defaults.FOOD_JUICE_HEAL, Defaults.FOOD_JUICE_SATURATION), "waxCapsuleJuice"); - ForestryItem.waxCapsuleIce.registerItem((new ItemLiquidContainer(EnumContainerType.CAPSULE, 0xdcffff)), "waxCapsuleIce"); + ForestryItem.waxCapsuleBiomass.registerContainer(CAPSULE, ForestryFluids.BIOMASS); + ForestryItem.waxCapsuleEthanol.registerContainer(CAPSULE, ForestryFluids.ETHANOL); + ForestryItem.waxCapsuleHoney.registerContainer(CAPSULE, ForestryFluids.HONEY, Defaults.FOOD_HONEY_HEAL, Defaults.FOOD_HONEY_SATURATION); + ForestryItem.waxCapsuleIce.registerContainer(CAPSULE, ForestryFluids.ICE); + ForestryItem.waxCapsuleJuice.registerContainer(CAPSULE, ForestryFluids.JUICE, Defaults.FOOD_JUICE_HEAL, Defaults.FOOD_JUICE_SATURATION); + ForestryItem.waxCapsuleSeedOil.registerContainer(CAPSULE, ForestryFluids.SEEDOIL); + ForestryItem.waxCapsuleWater.registerContainer(CAPSULE, Blocks.flowing_water, colorWater); // / CANS - ForestryItem.canWater.registerItem((new ItemLiquidContainer(EnumContainerType.CAN, 0x2432ec)), "waterCan"); - ForestryItem.canBiomass.registerItem((new ItemLiquidContainer(EnumContainerType.CAN, 0x83d41c)), "biomassCan"); - ForestryItem.canBiofuel.registerItem((new ItemLiquidContainer(EnumContainerType.CAN, 0xff7909)), "biofuelCan"); - ForestryItem.canOil.registerItem((new ItemLiquidContainer(EnumContainerType.CAN, 0x404040)), "canOil"); - ForestryItem.canFuel.registerItem((new ItemLiquidContainer(EnumContainerType.CAN, 0xffff00)), "canFuel"); - ForestryItem.canLava.registerItem((new ItemLiquidContainer(EnumContainerType.CAN, 0xfd461f)), "canLava"); - ForestryItem.canSeedOil.registerItem((new ItemLiquidContainer(EnumContainerType.CAN, 0xffffa9)), "canSeedOil"); - ForestryItem.canHoney.registerItem((new ItemLiquidContainer(EnumContainerType.CAN, 0xffda47)).setDrink(Defaults.FOOD_HONEY_HEAL, Defaults.FOOD_HONEY_SATURATION), "canHoney"); - ForestryItem.canJuice.registerItem((new ItemLiquidContainer(EnumContainerType.CAN, 0x99d04e)).setDrink(Defaults.FOOD_JUICE_HEAL, Defaults.FOOD_JUICE_SATURATION), "canJuice"); - ForestryItem.canIce.registerItem((new ItemLiquidContainer(EnumContainerType.CAN, 0xdcffff)), "canIce"); + ForestryItem.canBiomass.registerContainer(CAN, ForestryFluids.BIOMASS); + ForestryItem.canEthanol.registerContainer(CAN, ForestryFluids.ETHANOL); + ForestryItem.canLava.registerContainer(CAN, Blocks.flowing_lava, colorLava); + ForestryItem.canHoney.registerContainer(CAN, ForestryFluids.HONEY, Defaults.FOOD_HONEY_HEAL, Defaults.FOOD_HONEY_SATURATION); + ForestryItem.canIce.registerContainer(CAN, ForestryFluids.ICE); + ForestryItem.canJuice.registerContainer(CAN, ForestryFluids.JUICE, Defaults.FOOD_JUICE_HEAL, Defaults.FOOD_JUICE_SATURATION); + ForestryItem.canSeedOil.registerContainer(CAN, ForestryFluids.SEEDOIL); + ForestryItem.canWater.registerContainer(CAN, Blocks.flowing_water, colorWater); // / REFRACTORY CAPSULES - ForestryItem.refractoryWater.registerItem((new ItemLiquidContainer(EnumContainerType.REFRACTORY, 0x2432ec)), "refractoryWater"); - ForestryItem.refractoryBiomass.registerItem((new ItemLiquidContainer(EnumContainerType.REFRACTORY, 0x83d41c)), "refractoryBiomass"); - ForestryItem.refractoryBiofuel.registerItem((new ItemLiquidContainer(EnumContainerType.REFRACTORY, 0xff7909)), "refractoryBiofuel"); - ForestryItem.refractoryOil.registerItem((new ItemLiquidContainer(EnumContainerType.REFRACTORY, 0x404040)), "refractoryOil"); - ForestryItem.refractoryFuel.registerItem((new ItemLiquidContainer(EnumContainerType.REFRACTORY, 0xffff00)), "refractoryFuel"); - ForestryItem.refractoryLava.registerItem((new ItemLiquidContainer(EnumContainerType.REFRACTORY, 0xfd461f)), "refractoryLava"); - ForestryItem.refractorySeedOil.registerItem((new ItemLiquidContainer(EnumContainerType.REFRACTORY, 0xffffa9)), "refractorySeedOil"); - ForestryItem.refractoryHoney.registerItem((new ItemLiquidContainer(EnumContainerType.REFRACTORY, 0xffda47)).setDrink(Defaults.FOOD_HONEY_HEAL, Defaults.FOOD_HONEY_SATURATION), "refractoryHoney"); - ForestryItem.refractoryJuice.registerItem((new ItemLiquidContainer(EnumContainerType.REFRACTORY, 0x99d04e)).setDrink(Defaults.FOOD_JUICE_HEAL, Defaults.FOOD_JUICE_SATURATION), "refractoryJuice"); - ForestryItem.refractoryIce.registerItem((new ItemLiquidContainer(EnumContainerType.REFRACTORY, 0xdcffff)), "refractoryIce"); + ForestryItem.refractoryBiomass.registerContainer(REFRACTORY, ForestryFluids.BIOMASS); + ForestryItem.refractoryEthanol.registerContainer(REFRACTORY, ForestryFluids.ETHANOL); + ForestryItem.refractoryLava.registerContainer(REFRACTORY, Blocks.flowing_lava, colorLava); + ForestryItem.refractoryHoney.registerContainer(REFRACTORY, ForestryFluids.HONEY, Defaults.FOOD_HONEY_HEAL, Defaults.FOOD_HONEY_SATURATION); + ForestryItem.refractoryIce.registerContainer(REFRACTORY, ForestryFluids.ICE); + ForestryItem.refractoryJuice.registerContainer(REFRACTORY, ForestryFluids.JUICE, Defaults.FOOD_JUICE_HEAL, Defaults.FOOD_JUICE_SATURATION); + ForestryItem.refractorySeedOil.registerContainer(REFRACTORY, ForestryFluids.SEEDOIL); + ForestryItem.refractoryWater.registerContainer(REFRACTORY, Blocks.flowing_water, colorWater); + } + @Override + public void postInit() { + ForestryFluids.postInit(); } @Override @@ -365,7 +388,7 @@ public class PluginCore extends ForestryPlugin { Proxies.common.addSmelting(ForestryBlock.resources.getItemStack(1, 2), ForestryItem.ingotTin.getItemStack(), 0.5f); /* BRONZE INGOTS */ - if (Config.getCraftingBronzeEnabled()) + if (Config.isCraftingBronzeEnabled()) Proxies.common.addShapelessRecipe(ForestryItem.ingotBronze.getItemStack(4), "ingotTin", "ingotCopper", "ingotCopper", "ingotCopper"); /* STURDY MACHINE */ diff --git a/src/main/java/forestry/plugins/PluginFood.java b/src/main/java/forestry/plugins/PluginFood.java index 5bf4f5b29..dc4cd9a21 100755 --- a/src/main/java/forestry/plugins/PluginFood.java +++ b/src/main/java/forestry/plugins/PluginFood.java @@ -67,7 +67,6 @@ public class PluginFood extends ForestryPlugin { ItemStack meadBottle = ForestryItem.beverage.getItemStack(); ((ItemBeverage) ForestryItem.beverage.item()).beverages[0].saveEffects(meadBottle, new IBeverageEffect[] { BeverageEffect.weakAlcoholic }); - Fluids.SHORT_MEAD.register(); LiquidHelper.injectLiquidContainer(Fluids.SHORT_MEAD, Defaults.BUCKET_VOLUME, meadBottle, new ItemStack(Items.glass_bottle)); } diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/bioethanol.png b/src/main/resources/assets/forestry/textures/blocks/liquid/bioethanol_still.png old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/assets/forestry/textures/blocks/liquid/bioethanol.png rename to src/main/resources/assets/forestry/textures/blocks/liquid/bioethanol_still.png diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/bioethanol.png.mcmeta b/src/main/resources/assets/forestry/textures/blocks/liquid/bioethanol_still.png.mcmeta old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/assets/forestry/textures/blocks/liquid/bioethanol.png.mcmeta rename to src/main/resources/assets/forestry/textures/blocks/liquid/bioethanol_still.png.mcmeta diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/biomass.png b/src/main/resources/assets/forestry/textures/blocks/liquid/biomass.png deleted file mode 100755 index 3f226d8c5..000000000 Binary files a/src/main/resources/assets/forestry/textures/blocks/liquid/biomass.png and /dev/null differ diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/biomass_still.png b/src/main/resources/assets/forestry/textures/blocks/liquid/biomass_still.png new file mode 100644 index 000000000..79660a1b6 Binary files /dev/null and b/src/main/resources/assets/forestry/textures/blocks/liquid/biomass_still.png differ diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/biomass.png.mcmeta b/src/main/resources/assets/forestry/textures/blocks/liquid/biomass_still.png.mcmeta old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/assets/forestry/textures/blocks/liquid/biomass.png.mcmeta rename to src/main/resources/assets/forestry/textures/blocks/liquid/biomass_still.png.mcmeta diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/for.honey_still.png b/src/main/resources/assets/forestry/textures/blocks/liquid/for.honey_still.png new file mode 100644 index 000000000..c9a6ab622 Binary files /dev/null and b/src/main/resources/assets/forestry/textures/blocks/liquid/for.honey_still.png differ diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/glass.png.mcmeta b/src/main/resources/assets/forestry/textures/blocks/liquid/for.honey_still.png.mcmeta old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/assets/forestry/textures/blocks/liquid/glass.png.mcmeta rename to src/main/resources/assets/forestry/textures/blocks/liquid/for.honey_still.png.mcmeta diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/glass.png b/src/main/resources/assets/forestry/textures/blocks/liquid/glass_still.png old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/assets/forestry/textures/blocks/liquid/glass.png rename to src/main/resources/assets/forestry/textures/blocks/liquid/glass_still.png diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/honey.png.mcmeta b/src/main/resources/assets/forestry/textures/blocks/liquid/glass_still.png.mcmeta old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/assets/forestry/textures/blocks/liquid/honey.png.mcmeta rename to src/main/resources/assets/forestry/textures/blocks/liquid/glass_still.png.mcmeta diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/honey.png b/src/main/resources/assets/forestry/textures/blocks/liquid/honey.png deleted file mode 100755 index 6c7973aa5..000000000 Binary files a/src/main/resources/assets/forestry/textures/blocks/liquid/honey.png and /dev/null differ diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/ice.png b/src/main/resources/assets/forestry/textures/blocks/liquid/ice.png deleted file mode 100755 index 96470cd62..000000000 Binary files a/src/main/resources/assets/forestry/textures/blocks/liquid/ice.png and /dev/null differ diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/ice_still.png b/src/main/resources/assets/forestry/textures/blocks/liquid/ice_still.png new file mode 100644 index 000000000..cbb2d11a2 Binary files /dev/null and b/src/main/resources/assets/forestry/textures/blocks/liquid/ice_still.png differ diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/ice.png.mcmeta b/src/main/resources/assets/forestry/textures/blocks/liquid/ice_still.png.mcmeta old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/assets/forestry/textures/blocks/liquid/ice.png.mcmeta rename to src/main/resources/assets/forestry/textures/blocks/liquid/ice_still.png.mcmeta diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/juice.png b/src/main/resources/assets/forestry/textures/blocks/liquid/juice.png deleted file mode 100755 index 1ccbd8b94..000000000 Binary files a/src/main/resources/assets/forestry/textures/blocks/liquid/juice.png and /dev/null differ diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/juice_still.png b/src/main/resources/assets/forestry/textures/blocks/liquid/juice_still.png new file mode 100644 index 000000000..853306a2f Binary files /dev/null and b/src/main/resources/assets/forestry/textures/blocks/liquid/juice_still.png differ diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/juice.png.mcmeta b/src/main/resources/assets/forestry/textures/blocks/liquid/juice_still.png.mcmeta old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/assets/forestry/textures/blocks/liquid/juice.png.mcmeta rename to src/main/resources/assets/forestry/textures/blocks/liquid/juice_still.png.mcmeta diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/milk.png b/src/main/resources/assets/forestry/textures/blocks/liquid/milk_still.png old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/assets/forestry/textures/blocks/liquid/milk.png rename to src/main/resources/assets/forestry/textures/blocks/liquid/milk_still.png diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/seedoil.png b/src/main/resources/assets/forestry/textures/blocks/liquid/seedoil_still.png old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/assets/forestry/textures/blocks/liquid/seedoil.png rename to src/main/resources/assets/forestry/textures/blocks/liquid/seedoil_still.png diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/seedoil.png.mcmeta b/src/main/resources/assets/forestry/textures/blocks/liquid/seedoil_still.png.mcmeta old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/assets/forestry/textures/blocks/liquid/seedoil.png.mcmeta rename to src/main/resources/assets/forestry/textures/blocks/liquid/seedoil_still.png.mcmeta diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/short.mead.png b/src/main/resources/assets/forestry/textures/blocks/liquid/short.mead.png deleted file mode 100755 index 49cdec0cf..000000000 Binary files a/src/main/resources/assets/forestry/textures/blocks/liquid/short.mead.png and /dev/null differ diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/short.mead_still.png b/src/main/resources/assets/forestry/textures/blocks/liquid/short.mead_still.png new file mode 100644 index 000000000..f4c802672 Binary files /dev/null and b/src/main/resources/assets/forestry/textures/blocks/liquid/short.mead_still.png differ diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/short.mead.png.mcmeta b/src/main/resources/assets/forestry/textures/blocks/liquid/short.mead_still.png.mcmeta old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/assets/forestry/textures/blocks/liquid/short.mead.png.mcmeta rename to src/main/resources/assets/forestry/textures/blocks/liquid/short.mead_still.png.mcmeta