mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-25 16:38:33 +01:00
Compare commits
No commits in common. "9bb1105c7c616ce13186a53dc907c79a68a05aa8" and "ff27e16bc1b34914938162e091233177983cca68" have entirely different histories.
9bb1105c7c
...
ff27e16bc1
9 changed files with 117 additions and 72 deletions
|
@ -57,6 +57,7 @@ public final class ActuallyAdditionsAPI {
|
|||
public static final List<IFarmerBehavior> FARMER_BEHAVIORS = new ArrayList<>();
|
||||
public static final List<CoffeeIngredient> COFFEE_MACHINE_INGREDIENTS = new ArrayList<>();
|
||||
// public static final List<CompostRecipe> COMPOST_RECIPES = new ArrayList<>();
|
||||
public static final List<OilGenRecipe> OIL_GENERATOR_RECIPES = new ArrayList<>();
|
||||
public static final List<IBookletEntry> BOOKLET_ENTRIES = new ArrayList<>();
|
||||
//This is added to automatically, you don't need to add anything to this list
|
||||
public static final List<IBookletChapter> ALL_CHAPTERS = new ArrayList<>();
|
||||
|
@ -178,6 +179,27 @@ public final class ActuallyAdditionsAPI {
|
|||
public static boolean addCrusherRecipes(List<ItemStack> inputs, ItemStack outputOne, int outputOneAmount, ItemStack outputTwo, int outputTwoAmount, int outputTwoChance) {
|
||||
return methodHandler.addCrusherRecipes(inputs, outputOne, outputOneAmount, outputTwo, outputTwoAmount, outputTwoChance);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new conversion recipe to the compost.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* 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-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.api.recipe;
|
||||
|
||||
public class OilGenRecipe {
|
||||
|
||||
public final String fluidName;
|
||||
public final int genAmount;
|
||||
public final int genTime;
|
||||
|
||||
/**
|
||||
* Oil generator recipe
|
||||
* @param fluidName The fluid
|
||||
* @param genAmount The power generated, in CF/t
|
||||
* @param genTime The length the fluid burns for, in seconds
|
||||
*/
|
||||
public OilGenRecipe(String fluidName, int genAmount, int genTime) {
|
||||
this.fluidName = fluidName;
|
||||
this.genAmount = genAmount;
|
||||
this.genTime = genTime;
|
||||
}
|
||||
|
||||
}
|
|
@ -11,7 +11,6 @@
|
|||
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.base.DirectionalBlock;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityOilGenerator;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
@ -29,7 +28,6 @@ import net.minecraft.world.World;
|
|||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockOilGenerator extends DirectionalBlock.Container {
|
||||
|
@ -38,14 +36,8 @@ public class BlockOilGenerator extends DirectionalBlock.Container {
|
|||
super(ActuallyBlocks.defaultPickProps(0).randomTicks());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||
//@Override
|
||||
public TileEntity newBlockEntity(IBlockReader worldIn) {
|
||||
return new TileEntityOilGenerator();
|
||||
}
|
||||
|
||||
|
@ -73,7 +65,7 @@ public class BlockOilGenerator extends DirectionalBlock.Container {
|
|||
}
|
||||
}
|
||||
|
||||
return ActionResultType.SUCCESS;
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -37,14 +37,12 @@ public class CommonConfig {
|
|||
public static class Machines {
|
||||
public static ForgeConfigSpec.IntValue FARMER_AREA;
|
||||
public static ForgeConfigSpec.IntValue RECONSTRUCTOR_POWER;
|
||||
public static ForgeConfigSpec.IntValue OIL_GENERATOR_TRANSFER;
|
||||
|
||||
public static void build() {
|
||||
BUILDER.comment("Machine Settings").push("machineSettings");
|
||||
|
||||
FARMER_AREA = BUILDER.comment("The size of the farmer's farming area. Default is 9x9, must be an odd number.").defineInRange("farmerArea", 9, 1, Integer.MAX_VALUE);
|
||||
RECONSTRUCTOR_POWER = BUILDER.comment("The amount of power the atomic reconstructor can store.").defineInRange("reconstructorPower", 300000, 300000, Integer.MAX_VALUE);
|
||||
OIL_GENERATOR_TRANSFER = BUILDER.comment("The amount of power the oil generator can transfer per tick.").defineInRange("oilGeneratorTransfer", 500, 100, Integer.MAX_VALUE);
|
||||
|
||||
BUILDER.pop();
|
||||
}
|
||||
|
|
|
@ -32,6 +32,12 @@ public final class InitCrafting {
|
|||
// ActuallyAdditionsAPI.addCompostRecipe(Ingredient.fromStacks(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.MASHED_FOOD.ordinal())), Blocks.LEAVES.getDefaultState(), new ItemStack(InitItems.itemFertilizer), Blocks.DIRT.getDefaultState());
|
||||
// ActuallyAdditionsAPI.addCompostRecipe(Ingredient.fromItems(InitItems.itemCanolaSeed), Blocks.DIRT.getDefaultState(), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.BIOMASS.ordinal()), Blocks.SOUL_SAND.getDefaultState());
|
||||
|
||||
int[] power = ConfigIntListValues.OIL_POWER.getValue();
|
||||
int[] time = ConfigIntListValues.OIL_TIME.getValue();
|
||||
ActuallyAdditionsAPI.addOilGenRecipe(InitFluids.CANOLA_OIL.getName(), power[0], time[0]);
|
||||
ActuallyAdditionsAPI.addOilGenRecipe(InitFluids.REFINED_CANOLA_OIL.getName(), power[1], time[1]);
|
||||
ActuallyAdditionsAPI.addOilGenRecipe(InitFluids.CRYSTALLIZED_OIL.getName(), power[2], time[2]);
|
||||
ActuallyAdditionsAPI.addOilGenRecipe(InitFluids.EMPOWERED_OIL.getName(), power[3], time[3]);
|
||||
|
||||
ActuallyAdditionsAPI.addFarmerBehavior(new DefaultFarmerBehavior());
|
||||
ActuallyAdditionsAPI.addFarmerBehavior(new CactusFarmerBehavior());
|
||||
|
|
|
@ -28,13 +28,6 @@ public class LiquidFuelRecipe implements IRecipe<IInventory> {
|
|||
private int totalEnergy;
|
||||
private ResourceLocation id;
|
||||
|
||||
/**
|
||||
* Oil generator recipe
|
||||
* @param id ResourceLocation of the recipe
|
||||
* @param fuel The fluid
|
||||
* @param totalEnergy The total power generated.
|
||||
* @param burnTime The length the fluid burns for, in ticks.
|
||||
*/
|
||||
public LiquidFuelRecipe(ResourceLocation id, FluidStack fuel, int totalEnergy, int burnTime) {
|
||||
this.fuel = fuel;
|
||||
this.burnTime = burnTime;
|
||||
|
@ -59,14 +52,6 @@ public class LiquidFuelRecipe implements IRecipe<IInventory> {
|
|||
return this.fuel.isFluidEqual(stack);
|
||||
}
|
||||
|
||||
public int getFuelAmount() {
|
||||
return this.fuel.getAmount();
|
||||
}
|
||||
|
||||
public FluidStack getFuel() {
|
||||
return fuel;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack assemble(@Nonnull IInventory pInv) {
|
||||
|
|
|
@ -45,10 +45,8 @@ public class GuiOilGenerator extends AAScreen<ContainerOilGenerator> {
|
|||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
this.energy = new EnergyDisplay(this.leftPos + 42, this.topPos + 5, this.generator.storage);
|
||||
this.fluid = new FluidDisplay(this.leftPos + 116, this.topPos + 5, this.generator.tank);
|
||||
titleLabelX = (int) (imageWidth / 2.0f - font.width(title) / 2.0f);
|
||||
titleLabelY = -10;
|
||||
//this.energy = new EnergyDisplay(this.leftPos + 42, this.topPos + 5, this.generator.storage);
|
||||
//this.fluid = new FluidDisplay(this.leftPos + 116, this.topPos + 5, this.generator.tank);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,6 +56,11 @@ public class GuiOilGenerator extends AAScreen<ContainerOilGenerator> {
|
|||
this.fluid.render(matrices, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderLabels(@Nonnull MatrixStack matrices, int x, int y) {
|
||||
AssetUtil.displayNameString(matrices, this.font, this.imageWidth, -10, this.generator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderBg(MatrixStack matrices, float f, int x, int y) {
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
@ -74,13 +77,12 @@ public class GuiOilGenerator extends AAScreen<ContainerOilGenerator> {
|
|||
}
|
||||
|
||||
if (this.generator.maxBurnTime > 0 && this.generator.currentEnergyProduce > 0) {
|
||||
drawCenteredString(matrices, this.font, this.generator.currentEnergyProduce + " " + I18n.get("actuallyadditions.fet"), this.leftPos + 87, this.topPos + 65, 0xFFFFFF);
|
||||
drawCenteredString(matrices, this.font, this.generator.currentEnergyProduce + " " + I18n.get("actuallyadditions.cft"), this.leftPos + 87, this.topPos + 65, 0xFFFFFF);
|
||||
drawCenteredString(matrices, this.font, "for " + this.generator.maxBurnTime + " t", this.leftPos + 87, this.topPos + 75, 0xFFFFFF);
|
||||
matrices.pushPose();
|
||||
matrices.translate(this.leftPos + 87, this.topPos + 85, 0);
|
||||
matrices.scale(0.5625F, 0.5625F, 1F);
|
||||
int usage = this.generator.fuelUsage;
|
||||
drawCenteredString(matrices, this.font, "(per " + usage + " mB)",0, 0, 0xFFFFFF);
|
||||
matrices.scale(0.75F, 0.75F, 1F);
|
||||
float xS = (this.leftPos + 87) * 1.365F - this.font.width("(per 50 mB)") / 2F;
|
||||
StringUtil.renderScaledAsciiString(this.font, "(per 50 mB)", xS, (this.topPos + 85) * 1.345F, 0xFFFFFF, true, 0.75F);
|
||||
matrices.popPose();
|
||||
}
|
||||
|
||||
|
|
|
@ -11,12 +11,14 @@
|
|||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.OilGenRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.LiquidFuelRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntListValues;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerOilGenerator;
|
||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
|
@ -24,12 +26,10 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.templates.FluidTank;
|
||||
|
@ -38,9 +38,12 @@ import javax.annotation.Nonnull;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
public class TileEntityOilGenerator extends TileEntityBase implements ISharingEnergyProvider, ISharingFluidHandler, INamedContainerProvider {
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(50000, 0, CommonConfig.Machines.OIL_GENERATOR_TRANSFER.get());
|
||||
|
||||
int[] i = ConfigIntListValues.OIL_POWER.getValue();
|
||||
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(50000, 0, Math.max(Math.max(this.i[0], this.i[1]), Math.max(this.i[2], this.i[3])) + 20);
|
||||
public final LazyOptional<IEnergyStorage> lazyEnergy = LazyOptional.of(() -> this.storage);
|
||||
public final FluidTank tank = new FluidTank(2 * FluidAttributes.BUCKET_VOLUME, fluid -> getRecipeForFluid(fluid) != null) {
|
||||
public final FluidTank tank = new FluidTank(2 * Util.BUCKET) {
|
||||
@Nonnull
|
||||
@Override
|
||||
public FluidStack drain(FluidStack resource, FluidAction action) {
|
||||
|
@ -52,6 +55,14 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn
|
|||
public FluidStack drain(int maxDrain, FluidAction action) {
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
//@Override
|
||||
public boolean canFillFluidType(FluidStack stack) {
|
||||
Fluid fluid = stack == null
|
||||
? null
|
||||
: stack.getFluid();
|
||||
return fluid != null && getRecipeForFluid(fluid.getRegistryName().toString()) != null;
|
||||
}
|
||||
};
|
||||
public final LazyOptional<IFluidHandler> lazyTank = LazyOptional.of(() -> this.tank);
|
||||
public int currentEnergyProduce;
|
||||
|
@ -63,16 +74,15 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn
|
|||
private int lastMaxBurnTime;
|
||||
private int lastEnergyProduce;
|
||||
private int lastCompare;
|
||||
public int fuelUsage;
|
||||
|
||||
public TileEntityOilGenerator() {
|
||||
super(ActuallyBlocks.OIL_GENERATOR.getTileEntityType());
|
||||
}
|
||||
|
||||
private static LiquidFuelRecipe getRecipeForFluid(FluidStack fluid) {
|
||||
if (fluid != null) {
|
||||
for (LiquidFuelRecipe recipe : ActuallyAdditionsAPI.LIQUID_FUEL_RECIPES) {
|
||||
if (recipe != null && recipe.matches(fluid)) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -85,10 +95,13 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn
|
|||
return this.currentBurnTime * i / this.maxBurnTime;
|
||||
}
|
||||
|
||||
private LiquidFuelRecipe getRecipeForCurrentFluid() {
|
||||
private OilGenRecipe getRecipeForCurrentFluid() {
|
||||
FluidStack stack = this.tank.getFluid();
|
||||
if (!stack.isEmpty()) {
|
||||
return getRecipeForFluid(stack);
|
||||
if (stack != null) {
|
||||
Fluid fluid = stack.getFluid();
|
||||
if (fluid != null) {
|
||||
return getRecipeForFluid(fluid.getRegistryName().toString());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -99,7 +112,6 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn
|
|||
compound.putInt("BurnTime", this.currentBurnTime);
|
||||
compound.putInt("CurrentEnergy", this.currentEnergyProduce);
|
||||
compound.putInt("MaxBurnTime", this.maxBurnTime);
|
||||
compound.putInt("FuelUsage", this.fuelUsage);
|
||||
}
|
||||
this.storage.writeToNBT(compound);
|
||||
this.tank.writeToNBT(compound);
|
||||
|
@ -112,7 +124,6 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn
|
|||
this.currentBurnTime = compound.getInt("BurnTime");
|
||||
this.currentEnergyProduce = compound.getInt("CurrentEnergy");
|
||||
this.maxBurnTime = compound.getInt("MaxBurnTime");
|
||||
this.fuelUsage = compound.getInt("FuelUsage");
|
||||
}
|
||||
this.storage.readFromNBT(compound);
|
||||
this.tank.readFromNBT(compound);
|
||||
|
@ -130,20 +141,19 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn
|
|||
|
||||
this.storage.receiveEnergyInternal(this.currentEnergyProduce, false);
|
||||
} else if (!this.isRedstonePowered) {
|
||||
int fuelUsed = 50;
|
||||
|
||||
LiquidFuelRecipe recipe = this.getRecipeForCurrentFluid();
|
||||
if (recipe != null && this.storage.getEnergyStored() < this.storage.getMaxEnergyStored() && this.tank.getFluidAmount() >= recipe.getFuelAmount()) {
|
||||
fuelUsage = recipe.getFuelAmount();
|
||||
this.currentEnergyProduce = recipe.getTotalEnergy() / recipe.getBurnTime();
|
||||
this.maxBurnTime = recipe.getBurnTime();
|
||||
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.getFluid().shrink(fuelUsage);
|
||||
this.tank.drain(fuelUsed, IFluidHandler.FluidAction.EXECUTE);
|
||||
} else {
|
||||
this.currentEnergyProduce = 0;
|
||||
this.currentBurnTime = 0;
|
||||
this.maxBurnTime = 0;
|
||||
this.fuelUsage = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -216,7 +226,7 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn
|
|||
|
||||
@Override
|
||||
public ITextComponent getDisplayName() {
|
||||
return new TranslationTextComponent("container.actuallyadditions.oilGenerator");
|
||||
return StringTextComponent.EMPTY;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.util;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
|
@ -71,15 +69,16 @@ public final class StringUtil {
|
|||
// }
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static void renderScaledString(MatrixStack matrices, FontRenderer font, String text, float x, float y, int color, boolean shadow, float scale) {
|
||||
matrices.pushPose();
|
||||
matrices.translate(x, y, 0);
|
||||
matrices.scale(scale, scale, 1.0F);
|
||||
if (shadow)
|
||||
font.drawShadow(matrices, text, 0, 0, color);
|
||||
else
|
||||
font.draw(matrices, text, x, y, color);
|
||||
matrices.popPose();
|
||||
public static void renderScaledAsciiString(FontRenderer font, String text, float x, float y, int color, boolean shadow, float scale) {
|
||||
// GlStateManager._pushMatrix();
|
||||
// GlStateManager.scale(scale, scale, scale);
|
||||
// boolean oldUnicode = font.getUnicodeFlag();
|
||||
// font.setUnicodeFlag(false);
|
||||
//
|
||||
// font.draw(text, x / scale, y / scale, color, shadow);
|
||||
//
|
||||
// font.setUnicodeFlag(oldUnicode);
|
||||
// GlStateManager._popMatrix();
|
||||
}
|
||||
|
||||
// static void setupLangMap() {
|
||||
|
|
Loading…
Reference in a new issue