Star to rework Machine localisation

This commit is contained in:
Nedelosk committed 2017-06-28 19:10:09 +02:00
1 parent 18f30c8c0d
commit b6d5901f07
17 files changed
+303 -63

No files matched your search

@@ -0,0 +1,67 @@
package binnie.genetics.machine;
import javax.annotation.Nullable;
import binnie.core.machines.power.CoreErrorCode;
import binnie.core.machines.power.EnumErrorType;
import binnie.core.machines.power.IErrorStateDefinition;
import binnie.core.util.I18N;
public enum GeneticsErrorCode implements IErrorStateDefinition {
NO_OWNER("no.owner"),
NO_INDIVIDUAL("no.individual", CoreErrorCode.NO_ITEM),
//Acclimatiser
ACCLIMATISER_NO_ITEM("acclimatiser.no.item", CoreErrorCode.NO_ITEM),
ACCLIMATISER_CAN_NOT_WORK(".acclimatiser.can.not.acclimatise", CoreErrorCode.INVALID_ITEM),
//Analyser
ANALYSER_NO_ITEM("analyser.no.item", CoreErrorCode.NO_ITEM),
ANALYSER_ALREADY_ANALYSED("analyser.already.analysed", EnumErrorType.ITEM),
ANALYSER_INSUFFICIENT_DYE("analyser.insufficient.dye", EnumErrorType.ITEM),
//Genepool
GENEPOOL_INSUFFICIENT_ETHANOL("genepool.insufficient.ethanol", CoreErrorCode.INSUFFICIENT_LIQUID),
GENEPOOL_INSUFFICIENT_ENZYME("genepool.insufficient.enzyme", CoreErrorCode.NO_ITEM),
//Incubator
INCUBATOR_INSUFFICIENT_LIQUID("incubator.insufficient.liquid");
String name;
@Nullable
IErrorStateDefinition parent;
@Nullable
EnumErrorType type;
GeneticsErrorCode(String name) {
this(name, null, EnumErrorType.NONE);
}
GeneticsErrorCode(String name, EnumErrorType type) {
this(name, null, type);
}
GeneticsErrorCode(String name, IErrorStateDefinition parent) {
this(name, parent, EnumErrorType.NONE);
}
GeneticsErrorCode(String name, IErrorStateDefinition parent, EnumErrorType type) {
this.name = name;
this.parent = parent;
}
public String getDescription(){
return I18N.localise("genetics.errors." + name + ".desc");
}
public String getName(){
if(parent != null){
return parent.getName();
}
return I18N.localise("genetics.errors." + name + ".name");
}
@Override
public EnumErrorType getType() {
if(parent != null){
return parent.getType();
}
return type;
}
}
@@ -8,7 +8,7 @@ import net.minecraft.item.ItemStack;
import binnie.core.machines.IMachine;
import binnie.core.machines.power.ComponentProcessIndefinate;
import binnie.core.machines.power.ErrorState;
import binnie.core.util.I18N;
import binnie.genetics.machine.GeneticsErrorCode;
public class AcclimatiserLogic extends ComponentProcessIndefinate {
public AcclimatiserLogic(final IMachine machine) {
@@ -18,10 +18,10 @@ public class AcclimatiserLogic extends ComponentProcessIndefinate {
@Override
public ErrorState canWork() {
if (this.getUtil().getStack(Acclimatiser.SLOT_TARGET).isEmpty()) {
return new ErrorState.NoItem(I18N.localise("genetics.machine.labMachine.acclimatiser.errors.no.individual.desc"), Acclimatiser.SLOT_TARGET);
return new ErrorState(GeneticsErrorCode.NO_INDIVIDUAL, Acclimatiser.SLOT_TARGET);
}
if (this.getUtil().getNonEmptyStacks(Acclimatiser.SLOT_ACCLIMATISER).isEmpty()) {
return new ErrorState.NoItem(I18N.localise("genetics.machine.labMachine.acclimatiser.errors.no.item.desc"), Acclimatiser.SLOT_ACCLIMATISER);
return new ErrorState(GeneticsErrorCode.ACCLIMATISER_NO_ITEM, Acclimatiser.SLOT_ACCLIMATISER);
}
return super.canWork();
}
@@ -29,7 +29,7 @@ public class AcclimatiserLogic extends ComponentProcessIndefinate {
@Override
public ErrorState canProgress() {
if (!Acclimatiser.canAcclimatise(this.getUtil().getStack(Acclimatiser.SLOT_TARGET), this.getUtil().getNonEmptyStacks(Acclimatiser.SLOT_ACCLIMATISER))) {
return new ErrorState.InvalidItem(I18N.localise("genetics.machine.labMachine.acclimatiser.errors.can.not.acclimatise.desc"), Acclimatiser.SLOT_TARGET);
return new ErrorState(GeneticsErrorCode.ACCLIMATISER_CAN_NOT_WORK, Acclimatiser.SLOT_TARGET);
}
return super.canProgress();
}
@@ -49,7 +49,7 @@ public class WindowAcclimatiser extends WindowMachine {
@Override
public String getTitle() {
return I18N.localise("genetics.machine.labMachine.acclimatiser");
return I18N.localise("genetics.lab_machine.acclimatiser");
}
@Override
@@ -6,7 +6,7 @@ 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.machine.GeneticsErrorCode;
public class AnalyserLogic extends ComponentProcessSetCost implements IProcess {
private static final float DYE_PER_TICK = 0.002f;
@@ -18,11 +18,11 @@ public class AnalyserLogic extends ComponentProcessSetCost implements IProcess {
@Override
public ErrorState canWork() {
if (this.getUtil().isSlotEmpty(Analyser.SLOT_TARGET)) {
return new ErrorState.NoItem(I18N.localise("genetics.machine.labMachine.analyser.errors.no.item.desc"), Analyser.SLOT_TARGET);
return new ErrorState(GeneticsErrorCode.ANALYSER_NO_ITEM, Analyser.SLOT_TARGET);
}
final boolean analysed = Analyser.isAnalysed(this.getUtil().getStack(Analyser.SLOT_TARGET));
if (analysed) {
return new ErrorState.InvalidItem(I18N.localise("genetics.machine.labMachine.analyser.errors.already.analysed.desc"), I18N.localise("genetics.machine.labMachine.analyser.errors.already.analysed.info"), Analyser.SLOT_TARGET);
return new ErrorState(GeneticsErrorCode.ANALYSER_ALREADY_ANALYSED, Analyser.SLOT_TARGET);
}
return super.canWork();
}
@@ -30,10 +30,10 @@ public class AnalyserLogic extends ComponentProcessSetCost implements IProcess {
@Override
public ErrorState canProgress() {
if(getMachine().getOwner() == null){
return new ErrorState.InvalidItem(I18N.localise("genetics.genetics.machine.errors.no.owner.desc"), I18N.localise("genetics.genetics.machine.errors.no.owner.info"), Analyser.SLOT_TARGET);
return new ErrorState(GeneticsErrorCode.NO_OWNER, Analyser.SLOT_TARGET);
}
if (this.getUtil().getSlotCharge(Analyser.SLOT_DYE) == 0.0f) {
return new ErrorState.Item(I18N.localise("genetics.machine.labMachine.analyser.errors.insufficient.dye.desc"), I18N.localise("genetics.machine.labMachine.analyser.errors.insufficient.dye.info"), new int[]{13});
return new ErrorState(GeneticsErrorCode.ANALYSER_INSUFFICIENT_DYE, new int[]{Analyser.SLOT_DYE});
}
return super.canProgress();
}
@@ -17,6 +17,6 @@ public class SlotValidatorUnanalysed extends SlotValidator {
@Override
public String getTooltip() {
return I18N.localise("genetics.machine.labMachine.analyser.tooltips.slots.unanalysed");
return I18N.localise("genetics.machine.lab_machine.analyser.tooltips.slots.unanalysed");
}
}
@@ -63,7 +63,7 @@ public class WindowAnalyser extends WindowMachine {
@Override
public String getTitle() {
return I18N.localise("genetics.machine.labMachine.analyser");
return I18N.localise("genetics.lab_machine.analyser");
}
@Override
@@ -7,12 +7,14 @@ import forestry.api.genetics.ISpeciesRoot;
import binnie.Binnie;
import binnie.core.machines.Machine;
import binnie.core.machines.MachineUtil;
import binnie.core.machines.inventory.IChargedSlots;
import binnie.core.machines.power.ComponentProcessSetCost;
import binnie.core.machines.power.CoreErrorCode;
import binnie.core.machines.power.ErrorState;
import binnie.core.machines.power.IProcess;
import binnie.core.util.I18N;
import binnie.genetics.item.GeneticLiquid;
import binnie.genetics.machine.GeneticsErrorCode;
public class GenepoolLogic extends ComponentProcessSetCost implements IProcess {
public static final float ENZYME_PER_PROCESS = 0.25f;
@@ -42,22 +44,23 @@ public class GenepoolLogic extends ComponentProcessSetCost implements IProcess {
@Override
public ErrorState canWork() {
if (this.getUtil().isSlotEmpty(Genepool.SLOT_BEE)) {
return new ErrorState.NoItem(I18N.localise("genetics.machine.errors.no.individual.desc"), Genepool.SLOT_BEE);
return new ErrorState(GeneticsErrorCode.NO_INDIVIDUAL, Genepool.SLOT_BEE);
}
return super.canWork();
}
@Override
public ErrorState canProgress() {
ItemStack individual = this.getUtil().getStack(Genepool.SLOT_BEE);
if (!this.getUtil().spaceInTank(Genepool.TANK_DNA, getDNAAmount(individual))) {
return new ErrorState.NoSpace(I18N.localise("genetics.machine.errors.tanks.no.room.desc"), new int[]{0});
MachineUtil util = getUtil();
ItemStack individual = util.getStack(Genepool.SLOT_BEE);
if (!util.spaceInTank(Genepool.TANK_DNA, getDNAAmount(individual))) {
return new ErrorState(CoreErrorCode.NO_SPACE_TANK, new int[]{Genepool.SLOT_BEE});
}
if (!this.getUtil().liquidInTank(Genepool.TANK_ETHANOL, 1)) {
return new ErrorState.InsufficientLiquid(I18N.localise("genetics.machine.labMachine.genepool.errors.not.enough.ethanol.desc"), Genepool.TANK_ETHANOL);
if (!util.liquidInTank(Genepool.TANK_ETHANOL, 1)) {
return new ErrorState(GeneticsErrorCode.GENEPOOL_INSUFFICIENT_ETHANOL, Genepool.TANK_ETHANOL);
}
if (this.getUtil().getSlotCharge(Genepool.SLOT_ENZYME) == 0.0f) {
return new ErrorState.NoItem(I18N.localise("genetics.machine.labMachine.genepool.errors.insufficient.enzyme.desc"), Genepool.SLOT_ENZYME);
if (util.getSlotCharge(Genepool.SLOT_ENZYME) == 0.0f) {
return new ErrorState(GeneticsErrorCode.GENEPOOL_INSUFFICIENT_ENZYME, Genepool.SLOT_ENZYME);
}
return super.canProgress();
}
@@ -65,18 +68,20 @@ public class GenepoolLogic extends ComponentProcessSetCost implements IProcess {
@Override
protected void onFinishTask() {
super.onFinishTask();
ItemStack individual = this.getUtil().getStack(Genepool.SLOT_BEE);
final int amount = getDNAAmount(individual);
this.getUtil().fillTank(Genepool.TANK_DNA, GeneticLiquid.RawDNA.get(amount));
this.getUtil().deleteStack(Genepool.SLOT_BEE);
MachineUtil util = getUtil();
ItemStack individual = util.getStack(Genepool.SLOT_BEE);
int amount = getDNAAmount(individual);
util.fillTank(Genepool.TANK_DNA, GeneticLiquid.RawDNA.get(amount));
util.deleteStack(Genepool.SLOT_BEE);
}
@Override
protected void onTickTask() {
ItemStack individual = this.getUtil().getStack(Genepool.SLOT_BEE);
MachineUtil util = getUtil();
ItemStack individual = util.getStack(Genepool.SLOT_BEE);
this.ethanolDrain += getDNAAmount(individual) * 1.2f * this.getProgressPerTick() / 100.0f;
if (this.ethanolDrain >= 1.0f) {
this.getUtil().drainTank(Genepool.TANK_ETHANOL, 1);
util.drainTank(Genepool.TANK_ETHANOL, 1);
--this.ethanolDrain;
}
IChargedSlots chargedSlots = this.getMachine().getInterface(IChargedSlots.class);
@@ -59,7 +59,7 @@ public class WindowGenepool extends WindowMachine {
@Override
public String getTitle() {
return I18N.localise("genetics.machine.labMachine.genepool");
return I18N.localise("genetics.machine.lab_machine.genepool");
}
@Override
@@ -10,11 +10,12 @@ import net.minecraftforge.oredict.OreDictionary;
import binnie.core.machines.Machine;
import binnie.core.machines.power.ComponentProcessIndefinate;
import binnie.core.machines.power.CoreErrorCode;
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.api.IIncubatorRecipe;
import binnie.genetics.machine.GeneticsErrorCode;
public class IncubatorLogic extends ComponentProcessIndefinate implements IProcess {
@Nullable
@@ -36,7 +37,7 @@ public class IncubatorLogic extends ComponentProcessIndefinate implements IProce
@Override
public ErrorState canWork() {
if (this.recipe == null) {
return new ErrorState(I18N.localise("genetics.machine.errors.no.recipe.desc"), I18N.localise("genetics.machine.errors.no.recipe.info"));
return new ErrorState(CoreErrorCode.NO_RECIPE);
}
return super.canWork();
}
@@ -45,10 +46,10 @@ public class IncubatorLogic extends ComponentProcessIndefinate implements IProce
public ErrorState canProgress() {
if (this.recipe != null) {
if (!this.recipe.isInputLiquidSufficient(this.getUtil().getFluid(Incubator.TANK_INPUT))) {
return new ErrorState.InsufficientLiquid(I18N.localise("genetics.machine.labMachine.incubator.errors.no.liquid.desc"), Incubator.TANK_INPUT);
return new ErrorState(GeneticsErrorCode.INCUBATOR_INSUFFICIENT_LIQUID, Incubator.TANK_INPUT);
}
if (!this.roomForOutput) {
return new ErrorState.TankSpace(I18N.localise("genetics.machine.labMachine.incubator.errors.no.room.desc"), Incubator.TANK_OUTPUT);
return new ErrorState(CoreErrorCode.NO_SPACE_TANK, Incubator.TANK_OUTPUT);
}
}
return super.canProgress();