Feature/refactoring (#81)

* Added some localization

* Added some localization

* Added some localization

* Added some localization
This commit is contained in:
Alexander Kornilov authored and mezz committed 2017-05-30 21:45:37 -07:00
1 parent 618b291015
commit b5a6919f7f
32 files changed
+362 -142

No files matched your search

@@ -46,7 +46,8 @@ public class GardenLogic extends FarmLogic {
public GardenLogic(IFarmHousing housing) {
super(housing);
produce = new ArrayList<>();
(farmables = new ArrayList<>()).add(new FarmableFlower());
farmables = new ArrayList<>();
farmables.add(new FarmableFlower());
farmables.add(new FarmableVanillaFlower());
}
@@ -81,7 +82,7 @@ public class GardenLogic extends FarmLogic {
public boolean cultivate(int x, int y, int z, FarmDirection direction, int extent) {
world = housing.getWorld();
return maintainSoil(x, y, z, direction, extent)
|| (!isManual && maintainWater(x, y, z, direction, extent))
|| !isManual && maintainWater(x, y, z, direction, extent)
|| maintainCrops(x, y + 1, z, direction, extent);
}
@@ -135,6 +136,7 @@ public class GardenLogic extends FarmLogic {
if (i % 2 == 0) {
return trySetSoil(position);
}
FarmDirection cclock = FarmDirection.EAST;
if (direction == FarmDirection.EAST) {
cclock = FarmDirection.SOUTH;
@@ -143,6 +145,7 @@ public class GardenLogic extends FarmLogic {
} else if (direction == FarmDirection.WEST) {
cclock = FarmDirection.SOUTH;
}
Vect previous = translateWithOffset(position.x, position.y, position.z, cclock, 1);
ItemStack soil2 = getAsItemStack(previous);
if (!Gardening.isSoil(soil2.getItem())) {
@@ -186,14 +189,31 @@ public class GardenLogic extends FarmLogic {
private ItemStack getAvailableLoam() {
EnumMoisture[] moistures;
if (moisture == EnumMoisture.DAMP) {
moistures = new EnumMoisture[]{EnumMoisture.DAMP, EnumMoisture.NORMAL, EnumMoisture.DRY};
moistures = new EnumMoisture[]{
EnumMoisture.DAMP,
EnumMoisture.NORMAL,
EnumMoisture.DRY
};
} else if (moisture == EnumMoisture.DRY) {
moistures = new EnumMoisture[]{EnumMoisture.DRY, EnumMoisture.DAMP, EnumMoisture.DRY};
moistures = new EnumMoisture[]{
EnumMoisture.DRY,
EnumMoisture.DAMP,
EnumMoisture.DRY
};
} else {
moistures = new EnumMoisture[]{EnumMoisture.DRY, EnumMoisture.NORMAL, EnumMoisture.DAMP};
moistures = new EnumMoisture[]{
EnumMoisture.DRY,
EnumMoisture.NORMAL,
EnumMoisture.DAMP
};
}
EnumAcidity[] acidities = {EnumAcidity.NEUTRAL, EnumAcidity.ACID, EnumAcidity.ALKALINE};
EnumAcidity[] acidities = {
EnumAcidity.NEUTRAL,
EnumAcidity.ACID,
EnumAcidity.ALKALINE
};
for (EnumMoisture moist : moistures) {
for (EnumAcidity acid : acidities) {
for (Block type : new Block[]{Botany.flowerbed, Botany.loam, Botany.soil}) {
@@ -205,6 +225,7 @@ public class GardenLogic extends FarmLogic {
}
}
}
if (housing.getFarmInventory().hasResources(new ItemStack[]{new ItemStack(Blocks.dirt)})) {
return new ItemStack(Blocks.dirt);
}
@@ -217,15 +238,17 @@ public class GardenLogic extends FarmLogic {
private boolean trySetSoil(Vect position, ItemStack loam) {
ItemStack copy = loam;
if (loam != null) {
if (loam.getItem() == Item.getItemFromBlock(Blocks.dirt)) {
loam = new ItemStack(Botany.soil, 0, 4);
}
setBlock(position, ((ItemBlock) loam.getItem()).field_150939_a, loam.getItemDamage());
housing.getFarmInventory().removeResources(new ItemStack[]{copy});
return true;
if (loam == null) {
return false;
}
return false;
if (loam.getItem() == Item.getItemFromBlock(Blocks.dirt)) {
loam = new ItemStack(Botany.soil, 0, 4);
}
setBlock(position, ((ItemBlock) loam.getItem()).field_150939_a, loam.getItemDamage());
housing.getFarmInventory().removeResources(new ItemStack[]{copy});
return true;
}
private boolean trySetWater(Vect position) {
@@ -195,7 +195,7 @@ public class BlockFlower extends BlockContainer {
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int blockMeta, int fortune) {
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
ArrayList<ItemStack> drops = new ArrayList<>();
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).getSection() == 0) {
ItemStack flower = ((TileEntityFlower) tile).getItemStack();
@@ -4,7 +4,6 @@ import forestry.api.genetics.IAlleleInteger;
public class AlleleColor implements IAlleleInteger {
private String uid;
private String name;
private int value;
private EnumFlowerColor color;
private boolean dominant = true;
@@ -12,7 +11,6 @@ public class AlleleColor implements IAlleleInteger {
public AlleleColor(EnumFlowerColor color, String uid, String name, int value) {
this.color = color;
this.uid = uid;
this.name = name;
this.value = value;
}
@@ -1,5 +1,6 @@
package binnie.core.craftgui.minecraft.control;
import binnie.core.BinnieCore;
import binnie.core.craftgui.CraftGUI;
import binnie.core.craftgui.IWidget;
import binnie.core.craftgui.Tooltip;
@@ -14,6 +15,7 @@ import binnie.core.craftgui.resource.minecraft.CraftGUITexture;
import binnie.core.machines.inventory.InventorySlot;
import binnie.core.machines.inventory.MachineSide;
import binnie.core.machines.inventory.SlotValidator;
import binnie.core.util.I18N;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.multiplayer.PlayerControllerMP;
import net.minecraft.entity.player.InventoryPlayer;
@@ -142,7 +144,7 @@ public class ControlSlot extends ControlSlotBase {
}
private List<ControlSlot> getControlSlots() {
List<ControlSlot> slots = new ArrayList<ControlSlot>();
List<ControlSlot> slots = new ArrayList<>();
if (getParent() instanceof ControlSlotArray || getParent() instanceof ControlPlayerInventory) {
for (IWidget child : getParent().getWidgets()) {
slots.add((ControlSlot) child);
@@ -166,11 +168,9 @@ public class ControlSlot extends ControlSlotBase {
}
public ControlSlot assign(InventoryType inventory, int index) {
if (slot != null) {
return this;
if (slot == null) {
slot = ((Window) getSuperParent()).getContainer().getOrCreateSlot(inventory, index);
}
slot = ((Window) getSuperParent()).getContainer().getOrCreateSlot(inventory, index);
return this;
}
@@ -183,22 +183,34 @@ public class ControlSlot extends ControlSlotBase {
InventorySlot slot = getInventorySlot();
if (getInventorySlot() != null) {
tooltip.add(slot.getName());
tooltip.add("Insert Side: " + MachineSide.asString(slot.getInputSides()));
tooltip.add("Extract Side: " + MachineSide.asString(slot.getOutputSides()));
tooltip.add(I18N.localise(BinnieCore.instance, "gui.side.insertSide", MachineSide.asString(slot.getInputSides())));
tooltip.add(I18N.localise(BinnieCore.instance, "gui.side.extractSide", MachineSide.asString(slot.getOutputSides())));
if (slot.isReadOnly()) {
tooltip.add("Pickup Only Slot");
tooltip.add(I18N.localise(BinnieCore.instance, "gui.slot.pickupOnly"));
}
if (slot.getValidator() == null) {
tooltip.add(I18N.localise(BinnieCore.instance, "gui.slot.accepts", I18N.localise(BinnieCore.instance, "gui.slot.anyItem")));
} else {
tooltip.add(I18N.localise(BinnieCore.instance, "gui.slot.accepts", slot.getValidator().getTooltip()));
}
tooltip.add("Accepts: " + ((slot.getValidator() == null) ? "Any Item" : slot.getValidator().getTooltip()));
} else if (this.slot.inventory instanceof WindowInventory) {
SlotValidator s = ((WindowInventory) this.slot.inventory).getValidator(this.slot.getSlotIndex());
tooltip.add("Accepts: " + ((s == null) ? "Any Item" : s.getTooltip()));
if (s == null) {
tooltip.add(I18N.localise(BinnieCore.instance, "gui.slot.accepts", I18N.localise(BinnieCore.instance, "gui.slot.anyItem")));
} else {
tooltip.add(I18N.localise(BinnieCore.instance, "gui.slot.accepts", s.getTooltip()));
}
} else if (this.slot.inventory instanceof InventoryPlayer) {
tooltip.add("Player Inventory");
tooltip.add(I18N.localise(BinnieCore.instance, "gui.slot.playerInventory"));
}
}
public InventorySlot getInventorySlot() {
return (slot instanceof CustomSlot) ? ((CustomSlot) slot).getInventorySlot() : null;
return (slot instanceof CustomSlot)
? ((CustomSlot) slot).getInventorySlot()
: null;
}
static {
@@ -1,5 +1,6 @@
package binnie.core.craftgui.minecraft.control;
import binnie.core.BinnieCore;
import binnie.core.craftgui.CraftGUI;
import binnie.core.craftgui.ITooltip;
import binnie.core.craftgui.IWidget;
@@ -7,6 +8,7 @@ import binnie.core.craftgui.Tooltip;
import binnie.core.craftgui.WidgetAttribute;
import binnie.core.craftgui.controls.core.Control;
import binnie.core.craftgui.resource.minecraft.CraftGUITexture;
import binnie.core.util.I18N;
public class ControlUser extends Control implements ITooltip {
protected String team;
@@ -28,8 +30,9 @@ public class ControlUser extends Control implements ITooltip {
@Override
public void getTooltip(Tooltip tooltip) {
tooltip.setType(Tooltip.Type.User);
tooltip.add("Owner");
if (username != "") {
tooltip.add(I18N.localise(BinnieCore.instance, "gui.tooltip.owner"));
if (!username.isEmpty()) {
tooltip.add(username);
}
tooltip.setMaxWidth(200);
@@ -1,24 +1,37 @@
package binnie.core.machines.inventory;
import binnie.core.BinnieCore;
import binnie.core.util.I18N;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.Collection;
import java.util.EnumSet;
public class MachineSide {
private static EnumSet<ForgeDirection> All = EnumSet.of(ForgeDirection.UP, ForgeDirection.DOWN, ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.EAST, ForgeDirection.WEST);
public static EnumSet<ForgeDirection> TopAndBottom = EnumSet.of(ForgeDirection.UP, ForgeDirection.DOWN);
public static EnumSet<ForgeDirection> None = EnumSet.noneOf(ForgeDirection.class);
public static EnumSet<ForgeDirection> Top = EnumSet.of(ForgeDirection.UP);
public static EnumSet<ForgeDirection> Bottom = EnumSet.of(ForgeDirection.DOWN);
public static EnumSet<ForgeDirection> Sides = EnumSet.of(ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.EAST, ForgeDirection.WEST);
public static final EnumSet<ForgeDirection> TOP_AND_BOTTOM = EnumSet.of(ForgeDirection.UP, ForgeDirection.DOWN);
public static final EnumSet<ForgeDirection> NONE = EnumSet.noneOf(ForgeDirection.class);
public static final EnumSet<ForgeDirection> SIDES = EnumSet.of(
ForgeDirection.NORTH,
ForgeDirection.SOUTH,
ForgeDirection.EAST,
ForgeDirection.WEST
);
private static final EnumSet<ForgeDirection> ALL = EnumSet.of(
ForgeDirection.UP,
ForgeDirection.DOWN,
ForgeDirection.NORTH,
ForgeDirection.SOUTH,
ForgeDirection.EAST,
ForgeDirection.WEST
);
public static String asString(Collection<ForgeDirection> sides) {
if (sides.containsAll(MachineSide.All)) {
return "Any";
if (sides.containsAll(MachineSide.ALL)) {
return I18N.localise(BinnieCore.instance, "gui.side.any");
}
if (sides.isEmpty()) {
return "None";
return I18N.localise(BinnieCore.instance, "gui.side.none");
}
String text = "";
@@ -26,48 +39,48 @@ public class MachineSide {
if (sides.size() > 0) {
text += ", ";
}
text += "Up";
text += I18N.localise(BinnieCore.instance, "gui.side.up");
}
if (sides.contains(ForgeDirection.DOWN)) {
if (sides.size() > 0) {
text += ", ";
}
text += "Down";
text += I18N.localise(BinnieCore.instance, "gui.side.down");
}
if (sides.containsAll(MachineSide.Sides)) {
if (sides.containsAll(MachineSide.SIDES)) {
if (sides.size() > 0) {
text += ", ";
}
text += "Sides";
text += I18N.localise(BinnieCore.instance, "gui.side.sides");
} else {
if (sides.contains(ForgeDirection.NORTH)) {
if (sides.size() > 0) {
text += ", ";
}
text += "North";
text += I18N.localise(BinnieCore.instance, "gui.side.north");
}
if (sides.contains(ForgeDirection.EAST)) {
if (sides.size() > 0) {
text += ", ";
}
text += "East";
text += I18N.localise(BinnieCore.instance, "gui.side.east");
}
if (sides.contains(ForgeDirection.SOUTH)) {
if (sides.size() > 0) {
text += ", ";
}
text += "South";
text += I18N.localise(BinnieCore.instance, "gui.side.south");
}
if (sides.contains(ForgeDirection.WEST)) {
if (sides.size() > 0) {
text += ", ";
}
text += "West";
text += I18N.localise(BinnieCore.instance, "gui.side.west");
}
}
return text;
@@ -1,5 +1,7 @@
package binnie.core.machines.inventory;
import binnie.core.BinnieCore;
import binnie.core.util.I18N;
import forestry.api.genetics.AlleleManager;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
@@ -53,7 +55,7 @@ public abstract class SlotValidator extends Validator<ItemStack> {
@Override
public String getTooltip() {
return "Breedable Individual";
return I18N.localise(BinnieCore.instance, "gui.slot.breedableIndividual");
}
}
}
@@ -174,11 +174,11 @@ public class Brewery {
ComponentTankContainer tanks = new ComponentTankContainer(machine);
tanks.addTank(Brewery.tankInput, "input", 5000);
tanks.getTankSlot(Brewery.tankInput).setValidator(new TankValidatorFermentInput());
tanks.getTankSlot(Brewery.tankInput).setOutputSides(MachineSide.TopAndBottom);
tanks.getTankSlot(Brewery.tankInput).setOutputSides(MachineSide.TOP_AND_BOTTOM);
tanks.addTank(Brewery.tankOutput, "output", 5000);
tanks.getTankSlot(Brewery.tankOutput).setValidator(new TankValidatorFermentOutput());
tanks.getTankSlot(Brewery.tankOutput).forbidInsertion();
tanks.getTankSlot(Brewery.tankOutput).setOutputSides(MachineSide.Sides);
tanks.getTankSlot(Brewery.tankOutput).setOutputSides(MachineSide.SIDES);
new ComponentPowerReceptor(machine);
new ComponentBreweryLogic(machine);
@@ -81,11 +81,11 @@ public class Distillery {
ComponentTankContainer tanks = new ComponentTankContainer(machine);
tanks.addTank(Distillery.tankInput, "input", 5000);
tanks.getTankSlot(Distillery.tankInput).setValidator(new TankValidatorDistilleryInput());
tanks.getTankSlot(Distillery.tankInput).setOutputSides(MachineSide.TopAndBottom);
tanks.getTankSlot(Distillery.tankInput).setOutputSides(MachineSide.TOP_AND_BOTTOM);
tanks.addTank(Distillery.tankOutput, "output", 5000);
tanks.getTankSlot(Distillery.tankOutput).setValidator(new TankValidatorDistilleryOutput());
tanks.getTankSlot(Distillery.tankOutput).setReadOnly();
tanks.getTankSlot(Distillery.tankOutput).setOutputSides(MachineSide.Sides);
tanks.getTankSlot(Distillery.tankOutput).setOutputSides(MachineSide.SIDES);
new ComponentPowerReceptor(machine);
new ComponentDistilleryLogic(machine);
}
@@ -14,6 +14,7 @@ import binnie.core.craftgui.minecraft.control.ControlSlot;
import binnie.core.craftgui.minecraft.control.ControlSlotArray;
import binnie.core.craftgui.resource.Texture;
import binnie.core.craftgui.resource.minecraft.StandardTexture;
import binnie.core.util.I18N;
import binnie.genetics.Genetics;
import binnie.genetics.core.GeneticsTexture;
import binnie.genetics.machine.incubator.Incubator;
@@ -22,8 +23,8 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
public class WindowIncubator extends WindowMachine {
protected static Texture ProgressBase = new StandardTexture(0, 91, 38, 32, GeneticsTexture.GUIProcess);
protected static Texture Progress = new StandardTexture(38, 91, 38, 32, GeneticsTexture.GUIProcess);
protected static Texture progressBase = new StandardTexture(0, 91, 38, 32, GeneticsTexture.GUIProcess);
protected static Texture progress = new StandardTexture(38, 91, 38, 32, GeneticsTexture.GUIProcess);
public WindowIncubator(EntityPlayer player, IInventory inventory, Side side) {
super(228, 196, player, inventory, side);
@@ -35,23 +36,23 @@ public class WindowIncubator extends WindowMachine {
@Override
public void initialiseClient() {
setTitle("Incubator");
setTitle(getTitle());
int x = 16;
int y = 32;
new ControlLiquidTank(this, x, y).setTankID(0);
new ControlLiquidTank(this, x, y).setTankID(Incubator.TANK_INPUT);
x += 26;
new ControlSlotArray(this, x, y + 3, 1, 3).create(Incubator.SLOT_QUEUE);
x += 20;
new ControlIconDisplay(this, x, y + 3 + 10, GUIIcon.ArrowRight.getIcon());
x += 18;
new ControlMachineProgress(this, x, y + 6, WindowIncubator.ProgressBase, WindowIncubator.Progress, Position.LEFT);
new ControlSlot(this, x + 11, y + 3 + 10).assign(3);
new ControlMachineProgress(this, x, y + 6, WindowIncubator.progressBase, WindowIncubator.progress, Position.LEFT);
new ControlSlot(this, x + 10, y + 3 + 10).assign(Incubator.SLOT_INCUBATOR);
x += 40;
new ControlIconDisplay(this, x, y + 3 + 10, GUIIcon.ArrowRight.getIcon());
x += 18;
new ControlSlotArray(this, x, y + 3, 1, 3).create(Incubator.SLOT_OUTPUT);
x += 26;
new ControlLiquidTank(this, x, y).setTankID(1);
new ControlLiquidTank(this, x, y).setTankID(Incubator.TANK_OUTPUT);
x += 34;
new ControlEnergyBar(this, x, y + 3, 16, 54, Position.BOTTOM);
new ControlErrorState(this, 91.0f, 82.0f);
@@ -60,7 +61,7 @@ public class WindowIncubator extends WindowMachine {
@Override
public String getTitle() {
return "Incubator";
return I18N.localise(Genetics.instance, "machine.labMachine.incubator");
}
@Override
@@ -70,6 +71,6 @@ public class WindowIncubator extends WindowMachine {
@Override
protected String getName() {
return "Incubator";
return getTitle();
}
}
@@ -16,6 +16,7 @@ import binnie.core.craftgui.minecraft.control.ControlSlot;
import binnie.core.craftgui.minecraft.control.ControlSlotArray;
import binnie.core.craftgui.resource.Texture;
import binnie.core.craftgui.resource.minecraft.StandardTexture;
import binnie.core.util.I18N;
import binnie.genetics.Genetics;
import binnie.genetics.core.GeneticsTexture;
import binnie.genetics.machine.inoculator.Inoculator;
@@ -37,7 +38,7 @@ public class WindowInoculator extends WindowMachine {
@Override
public void initialiseClient() {
setTitle("Inoculator");
setTitle(getTitle());
int x = 16;
int y = 32;
new ControlLiquidTank(this, x, y + 18 + 16).setTankID(0);
@@ -55,7 +56,7 @@ public class WindowInoculator extends WindowMachine {
@Override
public String getTitle() {
return "Inoculator";
return I18N.localise(Genetics.instance, "machine.machine.inoculator");
}
@Override
@@ -65,6 +66,6 @@ public class WindowInoculator extends WindowMachine {
@Override
protected String getName() {
return "Inoculator";
return getTitle();
}
}
@@ -15,6 +15,7 @@ import binnie.core.craftgui.minecraft.control.ControlSlotArray;
import binnie.core.craftgui.minecraft.control.ControlSlotCharge;
import binnie.core.craftgui.resource.Texture;
import binnie.core.craftgui.resource.minecraft.StandardTexture;
import binnie.core.util.I18N;
import binnie.extrabees.core.ExtraBeeTexture;
import binnie.genetics.Genetics;
import binnie.genetics.machine.isolator.Isolator;
@@ -36,23 +37,23 @@ public class WindowIsolator extends WindowMachine {
@Override
public void initialiseClient() {
setTitle("Isolator");
setTitle(getTitle());
int x = 16;
int y = 32;
new ControlLiquidTank(this, x, y).setTankID(0);
new ControlLiquidTank(this, x, y).setTankID(Isolator.TANK_ETHANOL);
x += 26;
new ControlSlotArray(this, x, y + 3, 1, 3).create(Isolator.SLOT_RESERVE);
x += 20;
new ControlIconDisplay(this, x, y + 3 + 1, GUIIcon.ArrowRight.getIcon());
x += 18;
new ControlSlot(this, x, y + 3).assign(5);
new ControlSlot(this, x, y + 36 + 3).assign(0);
new ControlSlotCharge(this, x + 18 + 2, y + 36 + 3, 0).setColor(15722671);
new ControlSlot(this, x, y + 3).assign(Isolator.SLOT_TARGET);
new ControlSlot(this, x, y + 36 + 3).assign(Isolator.SLOT_ENZYME);
new ControlSlotCharge(this, x + 18 + 2, y + 36 + 3, 0).setColor(0xefe8af);
x += 18;
new ControlProgress(this, x, y + 3, WindowIsolator.ProgressBase, WindowIsolator.Progress, Position.LEFT);
x += 142;
new ControlSlot(this, x, y + 3).assign(6);
new ControlSlot(this, x, y + 3 + 36).assign(1);
new ControlSlot(this, x, y + 3).assign(Isolator.SLOT_RESULT);
new ControlSlot(this, x, y + 3 + 36).assign(Isolator.SLOT_SEQUENCER_VIAL);
new ControlIconDisplay(this, x + 1, y + 3 + 19, GUIIcon.ArrowUp.getIcon());
x += 20;
new ControlIconDisplay(this, x, y + 3 + 1, GUIIcon.ArrowRight.getIcon());
@@ -65,7 +66,7 @@ public class WindowIsolator extends WindowMachine {
@Override
public String getTitle() {
return "Incubator";
return I18N.localise(Genetics.instance, "machine.machine.isolator");
}
@Override
@@ -75,6 +76,6 @@ public class WindowIsolator extends WindowMachine {
@Override
protected String getName() {
return "Isolator";
return getTitle();
}
}
@@ -20,7 +20,11 @@ public class Incubator {
public static final int SLOT_INCUBATOR = 3;
public static final int TANK_INPUT = 0;
public static final int TANK_OUTPUT = 1;
public static final float ENERGY_PER_TICK = 2.0f;
public static final List<IIncubatorRecipe> RECIPES = new ArrayList<>();
public static final int POWER_CAPACITY = 2000;
public static final int INPUT_TANK_CAPACITY = 2000;
public static final int OUTPU_TANK_CAPACITY = 2000;
public static void addRecipes() {
Incubator.RECIPES.add(new IncubatorRecipe(Binnie.Liquid.getLiquidStack("water", 25), GeneticLiquid.GrowthMedium.get(25), 0.2f) {
@@ -5,6 +5,8 @@ import binnie.core.machines.power.ComponentProcessIndefinate;
import binnie.core.machines.power.ErrorState;
import binnie.core.machines.power.IProcess;
import binnie.core.machines.transfer.TransferRequest;
import binnie.core.util.I18N;
import binnie.genetics.Genetics;
import binnie.genetics.api.IIncubatorRecipe;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
@@ -17,7 +19,7 @@ public class IncubatorComponentLogic extends ComponentProcessIndefinate implemen
private boolean roomForOutput;
public IncubatorComponentLogic(Machine machine) {
super(machine, 2.0f);
super(machine, Incubator.ENERGY_PER_TICK);
recipe = null;
rand = new Random();
roomForOutput = true;
@@ -25,20 +27,29 @@ public class IncubatorComponentLogic extends ComponentProcessIndefinate implemen
@Override
public ErrorState canWork() {
if (recipe == null) {
return new ErrorState("No Recipe", "There is no valid recipe");
if (recipe != null) {
return super.canWork();
}
return super.canWork();
return new ErrorState(
I18N.localise(Genetics.instance, "machine.incubator.error.noRecipe.title"),
I18N.localise(Genetics.instance, "machine.incubator.error.noRecipe")
);
}
@Override
public ErrorState canProgress() {
if (recipe != null) {
if (!recipe.isInputLiquidSufficient(getUtil().getFluid(Incubator.TANK_INPUT))) {
return new ErrorState.InsufficientLiquid("Not enough incubation liquid", Incubator.TANK_INPUT);
return new ErrorState.InsufficientLiquid(
I18N.localise(Genetics.instance, "machine.incubator.error.noLiquid"),
Incubator.TANK_INPUT
);
}
if (!roomForOutput) {
return new ErrorState.TankSpace("No room for output", Incubator.TANK_OUTPUT);
return new ErrorState.TankSpace(
I18N.localise(Genetics.instance, "machine.incubator.error.noRoom"),
Incubator.TANK_OUTPUT
);
}
}
return super.canProgress();
@@ -37,10 +37,10 @@ public class IncubatorPackage extends PackageGeneticBase implements IMachineInfo
slot.setReadOnly();
}
new ComponentPowerReceptor(machine, 2000);
new ComponentPowerReceptor(machine, Incubator.POWER_CAPACITY);
ComponentTankContainer tanks = new ComponentTankContainer(machine);
tanks.addTank(Incubator.TANK_INPUT, "input", 2000).forbidExtraction();
tanks.addTank(Incubator.TANK_OUTPUT, "output", 2000).setReadOnly();
tanks.addTank(Incubator.TANK_INPUT, "input", Incubator.INPUT_TANK_CAPACITY).forbidExtraction();
tanks.addTank(Incubator.TANK_OUTPUT, "output", Incubator.OUTPU_TANK_CAPACITY).setReadOnly();
new IncubatorComponentLogic(machine);
}
@@ -75,23 +75,21 @@ public abstract class IncubatorRecipe implements IIncubatorRecipe {
@Override
public boolean roomForOutput(MachineUtil machine) {
if (output != null && !machine.isTankEmpty(Incubator.TANK_OUTPUT)) {
if (!machine.getFluid(Incubator.TANK_OUTPUT).isFluidEqual(output)) {
return false;
}
if (!machine.spaceInTank(Incubator.TANK_OUTPUT, output.amount)) {
if (!machine.getFluid(Incubator.TANK_OUTPUT).isFluidEqual(output) ||
!machine.spaceInTank(Incubator.TANK_OUTPUT, output.amount)) {
return false;
}
}
ItemStack outputStack = getOutputStack(machine);
if (outputStack != null) {
ItemStack output = outputStack.copy();
TransferRequest product = new TransferRequest(output, machine.getInventory())
.setTargetSlots(Incubator.SLOT_OUTPUT)
.ignoreValidation();
ItemStack leftover = product.transfer(false);
return leftover == null;
if (outputStack == null) {
return true;
}
return true;
ItemStack output = outputStack.copy();
TransferRequest product = new TransferRequest(output, machine.getInventory())
.setTargetSlots(Incubator.SLOT_OUTPUT)
.ignoreValidation();
return product.transfer(false) == null;
}
}
@@ -2,6 +2,8 @@ package binnie.genetics.machine.inoculator;
import binnie.Binnie;
import binnie.core.machines.inventory.SlotValidator;
import binnie.core.util.I18N;
import binnie.genetics.Genetics;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.ISpeciesRoot;
import net.minecraft.item.ItemStack;
@@ -19,6 +21,6 @@ public class IndividualInoculateValidator extends SlotValidator {
@Override
public String getTooltip() {
return "Inoculable Individual";
return I18N.localise(Genetics.instance, "machine.inoculator.inoculableIndividual");
}
}
@@ -17,6 +17,9 @@ public class Inoculator {
public static final int[] SLOT_FINISHED = new int[]{10, 11, 12, 13};
public static final int TANK_VECTOR = 0;
public static final int TANK_CAPACITY = 1000;
public static final int RF_COST = 600000;
public static final int TIME_PERIOD = 12000;
public static final int POWER_STORAGE = 15000;
public static void setGene(IGene gene, ItemStack target, int chromoN) {
int chromosomeID = gene.getChromosome().ordinal();
@@ -89,7 +89,7 @@ public class InoculatorComponentFX extends MachineComponent implements
return;
}
ItemStack stack = getUtil().getStack(9);
ItemStack stack = getUtil().getStack(Inoculator.SLOT_TARGET);
dummyEntityItem.worldObj = getMachine().getWorld();
dummyEntityItem.setEntityItemStack(stack);
EntityItem dummyEntityItem = this.dummyEntityItem;
@@ -4,6 +4,8 @@ import binnie.core.machines.Machine;
import binnie.core.machines.power.ComponentProcessSetCost;
import binnie.core.machines.power.ErrorState;
import binnie.core.machines.power.IProcess;
import binnie.core.util.I18N;
import binnie.genetics.Genetics;
import binnie.genetics.api.IGene;
import binnie.genetics.api.IItemSerum;
import binnie.genetics.genetics.Engineering;
@@ -16,11 +18,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class InoculatorComponentLogic extends ComponentProcessSetCost implements IProcess {
private float bacteriaDrain;
private float bacteriaDrain = 0.0f;
public InoculatorComponentLogic(Machine machine) {
super(machine, 600000, 12000);
bacteriaDrain = 0.0f;
super(machine, Inoculator.RF_COST, Inoculator.TIME_PERIOD);
}
@Override
@@ -44,19 +45,31 @@ public class InoculatorComponentLogic extends ComponentProcessSetCost implements
@Override
public String getTooltip() {
int n = getNumberOfGenes();
return "Inoculating with " + n + " gene" + ((n > 1) ? "s" : "");
if (n > 1) {
return I18N.localise(Genetics.instance, "machine.inoculator.inoculatingWithGenes", n);
}
return I18N.localise(Genetics.instance, "machine.inoculator.inoculatingWithGene");
}
@Override
public ErrorState canWork() {
if (getUtil().isSlotEmpty(Inoculator.SLOT_TARGET)) {
return new ErrorState.NoItem("No Individual to Inoculate", Inoculator.SLOT_TARGET);
return new ErrorState.NoItem(
I18N.localise(Genetics.instance, "machine.inoculator.error.noIndividual"),
Inoculator.SLOT_TARGET
);
}
if (getUtil().isSlotEmpty(Inoculator.SLOT_SERUM_VIAL)) {
return new ErrorState.NoItem("No Serum", Inoculator.SLOT_SERUM_VIAL);
return new ErrorState.NoItem(
I18N.localise(Genetics.instance, "machine.inoculator.error.noSerum"),
Inoculator.SLOT_SERUM_VIAL
);
}
if (getUtil().isTankEmpty(Inoculator.TANK_VECTOR)) {
return new ErrorState.InsufficientLiquid("Not enough liquid", Inoculator.TANK_VECTOR);
return new ErrorState.InsufficientLiquid(
I18N.localise(Genetics.instance, "machine.inoculator.error.noLiquid"),
Inoculator.TANK_VECTOR
);
}
ErrorState state = isValidSerum();
@@ -66,7 +79,10 @@ public class InoculatorComponentLogic extends ComponentProcessSetCost implements
ItemStack stack = getUtil().getStack(Inoculator.SLOT_SERUM_VIAL);
if (stack != null && Engineering.getCharges(stack) == 0) {
return new ErrorState("Empty Serum", "Serum is empty");
return new ErrorState(
I18N.localise(Genetics.instance, "machine.inoculator.error.emptySerum.title"),
I18N.localise(Genetics.instance, "machine.inoculator.error.emptySerum")
);
}
return super.canWork();
}
@@ -76,30 +92,40 @@ public class InoculatorComponentLogic extends ComponentProcessSetCost implements
ItemStack target = getUtil().getStack(Inoculator.SLOT_TARGET);
IGene[] genes = Engineering.getGenes(serum);
if (genes.length == 0) {
return new ErrorState("Invalid Serum", "Serum does not hold any genes");
return new ErrorState(
I18N.localise(Genetics.instance, "machine.inoculator.error.invalidSerum.title"),
I18N.localise(Genetics.instance, "machine.inoculator.error.invalidSerum.0")
);
}
if (!genes[0].getSpeciesRoot().isMember(target)) {
return new ErrorState("Invalid Serum", "Mismatch of Serum Type and Target");
return new ErrorState(
I18N.localise(Genetics.instance, "machine.inoculator.error.invalidSerum.title"),
I18N.localise(Genetics.instance, "machine.inoculator.error.invalidSerum.1")
);
}
IIndividual individual = genes[0].getSpeciesRoot().getMember(target);
boolean hasAll = true;
for (IGene gene : genes) {
if (hasAll) {
IGenome genome = individual.getGenome();
IChromosomeType chromosome = gene.getChromosome();
String geneAlleleUID = gene.getAllele().getUID();
IAllele a = genome.getActiveAllele(chromosome);
IAllele b = genome.getInactiveAllele(chromosome);
hasAll = a.getUID().equals(geneAlleleUID)
&& b.getUID().equals(geneAlleleUID);
if (!hasAll) {
continue;
}
IGenome genome = individual.getGenome();
IChromosomeType chromosome = gene.getChromosome();
String geneAlleleUID = gene.getAllele().getUID();
IAllele a = genome.getActiveAllele(chromosome);
IAllele b = genome.getInactiveAllele(chromosome);
hasAll = a.getUID().equals(geneAlleleUID) && b.getUID().equals(geneAlleleUID);
}
if (hasAll) {
return new ErrorState("Defunct Serum", "Individual already possesses this allele");
if (!hasAll) {
return null;
}
return null;
return new ErrorState(
I18N.localise(Genetics.instance, "machine.inoculator.error.defunctSerum.title"),
I18N.localise(Genetics.instance, "machine.inoculator.error.defunctSerum")
);
}
@Override
@@ -132,7 +158,7 @@ public class InoculatorComponentLogic extends ComponentProcessSetCost implements
protected void onTickTask() {
bacteriaDrain += 15.0f * getProgressPerTick() / 100.0f;
if (bacteriaDrain >= 1.0f) {
getUtil().drainTank(0, 1);
getUtil().drainTank(Inoculator.TANK_VECTOR, 1);
bacteriaDrain--;
}
}
@@ -65,7 +65,7 @@ public class InoculatorPackage extends PackageGeneticBase implements IMachineInf
ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
transfer.addRestock(Inoculator.SLOT_RESERVE, Inoculator.SLOT_TARGET, 1);
transfer.addRestock(Inoculator.SLOT_SERUM_RESERVE, Inoculator.SLOT_SERUM_VIAL);
transfer.addStorage(0, Inoculator.SLOT_SERUM_EXPENDED, new ComponentInventoryTransfer.Condition() {
transfer.addStorage(Inoculator.SLOT_SERUM_VIAL, Inoculator.SLOT_SERUM_EXPENDED, new ComponentInventoryTransfer.Condition() {
@Override
public boolean fufilled(ItemStack stack) {
return Engineering.getCharges(stack) == 0;
@@ -81,7 +81,7 @@ public class InoculatorPackage extends PackageGeneticBase implements IMachineInf
}
});
new ComponentPowerReceptor(machine, 15000);
new ComponentPowerReceptor(machine, Inoculator.POWER_STORAGE);
new InoculatorComponentLogic(machine);
new InoculatorComponentFX(machine);
new ComponentTankContainer(machine)
@@ -1,6 +1,8 @@
package binnie.genetics.machine.inoculator;
import binnie.core.machines.inventory.SlotValidator;
import binnie.core.util.I18N;
import binnie.genetics.Genetics;
import binnie.genetics.api.IItemSerum;
import binnie.genetics.machine.ModuleMachine;
import net.minecraft.item.ItemStack;
@@ -17,6 +19,6 @@ public class SerumSlotValidator extends SlotValidator {
@Override
public String getTooltip() {
return "Serum Vials & Arrays";
return I18N.localise(Genetics.instance, "machine.inoculator.serums");
}
}
@@ -1,12 +1,13 @@
package binnie.genetics.machine.isolator;
import binnie.core.machines.inventory.TankValidator;
import binnie.core.util.I18N;
import net.minecraftforge.fluids.FluidStack;
public class EthanolTankValidator extends TankValidator {
@Override
public String getTooltip() {
return "Ethanol";
return I18N.localise("fluid.bioethanol");
}
@Override
@@ -8,4 +8,8 @@ public class Isolator {
public static final int SLOT_TARGET = 5;
public static final int SLOT_RESULT = 6;
public static final int TANK_ETHANOL = 0;
public static final int RF_COST = 192000;
public static final int TIME_PERIOD = 4800;
public static final int POWER_CAPACITY = 20000;
public static final int ETHANOL_CAPACITY = 1000;
}
@@ -22,6 +22,7 @@ public class IsolatorComponentFX extends MachineComponent implements IRender.Ran
if (!getUtil().getProcess().isInProgress()) {
return;
}
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new EntityFX(world, x + 0.4 + 0.2 * rand.nextDouble(), y + 1.6, z + 0.4 + rand.nextDouble() * 0.2, 0.0, 0.0, 0.0) {
double angle = 0.0;
@@ -6,6 +6,8 @@ import binnie.core.machines.inventory.IChargedSlots;
import binnie.core.machines.power.ComponentProcessSetCost;
import binnie.core.machines.power.ErrorState;
import binnie.core.machines.power.IProcess;
import binnie.core.util.I18N;
import binnie.genetics.Genetics;
import binnie.genetics.item.ItemSequence;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
@@ -17,26 +19,33 @@ import net.minecraft.item.ItemStack;
import java.util.Random;
public class IsolatorComponentLogic extends ComponentProcessSetCost implements IProcess {
protected float enzymePerProcess;
protected float ethanolPerProcess;
protected float enzymePerProcess = 0.5f;
protected float ethanolPerProcess = 10.0f;
public IsolatorComponentLogic(Machine machine) {
super(machine, 192000, 4800);
enzymePerProcess = 0.5f;
ethanolPerProcess = 10.0f;
super(machine, Isolator.RF_COST, Isolator.TIME_PERIOD);
}
@Override
public ErrorState canWork() {
if (getUtil().isSlotEmpty(Isolator.SLOT_TARGET)) {
return new ErrorState.NoItem("No individual to isolate", Isolator.SLOT_TARGET);
return new ErrorState.NoItem(
I18N.localise(Genetics.instance, "machine.isolator.error.noIndividual"),
Isolator.SLOT_TARGET
);
}
// TODO check slot id in validation
if (!getUtil().isSlotEmpty(Isolator.SLOT_RESULT)) {
return new ErrorState.NoSpace("No room for DNA sequences", Isolator.SLOT_FINISHED);
return new ErrorState.NoSpace(
I18N.localise(Genetics.instance, "machine.isolator.error.noRoom"),
Isolator.SLOT_FINISHED
);
}
if (getUtil().isSlotEmpty(Isolator.SLOT_SEQUENCER_VIAL)) {
return new ErrorState.NoItem("No empty sequencer vials", Isolator.SLOT_SEQUENCER_VIAL);
return new ErrorState.NoItem(
I18N.localise(Genetics.instance, "machine.isolator.error.noVials"),
Isolator.SLOT_SEQUENCER_VIAL
);
}
return super.canWork();
}
@@ -44,10 +53,16 @@ public class IsolatorComponentLogic extends ComponentProcessSetCost implements I
@Override
public ErrorState canProgress() {
if (!getUtil().liquidInTank(Isolator.TANK_ETHANOL, (int) ethanolPerProcess)) {
return new ErrorState.InsufficientLiquid("Insufficient ethanol", Isolator.TANK_ETHANOL);
return new ErrorState.InsufficientLiquid(
I18N.localise(Genetics.instance, "machine.isolator.error.noLiquid"),
Isolator.TANK_ETHANOL
);
}
if (getUtil().getSlotCharge(Isolator.SLOT_ENZYME) == 0.0f) {
return new ErrorState.NoItem("No enzyme", Isolator.SLOT_ENZYME);
return new ErrorState.NoItem(
I18N.localise(Genetics.instance, "machine.isolator.error.noEnzyme"),
Isolator.SLOT_ENZYME
);
}
return super.canProgress();
}
@@ -57,7 +57,7 @@ public class IsolatorPackage extends PackageGeneticBase implements IMachineInfor
}
ComponentTankContainer tanks = new ComponentTankContainer(machine);
tanks.addTank(Isolator.TANK_ETHANOL, "input", 1000);
tanks.addTank(Isolator.TANK_ETHANOL, "input", Isolator.ETHANOL_CAPACITY);
tanks.getTankSlot(Isolator.TANK_ETHANOL).setValidator(new EthanolTankValidator());
ComponentChargedSlots chargedSlots = new ComponentChargedSlots(machine);
@@ -66,7 +66,7 @@ public class IsolatorPackage extends PackageGeneticBase implements IMachineInfor
ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
transfer.addRestock(Isolator.SLOT_RESERVE, Isolator.SLOT_TARGET, 1);
transfer.addStorage(Isolator.SLOT_RESULT, Isolator.SLOT_FINISHED);
new ComponentPowerReceptor(machine, 20000);
new ComponentPowerReceptor(machine, Isolator.POWER_CAPACITY);
new IsolatorComponentLogic(machine);
new IsolatorComponentFX(machine);
}