mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-26 15:03:14 +00:00
Localization and refactoring (#77)
* Some refactoring for bee production * Code cleanup * Code cleanup * Added some localization * Fix wrong dropped class * Added some localization * Added some localization * Added some localization * Fix wrong import
This commit is contained in:
1 parent
68bbe7710c
commit
1ea7b62e5f
157 files changed
+3240
-5045
No files matched your search
@@ -0,0 +1,16 @@
|
||||
package binnie.genetics.machine.genepool;
|
||||
|
||||
import binnie.core.machines.inventory.TankValidator;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
class EthanolTankValidator extends TankValidator {
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Ethanol";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(FluidStack liquid) {
|
||||
return liquid.getFluid().getName().equals("bioethanol");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package binnie.genetics.machine.genepool;
|
||||
|
||||
public class Genepool {
|
||||
public static final int SLOT_BEE = 0;
|
||||
public static final int TANK_DNA = 0;
|
||||
public static final int TANK_ETHANOL = 1;
|
||||
public static final int SLOT_ENZYME = 7;
|
||||
public static final int[] SLOT_RESERVE = new int[]{1, 2, 3, 4, 5, 6};
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package binnie.genetics.machine.genepool;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import binnie.core.machines.component.IRender;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class GenepoolComponentFX extends MachineComponent implements IRender.RandomDisplayTick, IRender.DisplayTick {
|
||||
public GenepoolComponentFX(IMachine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onRandomDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
if (rand.nextFloat() < 1.0f && getUtil().getProcess().isInProgress()) {
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new EntityFX(world, x + 0.3 + rand.nextDouble() * 0.4, y + 1, z + 0.3 + rand.nextDouble() * 0.4, 0.0, 0.0, 0.0) {
|
||||
double axisX = posX;
|
||||
double axisZ = posZ;
|
||||
double angle = rand.nextDouble() * 2.0 * 3.1415;
|
||||
|
||||
{
|
||||
axisX = 0.0;
|
||||
axisZ = 0.0;
|
||||
angle = 0.0;
|
||||
motionX = 0.0;
|
||||
motionZ = 0.0;
|
||||
motionY = rand.nextFloat() * 0.01;
|
||||
particleMaxAge = 25;
|
||||
particleGravity = 0.0f;
|
||||
noClip = true;
|
||||
setRBGColorF(0.4f + 0.6f * rand.nextFloat(), 0.6f * rand.nextFloat(), 0.6f + 0.4f * rand.nextFloat());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
setAlphaF((float) Math.cos(1.57 * particleAge / particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package binnie.genetics.machine.genepool;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.machines.Machine;
|
||||
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.genetics.item.GeneticLiquid;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class GenepoolComponentLogic extends ComponentProcessSetCost implements IProcess {
|
||||
float enzymePerProcess;
|
||||
float ethanolPerProcess;
|
||||
private float ethanolDrain;
|
||||
|
||||
public GenepoolComponentLogic(Machine machine) {
|
||||
super(machine, 8000, 400);
|
||||
enzymePerProcess = 0.25f;
|
||||
ethanolPerProcess = 50.0f;
|
||||
ethanolDrain = 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (getUtil().isSlotEmpty(0)) {
|
||||
return new ErrorState.NoItem("No Individual", Genepool.SLOT_BEE);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (!getUtil().spaceInTank(Genepool.TANK_DNA, getDNAAmount(getUtil().getStack(Genepool.TANK_DNA)))) {
|
||||
return new ErrorState.NoSpace("Not enough room in Tank", new int[]{Genepool.TANK_DNA});
|
||||
}
|
||||
if (!getUtil().liquidInTank(1, 1)) {
|
||||
return new ErrorState.InsufficientLiquid("Not enough Ethanol", Genepool.TANK_ETHANOL);
|
||||
}
|
||||
if (getUtil().getSlotCharge(Genepool.SLOT_ENZYME) == 0.0f) {
|
||||
return new ErrorState.NoItem("Insufficient Enzyme", Genepool.SLOT_ENZYME);
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
int amount = getDNAAmount(getUtil().getStack(Genepool.TANK_DNA));
|
||||
getUtil().fillTank(Genepool.TANK_DNA, GeneticLiquid.RawDNA.get(amount));
|
||||
getUtil().deleteStack(Genepool.TANK_DNA);
|
||||
}
|
||||
|
||||
private int getDNAAmount(ItemStack stack) {
|
||||
ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack);
|
||||
if (root == null
|
||||
|| root != Binnie.Genetics.getBeeRoot()
|
||||
|| Binnie.Genetics.getBeeRoot().isDrone(stack)) {
|
||||
return 10;
|
||||
}
|
||||
if (Binnie.Genetics.getBeeRoot().isMated(stack)) {
|
||||
return 50;
|
||||
}
|
||||
return 30;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
ethanolDrain += getDNAAmount(getUtil().getStack(Genepool.TANK_DNA)) * 1.2f * getProgressPerTick() / 100.0f;
|
||||
if (ethanolDrain >= 1.0f) {
|
||||
getUtil().drainTank(Genepool.TANK_ETHANOL, 1);
|
||||
ethanolDrain--;
|
||||
}
|
||||
getMachine().getInterface(IChargedSlots.class).alterCharge(Genepool.SLOT_ENZYME, -enzymePerProcess * getProgressPerTick() / 100.0f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package binnie.genetics.machine.genepool;
|
||||
|
||||
import binnie.core.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.machines.inventory.ComponentChargedSlots;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.ComponentInventoryTransfer;
|
||||
import binnie.core.machines.inventory.ComponentTankContainer;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.machines.inventory.TankSlot;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import binnie.genetics.machine.ComponentGeneticGUI;
|
||||
import binnie.genetics.machine.ModuleMachine;
|
||||
import binnie.genetics.machine.PackageGeneticBase;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class GenepoolPackage extends PackageGeneticBase implements IMachineInformation {
|
||||
public GenepoolPackage() {
|
||||
super("genepool", GeneticsTexture.Genepool, 0xc134b6, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Genepool);
|
||||
ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
InventorySlot enzymeSlot = inventory.addSlot(Genepool.SLOT_ENZYME, "enzyme");
|
||||
enzymeSlot.setValidator(new SlotValidator.Item(GeneticsItems.Enzyme.get(1), ModuleMachine.IconEnzyme));
|
||||
enzymeSlot.forbidExtraction();
|
||||
|
||||
InventorySlot slotBee = inventory.addSlot(Genepool.SLOT_BEE, "process");
|
||||
slotBee.setValidator(new SlotValidator.Individual());
|
||||
slotBee.setReadOnly();
|
||||
slotBee.forbidExtraction();
|
||||
inventory.addSlotArray(Genepool.SLOT_RESERVE, "input");
|
||||
|
||||
for (InventorySlot slot : inventory.getSlots(Genepool.SLOT_RESERVE)) {
|
||||
slot.setValidator(new SlotValidator.Individual());
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
|
||||
ComponentTankContainer tanks = new ComponentTankContainer(machine);
|
||||
TankSlot dnaSlot = tanks.addTank(Genepool.TANK_DNA, "output", 2000);
|
||||
dnaSlot.setReadOnly();
|
||||
|
||||
TankSlot ethanolSlot = tanks.addTank(Genepool.TANK_ETHANOL, "input", 1000);
|
||||
ethanolSlot.forbidExtraction();
|
||||
ethanolSlot.setValidator(new EthanolTankValidator());
|
||||
|
||||
ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Genepool.SLOT_RESERVE, Genepool.SLOT_BEE, 1);
|
||||
new ComponentPowerReceptor(machine, 1600);
|
||||
new GenepoolComponentLogic(machine);
|
||||
ComponentChargedSlots chargedSlots = new ComponentChargedSlots(machine);
|
||||
chargedSlots.addCharge(Genepool.SLOT_ENZYME);
|
||||
new GenepoolComponentFX(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user