Added different kinds of oils and made oil generator be able to use different types to create different amounts of RF.

This basically closes #224
This commit is contained in:
Ellpeck 2016-09-01 22:11:51 +02:00
parent ca9442e081
commit 340d7cf780
18 changed files with 93 additions and 24 deletions

View file

@ -20,6 +20,7 @@ import de.ellpeck.actuallyadditions.api.recipe.*;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList; import java.util.ArrayList;
@ -41,6 +42,7 @@ public final class ActuallyAdditionsAPI{
public static final Map<Item, IColorLensChanger> RECONSTRUCTOR_LENS_COLOR_CHANGERS = new HashMap<Item, IColorLensChanger>(); 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<CoffeeIngredient> COFFEE_MACHINE_INGREDIENTS = new ArrayList<CoffeeIngredient>();
public static final List<CompostRecipe> COMPOST_RECIPES = new ArrayList<CompostRecipe>(); 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<IBookletEntry> BOOKLET_ENTRIES = new ArrayList<IBookletEntry>(); public static final List<IBookletEntry> BOOKLET_ENTRIES = new ArrayList<IBookletEntry>();
public static final List<BookletPage> BOOKLET_PAGES_WITH_ITEM_DATA = new ArrayList<BookletPage>(); public static final List<BookletPage> BOOKLET_PAGES_WITH_ITEM_DATA = new ArrayList<BookletPage>();
@ -147,6 +149,15 @@ public final class ActuallyAdditionsAPI{
} }
} }
/**
* 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){
OIL_GENERATOR_RECIPES.put(fluidName, genAmount);
}
/** /**
* Adds a new conversion recipe to the compost. * Adds a new conversion recipe to the compost.
* StackSize is regarded on both input and output and they can be different. * StackSize is regarded on both input and output and they can be different.

View file

@ -150,7 +150,7 @@ public final class InitBooklet{
//RF Generating Blocks //RF Generating Blocks
new BookletChapter("solarPanel", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockFurnaceSolar), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityFurnaceSolar.PRODUCE), new PageCrafting(2, BlockCrafting.recipeSolar).setNoText()); new BookletChapter("solarPanel", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockFurnaceSolar), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityFurnaceSolar.PRODUCE), new PageCrafting(2, BlockCrafting.recipeSolar).setNoText());
new BookletChapter("heatCollector", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockHeatCollector), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityHeatCollector.ENERGY_PRODUCE).addTextReplacement("<min>", TileEntityHeatCollector.BLOCKS_NEEDED), new PageCrafting(2, BlockCrafting.recipeHeatCollector).setNoText()); new BookletChapter("heatCollector", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockHeatCollector), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityHeatCollector.ENERGY_PRODUCE).addTextReplacement("<min>", TileEntityHeatCollector.BLOCKS_NEEDED), new PageCrafting(2, BlockCrafting.recipeHeatCollector).setNoText());
new BookletChapter("canola", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockFermentingBarrel), new PageTextOnly(1).setStacks(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CANOLA.ordinal())).addTextReplacement("<pressRF>", TileEntityCanolaPress.ENERGY_USE).addTextReplacement("<canola>", TileEntityCanolaPress.PRODUCE).addTextReplacement("<rf>", TileEntityOilGenerator.ENERGY_PRODUCED), new PageTextOnly(2).setStacks(new ItemStack(InitItems.itemCanolaSeed), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.BIOMASS.ordinal()), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.BIOCOAL.ordinal())), new PageCrafting(3, BlockCrafting.recipeCanolaPress).setNoText(), new PageCrafting(4, BlockCrafting.recipeFermentingBarrel).setNoText(), new PageCrafting(4, BlockCrafting.recipeOilGen).setNoText().setPageStacksWildcard()); new BookletChapter("canola", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockFermentingBarrel), new PageTextOnly(1).setStacks(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CANOLA.ordinal())).addTextReplacement("<pressRF>", TileEntityCanolaPress.ENERGY_USE).addTextReplacement("<canola>", TileEntityCanolaPress.PRODUCE), new PageTextOnly(2).setStacks(new ItemStack(InitItems.itemCanolaSeed), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.BIOMASS.ordinal()), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.BIOCOAL.ordinal())), new PageCrafting(3, BlockCrafting.recipeCanolaPress).setNoText(), new PageCrafting(4, BlockCrafting.recipeFermentingBarrel).setNoText(), new PageCrafting(4, BlockCrafting.recipeOilGen).setNoText().setPageStacksWildcard());
new BookletChapter("leafGen", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockLeafGenerator), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityLeafGenerator.ENERGY_PRODUCED).addTextReplacement("<range>", TileEntityLeafGenerator.RANGE), new PageCrafting(2, BlockCrafting.recipeLeafGen)).setImportant(); new BookletChapter("leafGen", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockLeafGenerator), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityLeafGenerator.ENERGY_PRODUCED).addTextReplacement("<range>", TileEntityLeafGenerator.RANGE), new PageCrafting(2, BlockCrafting.recipeLeafGen)).setImportant();
//No RF Using Items //No RF Using Items

View file

@ -11,6 +11,7 @@
package de.ellpeck.actuallyadditions.mod.crafting; package de.ellpeck.actuallyadditions.mod.crafting;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
import de.ellpeck.actuallyadditions.mod.items.InitItems; import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
@ -32,6 +33,11 @@ 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.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.addCompostRecipe(new ItemStack(InitItems.itemCanolaSeed, 20), Blocks.DIRT, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.BIOMASS.ordinal()), Blocks.SOUL_SAND);
ActuallyAdditionsAPI.addOilGenRecipe(InitFluids.fluidCanolaOil.getName(), 30);
ActuallyAdditionsAPI.addOilGenRecipe(InitFluids.fluidOil.getName(), 70);
ActuallyAdditionsAPI.addOilGenRecipe(InitFluids.fluidCrystalOil.getName(), 125);
ActuallyAdditionsAPI.addOilGenRecipe(InitFluids.fluidEmpoweredOil.getName(), 200);
RecipeSorter.register(ModUtil.MOD_ID+":recipeKeepDataShaped", RecipeKeepDataShaped.class, RecipeSorter.Category.SHAPED, "after:minecraft:shaped"); 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"); RecipeSorter.register(ModUtil.MOD_ID+":recipeKeepDataShapeless", RecipeKeepDataShapeless.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless");
} }

View file

@ -189,8 +189,11 @@ public class CreativeTab extends CreativeTabs{
this.add(InitItems.itemMagnetRing); this.add(InitItems.itemMagnetRing);
this.add(InitItems.itemWaterRemovalRing); this.add(InitItems.itemWaterRemovalRing);
this.list.add(UniversalBucket.getFilledBucket(ForgeModContainer.getInstance().universalBucket, InitFluids.fluidCanolaOil)); UniversalBucket bucket = ForgeModContainer.getInstance().universalBucket;
this.list.add(UniversalBucket.getFilledBucket(ForgeModContainer.getInstance().universalBucket, InitFluids.fluidOil)); this.list.add(UniversalBucket.getFilledBucket(bucket, InitFluids.fluidCanolaOil));
this.list.add(UniversalBucket.getFilledBucket(bucket, InitFluids.fluidOil));
this.list.add(UniversalBucket.getFilledBucket(bucket, InitFluids.fluidCrystalOil));
this.list.add(UniversalBucket.getFilledBucket(bucket, InitFluids.fluidEmpoweredOil));
this.add(InitItems.itemPhantomConnector); this.add(InitItems.itemPhantomConnector);
this.add(InitItems.itemFilter); this.add(InitItems.itemFilter);

View file

@ -23,16 +23,24 @@ public final class InitFluids{
public static Fluid fluidCanolaOil; public static Fluid fluidCanolaOil;
public static Fluid fluidOil; public static Fluid fluidOil;
public static Fluid fluidCrystalOil;
public static Fluid fluidEmpoweredOil;
public static Block blockCanolaOil; public static Block blockCanolaOil;
public static Block blockOil; public static Block blockOil;
public static Block blockCrystalOil;
public static Block blockEmpoweredOil;
public static void init(){ public static void init(){
fluidCanolaOil = registerFluid("canolaoil", "blockCanolaOil", EnumRarity.UNCOMMON); fluidCanolaOil = registerFluid("canolaoil", "blockCanolaOil", EnumRarity.UNCOMMON);
fluidOil = registerFluid("oil", "blockOil", EnumRarity.UNCOMMON); fluidOil = registerFluid("oil", "blockOil", EnumRarity.UNCOMMON);
fluidCrystalOil = registerFluid("crystaloil", "blockCrystalOil", EnumRarity.RARE);
fluidEmpoweredOil = registerFluid("empoweredoil", "blockEmpoweredOil", EnumRarity.EPIC);
blockCanolaOil = registerFluidBlock(fluidCanolaOil, Material.WATER, "blockCanolaOil"); blockCanolaOil = registerFluidBlock(fluidCanolaOil, Material.WATER, "blockCanolaOil");
blockOil = registerFluidBlock(fluidOil, Material.WATER, "blockOil"); blockOil = registerFluidBlock(fluidOil, Material.WATER, "blockOil");
blockCrystalOil = registerFluidBlock(fluidCrystalOil, Material.WATER, "blockCrystalOil");
blockEmpoweredOil = registerFluidBlock(fluidEmpoweredOil, Material.WATER, "blockEmpoweredOil");
} }
private static Fluid registerFluid(String fluidName, String fluidTextureName, EnumRarity rarity){ private static Fluid registerFluid(String fluidName, String fluidTextureName, EnumRarity rarity){

View file

@ -80,6 +80,10 @@ public class GuiOilGenerator extends GuiContainer{
this.drawTexturedModalRect(this.guiLeft+72, this.guiTop+44+12-i, 176, 96-i, 14, i); 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);
}
this.energy.draw(); this.energy.draw();
this.fluid.draw(); this.fluid.draw();
} }

View file

@ -110,6 +110,8 @@ public class ClientProxy implements IProxy{
this.registerCustomFluidBlockRenderer(InitFluids.fluidCanolaOil); this.registerCustomFluidBlockRenderer(InitFluids.fluidCanolaOil);
this.registerCustomFluidBlockRenderer(InitFluids.fluidOil); this.registerCustomFluidBlockRenderer(InitFluids.fluidOil);
this.registerCustomFluidBlockRenderer(InitFluids.fluidCrystalOil);
this.registerCustomFluidBlockRenderer(InitFluids.fluidEmpoweredOil);
IResourceManager manager = Minecraft.getMinecraft().getResourceManager(); IResourceManager manager = Minecraft.getMinecraft().getResourceManager();
if(manager instanceof IReloadableResourceManager){ if(manager instanceof IReloadableResourceManager){

View file

@ -11,8 +11,7 @@
package de.ellpeck.actuallyadditions.mod.tile; package de.ellpeck.actuallyadditions.mod.tile;
import cofh.api.energy.EnergyStorage; import cofh.api.energy.EnergyStorage;
import cofh.api.energy.IEnergyProvider; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
import de.ellpeck.actuallyadditions.mod.util.Util; import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
@ -24,7 +23,6 @@ import net.minecraftforge.fml.relauncher.SideOnly;
public class TileEntityOilGenerator extends TileEntityBase implements ISharingEnergyProvider, ISharingFluidHandler{ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEnergyProvider, ISharingFluidHandler{
public static final int ENERGY_PRODUCED = 76;
private static final int BURN_TIME = 100; private static final int BURN_TIME = 100;
public final EnergyStorage storage = new EnergyStorage(50000); public final EnergyStorage storage = new EnergyStorage(50000);
public final FluidTank tank = new FluidTank(2*Util.BUCKET){ public final FluidTank tank = new FluidTank(2*Util.BUCKET){
@ -34,29 +32,22 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn
} }
@Override @Override
public boolean canFillFluidType(FluidStack fluid){ public boolean canFillFluidType(FluidStack stack){
return fluid.getFluid() == InitFluids.fluidOil; Fluid fluid = stack.getFluid();
return fluid != null && ActuallyAdditionsAPI.OIL_GENERATOR_RECIPES.containsKey(fluid.getName());
} }
}; };
public int currentEnergyProduce;
public int currentBurnTime; public int currentBurnTime;
private int lastEnergy; private int lastEnergy;
private int lastTank; private int lastTank;
private int lastBurnTime; private int lastBurnTime;
private int lastEnergyProduce;
public TileEntityOilGenerator(){ public TileEntityOilGenerator(){
super("oilGenerator"); super("oilGenerator");
} }
@SideOnly(Side.CLIENT)
public int getEnergyScaled(int i){
return this.storage.getEnergyStored()*i/this.storage.getMaxEnergyStored();
}
@SideOnly(Side.CLIENT)
public int getTankScaled(int i){
return this.tank.getFluidAmount()*i/this.tank.getCapacity();
}
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int getBurningScaled(int i){ public int getBurningScaled(int i){
return this.currentBurnTime*i/BURN_TIME; return this.currentBurnTime*i/BURN_TIME;
@ -66,6 +57,7 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn
public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ public void writeSyncableNBT(NBTTagCompound compound, NBTType type){
if(type != NBTType.SAVE_BLOCK){ if(type != NBTType.SAVE_BLOCK){
compound.setInteger("BurnTime", this.currentBurnTime); compound.setInteger("BurnTime", this.currentBurnTime);
compound.setInteger("CurrentEnergy", this.currentEnergyProduce);
} }
this.storage.writeToNBT(compound); this.storage.writeToNBT(compound);
this.tank.writeToNBT(compound); this.tank.writeToNBT(compound);
@ -76,6 +68,7 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn
public void readSyncableNBT(NBTTagCompound compound, NBTType type){ public void readSyncableNBT(NBTTagCompound compound, NBTType type){
if(type != NBTType.SAVE_BLOCK){ if(type != NBTType.SAVE_BLOCK){
this.currentBurnTime = compound.getInteger("BurnTime"); this.currentBurnTime = compound.getInteger("BurnTime");
this.currentEnergyProduce = compound.getInteger("CurrentEnergy");
} }
this.storage.readFromNBT(compound); this.storage.readFromNBT(compound);
this.tank.readFromNBT(compound); this.tank.readFromNBT(compound);
@ -88,31 +81,47 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn
if(!this.worldObj.isRemote){ if(!this.worldObj.isRemote){
boolean flag = this.currentBurnTime > 0; boolean flag = this.currentBurnTime > 0;
if(this.currentBurnTime > 0){ if(this.currentBurnTime > 0 && this.currentEnergyProduce > 0){
this.currentBurnTime--; this.currentBurnTime--;
this.storage.receiveEnergy(ENERGY_PRODUCED, false); this.storage.receiveEnergy(this.currentEnergyProduce, false);
} }
else{
this.currentEnergyProduce = this.getEnergyForCurrentFluid();
int fuelUsed = 50; int fuelUsed = 50;
if(ENERGY_PRODUCED*BURN_TIME <= this.storage.getMaxEnergyStored()-this.storage.getEnergyStored()){ if(this.storage.getEnergyStored() < this.storage.getMaxEnergyStored() && this.tank.getFluidAmount() >= fuelUsed){
if(this.currentBurnTime <= 0 && this.tank.getFluidAmount() >= fuelUsed){
this.currentBurnTime = BURN_TIME; this.currentBurnTime = BURN_TIME;
this.tank.drainInternal(fuelUsed, true); this.tank.drainInternal(fuelUsed, true);
} }
else{
this.currentBurnTime = 0;
}
} }
if(flag != this.currentBurnTime > 0){ if(flag != this.currentBurnTime > 0){
this.markDirty(); this.markDirty();
} }
if((this.storage.getEnergyStored() != this.lastEnergy || this.tank.getFluidAmount() != this.lastTank || this.lastBurnTime != this.currentBurnTime) && this.sendUpdateWithInterval()){ if((this.storage.getEnergyStored() != this.lastEnergy || this.tank.getFluidAmount() != this.lastTank || this.lastBurnTime != this.currentBurnTime || this.lastEnergyProduce != this.currentEnergyProduce) && this.sendUpdateWithInterval()){
this.lastEnergy = this.storage.getEnergyStored(); this.lastEnergy = this.storage.getEnergyStored();
this.lastTank = this.tank.getFluidAmount(); this.lastTank = this.tank.getFluidAmount();
this.lastBurnTime = this.currentBurnTime; this.lastBurnTime = this.currentBurnTime;
this.lastEnergyProduce = this.currentEnergyProduce;
} }
} }
} }
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 @Override
public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate){ public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate){
return this.storage.extractEnergy(maxExtract, simulate); return this.storage.extractEnergy(maxExtract, simulate);

View file

@ -8,6 +8,14 @@
"oil": { "oil": {
"model": "forge:fluid", "model": "forge:fluid",
"custom": { "fluid": "oil" } "custom": { "fluid": "oil" }
},
"crystaloil": {
"model": "forge:fluid",
"custom": { "fluid": "crystaloil" }
},
"empoweredoil": {
"model": "forge:fluid",
"custom": { "fluid": "empoweredoil" }
} }
} }
} }

View file

@ -6,6 +6,8 @@ actuallyadditions.lolWutHowUDoDis.name=This is bugged. Throw it away. Please.
#Fluids #Fluids
fluid.actuallyadditions.oil=Oil fluid.actuallyadditions.oil=Oil
fluid.actuallyadditions.canolaoil=Canola Oil fluid.actuallyadditions.canolaoil=Canola Oil
fluid.actuallyadditions.crystaloil=Crystallized Oil
fluid.actuallyadditions.empoweredoil=Empowered Oil
#Banners #Banners
item.banner.actuallyadditionsBook.black=Black Actually Additions Manual Pattern item.banner.actuallyadditionsBook.black=Black Actually Additions Manual Pattern

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View file

@ -0,0 +1,3 @@
{
"animation": {}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

View file

@ -0,0 +1,5 @@
{
"animation": {
"frametime": 2
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View file

@ -0,0 +1,5 @@
{
"animation": {
"frametime": 2
}
}