Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bio-Fuel rework [WIP] #48

Merged
merged 6 commits into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/mekanism/api/MekanismConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public static class generators
{
public static double advancedSolarGeneration;
public static double bioGeneration;
public static double ethanolMultiplier;
public static double heatGeneration;
public static double heatGenerationLava;
public static double heatGenerationNether;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ else if(gasType == GasRegistry.getGas("hydrogenChloride"))

return fuels;
}
else if(gasType == GasRegistry.getGas("glucose"))
{
List<ItemStack> fuels = new ArrayList<ItemStack>();
fuels.addAll(OreDictionary.getOres("dustSugar"));

for(GasTankTier tier : GasTankTier.values())
{
fuels.add(MekanismUtils.getFullGasTank(tier, GasRegistry.getGas("glucose")));
}

return fuels;
}

return new ArrayList<ItemStack>();
}
Expand Down
17 changes: 15 additions & 2 deletions src/main/java/mekanism/client/render/MekanismRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public class MekanismRenderer
public static IIcon[] colors = new IIcon[256];

public static IIcon energyIcon;

public static IIcon biomatterIcon;
public static IIcon ethanolIcon;

public static IIcon heatIcon;

public static float GAS_RENDER_BASE = 0.2F;
Expand Down Expand Up @@ -96,7 +100,11 @@ public void onStitch(TextureStitchEvent.Pre event)

energyIcon = event.map.registerIcon("mekanism:liquid/LiquidEnergy");
heatIcon = event.map.registerIcon("mekanism:liquid/LiquidHeat");


ethanolIcon = event.map.registerIcon("mekanism:liquid/LiquidEthanol");
biomatterIcon = event.map.registerIcon("mekanism:liquid/LiquidBiomatter");


GasRegistry.getGas("hydrogen").setIcon(event.map.registerIcon("mekanism:liquid/LiquidHydrogen"));
GasRegistry.getGas("oxygen").setIcon(event.map.registerIcon("mekanism:liquid/LiquidOxygen"));
GasRegistry.getGas("water").setIcon(event.map.registerIcon("mekanism:liquid/LiquidSteam"));
Expand All @@ -115,6 +123,11 @@ public void onStitch(TextureStitchEvent.Pre event)
GasRegistry.getGas("fusionFuelDT").setIcon(event.map.registerIcon("mekanism:liquid/LiquidDT"));
GasRegistry.getGas("lithium").setIcon(event.map.registerIcon("mekanism:liquid/LiquidLithium"));
GasRegistry.getGas("methane").setIcon(event.map.registerIcon("mekanism:liquid/LiquidMethane"));
GasRegistry.getGas("glucose").setIcon(event.map.registerIcon("mekanism:liquid/LiquidGlucose"));

GasRegistry.getGas("biomatter").setIcon(biomatterIcon);
GasRegistry.getGas("bioethanol").setIcon(ethanolIcon);


