mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 08:48:34 +01:00
Made the Oil Generator scale per time, not per energy
This commit is contained in:
parent
32b757d71f
commit
dd7e522605
5 changed files with 91 additions and 31 deletions
|
@ -31,7 +31,7 @@ public final class ActuallyAdditionsAPI{
|
|||
|
||||
public static final String MOD_ID = "actuallyadditions";
|
||||
public static final String API_ID = MOD_ID+"api";
|
||||
public static final String API_VERSION = "29";
|
||||
public static final String API_VERSION = "30";
|
||||
|
||||
public static final List<CrusherRecipe> CRUSHER_RECIPES = new ArrayList<CrusherRecipe>();
|
||||
public static final List<BallOfFurReturn> BALL_OF_FUR_RETURN_ITEMS = new ArrayList<BallOfFurReturn>();
|
||||
|
@ -41,7 +41,7 @@ public final class ActuallyAdditionsAPI{
|
|||
public static final Map<Item, IColorLensChanger> RECONSTRUCTOR_LENS_COLOR_CHANGERS = new HashMap<Item, IColorLensChanger>();
|
||||
public static final List<CoffeeIngredient> COFFEE_MACHINE_INGREDIENTS = new ArrayList<CoffeeIngredient>();
|
||||
public static final List<CompostRecipe> COMPOST_RECIPES = new ArrayList<CompostRecipe>();
|
||||
public static final Map<String, Integer> OIL_GENERATOR_RECIPES = new HashMap<String, Integer>();
|
||||
public static final List<OilGenRecipe> OIL_GENERATOR_RECIPES = new ArrayList<OilGenRecipe>();
|
||||
public static final List<IBookletEntry> BOOKLET_ENTRIES = new ArrayList<IBookletEntry>();
|
||||
//This is added to automatically, you don't need to add anything to this list
|
||||
public static final List<IBookletChapter> ALL_CHAPTERS = new ArrayList<IBookletChapter>();
|
||||
|
@ -148,7 +148,17 @@ public final class ActuallyAdditionsAPI{
|
|||
* @param genAmount The amount of energy generated per operation
|
||||
*/
|
||||
public static void addOilGenRecipe(String fluidName, int genAmount){
|
||||
OIL_GENERATOR_RECIPES.put(fluidName, genAmount);
|
||||
addOilGenRecipe(fluidName, genAmount, 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a Recipe to the Oil generator
|
||||
*
|
||||
* @param fluidName The name of the fluid to be consumed
|
||||
* @param genAmount The amount of energy generated per operation
|
||||
*/
|
||||
public static void addOilGenRecipe(String fluidName, int genAmount, int genTime){
|
||||
OIL_GENERATOR_RECIPES.add(new OilGenRecipe(fluidName, genAmount, genTime));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* This file ("OilGenRecipe.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.api.recipe;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class OilGenRecipe{
|
||||
|
||||
public final String fluidName;
|
||||
public final int genAmount;
|
||||
public final int genTime;
|
||||
|
||||
public OilGenRecipe(String fluidName, int genAmount, int genTime){
|
||||
this.fluidName = fluidName;
|
||||
this.genAmount = genAmount;
|
||||
this.genTime = genTime;
|
||||
}
|
||||
|
||||
}
|
|
@ -33,10 +33,10 @@ public final class InitCrafting{
|
|||
ActuallyAdditionsAPI.addCompostRecipe(new ItemStack(InitItems.itemMisc, 10, TheMiscItems.MASHED_FOOD.ordinal()), Blocks.LEAVES, new ItemStack(InitItems.itemFertilizer, 10), Blocks.DIRT);
|
||||
ActuallyAdditionsAPI.addCompostRecipe(new ItemStack(InitItems.itemCanolaSeed, 20), Blocks.DIRT, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.BIOMASS.ordinal()), Blocks.SOUL_SAND);
|
||||
|
||||
ActuallyAdditionsAPI.addOilGenRecipe(InitFluids.fluidCanolaOil.getName(), 40);
|
||||
ActuallyAdditionsAPI.addOilGenRecipe(InitFluids.fluidOil.getName(), 100);
|
||||
ActuallyAdditionsAPI.addOilGenRecipe(InitFluids.fluidCrystalOil.getName(), 200);
|
||||
ActuallyAdditionsAPI.addOilGenRecipe(InitFluids.fluidEmpoweredOil.getName(), 350);
|
||||
ActuallyAdditionsAPI.addOilGenRecipe(InitFluids.fluidCanolaOil.getName(), 40, 100);
|
||||
ActuallyAdditionsAPI.addOilGenRecipe(InitFluids.fluidOil.getName(), 60, 100);
|
||||
ActuallyAdditionsAPI.addOilGenRecipe(InitFluids.fluidCrystalOil.getName(), 80, 200);
|
||||
ActuallyAdditionsAPI.addOilGenRecipe(InitFluids.fluidEmpoweredOil.getName(), 80, 350);
|
||||
|
||||
RecipeSorter.register(ModUtil.MOD_ID+":recipeKeepDataShaped", RecipeKeepDataShaped.class, RecipeSorter.Category.SHAPED, "after:minecraft:shaped");
|
||||
RecipeSorter.register(ModUtil.MOD_ID+":recipeKeepDataShapeless", RecipeKeepDataShapeless.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless");
|
||||
|
|
|
@ -75,13 +75,14 @@ public class GuiOilGenerator extends GuiContainer{
|
|||
this.mc.getTextureManager().bindTexture(RES_LOC);
|
||||
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93);
|
||||
|
||||
if(this.generator.currentBurnTime > 0){
|
||||
if(this.generator.currentBurnTime > 0 && this.generator.maxBurnTime > 0){
|
||||
int i = this.generator.getBurningScaled(13);
|
||||
this.drawTexturedModalRect(this.guiLeft+72, this.guiTop+44+12-i, 176, 96-i, 14, i);
|
||||
}
|
||||
|
||||
if(this.generator.currentEnergyProduce > 0){
|
||||
this.drawCenteredString(this.fontRendererObj, this.generator.currentEnergyProduce+" RF/t", this.guiLeft+87, this.guiTop+75, 0xFFFFFF);
|
||||
if(this.generator.maxBurnTime > 0 && this.generator.currentEnergyProduce > 0){
|
||||
this.drawCenteredString(this.fontRendererObj, this.generator.currentEnergyProduce+" RF/t", this.guiLeft+87, this.guiTop+65, 0xFFFFFF);
|
||||
this.drawCenteredString(this.fontRendererObj, "for "+this.generator.maxBurnTime+" t", this.guiLeft+87, this.guiTop+75, 0xFFFFFF);
|
||||
}
|
||||
|
||||
this.energy.draw();
|
||||
|
|
|
@ -12,18 +12,19 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
|||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.OilGenRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.fluids.*;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileEntityOilGenerator extends TileEntityBase implements ISharingEnergyProvider, ISharingFluidHandler{
|
||||
|
||||
private static final int BURN_TIME = 100;
|
||||
public final EnergyStorage storage = new EnergyStorage(50000);
|
||||
public final FluidTank tank = new FluidTank(2*Util.BUCKET){
|
||||
@Override
|
||||
|
@ -34,14 +35,16 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn
|
|||
@Override
|
||||
public boolean canFillFluidType(FluidStack stack){
|
||||
Fluid fluid = stack.getFluid();
|
||||
return fluid != null && ActuallyAdditionsAPI.OIL_GENERATOR_RECIPES.containsKey(fluid.getName());
|
||||
return fluid != null && getRecipeForFluid(fluid.getName()) != null;
|
||||
}
|
||||
};
|
||||
public int currentEnergyProduce;
|
||||
public int currentBurnTime;
|
||||
public int maxBurnTime;
|
||||
private int lastEnergy;
|
||||
private int lastTank;
|
||||
private int lastBurnTime;
|
||||
private int lastMaxBurnTime;
|
||||
private int lastEnergyProduce;
|
||||
|
||||
public TileEntityOilGenerator(){
|
||||
|
@ -50,7 +53,29 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn
|
|||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getBurningScaled(int i){
|
||||
return this.currentBurnTime*i/BURN_TIME;
|
||||
return this.currentBurnTime*i/this.maxBurnTime;
|
||||
}
|
||||
|
||||
private OilGenRecipe getRecipeForCurrentFluid(){
|
||||
FluidStack stack = this.tank.getFluid();
|
||||
if(stack != null){
|
||||
Fluid fluid = stack.getFluid();
|
||||
if(fluid != null){
|
||||
return getRecipeForFluid(fluid.getName());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static OilGenRecipe getRecipeForFluid(String fluidName){
|
||||
if(fluidName != null){
|
||||
for(OilGenRecipe recipe : ActuallyAdditionsAPI.OIL_GENERATOR_RECIPES){
|
||||
if(recipe != null && fluidName.equals(recipe.fluidName)){
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,6 +83,7 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn
|
|||
if(type != NBTType.SAVE_BLOCK){
|
||||
compound.setInteger("BurnTime", this.currentBurnTime);
|
||||
compound.setInteger("CurrentEnergy", this.currentEnergyProduce);
|
||||
compound.setInteger("MaxBurnTime", this.maxBurnTime);
|
||||
}
|
||||
this.storage.writeToNBT(compound);
|
||||
this.tank.writeToNBT(compound);
|
||||
|
@ -69,6 +95,7 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn
|
|||
if(type != NBTType.SAVE_BLOCK){
|
||||
this.currentBurnTime = compound.getInteger("BurnTime");
|
||||
this.currentEnergyProduce = compound.getInteger("CurrentEnergy");
|
||||
this.maxBurnTime = compound.getInteger("MaxBurnTime");
|
||||
}
|
||||
this.storage.readFromNBT(compound);
|
||||
this.tank.readFromNBT(compound);
|
||||
|
@ -86,15 +113,20 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn
|
|||
this.storage.receiveEnergy(this.currentEnergyProduce, false);
|
||||
}
|
||||
else{
|
||||
this.currentEnergyProduce = this.getEnergyForCurrentFluid();
|
||||
|
||||
int fuelUsed = 50;
|
||||
if(this.storage.getEnergyStored() < this.storage.getMaxEnergyStored() && this.tank.getFluidAmount() >= fuelUsed){
|
||||
this.currentBurnTime = BURN_TIME;
|
||||
|
||||
OilGenRecipe recipe = this.getRecipeForCurrentFluid();
|
||||
if(recipe != null && this.storage.getEnergyStored() < this.storage.getMaxEnergyStored() && this.tank.getFluidAmount() >= fuelUsed){
|
||||
this.currentEnergyProduce = recipe.genAmount;
|
||||
this.maxBurnTime = recipe.genTime;
|
||||
this.currentBurnTime = this.maxBurnTime;
|
||||
|
||||
this.tank.drainInternal(fuelUsed, true);
|
||||
}
|
||||
else{
|
||||
this.currentEnergyProduce = 0;
|
||||
this.currentBurnTime = 0;
|
||||
this.maxBurnTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,26 +134,16 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn
|
|||
this.markDirty();
|
||||
}
|
||||
|
||||
if((this.storage.getEnergyStored() != this.lastEnergy || this.tank.getFluidAmount() != this.lastTank || this.lastBurnTime != this.currentBurnTime || this.lastEnergyProduce != this.currentEnergyProduce) && this.sendUpdateWithInterval()){
|
||||
if((this.storage.getEnergyStored() != this.lastEnergy || this.tank.getFluidAmount() != this.lastTank || this.lastBurnTime != this.currentBurnTime || this.lastEnergyProduce != this.currentEnergyProduce || this.lastMaxBurnTime != this.maxBurnTime) && this.sendUpdateWithInterval()){
|
||||
this.lastEnergy = this.storage.getEnergyStored();
|
||||
this.lastTank = this.tank.getFluidAmount();
|
||||
this.lastBurnTime = this.currentBurnTime;
|
||||
this.lastEnergyProduce = this.currentEnergyProduce;
|
||||
this.lastMaxBurnTime = this.maxBurnTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getEnergyForCurrentFluid(){
|
||||
FluidStack stack = this.tank.getFluid();
|
||||
if(stack != null){
|
||||
Fluid fluid = stack.getFluid();
|
||||
if(fluid != null){
|
||||
return ActuallyAdditionsAPI.OIL_GENERATOR_RECIPES.get(fluid.getName());
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate){
|
||||
return this.storage.extractEnergy(maxExtract, simulate);
|
||||
|
|
Loading…
Reference in a new issue