mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-21 04:22:32 +00:00
Refactor fluids code, create PluginFluids
This commit is contained in:
1 parent
a4f7e4c583
commit
98e62aa1e3
17 files changed
+645
-556
No files matched your search
@@ -23,7 +23,6 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.ErrorStateRegistry;
|
||||
import forestry.core.fluids.ForestryFluids;
|
||||
import forestry.core.interfaces.IOreDictionaryHandler;
|
||||
import forestry.core.interfaces.IPickupHandler;
|
||||
import forestry.core.interfaces.ISaveEventHandler;
|
||||
|
||||
@@ -43,7 +43,6 @@ import forestry.core.gadgets.TileEngine;
|
||||
import forestry.core.gadgets.TileMachine;
|
||||
import forestry.core.gadgets.TileMill;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.LiquidHelper;
|
||||
import forestry.plugins.PluginManager;
|
||||
|
||||
public class ForestryCore {
|
||||
@@ -66,8 +65,6 @@ public class ForestryCore {
|
||||
|
||||
public void init(Object basemod) {
|
||||
|
||||
registerLiquidContainers();
|
||||
|
||||
// Register world generator
|
||||
GameRegistry.registerWorldGenerator(new WorldGenerator(), 0);
|
||||
|
||||
@@ -146,15 +143,4 @@ public class ForestryCore {
|
||||
public String getPriorities() {
|
||||
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() {
|
||||
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());
|
||||
}
|
||||
}
|
||||
@@ -19,11 +19,10 @@ 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.fluids.Fluids;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class Config {
|
||||
@@ -88,8 +87,8 @@ public class Config {
|
||||
return !Config.disabledStructures.contains(uid);
|
||||
}
|
||||
|
||||
public static boolean isFluidEnabled(ForestryFluids fluids) {
|
||||
return !Config.disabledFluids.contains(fluids.tag);
|
||||
public static boolean isFluidEnabled(Fluids fluids) {
|
||||
return !Config.disabledFluids.contains(fluids.getTag());
|
||||
}
|
||||
|
||||
public static boolean isBlockEnabled(String tag) {
|
||||
@@ -244,16 +243,16 @@ public class Config {
|
||||
|
||||
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;
|
||||
for (Fluids fluid : Fluids.values()) {
|
||||
property = config.get("disable.fluid." + fluid.getTag(), CATEGORY_FLUIDS, false);
|
||||
property.comment = "set to true to disable the fluid for " + fluid.getTag();
|
||||
if (Boolean.parseBoolean(property.value))
|
||||
Config.disabledFluids.add(fluid.tag);
|
||||
Config.disabledFluids.add(fluid.getTag());
|
||||
|
||||
property = config.get("disable.fluidBlock." + fluid.tag, CATEGORY_FLUIDS, false);
|
||||
property.comment = "set to true to disable the in-world FluidBlock for " + fluid.tag;
|
||||
property = config.get("disable.fluidBlock." + fluid.getTag(), CATEGORY_FLUIDS, false);
|
||||
property.comment = "set to true to disable the in-world FluidBlock for " + fluid.getTag();
|
||||
if (Boolean.parseBoolean(property.value))
|
||||
Config.disabledBlocks.add(fluid.tag);
|
||||
Config.disabledBlocks.add(fluid.getTag());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,16 +10,12 @@
|
||||
******************************************************************************/
|
||||
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;
|
||||
@@ -295,18 +291,4 @@ 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());
|
||||
}
|
||||
}
|
||||
@@ -11,9 +11,7 @@
|
||||
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;
|
||||
|
||||
@@ -52,12 +50,12 @@ public class BlockForestryFluid extends BlockFluidClassic {
|
||||
@SideOnly(Side.CLIENT)
|
||||
private List<IIcon> icons;
|
||||
|
||||
public BlockForestryFluid(ForestryFluids forestryFluid) {
|
||||
public BlockForestryFluid(Fluids forestryFluid) {
|
||||
this(forestryFluid, 0, false);
|
||||
}
|
||||
|
||||
public BlockForestryFluid(ForestryFluids forestryFluid, int flammability, boolean flammable) {
|
||||
this(forestryFluid.standardFluid.getFluid(), flammability, flammable, forestryFluid.getColor());
|
||||
public BlockForestryFluid(Fluids forestryFluid, int flammability, boolean flammable) {
|
||||
this(forestryFluid.getFluid(), flammability, flammable, forestryFluid.getColor());
|
||||
}
|
||||
|
||||
private BlockForestryFluid(Fluid fluid, int flammability, boolean flammable, Color color) {
|
||||
|
||||
@@ -365,4 +365,9 @@ public final class FluidHelper {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean areEqual(Fluid fluid, FluidStack fluidStack) {
|
||||
if (fluidStack != null && fluid == fluidStack.getFluid())
|
||||
return true;
|
||||
return fluid == null && fluidStack == null;
|
||||
}
|
||||
}
|
||||
@@ -1,75 +1,415 @@
|
||||
/*******************************************************************************
|
||||
* 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.util.Locale;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author CovertJaguar <http://www.railcraft.info>
|
||||
*/
|
||||
public enum Fluids {
|
||||
|
||||
WATER, LAVA,
|
||||
FUEL, OIL, BIOFUEL,
|
||||
CREOSOTE, STEAM,
|
||||
COAL, PYROTHEUM,
|
||||
BIOMASS, BIOETHANOL, LEGACY_HONEY("honey"), HONEY("for.honey"), MILK, JUICE, ICE, GLASS, SEEDOIL, SHORT_MEAD("short.mead");
|
||||
|
||||
private final String tag;
|
||||
|
||||
private Fluids() {
|
||||
tag = name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
private Fluids(String tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public Fluid getFluid() {
|
||||
return FluidRegistry.getFluid(tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a FluidStack filled with mb milliBuckets worth of Fluid.
|
||||
*/
|
||||
public FluidStack getFluid(int mb) {
|
||||
return FluidRegistry.getFluidStack(tag, mb);
|
||||
}
|
||||
|
||||
public boolean is(Fluid fluid) {
|
||||
return getFluid() == fluid;
|
||||
}
|
||||
|
||||
public boolean is(FluidStack fluidStack) {
|
||||
return fluidStack != null && getFluid() == fluidStack.getFluid();
|
||||
}
|
||||
|
||||
public boolean isContained(ItemStack containerStack) {
|
||||
return containerStack != null && FluidHelper.containsFluid(containerStack, getFluid());
|
||||
}
|
||||
|
||||
public static boolean areEqual(Fluid fluid, FluidStack fluidStack) {
|
||||
if (fluidStack != null && fluid == fluidStack.getFluid())
|
||||
return true;
|
||||
return fluid == null && fluidStack == null;
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
* 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 java.util.Locale;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.items.ItemLiquidContainer;
|
||||
|
||||
import static forestry.core.items.ItemLiquidContainer.EnumContainerType;
|
||||
|
||||
public enum Fluids {
|
||||
|
||||
ETHANOL(new Color(255, 111, 0), 790, 1000) {
|
||||
@Override
|
||||
public String getTag() {
|
||||
return "bioethanol";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block makeBlock() {
|
||||
return new BlockForestryFluid(this, 300, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForestryItem getContainerForType(EnumContainerType type) {
|
||||
switch (type) {
|
||||
case BUCKET:
|
||||
return ForestryItem.bucketEthanol;
|
||||
case CAN:
|
||||
return ForestryItem.canEthanol;
|
||||
case CAPSULE:
|
||||
return ForestryItem.waxCapsuleEthanol;
|
||||
case REFRACTORY:
|
||||
return ForestryItem.refractoryEthanol;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
},
|
||||
BIOMASS(new Color(100, 132, 41), 400, 6560) {
|
||||
@Override
|
||||
public Block makeBlock() {
|
||||
return new BlockForestryFluid(this, 100, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForestryItem getContainerForType(EnumContainerType type) {
|
||||
switch (type) {
|
||||
case BUCKET:
|
||||
return ForestryItem.bucketBiomass;
|
||||
case CAN:
|
||||
return ForestryItem.canBiomass;
|
||||
case CAPSULE:
|
||||
return ForestryItem.waxCapsuleBiomass;
|
||||
case REFRACTORY:
|
||||
return ForestryItem.refractoryBiomass;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
},
|
||||
GLASS(new Color(164, 164, 164), 2400, 10000) {
|
||||
@Override
|
||||
public int getTemperature() {
|
||||
return 1200;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block makeBlock() {
|
||||
return new BlockForestryFluid(this, 0, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForestryItem getContainerForType(EnumContainerType type) {
|
||||
switch (type) {
|
||||
case BUCKET:
|
||||
return ForestryItem.bucketGlass;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
},
|
||||
HONEY(new Color(255, 196, 35), 1420, 73600) {
|
||||
@Override
|
||||
public String getTag() {
|
||||
return "for.honey";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block makeBlock() {
|
||||
return new BlockForestryFluid(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForestryItem getContainerForType(EnumContainerType type) {
|
||||
switch (type) {
|
||||
case BUCKET:
|
||||
return ForestryItem.bucketHoney;
|
||||
case CAN:
|
||||
return ForestryItem.canHoney;
|
||||
case CAPSULE:
|
||||
return ForestryItem.waxCapsuleHoney;
|
||||
case REFRACTORY:
|
||||
return ForestryItem.refractoryHoney;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDrink(ItemLiquidContainer liquidContainer) {
|
||||
if (liquidContainer.getType() != EnumContainerType.BUCKET)
|
||||
liquidContainer.setDrink(Defaults.FOOD_HONEY_HEAL, Defaults.FOOD_HONEY_SATURATION);
|
||||
}
|
||||
},
|
||||
LEGACY_HONEY {
|
||||
@Override
|
||||
public String getTag() {
|
||||
return "honey";
|
||||
}
|
||||
},
|
||||
ICE(new Color(175, 242, 255), 920, 1000) {
|
||||
@Override
|
||||
public int getTemperature() {
|
||||
return 265;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block makeBlock() {
|
||||
return new BlockForestryFluid(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForestryItem getContainerForType(EnumContainerType type) {
|
||||
switch (type) {
|
||||
case BUCKET:
|
||||
return ForestryItem.bucketIce;
|
||||
case CAN:
|
||||
return ForestryItem.canIce;
|
||||
case CAPSULE:
|
||||
return ForestryItem.waxCapsuleIce;
|
||||
case REFRACTORY:
|
||||
return ForestryItem.refractoryIce;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
},
|
||||
JUICE(new Color(168, 201, 114)) {
|
||||
@Override
|
||||
public Block makeBlock() {
|
||||
return new BlockForestryFluid(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForestryItem getContainerForType(EnumContainerType type) {
|
||||
switch (type) {
|
||||
case BUCKET:
|
||||
return ForestryItem.bucketJuice;
|
||||
case CAN:
|
||||
return ForestryItem.canJuice;
|
||||
case CAPSULE:
|
||||
return ForestryItem.waxCapsuleJuice;
|
||||
case REFRACTORY:
|
||||
return ForestryItem.refractoryJuice;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDrink(ItemLiquidContainer liquidContainer) {
|
||||
if (liquidContainer.getType() != EnumContainerType.BUCKET)
|
||||
liquidContainer.setDrink(Defaults.FOOD_JUICE_HEAL, Defaults.FOOD_JUICE_SATURATION);
|
||||
}
|
||||
},
|
||||
MILK(new Color(255, 255, 255), 1030, 3000) {
|
||||
@Override
|
||||
public Block makeBlock() {
|
||||
return new BlockForestryFluid(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getOtherContainers() {
|
||||
return Arrays.asList(
|
||||
new ItemStack(Items.milk_bucket)
|
||||
);
|
||||
}
|
||||
},
|
||||
SEEDOIL(new Color(255, 255, 168), 885, 5000) {
|
||||
@Override
|
||||
public Block makeBlock() {
|
||||
return new BlockForestryFluid(this, 2, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForestryItem getContainerForType(EnumContainerType type) {
|
||||
switch (type) {
|
||||
case BUCKET:
|
||||
return ForestryItem.bucketSeedoil;
|
||||
case CAN:
|
||||
return ForestryItem.canSeedOil;
|
||||
case CAPSULE:
|
||||
return ForestryItem.waxCapsuleSeedOil;
|
||||
case REFRACTORY:
|
||||
return ForestryItem.refractorySeedOil;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
},
|
||||
SHORT_MEAD(new Color(239, 154, 56), 1000, 1200) {
|
||||
@Override
|
||||
public String getTag() {
|
||||
return "short.mead";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block makeBlock() {
|
||||
return new BlockForestryFluid(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForestryItem getContainerForType(EnumContainerType type) {
|
||||
switch (type) {
|
||||
case BUCKET:
|
||||
return ForestryItem.bucketShortMead;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
},
|
||||
// Vanilla
|
||||
WATER(new Color(0x2432ec)) {
|
||||
@Override
|
||||
public ForestryItem getContainerForType(EnumContainerType type) {
|
||||
switch (type) {
|
||||
case CAN:
|
||||
return ForestryItem.canWater;
|
||||
case CAPSULE:
|
||||
return ForestryItem.waxCapsuleWater;
|
||||
case REFRACTORY:
|
||||
return ForestryItem.refractoryWater;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
},
|
||||
LAVA(new Color(0xfd461f)) {
|
||||
@Override
|
||||
public ForestryItem getContainerForType(EnumContainerType type) {
|
||||
switch (type) {
|
||||
case CAN:
|
||||
return ForestryItem.canLava;
|
||||
case REFRACTORY:
|
||||
return ForestryItem.refractoryLava;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
},
|
||||
// BuildCraft
|
||||
FUEL(new Color(0xffff00)) {
|
||||
@Override
|
||||
public ForestryItem getContainerForType(EnumContainerType type) {
|
||||
switch (type) {
|
||||
case CAN:
|
||||
return ForestryItem.canFuel;
|
||||
case CAPSULE:
|
||||
return ForestryItem.waxCapsuleFuel;
|
||||
case REFRACTORY:
|
||||
return ForestryItem.refractoryFuel;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
},
|
||||
OIL(new Color(0x404040)) {
|
||||
@Override
|
||||
public ForestryItem getContainerForType(EnumContainerType type) {
|
||||
switch (type) {
|
||||
case CAN:
|
||||
return ForestryItem.canOil;
|
||||
case CAPSULE:
|
||||
return ForestryItem.waxCapsuleOil;
|
||||
case REFRACTORY:
|
||||
return ForestryItem.refractoryOil;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
},
|
||||
// Railcraft
|
||||
CREOSOTE, STEAM,
|
||||
// Thermal Expansion
|
||||
COAL, PYROTHEUM;
|
||||
|
||||
private final String tag;
|
||||
private final int density, viscosity;
|
||||
private final Color color;
|
||||
|
||||
private Fluids() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
private Fluids(Color color) {
|
||||
this(color, 1000, 1000);
|
||||
}
|
||||
|
||||
private Fluids(Color color, int density, int viscosity) {
|
||||
this.tag = name().toLowerCase(Locale.ENGLISH);
|
||||
this.color = color;
|
||||
this.density = density;
|
||||
this.viscosity = viscosity;
|
||||
}
|
||||
|
||||
public int getTemperature() {
|
||||
return 295;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public final int getDensity() {
|
||||
return density;
|
||||
}
|
||||
|
||||
public final int getViscosity() {
|
||||
return viscosity;
|
||||
}
|
||||
|
||||
public final Fluid getFluid() {
|
||||
return FluidRegistry.getFluid(getTag());
|
||||
}
|
||||
|
||||
public final FluidStack getFluid(int mb) {
|
||||
return FluidRegistry.getFluidStack(getTag(), mb);
|
||||
}
|
||||
|
||||
public final Block getBlock() {
|
||||
Fluid fluid = getFluid();
|
||||
if (fluid == null)
|
||||
return null;
|
||||
return fluid.getBlock();
|
||||
}
|
||||
|
||||
public final Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public final boolean is(Fluid fluid) {
|
||||
return getFluid() == fluid;
|
||||
}
|
||||
|
||||
public final boolean is(FluidStack fluidStack) {
|
||||
return fluidStack != null && getFluid() == fluidStack.getFluid();
|
||||
}
|
||||
|
||||
public final boolean isContained(ItemStack containerStack) {
|
||||
return containerStack != null && FluidHelper.containsFluid(containerStack, getFluid());
|
||||
}
|
||||
|
||||
/** FluidBlock and Container registration */
|
||||
|
||||
/**
|
||||
* Add the filled containers for the fluid, to have them get created and registered.
|
||||
*/
|
||||
public ForestryItem getContainerForType(EnumContainerType type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add non-forestry containers for the fluid.
|
||||
*/
|
||||
public List<ItemStack> getOtherContainers() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Override for Forestry fluids to create FluidBlocks.
|
||||
*/
|
||||
public Block makeBlock() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the drink properties for a ItemLiquidContainer before it gets registered.
|
||||
*/
|
||||
public void setDrink(ItemLiquidContainer liquidContainer) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,323 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* 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<ItemStack> 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<ItemStack> 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<ItemStack> 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<ItemStack> getFilledContainers() {
|
||||
return Arrays.asList(
|
||||
ForestryItem.bucketHoney.getItemStack(),
|
||||
ForestryItem.canHoney.getItemStack(),
|
||||
ForestryItem.waxCapsuleHoney.getItemStack(),
|
||||
ForestryItem.refractoryHoney.getItemStack()
|
||||
);
|
||||
}
|
||||
},
|
||||
LEGACY_HONEY(Fluids.LEGACY_HONEY, new Color(224, 194, 57), 1420, 73600),
|
||||
ICE(Fluids.ICE, new Color(175, 242, 255), 920, 1000, 265) {
|
||||
@Override
|
||||
public Block makeBlock() {
|
||||
return new BlockForestryFluid(this);
|
||||
}
|
||||
@Override
|
||||
List<ItemStack> 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<ItemStack> 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<ItemStack> 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<ItemStack> 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<ItemStack> 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) {
|
||||
this(standardFluid, color, 1000, 1000, 295);
|
||||
}
|
||||
|
||||
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)) {
|
||||
String fluidName = standardFluid.getTag();
|
||||
if (!FluidRegistry.isFluidRegistered(fluidName)) {
|
||||
fluid = new Fluid(fluidName).setDensity(density).setViscosity(viscosity).setTemperature(temperature);
|
||||
FluidRegistry.registerFluid(fluid);
|
||||
initBlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<ItemStack> getFilledContainers() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Block makeBlock() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void initBlock() {
|
||||
if (fluidBlock != null)
|
||||
return;
|
||||
|
||||
Fluid fluid = standardFluid.getFluid();
|
||||
if (fluid == null)
|
||||
return;
|
||||
|
||||
fluidBlock = fluid.getBlock();
|
||||
|
||||
if (Config.isBlockEnabled(tag))
|
||||
if (fluidBlock == null) {
|
||||
fluidBlock = makeBlock();
|
||||
if (fluidBlock != null) {
|
||||
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 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.getFluid() == 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.getFluid() == 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();
|
||||
}
|
||||
}
|
||||
@@ -63,12 +63,10 @@ public class ItemLiquidContainer extends Item {
|
||||
private final Color color;
|
||||
|
||||
public ItemLiquidContainer(EnumContainerType type, Block contents, Color color) {
|
||||
super();
|
||||
this.type = type;
|
||||
this.contents = contents;
|
||||
this.color = color;
|
||||
setCreativeTab(CreativeTabForestry.tabForestry);
|
||||
setMaxStackSize(16);
|
||||
if (type == EnumContainerType.BUCKET) {
|
||||
setContainerItem(Items.bucket);
|
||||
this.maxStackSize = 1;
|
||||
|
||||
@@ -10,23 +10,16 @@
|
||||
******************************************************************************/
|
||||
package forestry.plugins;
|
||||
|
||||
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 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 {
|
||||
@@ -46,42 +39,12 @@ public class PluginBuildCraftFuels extends ForestryPlugin {
|
||||
public void doInit() {
|
||||
BuildcraftFuelRegistry.coolant.addCoolant(Fluids.ICE.getFluid(), 10.0f);
|
||||
|
||||
Fluid ethanol = Fluids.BIOETHANOL.getFluid();
|
||||
Fluid ethanol = Fluids.ETHANOL.getFluid();
|
||||
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);
|
||||
}
|
||||
|
||||
Fluid oil = Fluids.OIL.getFluid();
|
||||
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.getFluid();
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,6 +33,6 @@ public class PluginBuildCraftRecipes extends ForestryPlugin {
|
||||
@Override
|
||||
protected void registerRecipes() {
|
||||
// Add recipe for ethanol
|
||||
BuildcraftRecipeRegistry.refinery.addRecipe("forestry:BiomassToEthanol", Fluids.BIOMASS.getFluid(4), Fluids.BIOETHANOL.getFluid(1), 100, 1);
|
||||
BuildcraftRecipeRegistry.refinery.addRecipe("forestry:BiomassToEthanol", Fluids.BIOMASS.getFluid(4), Fluids.ETHANOL.getFluid(1), 100, 1);
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.plugins;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -43,7 +42,6 @@ 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;
|
||||
@@ -65,7 +63,6 @@ import forestry.core.items.ItemForestryBlock;
|
||||
import forestry.core.items.ItemForestryPickaxe;
|
||||
import forestry.core.items.ItemForestryShovel;
|
||||
import forestry.core.items.ItemFruit;
|
||||
import forestry.core.items.ItemLiquidContainer;
|
||||
import forestry.core.items.ItemMisc;
|
||||
import forestry.core.items.ItemOverlay;
|
||||
import forestry.core.items.ItemOverlay.OverlayInfo;
|
||||
@@ -76,11 +73,6 @@ import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.ForestryModEnvWarningCallable;
|
||||
import forestry.core.utils.ShapedRecipeCustom;
|
||||
|
||||
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 {
|
||||
|
||||
@@ -96,10 +88,6 @@ 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();
|
||||
@@ -149,8 +137,6 @@ public class PluginCore extends ForestryPlugin {
|
||||
public void doInit() {
|
||||
super.doInit();
|
||||
|
||||
ForestryFluids.init();
|
||||
|
||||
definitionEscritoire.register();
|
||||
crashCallable = new ForestryModEnvWarningCallable();
|
||||
|
||||
@@ -174,7 +160,6 @@ public class PluginCore extends ForestryPlugin {
|
||||
|
||||
@Override
|
||||
protected void registerItems() {
|
||||
|
||||
// / FERTILIZERS
|
||||
ForestryItem.fertilizerBio.registerItem((new ItemForestry()), "fertilizerBio");
|
||||
ForestryItem.fertilizerCompound.registerItem((new ItemForestry()).setBonemeal(true), "fertilizerCompound");
|
||||
@@ -278,58 +263,10 @@ public class PluginCore extends ForestryPlugin {
|
||||
|
||||
// FRUITS
|
||||
ForestryItem.fruits.registerItem(new ItemFruit(), "fruits");
|
||||
|
||||
// / EMPTY LIQUID CONTAINERS
|
||||
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.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.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.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.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
|
||||
|
||||
Executable → Regular
+1
-1
@@ -297,7 +297,7 @@ public class PluginFactory extends ForestryPlugin {
|
||||
|
||||
// STILL
|
||||
RecipeManagers.stillManager.addRecipe(Defaults.STILL_DESTILLATION_DURATION, Fluids.BIOMASS.getFluid(Defaults.STILL_DESTILLATION_INPUT),
|
||||
Fluids.BIOETHANOL.getFluid(Defaults.STILL_DESTILLATION_OUTPUT));
|
||||
Fluids.ETHANOL.getFluid(Defaults.STILL_DESTILLATION_OUTPUT));
|
||||
|
||||
// convert old honey to new honey
|
||||
RecipeManagers.stillManager.addRecipe(1, Fluids.LEGACY_HONEY.getFluid(1000), Fluids.HONEY.getFluid(1000));
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
/*******************************************************************************
|
||||
* 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.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
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.common.MinecraftForge;
|
||||
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.Defaults;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.fluids.BlockForestryFluid;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.items.ItemLiquidContainer;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.LiquidHelper;
|
||||
|
||||
import static forestry.core.items.ItemLiquidContainer.EnumContainerType;
|
||||
|
||||
@Plugin(pluginID = "Fluids", name = "Fluids", author = "mezz", url = Defaults.URL, unlocalizedDescription = "for.plugin.fluids.description")
|
||||
public class PluginFluids extends ForestryPlugin {
|
||||
|
||||
private static final List<Fluids> forestryFluidsWithBlocks = new ArrayList<Fluids>();
|
||||
|
||||
private static void createFluid(Fluids forestryFluid) {
|
||||
if (forestryFluid.getFluid() == null && Config.isFluidEnabled(forestryFluid)) {
|
||||
String fluidName = forestryFluid.getTag();
|
||||
if (!FluidRegistry.isFluidRegistered(fluidName)) {
|
||||
Fluid fluid = new Fluid(fluidName).setDensity(forestryFluid.getDensity()).setViscosity(forestryFluid.getViscosity()).setTemperature(forestryFluid.getTemperature());
|
||||
FluidRegistry.registerFluid(fluid);
|
||||
createBlock(forestryFluid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void createBlock(Fluids forestryFluid) {
|
||||
Fluid fluid = forestryFluid.getFluid();
|
||||
Block fluidBlock = fluid.getBlock();
|
||||
|
||||
if (Config.isBlockEnabled(forestryFluid.getTag())) {
|
||||
if (fluidBlock == null) {
|
||||
fluidBlock = forestryFluid.makeBlock();
|
||||
if (fluidBlock != null) {
|
||||
fluidBlock.setBlockName("forestry.fluid." + forestryFluid.getTag());
|
||||
Proxies.common.registerBlock(fluidBlock, ItemBlock.class);
|
||||
forestryFluidsWithBlocks.add(forestryFluid);
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
for (Fluids fluidType : Fluids.values()) {
|
||||
createFluid(fluidType);
|
||||
}
|
||||
MinecraftForge.EVENT_BUS.register(getTextureHook());
|
||||
MinecraftForge.EVENT_BUS.register(getFillBucketHook());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerItems() {
|
||||
for (EnumContainerType type : EnumContainerType.values()) {
|
||||
Item emptyContainer = new ItemLiquidContainer(type, Blocks.air, null);
|
||||
switch (type) {
|
||||
case CAN:
|
||||
ForestryItem.canEmpty.registerItem(emptyContainer, "canEmpty");
|
||||
break;
|
||||
case CAPSULE:
|
||||
ForestryItem.waxCapsule.registerItem(emptyContainer, "waxCapsule");
|
||||
break;
|
||||
case REFRACTORY:
|
||||
ForestryItem.refractoryEmpty.registerItem(emptyContainer, "refractoryEmpty");
|
||||
break;
|
||||
}
|
||||
|
||||
for (Fluids fluidType : Fluids.values()) {
|
||||
ForestryItem container = fluidType.getContainerForType(type);
|
||||
if (container == null)
|
||||
continue;
|
||||
|
||||
ItemLiquidContainer liquidContainer = new ItemLiquidContainer(type, fluidType.getBlock(), fluidType.getColor());
|
||||
fluidType.setDrink(liquidContainer);
|
||||
container.registerItem(liquidContainer, container.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doInit() {
|
||||
for (Fluids fluidType : Fluids.values()) {
|
||||
if (fluidType.getFluid() == null)
|
||||
continue;
|
||||
|
||||
for (EnumContainerType type : EnumContainerType.values()) {
|
||||
ForestryItem container = fluidType.getContainerForType(type);
|
||||
if (container == null)
|
||||
continue;
|
||||
|
||||
LiquidHelper.injectLiquidContainer(fluidType, container.getItemStack());
|
||||
}
|
||||
|
||||
for (ItemStack filledContainer : fluidType.getOtherContainers()) {
|
||||
LiquidHelper.injectLiquidContainer(fluidType, filledContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class MissingFluidException extends RuntimeException {
|
||||
public MissingFluidException(String tag) {
|
||||
super("Fluid '" + tag + "' was not found. Please check your configs.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
for (Fluids fluidType : Fluids.values()) {
|
||||
if (fluidType.getFluid() == null)
|
||||
throw new MissingFluidException(fluidType.getTag());
|
||||
}
|
||||
}
|
||||
|
||||
public static class TextureHook {
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void textureHook(TextureStitchEvent.Post event) {
|
||||
if (event.map.getTextureType() == 0) {
|
||||
for (Fluids fluidType : forestryFluidsWithBlocks) {
|
||||
Fluid fluid = fluidType.getFluid();
|
||||
Block fluidBlock = fluidType.getBlock();
|
||||
if (fluid != null && fluidBlock != null)
|
||||
fluid.setIcons(fluidBlock.getBlockTextureFromSide(1), fluidBlock.getBlockTextureFromSide(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Object getFillBucketHook() {
|
||||
return new FillBucketHook();
|
||||
}
|
||||
}
|
||||
@@ -195,7 +195,7 @@ public class PluginIC2 extends ForestryPlugin {
|
||||
definitionEngineTin.register();
|
||||
definitionGenerator.register();
|
||||
|
||||
FluidStack ethanol = Fluids.BIOETHANOL.getFluid(1);
|
||||
FluidStack ethanol = Fluids.ETHANOL.getFluid(1);
|
||||
GeneratorFuel ethanolFuel = new GeneratorFuel(ethanol, (int) (32 * GameMode.getGameMode().getFloatSetting("fuel.ethanol.generator")), 4);
|
||||
FuelManager.generatorFuel.put(ethanol.getFluid(), ethanolFuel);
|
||||
|
||||
|
||||
@@ -61,7 +61,8 @@ public class PluginManager {
|
||||
|
||||
public enum Module {
|
||||
|
||||
CORE(new PluginCore()),
|
||||
CORE(new PluginCore(), false),
|
||||
FLUIDS(new PluginFluids(), false),
|
||||
APICULTURE(new PluginApiculture()),
|
||||
ARBORICULTURE(new PluginArboriculture()),
|
||||
ENERGY(new PluginEnergy()),
|
||||
@@ -82,9 +83,15 @@ public class PluginManager {
|
||||
NATURA(new PluginNatura()),;
|
||||
|
||||
private final ForestryPlugin instance;
|
||||
private final boolean canBeDisabled;
|
||||
|
||||
private Module(ForestryPlugin plugin) {
|
||||
this(plugin, true);
|
||||
}
|
||||
|
||||
private Module(ForestryPlugin plugin, boolean canBeDisabled) {
|
||||
this.instance = plugin;
|
||||
this.canBeDisabled = canBeDisabled;
|
||||
}
|
||||
|
||||
public ForestryPlugin instance() {
|
||||
@@ -95,6 +102,10 @@ public class PluginManager {
|
||||
return isModuleLoaded(this);
|
||||
}
|
||||
|
||||
public boolean canBeDisabled() {
|
||||
return canBeDisabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Stage getStage() {
|
||||
@@ -128,7 +139,7 @@ public class PluginManager {
|
||||
Iterator<Module> it = toLoad.iterator();
|
||||
while (it.hasNext()) {
|
||||
Module m = it.next();
|
||||
if (m == Module.CORE)
|
||||
if (!m.canBeDisabled())
|
||||
continue;
|
||||
if (!isEnabled(config, m)) {
|
||||
it.remove();
|
||||
|
||||
Reference in new issue
Block a user