for(Gas gas : GasRegistry.getRegisteredGasses())
{
Expand All @@ -133,7 +146,7 @@ public void onStitch(TextureStitchEvent.Pre event)
FluidRegistry.getFluid("brine").setIcons(event.map.registerIcon("mekanism:liquid/LiquidBrine"));
FluidRegistry.getFluid("heavywater").setIcons(event.map.registerIcon("mekanism:liquid/LiquidHeavyWater"));
FluidRegistry.getFluid("steam").setIcons(event.map.registerIcon("mekanism:liquid/LiquidSteam"));

for(InfuseType type : InfuseRegistry.getInfuseMap().values())
{
type.setIcon(event.map.registerIcon(type.textureLocation));
Expand Down
28 changes: 22 additions & 6 deletions src/main/java/mekanism/common/Mekanism.java
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,7 @@ public void addRecipes()
RecipeHandler.addChemicalInjectionChamberRecipe(new ItemStack(Blocks.hardened_clay), "water", new ItemStack(Blocks.clay));
RecipeHandler.addChemicalInjectionChamberRecipe(new ItemStack(Items.brick), "water", new ItemStack(Items.clay_ball));
RecipeHandler.addChemicalInjectionChamberRecipe(new ItemStack(Items.gunpowder), "hydrogenChloride", new ItemStack(MekanismItems.OtherDust, 1, 3));
RecipeHandler.addChemicalInjectionChamberRecipe(new ItemStack(MekanismItems.Yeast), "glucose", new ItemStack(MekanismItems.Yeast, 3));

//Precision Sawmill Recipes
RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.ladder, 3), new ItemStack(Items.stick, 7));
Expand All @@ -1123,6 +1124,7 @@ public void addRecipes()
//Metallurgic Infuser Recipes
RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("CARBON"), 10, new ItemStack(Items.iron_ingot), new ItemStack(MekanismItems.EnrichedIron));
RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("CARBON"), 10, new ItemStack(MekanismItems.EnrichedIron), new ItemStack(MekanismItems.OtherDust, 1, 1));
RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("FUNGI"), 10, new ItemStack(Items.sugar), new ItemStack(MekanismItems.Yeast));
RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("FUNGI"), 10, new ItemStack(Blocks.dirt), new ItemStack(Blocks.mycelium));
RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("BIO"), 10, new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.mossy_cobblestone));
RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("BIO"), 10, new ItemStack(Blocks.stonebrick, 1, 0), new ItemStack(Blocks.stonebrick, 1, 1));
Expand All @@ -1149,6 +1151,7 @@ public void addRecipes()
//Thermal Evaporation Plant Recipes
RecipeHandler.addThermalEvaporationRecipe(FluidRegistry.getFluidStack("water", 10), FluidRegistry.getFluidStack("brine", 1));
RecipeHandler.addThermalEvaporationRecipe(FluidRegistry.getFluidStack("brine", 10), FluidRegistry.getFluidStack("lithium", 1));
RecipeHandler.addThermalEvaporationRecipe(FluidRegistry.getFluidStack("bioethanol", 5), FluidRegistry.getFluidStack("ethene", 1));

//Chemical Crystallizer Recipes
RecipeHandler.addChemicalCrystallizerRecipe(new GasStack(GasRegistry.getGas("lithium"), 100), new ItemStack(MekanismItems.OtherDust, 1, 4));
Expand All @@ -1167,12 +1170,13 @@ public void addRecipes()
}

//Pressurized Reaction Chamber Recipes

RecipeHandler.addPRCRecipe(
new ItemStack(MekanismItems.BioFuel, 2), new FluidStack(FluidRegistry.WATER, 10), new GasStack(GasRegistry.getGas("hydrogen"), 100),
new ItemStack(MekanismItems.Substrate), new GasStack(GasRegistry.getGas("ethene"), 100),
0,
100
);
new ItemStack(MekanismItems.Yeast), new FluidStack(FluidRegistry.WATER, 200), new GasStack(GasRegistry.getGas("biomatter"), 150),
new ItemStack(MekanismItems.Substrate), new GasStack(GasRegistry.getGas("bioethanol"), 50),
100,
50);

RecipeHandler.addPRCRecipe(
new ItemStack(MekanismItems.Substrate), new FluidStack(FluidRegistry.getFluid("ethene"), 50), new GasStack(GasRegistry.getGas("oxygen"), 10),
new ItemStack(MekanismItems.Polyethene), new GasStack(GasRegistry.getGas("oxygen"), 5),
Expand All @@ -1185,7 +1189,6 @@ public void addRecipes()
200,
400
);

//Solar Neutron Activator Recipes
RecipeHandler.addSolarNeutronRecipe(new GasStack(GasRegistry.getGas("lithium"), 1), new GasStack(GasRegistry.getGas("tritium"), 1));

Expand All @@ -1206,6 +1209,9 @@ public void addRecipes()
InfuseRegistry.registerInfuseObject(Amethyst, new InfuseObject(InfuseRegistry.get("ENDER"), 10));
}

//Chemical Oxidiser Recipes
RecipeHandler.addChemicalOxidizerRecipe(new ItemStack(MekanismItems.BioFuel), new GasStack(GasRegistry.getGas("biomatter"), 150));

