mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-21 20:52:22 +00:00
Clean Up Fluids
This commit is contained in:
1 parent
40f8c11a1b
commit
c247bd1243
15 files changed
+334
-381
No files matched your search
@@ -7,14 +7,14 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
class BinnieFluid extends Fluid {
|
||||
private final String name;
|
||||
private final IFluidType fluidType;
|
||||
private final FluidDefinition fluidDefinition;
|
||||
private final int color;
|
||||
|
||||
public BinnieFluid(final IFluidType fluid) {
|
||||
public BinnieFluid(FluidDefinition fluid) {
|
||||
super(fluid.getIdentifier(), fluid.getStill(), fluid.getFlowing());
|
||||
this.fluidType = fluid;
|
||||
this.fluidDefinition = fluid;
|
||||
this.name = fluid.getDisplayName();
|
||||
this.color = new Color(this.fluidType.getColor()).getRGB();
|
||||
this.color = new Color(this.fluidDefinition.getColor()).getRGB();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -27,7 +27,7 @@ class BinnieFluid extends Fluid {
|
||||
return color;
|
||||
}
|
||||
|
||||
public IFluidType getType() {
|
||||
return this.fluidType;
|
||||
public FluidDefinition getDefinition() {
|
||||
return this.fluidDefinition;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package binnie.core.liquid;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import binnie.core.Binnie;
|
||||
import binnie.core.Constants;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public class FluidDefinition {
|
||||
public ResourceLocation textureFlowing;
|
||||
public ResourceLocation textureStill;
|
||||
public int color;
|
||||
public int containerColor;
|
||||
public int transparency;
|
||||
public String unlocalizedName;
|
||||
public String identifier;
|
||||
public ContainerShowHandler showHandler = (t)->true;
|
||||
public ContainerPlaceHandler placeHandler = (t)->true;
|
||||
|
||||
public FluidDefinition(String identifier, String unlocalizedName, int color) {
|
||||
this.identifier = "binnie." + identifier;
|
||||
this.unlocalizedName = unlocalizedName;
|
||||
this.color = color;
|
||||
this.containerColor = color;
|
||||
setTextures(new ResourceLocation(Constants.CORE_MOD_ID, "blocks/liquids/blank"));
|
||||
}
|
||||
|
||||
/* TEXTURES */
|
||||
public FluidDefinition setTextures(ResourceLocation texture) {
|
||||
this.textureFlowing = texture;
|
||||
this.textureStill = texture;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FluidDefinition setTextureFlowing(ResourceLocation textureFlowing) {
|
||||
this.textureFlowing = textureFlowing;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResourceLocation getFlowing() {
|
||||
return textureFlowing;
|
||||
}
|
||||
|
||||
public FluidDefinition setTextureStill(ResourceLocation textureStill) {
|
||||
this.textureStill = textureStill;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResourceLocation getStill() {
|
||||
return textureStill;
|
||||
}
|
||||
|
||||
/* NAMES */
|
||||
public String getDisplayName() {
|
||||
return I18N.localise(unlocalizedName);
|
||||
}
|
||||
|
||||
public FluidDefinition setUnlocalizedName(String unlocalizedName) {
|
||||
this.unlocalizedName = unlocalizedName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FluidDefinition setIdentifier(String identifier) {
|
||||
this.identifier = identifier;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getDisplayName();
|
||||
}
|
||||
|
||||
public FluidStack get(int amount) {
|
||||
return Binnie.LIQUID.getFluidStack(this.getIdentifier(), amount);
|
||||
}
|
||||
|
||||
public FluidStack get() {
|
||||
return get(Fluid.BUCKET_VOLUME);
|
||||
}
|
||||
|
||||
/* COLORS */
|
||||
public FluidDefinition setColor(int color) {
|
||||
this.color = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public FluidDefinition setContainerColor(int containerColor) {
|
||||
this.containerColor = containerColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getContainerColor() {
|
||||
return containerColor;
|
||||
}
|
||||
|
||||
public FluidDefinition setTransparency(double transparency) {
|
||||
this.transparency = (int)(Math.min(1.0, transparency + 0.3) * 255.0);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FluidDefinition setTransparency(int transparency) {
|
||||
this.transparency = transparency;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getTransparency() {
|
||||
return transparency;
|
||||
}
|
||||
|
||||
/* HANDLERS*/
|
||||
public FluidDefinition setPlaceHandler(ContainerPlaceHandler placeHandler) {
|
||||
this.placeHandler = placeHandler;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FluidDefinition setShowHandler(ContainerShowHandler showHandler) {
|
||||
this.showHandler = showHandler;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean canPlaceIn(FluidContainerType type) {
|
||||
return placeHandler.canPlaceIn(type);
|
||||
}
|
||||
|
||||
public boolean showInCreative(FluidContainerType type) {
|
||||
return showHandler.showInCreative(type);
|
||||
}
|
||||
|
||||
public static interface ContainerShowHandler{
|
||||
boolean showInCreative(FluidContainerType type);
|
||||
}
|
||||
|
||||
public static interface ContainerPlaceHandler{
|
||||
boolean canPlaceIn(FluidContainerType type);
|
||||
}
|
||||
|
||||
public FluidDefinition getDefinition() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,8 @@ public class FluidHandlerItemBinnie extends FluidHandlerItemStackSimple {
|
||||
|
||||
if (fluid instanceof BinnieFluid) {
|
||||
BinnieFluid binnieFluid = (BinnieFluid) fluid;
|
||||
return binnieFluid.getType().canPlaceIn(containerType);
|
||||
FluidDefinition definition = binnieFluid.getDefinition();
|
||||
return definition.canPlaceIn(containerType);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,33 +1,15 @@
|
||||
package binnie.core.liquid;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public interface IFluidType {
|
||||
|
||||
ResourceLocation getFlowing();
|
||||
|
||||
ResourceLocation getStill();
|
||||
|
||||
String getDisplayName();
|
||||
|
||||
String getIdentifier();
|
||||
|
||||
FluidStack get(int amount);
|
||||
|
||||
default FluidStack get(){
|
||||
return get(Fluid.BUCKET_VOLUME);
|
||||
}
|
||||
|
||||
int getColor();
|
||||
|
||||
int getContainerColor();
|
||||
|
||||
int getTransparency();
|
||||
|
||||
boolean canPlaceIn(FluidContainerType type);
|
||||
|
||||
boolean showInCreative(FluidContainerType type);
|
||||
FluidDefinition getDefinition();
|
||||
}
|
||||
@@ -24,7 +24,6 @@ import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
@@ -63,14 +62,14 @@ public class ItemFluidContainer extends ItemFood implements IItemModelRegister {
|
||||
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
|
||||
super.getSubItems(tab, items);
|
||||
if (this.isInCreativeTab(tab)) {
|
||||
for (final IFluidType liquid : Binnie.LIQUID.fluids.values()) {
|
||||
if (!liquid.canPlaceIn(this.container)) {
|
||||
for (FluidDefinition definition : Binnie.LIQUID.definitions.values()) {
|
||||
if (!definition.canPlaceIn(this.container)) {
|
||||
continue;
|
||||
}
|
||||
if (!liquid.showInCreative(this.container)) {
|
||||
if (!definition.showInCreative(this.container)) {
|
||||
continue;
|
||||
}
|
||||
items.add(getContainer(liquid));
|
||||
items.add(getContainer(definition));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,10 +84,14 @@ public class ItemFluidContainer extends ItemFood implements IItemModelRegister {
|
||||
return fluidHandler.drain(Integer.MAX_VALUE, false);
|
||||
}
|
||||
|
||||
public ItemStack getContainer(final IFluidType liquid) {
|
||||
public ItemStack getContainer(FluidDefinition definition) {
|
||||
ItemStack itemStack = new ItemStack(this);
|
||||
IFluidHandler fluidHandler = new FluidHandlerItemBinnie(itemStack, container);
|
||||
if (fluidHandler.fill(new FluidStack(FluidRegistry.getFluid(liquid.getIdentifier()), Fluid.BUCKET_VOLUME), true) == Fluid.BUCKET_VOLUME) {
|
||||
FluidStack fluidStack = definition.get();
|
||||
if(fluidStack == null){
|
||||
return container.getEmpty();
|
||||
}
|
||||
if (fluidHandler.fill(fluidStack, true) == Fluid.BUCKET_VOLUME) {
|
||||
return itemStack;
|
||||
}
|
||||
return container.getEmpty();
|
||||
|
||||
@@ -4,14 +4,13 @@ import javax.annotation.Nullable;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import binnie.core.Constants;
|
||||
import binnie.core.util.RecipeUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
@@ -21,30 +20,33 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.core.utils.OreDictUtil;
|
||||
|
||||
import binnie.core.Constants;
|
||||
import binnie.core.ManagerBase;
|
||||
import binnie.core.util.RecipeUtil;
|
||||
|
||||
public class ManagerLiquid extends ManagerBase {
|
||||
public static final String WATER = "water";
|
||||
//TODO: test if the name is "Creosote Oil" and not "fluid.creosote"
|
||||
public static final String CREOSOTE = "fluid.creosote";
|
||||
|
||||
Map<String, IFluidType> fluids;
|
||||
|
||||
Map<String, FluidDefinition> definitions;
|
||||
|
||||
public ManagerLiquid() {
|
||||
this.fluids = new LinkedHashMap<>();
|
||||
this.definitions = new LinkedHashMap<>();
|
||||
}
|
||||
|
||||
public void createLiquids(final IFluidType[] liquids) {
|
||||
for (final IFluidType liquid : liquids) {
|
||||
final BinnieFluid fluid = this.createLiquid(liquid);
|
||||
public void createLiquids(IFluidType[] liquids) {
|
||||
for (IFluidType liquid : liquids) {
|
||||
FluidDefinition definition = liquid.getDefinition();
|
||||
final BinnieFluid fluid = this.createLiquid(definition);
|
||||
if (fluid == null) {
|
||||
throw new RuntimeException("Liquid registered incorrectly - " + liquid.getIdentifier());
|
||||
throw new RuntimeException("Liquid registered incorrectly - " + definition.getIdentifier());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BinnieFluid createLiquid(final IFluidType fluid) {
|
||||
this.fluids.put(fluid.getIdentifier().toLowerCase(), fluid);
|
||||
public BinnieFluid createLiquid(FluidDefinition fluid) {
|
||||
this.definitions.put(fluid.getIdentifier().toLowerCase(), fluid);
|
||||
final BinnieFluid bFluid = new BinnieFluid(fluid);
|
||||
FluidRegistry.registerFluid(bFluid);
|
||||
FluidRegistry.addBucketForFluid(bFluid);
|
||||
@@ -56,6 +58,11 @@ public class ManagerLiquid extends ManagerBase {
|
||||
return FluidRegistry.getFluidStack(name.toLowerCase(), amount);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public FluidStack getFluidStack(String name) {
|
||||
return getFluidStack(name, Fluid.BUCKET_VOLUME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
}
|
||||
@@ -75,9 +82,9 @@ public class ManagerLiquid extends ManagerBase {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerSprites(TextureStitchEvent event) {
|
||||
TextureMap textureMap = Minecraft.getMinecraft().getTextureMapBlocks();
|
||||
for (IFluidType fluid : this.fluids.values()) {
|
||||
textureMap.registerSprite(fluid.getFlowing());
|
||||
textureMap.registerSprite(fluid.getStill());
|
||||
for (FluidDefinition definition : definitions.values()) {
|
||||
textureMap.registerSprite(definition.getFlowing());
|
||||
textureMap.registerSprite(definition.getStill());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,9 +7,9 @@ import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import binnie.core.Binnie;
|
||||
import binnie.core.Constants;
|
||||
import binnie.core.liquid.FluidContainerType;
|
||||
import binnie.core.liquid.FluidDefinition;
|
||||
import binnie.core.liquid.IFluidType;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
@@ -127,27 +127,31 @@ public enum Alcohol implements IFluidType, ICocktailLiquid {
|
||||
Rye("mash.rye", 10836007, 0.9, 0.05),
|
||||
Corn("mash.corn", 13411364, 0.9, 0.05);
|
||||
|
||||
List<String> fermentationLiquid;
|
||||
final List<String> fermentationLiquid;
|
||||
final float abv;
|
||||
final FluidDefinition definition;
|
||||
String fermentationSolid;
|
||||
String ident;
|
||||
int colour;
|
||||
float transparency;
|
||||
float abv;
|
||||
|
||||
Alcohol(final String ident, final int colour, final double transparency, final double abv) {
|
||||
Alcohol(final String ident, final int color, final double transparency, final double abv) {
|
||||
this.fermentationLiquid = new ArrayList<>();
|
||||
this.fermentationSolid = "";
|
||||
this.ident = ident;
|
||||
this.colour = colour;
|
||||
this.transparency = (float) transparency;
|
||||
this.abv = (float) abv;
|
||||
init();
|
||||
definition = new FluidDefinition(ident, "extratrees.fluid.alcohol." + this.name().toLowerCase(), color)
|
||||
.setTransparency(transparency)
|
||||
.setTextures(new ResourceLocation(Constants.EXTRA_TREES_MOD_ID, "blocks/liquids/liquid"))
|
||||
.setPlaceHandler((type) -> type == FluidContainerType.GLASS);
|
||||
}
|
||||
|
||||
protected void init(){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidDefinition getDefinition() {
|
||||
return definition;
|
||||
}
|
||||
|
||||
public List<String> getFermentationLiquid() {
|
||||
return fermentationLiquid;
|
||||
}
|
||||
@@ -165,16 +169,6 @@ public enum Alcohol implements IFluidType, ICocktailLiquid {
|
||||
return this.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getFlowing() {
|
||||
return new ResourceLocation(Constants.EXTRA_TREES_MOD_ID, "blocks/liquids/liquid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getStill() {
|
||||
return new ResourceLocation(Constants.EXTRA_TREES_MOD_ID, "blocks/liquids/liquid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return I18N.localise("extratrees.fluid.alcohol." + this.name().toLowerCase());
|
||||
@@ -182,46 +176,33 @@ public enum Alcohol implements IFluidType, ICocktailLiquid {
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "binnie." + this.ident;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return this.colour;
|
||||
return definition.getIdentifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack get(final int amount) {
|
||||
return Binnie.LIQUID.getFluidStack(this.getIdentifier(), amount);
|
||||
return definition.get(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return definition.getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTransparency() {
|
||||
return (int) (Math.min(1.0, this.transparency + 0.3) * 255.0);
|
||||
return definition.getTransparency();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip(final int ratio) {
|
||||
return ratio + " Part" + ((ratio > 1) ? "s " : " ") + this.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceIn(final FluidContainerType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInCreative(final FluidContainerType type) {
|
||||
return type == FluidContainerType.GLASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getContainerColor() {
|
||||
return this.getColor();
|
||||
return ratio + " Part" + ((ratio > 1) ? "s " : " ") + definition.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getABV() {
|
||||
return this.abv;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -4,9 +4,9 @@ import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import binnie.core.Binnie;
|
||||
import binnie.core.Constants;
|
||||
import binnie.core.liquid.FluidContainerType;
|
||||
import binnie.core.liquid.FluidDefinition;
|
||||
import binnie.core.liquid.IFluidType;
|
||||
|
||||
public enum Juice implements IFluidType, ICocktailLiquid {
|
||||
@@ -31,18 +31,15 @@ public enum Juice implements IFluidType, ICocktailLiquid {
|
||||
RedGrape("Red Grape Juice", "juice.red.grape", 9775412, 0.6, "RedGrape");
|
||||
|
||||
public String squeezing;
|
||||
String name;
|
||||
String ident;
|
||||
//IIcon icon;
|
||||
int colour;
|
||||
float transparency;
|
||||
FluidDefinition definition;
|
||||
|
||||
Juice(final String name, final String ident, final int colour, final double transparency, final String squeezing) {
|
||||
this.name = name;
|
||||
this.ident = ident;
|
||||
this.colour = colour;
|
||||
this.transparency = (float) transparency;
|
||||
this.addSqueezing("crop" + squeezing);
|
||||
|
||||
definition = new FluidDefinition(ident, name, colour)
|
||||
.setTransparency(transparency)
|
||||
.setTextures(new ResourceLocation(Constants.EXTRA_TREES_MOD_ID, "blocks/liquids/liquid"))
|
||||
.setShowHandler(type -> type == FluidContainerType.GLASS);
|
||||
}
|
||||
|
||||
private void addSqueezing(final String oreDict) {
|
||||
@@ -51,66 +48,46 @@ public enum Juice implements IFluidType, ICocktailLiquid {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceIn(final FluidContainerType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInCreative(final FluidContainerType type) {
|
||||
return type == FluidContainerType.GLASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getFlowing() {
|
||||
return new ResourceLocation(Constants.EXTRA_TREES_MOD_ID, "blocks/liquids/liquid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getStill() {
|
||||
return new ResourceLocation(Constants.EXTRA_TREES_MOD_ID, "blocks/liquids/liquid");
|
||||
return definition.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return this.name;
|
||||
return definition.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "binnie." + this.ident;
|
||||
return definition.getIdentifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return this.colour;
|
||||
return definition.getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack get(final int amount) {
|
||||
return Binnie.LIQUID.getFluidStack(this.getIdentifier(), amount);
|
||||
return definition.get(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTransparency() {
|
||||
return (int) (Math.min(1.0, this.transparency + 0.3) * 255.0);
|
||||
return definition.getTransparency();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip(final int ratio) {
|
||||
return ratio + " Part" + ((ratio > 1) ? "s " : " ") + this.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getContainerColor() {
|
||||
return this.getColor();
|
||||
return ratio + " Part" + ((ratio > 1) ? "s " : " ") + definition.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getABV() {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidDefinition getDefinition() {
|
||||
return definition;
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,9 @@ import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import binnie.core.Binnie;
|
||||
import binnie.core.Constants;
|
||||
import binnie.core.liquid.FluidContainerType;
|
||||
import binnie.core.liquid.FluidDefinition;
|
||||
import binnie.core.liquid.IFluidType;
|
||||
|
||||
public enum Liqueur implements IFluidType, ICocktailLiquid {
|
||||
@@ -48,22 +48,19 @@ public enum Liqueur implements IFluidType, ICocktailLiquid {
|
||||
Liqueur.Raspberry.addFlavour("cropRaspberry");
|
||||
}
|
||||
|
||||
String name;
|
||||
String ident;
|
||||
int colour;
|
||||
float transparency;
|
||||
float abv;
|
||||
final FluidDefinition definition;
|
||||
|
||||
Liqueur(final String name, final int colour, final double transparency, final double abv) {
|
||||
this(name + " Liqueur", "liqueur." + name.toLowerCase(), colour, transparency, abv);
|
||||
}
|
||||
|
||||
Liqueur(final String name, final String ident, final int colour, final double transparency, final double abv) {
|
||||
this.name = name;
|
||||
this.ident = ident;
|
||||
this.colour = colour;
|
||||
this.transparency = (float) transparency;
|
||||
Liqueur(final String name, final String ident, final int color, final double transparency, final double abv) {
|
||||
this.abv = (float) abv;
|
||||
definition = new FluidDefinition(ident, name, color)
|
||||
.setTransparency(transparency)
|
||||
.setTextures(new ResourceLocation(Constants.EXTRA_TREES_MOD_ID, "blocks/liquids/liquid"))
|
||||
.setShowHandler((type)->type == FluidContainerType.GLASS);
|
||||
}
|
||||
|
||||
private void addFlavour(final String oreDict) {
|
||||
@@ -71,66 +68,48 @@ public enum Liqueur implements IFluidType, ICocktailLiquid {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceIn(final FluidContainerType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInCreative(final FluidContainerType type) {
|
||||
return type == FluidContainerType.GLASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getFlowing() {
|
||||
return new ResourceLocation(Constants.EXTRA_TREES_MOD_ID, "blocks/liquids/liquid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getStill() {
|
||||
return new ResourceLocation(Constants.EXTRA_TREES_MOD_ID, "blocks/liquids/liquid");
|
||||
return definition.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "binnie." + this.ident;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return this.colour;
|
||||
return definition.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack get(final int amount) {
|
||||
return Binnie.LIQUID.getFluidStack(this.getIdentifier(), amount);
|
||||
return definition.get(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return definition.getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTransparency() {
|
||||
return (int) (Math.min(1.0, this.transparency + 0.3) * 255.0);
|
||||
return definition.getTransparency();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip(final int ratio) {
|
||||
return ratio + " Part" + ((ratio > 1) ? "s " : " ") + this.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getContainerColor() {
|
||||
return this.getColor();
|
||||
return ratio + " Part" + ((ratio > 1) ? "s " : " ") + definition.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getABV() {
|
||||
return this.abv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return definition.getIdentifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidDefinition getDefinition() {
|
||||
return definition;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -4,9 +4,9 @@ import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import binnie.core.Binnie;
|
||||
import binnie.core.Constants;
|
||||
import binnie.core.liquid.FluidContainerType;
|
||||
import binnie.core.liquid.FluidDefinition;
|
||||
import binnie.core.liquid.IFluidType;
|
||||
|
||||
public enum MiscFluid implements IFluidType, ICocktailLiquid {
|
||||
@@ -19,67 +19,43 @@ public enum MiscFluid implements IFluidType, ICocktailLiquid {
|
||||
AgaveNectar("Agave Nectar", "syrup.agave", 13598245, 0.699999988079071),
|
||||
GrenadineSyrup("Grenadine Syrup", "syrup.grenadine", 16009573, 0.800000011920929);
|
||||
|
||||
String name;
|
||||
String ident;
|
||||
//IIcon icon;
|
||||
int colour;
|
||||
float transparency;
|
||||
FluidDefinition definition;
|
||||
|
||||
MiscFluid(final String name, final String ident, final int colour, final double transparency) {
|
||||
this.name = name;
|
||||
this.ident = ident;
|
||||
this.colour = colour;
|
||||
this.transparency = (float) transparency;
|
||||
MiscFluid(final String name, final String ident, final int color, final double transparency) {
|
||||
definition = new FluidDefinition(ident, name, color)
|
||||
.setTransparency(transparency)
|
||||
.setTextures(new ResourceLocation(Constants.EXTRA_TREES_MOD_ID, "blocks/liquids/liquid"))
|
||||
.setShowHandler((type)-> type == FluidContainerType.GLASS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceIn(final FluidContainerType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInCreative(final FluidContainerType type) {
|
||||
return type == FluidContainerType.GLASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getFlowing() {
|
||||
return new ResourceLocation(Constants.EXTRA_TREES_MOD_ID, "blocks/liquids/liquid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getStill() {
|
||||
return new ResourceLocation(Constants.EXTRA_TREES_MOD_ID, "blocks/liquids/liquid");
|
||||
return definition.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return this.name;
|
||||
return definition.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "binnie." + this.ident;
|
||||
return definition.getIdentifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return this.colour;
|
||||
return definition.getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack get(final int amount) {
|
||||
return Binnie.LIQUID.getFluidStack(this.getIdentifier(), amount);
|
||||
return definition.get(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTransparency() {
|
||||
return (int) (Math.min(1.0, this.transparency + 0.3) * 255.0);
|
||||
return definition.getTransparency();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -87,13 +63,13 @@ public enum MiscFluid implements IFluidType, ICocktailLiquid {
|
||||
return ratio + " Part" + ((ratio > 1) ? "s " : " ") + this.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getContainerColor() {
|
||||
return this.getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getABV() {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidDefinition getDefinition() {
|
||||
return definition;
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,9 @@ import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import binnie.core.Binnie;
|
||||
import binnie.core.Constants;
|
||||
import binnie.core.liquid.FluidContainerType;
|
||||
import binnie.core.liquid.FluidDefinition;
|
||||
import binnie.core.liquid.IFluidType;
|
||||
|
||||
public enum Spirit implements IFluidType, ICocktailLiquid {
|
||||
@@ -38,82 +38,58 @@ public enum Spirit implements IFluidType, ICocktailLiquid {
|
||||
ApricotLiquor("Apricot Liquor", "liquor.apricot", 13421772, 0.05, 0.4),
|
||||
FruitLiquor("Fruit Liquor", "liquor.fruit", 13421772, 0.05, 0.4);
|
||||
|
||||
String name;
|
||||
String ident;
|
||||
int colour;
|
||||
float transparency;
|
||||
float abv;
|
||||
FluidDefinition definition;
|
||||
|
||||
Spirit(final String name, final String ident, final int colour, final double transparency, final double abv) {
|
||||
this.name = name;
|
||||
this.ident = ident;
|
||||
this.colour = colour;
|
||||
this.transparency = (float) transparency;
|
||||
Spirit(final String name, final String ident, final int color, final double transparency, final double abv) {
|
||||
this.abv = (float) abv;
|
||||
definition = new FluidDefinition(ident, name, color)
|
||||
.setTextures(new ResourceLocation(Constants.EXTRA_TREES_MOD_ID, "blocks/liquids/liquid"))
|
||||
.setShowHandler(type -> type == FluidContainerType.GLASS)
|
||||
.setTransparency(transparency);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceIn(final FluidContainerType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInCreative(final FluidContainerType type) {
|
||||
return type == FluidContainerType.GLASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getFlowing() {
|
||||
return new ResourceLocation(Constants.EXTRA_TREES_MOD_ID, "blocks/liquids/liquid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getStill() {
|
||||
return new ResourceLocation(Constants.EXTRA_TREES_MOD_ID, "blocks/liquids/liquid");
|
||||
return definition.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return this.name;
|
||||
return definition.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "binnie." + this.ident;
|
||||
return definition.getIdentifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return this.colour;
|
||||
return definition.getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack get(final int amount) {
|
||||
return Binnie.LIQUID.getFluidStack(this.getIdentifier(), amount);
|
||||
return definition.get(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTransparency() {
|
||||
return (int) (Math.min(1.0, this.transparency + 0.3) * 255.0);
|
||||
return definition.getTransparency();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip(final int ratio) {
|
||||
return ratio + " Part" + ((ratio > 1) ? "s " : " ") + this.getDisplayName();
|
||||
return ratio + " Part" + ((ratio > 1) ? "s " : " ") + definition.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getContainerColor() {
|
||||
return this.getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getABV() {
|
||||
return this.abv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidDefinition getDefinition() {
|
||||
return definition;
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,9 @@ import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import binnie.core.Binnie;
|
||||
import binnie.core.Constants;
|
||||
import binnie.core.liquid.FluidContainerType;
|
||||
import binnie.core.liquid.FluidDefinition;
|
||||
import binnie.core.liquid.ILiquidType;
|
||||
|
||||
public enum ExtraTreeLiquid implements ILiquidType {
|
||||
@@ -15,64 +15,22 @@ public enum ExtraTreeLiquid implements ILiquidType {
|
||||
Latex("Latex", "latex", 14212041),
|
||||
Turpentine("Turpentine", "turpentine", 7951162);
|
||||
|
||||
public String name;
|
||||
String ident;
|
||||
int colour;
|
||||
FluidDefinition definition;
|
||||
|
||||
ExtraTreeLiquid(final String name, final String ident, final int colour) {
|
||||
this.name = "";
|
||||
this.name = name;
|
||||
this.ident = ident;
|
||||
this.colour = colour;
|
||||
ExtraTreeLiquid(final String name, final String ident, final int color) {
|
||||
definition = new FluidDefinition(ident, name, color)
|
||||
.setShowHandler((type)->type == FluidContainerType.CAN || type == FluidContainerType.CAPSULE)
|
||||
.setTransparency(255)
|
||||
.setTextures(new ResourceLocation(Constants.EXTRA_TREES_MOD_ID, "blocks/liquids/" + ident));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getStill() {
|
||||
return new ResourceLocation(Constants.EXTRA_TREES_MOD_ID, "blocks/liquids/" + this.getIdentifier());
|
||||
public FluidStack get(final int amount) {
|
||||
return definition.get(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getFlowing() {
|
||||
return new ResourceLocation(Constants.EXTRA_TREES_MOD_ID, "blocks/liquids/" + this.getIdentifier());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return this.ident;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return 16777215;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack get(final int i) {
|
||||
return Binnie.LIQUID.getFluidStack(this.ident, i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTransparency() {
|
||||
return 255;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceIn(final FluidContainerType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInCreative(final FluidContainerType type) {
|
||||
return type == FluidContainerType.CAN || type == FluidContainerType.CAPSULE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getContainerColor() {
|
||||
return this.colour;
|
||||
public FluidDefinition getDefinition() {
|
||||
return definition;
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import java.util.Objects;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
@@ -18,7 +17,12 @@ import forestry.core.fluids.Fluids;
|
||||
import binnie.core.Binnie;
|
||||
import binnie.core.Constants;
|
||||
import binnie.core.Mods;
|
||||
import binnie.core.liquid.DrinkManager;
|
||||
import binnie.core.liquid.FluidDefinition;
|
||||
import binnie.core.liquid.IFluidType;
|
||||
import binnie.core.modules.BinnieModule;
|
||||
import binnie.core.modules.ExtraTreesModuleUIDs;
|
||||
import binnie.core.modules.Module;
|
||||
import binnie.core.resource.BinnieSprite;
|
||||
import binnie.core.util.OreDictionaryUtil;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
@@ -29,7 +33,6 @@ import binnie.extratrees.alcohol.Juice;
|
||||
import binnie.extratrees.alcohol.Liqueur;
|
||||
import binnie.extratrees.alcohol.Spirit;
|
||||
import binnie.extratrees.alcohol.drink.DrinkLiquid;
|
||||
import binnie.core.liquid.DrinkManager;
|
||||
import binnie.extratrees.alcohol.drink.ItemDrink;
|
||||
import binnie.extratrees.api.recipes.ExtraTreesRecipeManager;
|
||||
import binnie.extratrees.api.recipes.IBreweryManager;
|
||||
@@ -38,9 +41,6 @@ import binnie.extratrees.api.recipes.IFruitPressManager;
|
||||
import binnie.extratrees.items.ExtraTreeItems;
|
||||
import binnie.extratrees.items.Food;
|
||||
import binnie.extratrees.machines.distillery.DistilleryLogic;
|
||||
import binnie.core.modules.ExtraTreesModuleUIDs;
|
||||
import binnie.core.modules.BinnieModule;
|
||||
import binnie.core.modules.Module;
|
||||
|
||||
@BinnieModule(moduleID = ExtraTreesModuleUIDs.ALCOHOL, moduleContainerID = Constants.EXTRA_TREES_MOD_ID, name = "Alcohol", unlocalizedDescription = "extratrees.module.alcohol")
|
||||
public class ModuleAlcohol extends Module {
|
||||
@@ -119,10 +119,11 @@ public class ModuleAlcohol extends Module {
|
||||
}
|
||||
}
|
||||
for (Alcohol alcohol : Alcohol.values()) {
|
||||
FluidDefinition definition = alcohol.getDefinition();
|
||||
for (String fermentLiquid : alcohol.getFermentationLiquid()) {
|
||||
FluidStack fluid = Binnie.LIQUID.getFluidStack(fermentLiquid, Fluid.BUCKET_VOLUME);
|
||||
FluidStack fluid = Binnie.LIQUID.getFluidStack(fermentLiquid);
|
||||
if (fluid != null) {
|
||||
breweryManager.addRecipe(fluid, alcohol.get());
|
||||
breweryManager.addRecipe(fluid, definition.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import binnie.core.Binnie;
|
||||
import binnie.core.liquid.FluidContainerType;
|
||||
import binnie.core.liquid.FluidDefinition;
|
||||
import binnie.core.liquid.IFluidType;
|
||||
import binnie.genetics.Genetics;
|
||||
|
||||
@@ -16,68 +16,29 @@ public enum GeneticLiquid implements IFluidType {
|
||||
RawDNA("Raw DNA", "dna.raw", 15089129),
|
||||
BacteriaVector("Bacteria Vector", "bacteria.vector", 15960958);
|
||||
|
||||
String name;
|
||||
String ident;
|
||||
int colour;
|
||||
FluidDefinition definition;
|
||||
|
||||
GeneticLiquid(final String name, final String ident, final int colour) {
|
||||
this.name = name;
|
||||
this.ident = ident;
|
||||
this.colour = colour;
|
||||
GeneticLiquid(final String name, final String ident, final int color) {
|
||||
definition = new FluidDefinition(ident, name, color)
|
||||
.setTextures(new ResourceLocation(Genetics.instance.getModID(), "blocks/liquids/" + ident.replace(".", "_")))
|
||||
.setColor(16777215)
|
||||
.setContainerColor(color)
|
||||
.setPlaceHandler((type)-> ordinal() == 0 || type == FluidContainerType.CYLINDER)
|
||||
.setShowHandler((type)->type == FluidContainerType.CYLINDER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getFlowing() {
|
||||
return new ResourceLocation(Genetics.instance.getModID(), "blocks/liquids/" + this.ident.replace(".", "_"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getStill() {
|
||||
return new ResourceLocation(Genetics.instance.getModID(), "blocks/liquids/" + this.ident.replace(".", "_"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "binnie." + this.ident;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return 16777215;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getContainerColor() {
|
||||
return this.colour;
|
||||
return definition.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack get(final int amount) {
|
||||
return Binnie.LIQUID.getFluidStack(this.getIdentifier(), amount);
|
||||
return definition.get(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTransparency() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceIn(final FluidContainerType type) {
|
||||
return this == GeneticLiquid.GrowthMedium || type == FluidContainerType.CYLINDER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInCreative(final FluidContainerType type) {
|
||||
return type == FluidContainerType.CYLINDER;
|
||||
public FluidDefinition getDefinition() {
|
||||
return definition;
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@ public class PackageInoculator extends GeneticMachine.PackageGeneticBase impleme
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return GeneticLiquid.BacteriaVector.getDisplayName();
|
||||
return GeneticLiquid.BacteriaVector.toString();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user