//Fuels
GameRegistry.registerFuelHandler(new IFuelHandler() {
@Override
Expand All @@ -1214,6 +1220,10 @@ public int getBurnTime(ItemStack fuel)
if(fuel.isItemEqual(new ItemStack(MekanismBlocks.BasicBlock, 1, 3)))
{
return 200*8*9;
}else if(fuel.isItemEqual(new ItemStack(MekanismItems.Substrate))){
return 400;
}else if(fuel.isItemEqual(new ItemStack(MekanismItems.Polyethene, 1, Short.MAX_VALUE))) {
return 600;
}

return 0;
Expand Down Expand Up @@ -1242,6 +1252,7 @@ public void registerOreDict()
OreDictionary.registerOre("dustWood", MekanismItems.Sawdust);
OreDictionary.registerOre("blockSalt", MekanismBlocks.SaltBlock);


//Alloys!
OreDictionary.registerOre("alloyBasic", new ItemStack(Items.redstone));
OreDictionary.registerOre("alloyAdvanced", new ItemStack(MekanismItems.EnrichedAlloy));
Expand All @@ -1251,6 +1262,8 @@ public void registerOreDict()
//GregoriousT?
OreDictionary.registerOre("itemSalt", MekanismItems.Salt);
OreDictionary.registerOre("dustSalt", MekanismItems.Salt);
OreDictionary.registerOre("dustYeast", MekanismItems.Yeast);
OreDictionary.registerOre("dustSugar", Items.sugar);

OreDictionary.registerOre("dustDiamond", new ItemStack(MekanismItems.OtherDust, 1, 0));
OreDictionary.registerOre("dustSteel", new ItemStack(MekanismItems.OtherDust, 1, 1));
Expand Down Expand Up @@ -1427,6 +1440,9 @@ public void preInit(FMLPreInitializationEvent event)
GasRegistry.register(new Gas("fusionFuelDT")).registerFluid();
GasRegistry.register(new Gas("lithium")).registerFluid();
GasRegistry.register(new Gas("methane")).registerFluid();
GasRegistry.register(new Gas("biomatter")).registerFluid();
GasRegistry.register(new Gas("bioethanol")).registerFluid();
GasRegistry.register(new Gas("glucose")).registerFluid();

FluidRegistry.registerFluid(new Fluid("heavyWater"));
FluidRegistry.registerFluid(new Fluid("steam").setGaseous(true));
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/mekanism/common/MekanismItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ public class MekanismItems
public static final Item Dust = new ItemDust();
public static final Item Sawdust = new ItemMekanism().setUnlocalizedName("Sawdust");
public static final Item Salt = new ItemMekanism().setUnlocalizedName("Salt");
public static final Item Yeast = new ItemMekanism().setUnlocalizedName("Yeast");

public static final Item Ingot = new ItemIngot();
public static final Item Clump = new ItemClump();
public static final Item DirtyDust = new ItemDirtyDust();
Expand Down Expand Up @@ -150,6 +152,7 @@ public static void register()
GameRegistry.registerItem(ElectrolyticCore, "ElectrolyticCore");
GameRegistry.registerItem(Sawdust, "Sawdust");
GameRegistry.registerItem(Salt, "Salt");
GameRegistry.registerItem(Yeast, "Yeast");
GameRegistry.registerItem(BrineBucket, "BrineBucket");
GameRegistry.registerItem(LithiumBucket, "LithiumBucket");
GameRegistry.registerItem(HeavyWaterBucket, "HeavyWaterBucket");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public GasStack getItemGas(ItemStack itemstack)
{
if(MekanismUtils.getOreDictName(itemstack).contains("dustSulfur")) return new GasStack(GasRegistry.getGas("sulfuricAcid"), 2);
if(MekanismUtils.getOreDictName(itemstack).contains("dustSalt")) return new GasStack(GasRegistry.getGas("hydrogenChloride"), 2);
if(MekanismUtils.getOreDictName(itemstack).contains("dustSugar") || MekanismUtils.getOreDictName(itemstack).contains("listAllSugar")) return new GasStack(GasRegistry.getGas("glucose"), 90);
if(Block.getBlockFromItem(itemstack.getItem()) == MekanismBlocks.GasTank && ((IGasItem)itemstack.getItem()).getGas(itemstack) != null &&
isValidGas(((IGasItem)itemstack.getItem()).getGas(itemstack).getGas())) return new GasStack(GasRegistry.getGas("sulfuricAcid"), 1);

Expand Down Expand Up @@ -101,7 +102,7 @@ public boolean canTubeConnect(ForgeDirection side)
@Override
public boolean isValidGas(Gas gas)
{
return gas == GasRegistry.getGas("sulfuricAcid") || gas == GasRegistry.getGas("water") || gas == GasRegistry.getGas("hydrogenChloride");
return gas == GasRegistry.getGas("sulfuricAcid") || gas == GasRegistry.getGas("water") || gas == GasRegistry.getGas("hydrogenChloride")|| gas == GasRegistry.getGas("glucose");
}

@Override
Expand Down
18 changes: 13 additions & 5 deletions src/main/java/mekanism/generators/client/gui/GuiBioGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public GuiBioGenerator(InventoryPlayer inventory, TileEntityBioGenerator tentity
public List<String> getInfo()
{
return ListUtils.asList(
LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.isActive ? generators.bioGeneration : 0) + "/t",
LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.isActive ? generators.bioGeneration * tileEntity.getMultiplier(tileEntity.fuelTank.getGasType()): 0) + "/t",
LangUtils.localize("gui.maxOutput") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t");
}
}, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBioGenerator.png")));
Expand All @@ -56,11 +56,16 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
super.drawGuiContainerForegroundLayer(mouseX, mouseY);

boolean isEthanol = tileEntity.getFuelType() == 1;

String bioFuel = isEthanol ? "gui.bioGenerator.bioEthanol" : "gui.bioGenerator.bioGas";
int colorFuel = isEthanol ? 0xFF8622 : 0x00CD00;

fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040);
fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00);
fontRendererObj.drawString(LangUtils.localize("gui.bioGenerator.bioFuel") + ": " + tileEntity.bioFuelSlot.fluidStored, 51, 35, 0x00CD00);
fontRendererObj.drawString(LangUtils.localize("gui.out") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t", 51, 44, 0x00CD00);
fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, colorFuel);
fontRendererObj.drawString(LangUtils.localize(bioFuel) + ": " + tileEntity.fuelTank.getStored(), 51, 35, colorFuel);
fontRendererObj.drawString(LangUtils.localize("gui.out") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t", 51, 44, colorFuel);
}

@Override
Expand All @@ -75,7 +80,10 @@ protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, in
int displayInt;

displayInt = tileEntity.getScaledFuelLevel(52);
drawTexturedModalRect(guiWidth + 7, guiHeight + 17 + 52 - displayInt, 176, 52 + 52 - displayInt, 4, displayInt);

int gasType = tileEntity.getFuelType() * 4;

drawTexturedModalRect(guiWidth + 7, guiHeight + 17 + 52 - displayInt, 176 + gasType, 52 + 52 - displayInt, 4, displayInt);

super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;

import org.lwjgl.opengl.GL11;
Expand All @@ -37,14 +38,16 @@ public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double

private void renderAModelAt(TileEntityBioGenerator tileEntity, double x, double y, double z, float partialTick)
{
if(tileEntity.bioFuelSlot.fluidStored > 0)
if(tileEntity.fuelTank.getStored() > 0)
{
push();

int gasType = tileEntity.getFuelType();

MekanismRenderer.glowOn();
GL11.glTranslatef((float)x, (float)y, (float)z);
bindTexture(MekanismRenderer.getBlocksTexture());
getDisplayList(ForgeDirection.getOrientation(tileEntity.facing))[tileEntity.getScaledFuelLevel(stages-1)].render();
getDisplayList(gasType, ForgeDirection.getOrientation(tileEntity.facing)) [tileEntity.getScaledFuelLevel(stages-1)].render();
MekanismRenderer.glowOff();

pop();
Expand All @@ -68,7 +71,7 @@ private void renderAModelAt(TileEntityBioGenerator tileEntity, double x, double
}

@SuppressWarnings("incomplete-switch")
private DisplayInteger[] getDisplayList(ForgeDirection side)
private DisplayInteger[] getDisplayList(int gasType, ForgeDirection side)
{
if(energyDisplays.containsKey(side))
{
Expand All @@ -79,7 +82,11 @@ private DisplayInteger[] getDisplayList(ForgeDirection side)

Model3D model3D = new Model3D();
model3D.baseBlock = Blocks.water;
model3D.setTexture(MekanismRenderer.energyIcon);

if (gasType == 1)
model3D.setTexture(MekanismRenderer.ethanolIcon);
else
model3D.setTexture(MekanismRenderer.biomatterIcon);

for(int i = 0; i < stages; i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ public void registerRenderInformation() {}
public void loadConfiguration()
{
generators.advancedSolarGeneration = Mekanism.configurationgenerators.get("generation", "AdvancedSolarGeneration", 300D).getDouble();
generators.bioGeneration = Mekanism.configurationgenerators.get("generation", "BioGeneration", 350D).getDouble();
generators.bioGeneration = Mekanism.configurationgenerators.get("generation", "BioGeneration", 100D).getDouble();
generators.ethanolMultiplier = Mekanism.configurationgenerators.get("generation", "EthanolMultiplier", 5D).getDouble();
generators.heatGeneration = Mekanism.configurationgenerators.get("generation", "HeatGeneration", 150D).getDouble();
generators.heatGenerationLava = Mekanism.configurationgenerators.get("generation", "HeatGenerationLava", 5D).getDouble();
generators.heatGenerationNether = Mekanism.configurationgenerators.get("generation", "HeatGenerationNether", 100D).getDouble();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ public void writeConfig(ByteBuf dataStream) throws IOException
{
dataStream.writeDouble(generators.advancedSolarGeneration);
dataStream.writeDouble(generators.bioGeneration);
dataStream.writeDouble(generators.ethanolMultiplier);
dataStream.writeDouble(generators.heatGeneration);
dataStream.writeDouble(generators.heatGenerationLava);
dataStream.writeDouble(generators.heatGenerationNether);
Expand Down Expand Up @@ -311,6 +312,7 @@ public void readConfig(ByteBuf dataStream) throws IOException
{
generators.advancedSolarGeneration = dataStream.readDouble();
generators.bioGeneration = dataStream.readDouble();
generators.ethanolMultiplier = dataStream.readDouble();
generators.heatGeneration = dataStream.readDouble();
generators.heatGenerationLava = dataStream.readDouble();
generators.heatGenerationNether = dataStream.readDouble();;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package mekanism.generators.common.inventory.container;

import mekanism.api.gas.IGasItem;
import mekanism.common.inventory.slot.SlotEnergy.SlotCharge;
import mekanism.common.util.ChargeUtils;
import mekanism.generators.common.tile.TileEntityBioGenerator;
Expand Down Expand Up @@ -82,7 +83,7 @@ else if(slotID == 1)
}
}
}
else if(tileEntity.getFuel(slotStack) > 0 || isBiofuel(slotStack))
else if(slotStack.getItem() instanceof IGasItem)
{
if(slotID != 0 && slotID != 1)
{
Expand Down Expand Up @@ -140,19 +141,4 @@ else if(slotID > 28)
return stack;
}

private boolean isBiofuel(ItemStack itemStack)
{
if(FluidRegistry.isFluidRegistered("bioethanol"))
{
if(FluidContainerRegistry.getFluidForFilledItem(itemStack) != null)
{
if(FluidContainerRegistry.getFluidForFilledItem(itemStack).getFluid() == FluidRegistry.getFluid("bioethanol"))
{
return true;
}
}
}

return false;
}
}