mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-14 01:14:21 +00:00
Some refacoring genetic machines (#67)
* #56 Fixed inoculator don't need Bacteria Vector to process Some refactored Inoculator machine class * Refactoring Inoculator and Sequencer machines
This commit is contained in:
1 parent
5052920d73
commit
bddd3e69a3
18 files changed
+795
-748
No files matched your search
@@ -18,7 +18,7 @@ import binnie.core.craftgui.resource.Texture;
|
||||
import binnie.core.craftgui.resource.minecraft.StandardTexture;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.machine.Inoculator;
|
||||
import binnie.genetics.machine.inoculator.Inoculator;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
@@ -19,7 +19,7 @@ import binnie.core.craftgui.resource.Texture;
|
||||
import binnie.core.craftgui.resource.minecraft.StandardTexture;
|
||||
import binnie.extrabees.core.ExtraBeeTexture;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.machine.Sequencer;
|
||||
import binnie.genetics.machine.sequencer.Sequencer;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
@@ -16,7 +16,7 @@ import binnie.core.craftgui.resource.Texture;
|
||||
import binnie.core.craftgui.resource.minecraft.StandardTexture;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.machine.Inoculator;
|
||||
import binnie.genetics.machine.inoculator.Inoculator;
|
||||
import binnie.genetics.machine.Splicer;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
@@ -20,6 +20,7 @@ import binnie.core.machines.power.ComponentProcessIndefinate;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.machine.inoculator.Inoculator;
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.EnumTolerance;
|
||||
|
||||
@@ -7,15 +7,17 @@ import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.resource.BinnieResource;
|
||||
import binnie.core.resource.IBinnieTexture;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.machine.inoculator.PackageInoculator;
|
||||
import binnie.genetics.machine.sequencer.PackageSequencer;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public enum GeneticMachine implements IMachineType {
|
||||
Isolator(Isolator.PackageIsolator.class),
|
||||
Sequencer(Sequencer.PackageSequencer.class),
|
||||
Sequencer(PackageSequencer.class),
|
||||
Polymeriser(Polymeriser.PackagePolymeriser.class),
|
||||
Inoculator(Inoculator.PackageInoculator.class);
|
||||
Inoculator(PackageInoculator.class);
|
||||
|
||||
protected Class<? extends MachinePackage> clss;
|
||||
|
||||
|
||||
@@ -1,436 +0,0 @@
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.machines.component.IRender;
|
||||
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.Validator;
|
||||
import binnie.core.machines.network.INetwork;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.core.machines.power.ComponentProcessSetCost;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.core.machines.power.IProcess;
|
||||
import binnie.genetics.api.IGene;
|
||||
import binnie.genetics.api.IItemSerum;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.genetics.Engineering;
|
||||
import binnie.genetics.item.GeneticLiquid;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.apiculture.IBeeRoot;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.IGenome;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Inoculator {
|
||||
public static final int SLOT_SERUM_VIAL = 0;
|
||||
public static final int[] SLOT_SERUM_RESERVE = new int[]{1, 2};
|
||||
public static final int[] SLOT_SERUM_EXPENDED = new int[]{3, 4};
|
||||
public static final int[] SLOT_RESERVE = new int[]{5, 6, 7, 8};
|
||||
public static final int SLOT_TARGET = 9;
|
||||
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 void setGene(IGene gene, ItemStack target, int chromoN) {
|
||||
int chromosomeID = gene.getChromosome().ordinal();
|
||||
if (chromosomeID >= EnumBeeChromosome.HUMIDITY.ordinal() && gene.getSpeciesRoot() instanceof IBeeRoot) {
|
||||
chromosomeID--;
|
||||
}
|
||||
|
||||
Class<? extends IAllele> cls = gene.getChromosome().getAlleleClass();
|
||||
if (!cls.isInstance(gene.getAllele())) {
|
||||
return;
|
||||
}
|
||||
|
||||
NBTTagCompound beeNBT = target.getTagCompound();
|
||||
NBTTagCompound genomeNBT = beeNBT.getCompoundTag("Genome");
|
||||
NBTTagList chromosomes = genomeNBT.getTagList("Chromosomes", 10);
|
||||
NBTTagCompound chromosomeNBT = chromosomes.getCompoundTagAt(chromosomeID);
|
||||
chromosomeNBT.setString("UID" + chromoN, gene.getAllele().getUID());
|
||||
target.setTagCompound(beeNBT);
|
||||
}
|
||||
|
||||
public static class PackageInoculator extends GeneticMachine.PackageGeneticBase implements IMachineInformation {
|
||||
public PackageInoculator() {
|
||||
super("inoculator", GeneticsTexture.Inoculator, 0xe22235, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Inoculator);
|
||||
ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
InventorySlot slotSerumVial = inventory.addSlot(SLOT_SERUM_VIAL, "serum.active");
|
||||
slotSerumVial.forbidInteraction();
|
||||
slotSerumVial.setReadOnly();
|
||||
|
||||
SlotValidator serumValid = new SlotValidator(ModuleMachine.IconSerum) {
|
||||
@Override
|
||||
public boolean isValid(ItemStack itemStack) {
|
||||
return itemStack.getItem() instanceof IItemSerum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Serum Vials & Arrays";
|
||||
}
|
||||
};
|
||||
|
||||
slotSerumVial.setValidator(serumValid);
|
||||
|
||||
inventory.addSlotArray(SLOT_SERUM_RESERVE, "serum.input");
|
||||
for (InventorySlot slot : inventory.getSlots(SLOT_SERUM_RESERVE)) {
|
||||
slot.setValidator(serumValid);
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
|
||||
inventory.addSlotArray(SLOT_SERUM_EXPENDED, "serum.output");
|
||||
for (InventorySlot slot : inventory.getSlots(SLOT_SERUM_EXPENDED)) {
|
||||
slot.setValidator(serumValid);
|
||||
slot.setReadOnly();
|
||||
}
|
||||
|
||||
inventory.addSlotArray(SLOT_RESERVE, "input");
|
||||
for (InventorySlot slot : inventory.getSlots(SLOT_RESERVE)) {
|
||||
slot.forbidExtraction();
|
||||
slot.setValidator(new ValidatorIndividualInoculate());
|
||||
}
|
||||
|
||||
inventory.addSlot(SLOT_TARGET, "process");
|
||||
inventory.getSlot(SLOT_TARGET).setValidator(new ValidatorIndividualInoculate());
|
||||
inventory.getSlot(SLOT_TARGET).setReadOnly();
|
||||
inventory.getSlot(SLOT_TARGET).forbidInteraction();
|
||||
inventory.addSlotArray(SLOT_FINISHED, "output");
|
||||
for (InventorySlot slot : inventory.getSlots(SLOT_FINISHED)) {
|
||||
slot.setReadOnly();
|
||||
slot.forbidInsertion();
|
||||
slot.setValidator(new ValidatorIndividualInoculate());
|
||||
}
|
||||
|
||||
ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(SLOT_RESERVE, SLOT_TARGET, 1);
|
||||
transfer.addRestock(SLOT_SERUM_RESERVE, SLOT_SERUM_VIAL);
|
||||
transfer.addStorage(0, SLOT_SERUM_EXPENDED, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(ItemStack stack) {
|
||||
return Engineering.getCharges(stack) == 0;
|
||||
}
|
||||
});
|
||||
|
||||
transfer.addStorage(9, SLOT_FINISHED, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(ItemStack stack) {
|
||||
return stack != null
|
||||
&& transfer.getMachine().getMachineUtil().getStack(SLOT_SERUM_VIAL) != null
|
||||
&& transfer.getMachine().getInterface(ComponentInoculatorLogic.class).isValidSerum() != null;
|
||||
}
|
||||
});
|
||||
|
||||
new ComponentPowerReceptor(machine, 15000);
|
||||
new ComponentInoculatorLogic(machine);
|
||||
new ComponentInoculatorFX(machine);
|
||||
new ComponentTankContainer(machine)
|
||||
.addTank(TANK_VECTOR, "input", TANK_CAPACITY)
|
||||
.setValidator(new Validator<FluidStack>() {
|
||||
@Override
|
||||
public boolean isValid(FluidStack object) {
|
||||
return GeneticLiquid.BacteriaVector.get(1).isFluidEqual(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return GeneticLiquid.BacteriaVector.getName();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentInoculatorLogic extends ComponentProcessSetCost implements IProcess {
|
||||
private float bacteriaDrain;
|
||||
|
||||
public ComponentInoculatorLogic(Machine machine) {
|
||||
super(machine, 600000, 12000);
|
||||
bacteriaDrain = 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessLength() {
|
||||
return super.getProcessLength() * getNumberOfGenes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessEnergy() {
|
||||
return super.getProcessEnergy() * getNumberOfGenes();
|
||||
}
|
||||
|
||||
private int getNumberOfGenes() {
|
||||
ItemStack serum = getUtil().getStack(SLOT_SERUM_VIAL);
|
||||
if (serum == null) {
|
||||
return 1;
|
||||
}
|
||||
return Engineering.getGenes(serum).length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
int n = getNumberOfGenes();
|
||||
return "Inoculating with " + n + " gene" + ((n > 1) ? "s" : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (getUtil().isSlotEmpty(SLOT_TARGET)) {
|
||||
return new ErrorState.NoItem("No Individual to Inoculate", SLOT_TARGET);
|
||||
}
|
||||
if (getUtil().isSlotEmpty(SLOT_SERUM_VIAL)) {
|
||||
return new ErrorState.NoItem("No Serum", SLOT_SERUM_VIAL);
|
||||
}
|
||||
System.out.println("EMPTY = " + getUtil().isTankEmpty(TANK_VECTOR));
|
||||
if (getUtil().isTankEmpty(TANK_VECTOR)) {
|
||||
return new ErrorState.InsufficientLiquid("Not enough liquid", TANK_VECTOR);
|
||||
}
|
||||
|
||||
ErrorState state = isValidSerum();
|
||||
if (state != null) {
|
||||
return state;
|
||||
}
|
||||
|
||||
ItemStack stack = getUtil().getStack(SLOT_SERUM_VIAL);
|
||||
if (stack != null && Engineering.getCharges(stack) == 0) {
|
||||
return new ErrorState("Empty Serum", "Serum is empty");
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
public ErrorState isValidSerum() {
|
||||
ItemStack serum = getUtil().getStack(SLOT_SERUM_VIAL);
|
||||
ItemStack target = getUtil().getStack(SLOT_TARGET);
|
||||
IGene[] genes = Engineering.getGenes(serum);
|
||||
if (genes.length == 0) {
|
||||
return new ErrorState("Invalid Serum", "Serum does not hold any genes");
|
||||
}
|
||||
if (!genes[0].getSpeciesRoot().isMember(target)) {
|
||||
return new ErrorState("Invalid Serum", "Mismatch of Serum Type and Target");
|
||||
}
|
||||
|
||||
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) {
|
||||
return new ErrorState("Defunct Serum", "Individual already possesses this allele");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
ItemStack serum = getUtil().getStack(SLOT_SERUM_VIAL);
|
||||
ItemStack target = getUtil().getStack(SLOT_TARGET);
|
||||
IIndividual ind = AlleleManager.alleleRegistry.getIndividual(target);
|
||||
if (!ind.isAnalyzed()) {
|
||||
ind.analyze();
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
ind.writeToNBT(nbttagcompound);
|
||||
target.setTagCompound(nbttagcompound);
|
||||
}
|
||||
|
||||
IGene[] genes = ((IItemSerum) serum.getItem()).getGenes(serum);
|
||||
for (IGene gene : genes) {
|
||||
setGene(gene, target, 0);
|
||||
setGene(gene, target, 1);
|
||||
}
|
||||
getUtil().damageItem(0, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
bacteriaDrain += 15.0f * getProgressPerTick() / 100.0f;
|
||||
if (bacteriaDrain >= 1.0f) {
|
||||
getUtil().drainTank(0, 1);
|
||||
bacteriaDrain--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentInoculatorFX extends MachineComponent implements
|
||||
IRender.RandomDisplayTick,
|
||||
IRender.DisplayTick,
|
||||
IRender.Render,
|
||||
INetwork.TilePacketSync {
|
||||
private EntityItem dummyEntityItem;
|
||||
|
||||
public ComponentInoculatorFX(IMachine machine) {
|
||||
super(machine);
|
||||
dummyEntityItem = new EntityItem(null);
|
||||
}
|
||||
|
||||
@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) {
|
||||
int tick = (int) (world.getTotalWorldTime() % 3L);
|
||||
if (tick == 0 && getUtil().getProcess().isInProgress()) {
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new EntityFX(world, x + 0.5, y + 0.92, z + 0.5, 0.0, 0.0, 0.0) {
|
||||
double axisX = posX;
|
||||
double axisZ = posZ;
|
||||
double angle = (int) (worldObj.getTotalWorldTime() % 4L) * 0.5 * 3.1415;
|
||||
|
||||
{
|
||||
axisX = 0.0;
|
||||
axisZ = 0.0;
|
||||
angle = 0.0;
|
||||
motionX = 0.0;
|
||||
motionZ = 0.0;
|
||||
motionY = 0.007 + rand.nextDouble() * 0.002;
|
||||
particleMaxAge = 240;
|
||||
particleGravity = 0.0f;
|
||||
noClip = true;
|
||||
setRBGColorF(0.8f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
double speed = 5.0E-4;
|
||||
if (particleAge > 60) {
|
||||
speed += (particleAge - 60) / 4000.0f;
|
||||
}
|
||||
angle += speed;
|
||||
double dist = 0.27;
|
||||
setPosition(axisX + dist * Math.sin(angle), posY, axisZ + dist * Math.cos(angle));
|
||||
setAlphaF((float) Math.cos(1.57 * particleAge / particleMaxAge));
|
||||
if (particleAge > 40) {
|
||||
setRBGColorF(particleRed + (1.0f - particleRed) / 10.0f, particleGreen + (0.0f - particleGreen) / 10.0f, particleBlue + (0.0f - particleBlue) / 10.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void renderInWorld(RenderItem renderItem, double x, double y, double z) {
|
||||
if (!getUtil().getProcess().isInProgress()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack stack = getUtil().getStack(9);
|
||||
dummyEntityItem.worldObj = getMachine().getWorld();
|
||||
dummyEntityItem.setEntityItemStack(stack);
|
||||
EntityItem dummyEntityItem = this.dummyEntityItem;
|
||||
dummyEntityItem.age++;
|
||||
this.dummyEntityItem.hoverStart = 0.0f;
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(180.0f, 0.0f, 0.0f, 1.0f);
|
||||
GL11.glTranslatef(0.0f, -0.25f, 0.0f);
|
||||
renderItem.doRender(this.dummyEntityItem, 0.0, 0.0, 0.0, 0.0f, 0.0f);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncToNBT(NBTTagCompound nbt) {
|
||||
NBTTagCompound item = new NBTTagCompound();
|
||||
ItemStack stack = getUtil().getStack(SLOT_TARGET);
|
||||
if (stack != null) {
|
||||
stack.writeToNBT(item);
|
||||
nbt.setTag("item", item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncFromNBT(NBTTagCompound nbt) {
|
||||
if (nbt.hasKey("item")) {
|
||||
getUtil().setStack(SLOT_TARGET, ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("item")));
|
||||
} else {
|
||||
getUtil().setStack(SLOT_TARGET, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryUpdate() {
|
||||
if (!getUtil().isServer()) {
|
||||
return;
|
||||
}
|
||||
getUtil().refreshBlock();
|
||||
}
|
||||
}
|
||||
|
||||
public static class ValidatorIndividualInoculate extends SlotValidator {
|
||||
public ValidatorIndividualInoculate() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(ItemStack object) {
|
||||
ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(object);
|
||||
return root != null && Binnie.Genetics.getSystem(root).isDNAManipulable(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Inoculable Individual";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,11 +17,11 @@ import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
|
||||
public class ModuleMachine implements IInitializable {
|
||||
public static ValidatorIcon IconDye;
|
||||
static ValidatorIcon IconSequencer;
|
||||
static ValidatorIcon IconSerum;
|
||||
static ValidatorIcon IconEnzyme;
|
||||
static ValidatorIcon IconBacteria;
|
||||
static ValidatorIcon IconNugget;
|
||||
public static ValidatorIcon IconSequencer;
|
||||
public static ValidatorIcon IconSerum;
|
||||
public static ValidatorIcon IconEnzyme;
|
||||
public static ValidatorIcon IconBacteria;
|
||||
public static ValidatorIcon IconNugget;
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
|
||||
@@ -1,302 +0,0 @@
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.machines.component.IRender;
|
||||
import binnie.core.machines.inventory.ComponentChargedSlots;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.ComponentInventoryTransfer;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.core.machines.power.ComponentProcess;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.core.machines.power.IProcess;
|
||||
import binnie.core.resource.BinnieIcon;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.genetics.GeneTracker;
|
||||
import binnie.genetics.genetics.SequencerItem;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Sequencer {
|
||||
public static final int[] SLOT_RESERVE = new int[]{1, 2, 3, 4};
|
||||
public static final int SLOT_DYE_INDEX = 0;
|
||||
public static final int SLOT_TARGET_INDEX = 5;
|
||||
public static final int SLOT_DONE_INDEX = 6;
|
||||
|
||||
public static BinnieIcon fxSeqA;
|
||||
public static BinnieIcon fxSeqG;
|
||||
public static BinnieIcon fxSeqT;
|
||||
public static BinnieIcon fxSeqC;
|
||||
|
||||
private static ComponentSequencerLogic logic;
|
||||
|
||||
public static class PackageSequencer extends GeneticMachine.PackageGeneticBase implements IMachineInformation {
|
||||
public PackageSequencer() {
|
||||
super("sequencer", GeneticsTexture.Sequencer, 0xb7ff32, true);
|
||||
Sequencer.fxSeqA = Binnie.Resource.getBlockIcon(Genetics.instance, "fx/sequencer.a");
|
||||
Sequencer.fxSeqG = Binnie.Resource.getBlockIcon(Genetics.instance, "fx/sequencer.g");
|
||||
Sequencer.fxSeqT = Binnie.Resource.getBlockIcon(Genetics.instance, "fx/sequencer.t");
|
||||
Sequencer.fxSeqC = Binnie.Resource.getBlockIcon(Genetics.instance, "fx/sequencer.c");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Sequencer);
|
||||
ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
|
||||
InventorySlot slotDye = inventory.addSlot(SLOT_DYE_INDEX, "dye");
|
||||
slotDye.setValidator(new SlotValidator.Item(GeneticsItems.FluorescentDye.get(1), ModuleMachine.IconDye));
|
||||
slotDye.forbidExtraction();
|
||||
|
||||
inventory.addSlotArray(SLOT_RESERVE, "input");
|
||||
for (InventorySlot slot : inventory.getSlots(SLOT_RESERVE)) {
|
||||
slot.setValidator(new SlotValidatorUnsequenced());
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
|
||||
InventorySlot slotTarget = inventory.addSlot(SLOT_TARGET_INDEX, "process");
|
||||
slotTarget.setValidator(new SlotValidatorUnsequenced());
|
||||
slotTarget.setReadOnly();
|
||||
slotTarget.forbidInteraction();
|
||||
|
||||
InventorySlot slotDone = inventory.addSlot(SLOT_DONE_INDEX, "output");
|
||||
slotDone.setReadOnly();
|
||||
|
||||
ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(SLOT_RESERVE, SLOT_TARGET_INDEX, 1);
|
||||
|
||||
new ComponentChargedSlots(machine).addCharge(SLOT_DYE_INDEX);
|
||||
new ComponentPowerReceptor(machine, 10000);
|
||||
logic = new ComponentSequencerLogic(machine);
|
||||
new ComponentSequencerFX(machine);
|
||||
|
||||
transfer.setTransferListener(logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentSequencerLogic extends ComponentProcess implements IProcess, ComponentInventoryTransfer.ITransferRestockListener {
|
||||
public ComponentSequencerLogic(Machine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
public float getSequenceStrength() {
|
||||
ItemStack stack = getUtil().getStack(SLOT_TARGET_INDEX);
|
||||
if (stack == null) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
float mult = 1.0f - stack.getItemDamage() % 6 / 5.0f;
|
||||
return 1.0f - mult * mult * 0.75f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessLength() {
|
||||
return (int) (19200.0f * getSequenceStrength());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessEnergy() {
|
||||
return getProcessLength() * 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (getUtil().isSlotEmpty(SLOT_TARGET_INDEX)) {
|
||||
return new ErrorState.NoItem("No DNA sequence", SLOT_TARGET_INDEX);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (getMachine().getOwner() == null) {
|
||||
return new ErrorState("No Owner", "Replace this block to claim this machine");
|
||||
}
|
||||
if (getUtil().getSlotCharge(SLOT_DYE_INDEX) == 0.0f) {
|
||||
return new ErrorState.NoItem("Insufficient Dye", SLOT_DYE_INDEX);
|
||||
}
|
||||
|
||||
ItemStack stack = getUtil().getStack(SLOT_DONE_INDEX);
|
||||
if (stack != null && stack.stackSize >= 64) {
|
||||
return new ErrorState.NoSpace("No space for empty sequences", new int[]{SLOT_DONE_INDEX});
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRestock(int target) {
|
||||
onStartTask();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStartTask() {
|
||||
super.onStartTask();
|
||||
ItemStack item = getUtil().getStack(SLOT_TARGET_INDEX);
|
||||
SequencerItem seqItem = new SequencerItem(item);
|
||||
int seq = seqItem.sequenced;
|
||||
if (seq != 0) {
|
||||
setProgress(seq);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
updateSequence();
|
||||
SequencerItem seqItem = new SequencerItem(getUtil().getStack(SLOT_TARGET_INDEX));
|
||||
GeneTracker.getTracker(getMachine().getWorld(), getMachine().getOwner()).registerGene(seqItem.getGene());
|
||||
getUtil().decreaseStack(SLOT_TARGET_INDEX, 1);
|
||||
|
||||
if (getUtil().getStack(SLOT_DONE_INDEX) == null) {
|
||||
getUtil().setStack(SLOT_DONE_INDEX, GeneticsItems.EmptySequencer.get(1));
|
||||
} else {
|
||||
getUtil().decreaseStack(SLOT_DONE_INDEX, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
updateSequence();
|
||||
getUtil().useCharge(SLOT_DYE_INDEX, 0.4f * getProgressPerTick() / 100.0f);
|
||||
}
|
||||
|
||||
private void updateSequence() {
|
||||
int prog = (int) getProgress();
|
||||
ItemStack item = getUtil().getStack(SLOT_TARGET_INDEX);
|
||||
SequencerItem seqItem = new SequencerItem(item);
|
||||
int seq = seqItem.sequenced;
|
||||
if (prog != seq) {
|
||||
seqItem.sequenced = prog;
|
||||
seqItem.writeToItem(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentSequencerFX extends MachineComponent implements IRender.RandomDisplayTick, IRender.DisplayTick {
|
||||
public ComponentSequencerFX(IMachine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onRandomDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
if (!getUtil().getProcess().isInProgress()) {
|
||||
return;
|
||||
}
|
||||
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new EntityFX(world, x + 0.5, y + 1.2 + rand.nextDouble() * 0.2, z + 0.5, 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 = 0.0;
|
||||
particleMaxAge = 200;
|
||||
particleGravity = 0.0f;
|
||||
noClip = true;
|
||||
setRBGColorF(0.6f + rand.nextFloat() * 0.2f, 1.0f, 0.8f * rand.nextFloat() * 0.2f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
angle += 0.03;
|
||||
setPosition(axisX + 0.4 * Math.sin(angle), posY, axisZ + 0.4 * Math.cos(angle));
|
||||
motionY = 0.0;
|
||||
setAlphaF((float) Math.sin(3.14 * particleAge / particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
int ticks = (int) (world.getTotalWorldTime() % 16L);
|
||||
if (ticks == 0 && getUtil().getProcess().isInProgress()) {
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new EntityFX(world, x + 0.5, y + 1, z + 0.5, 0.0, 0.0, 0.0) {
|
||||
{
|
||||
motionX = 0.0;
|
||||
motionZ = 0.0;
|
||||
motionY = 0.012;
|
||||
particleMaxAge = 50;
|
||||
particleGravity = 0.0f;
|
||||
noClip = true;
|
||||
particleScale = 2.0f;
|
||||
|
||||
setParticleIcon((new BinnieIcon[]{
|
||||
fxSeqA,
|
||||
fxSeqG,
|
||||
fxSeqC,
|
||||
fxSeqT
|
||||
})[rand.nextInt(4)].getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
motionY = 0.012;
|
||||
if (particleAge > 40) {
|
||||
setAlphaF((50 - particleAge) / 10.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class SlotValidatorUnsequenced extends SlotValidator {
|
||||
public SlotValidatorUnsequenced() {
|
||||
super(ModuleMachine.IconSequencer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(ItemStack itemStack) {
|
||||
if (itemStack.getItem() == Genetics.itemSequencer) {
|
||||
SequencerItem seq = new SequencerItem(itemStack);
|
||||
return seq.sequenced < 100;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Unsequenced DNA";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package binnie.genetics.machine.inoculator;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import binnie.core.machines.component.IRender;
|
||||
import binnie.core.machines.network.INetwork;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class ComponentInoculatorFX extends MachineComponent implements
|
||||
IRender.RandomDisplayTick,
|
||||
IRender.DisplayTick,
|
||||
IRender.Render,
|
||||
INetwork.TilePacketSync {
|
||||
private EntityItem dummyEntityItem;
|
||||
|
||||
public ComponentInoculatorFX(IMachine machine) {
|
||||
super(machine);
|
||||
dummyEntityItem = new EntityItem(null);
|
||||
}
|
||||
|
||||
@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) {
|
||||
int tick = (int) (world.getTotalWorldTime() % 3L);
|
||||
if (tick == 0 && getUtil().getProcess().isInProgress()) {
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new EntityFX(world, x + 0.5, y + 0.92, z + 0.5, 0.0, 0.0, 0.0) {
|
||||
double axisX = posX;
|
||||
double axisZ = posZ;
|
||||
double angle = (int) (worldObj.getTotalWorldTime() % 4L) * 0.5 * 3.1415;
|
||||
|
||||
{
|
||||
axisX = 0.0;
|
||||
axisZ = 0.0;
|
||||
angle = 0.0;
|
||||
motionX = 0.0;
|
||||
motionZ = 0.0;
|
||||
motionY = 0.007 + rand.nextDouble() * 0.002;
|
||||
particleMaxAge = 240;
|
||||
particleGravity = 0.0f;
|
||||
noClip = true;
|
||||
setRBGColorF(0.8f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
double speed = 5.0E-4;
|
||||
if (particleAge > 60) {
|
||||
speed += (particleAge - 60) / 4000.0f;
|
||||
}
|
||||
angle += speed;
|
||||
double dist = 0.27;
|
||||
setPosition(axisX + dist * Math.sin(angle), posY, axisZ + dist * Math.cos(angle));
|
||||
setAlphaF((float) Math.cos(1.57 * particleAge / particleMaxAge));
|
||||
if (particleAge > 40) {
|
||||
setRBGColorF(particleRed + (1.0f - particleRed) / 10.0f, particleGreen + (0.0f - particleGreen) / 10.0f, particleBlue + (0.0f - particleBlue) / 10.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void renderInWorld(RenderItem renderItem, double x, double y, double z) {
|
||||
if (!getUtil().getProcess().isInProgress()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack stack = getUtil().getStack(9);
|
||||
dummyEntityItem.worldObj = getMachine().getWorld();
|
||||
dummyEntityItem.setEntityItemStack(stack);
|
||||
EntityItem dummyEntityItem = this.dummyEntityItem;
|
||||
dummyEntityItem.age++;
|
||||
this.dummyEntityItem.hoverStart = 0.0f;
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(180.0f, 0.0f, 0.0f, 1.0f);
|
||||
GL11.glTranslatef(0.0f, -0.25f, 0.0f);
|
||||
renderItem.doRender(this.dummyEntityItem, 0.0, 0.0, 0.0, 0.0f, 0.0f);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncToNBT(NBTTagCompound nbt) {
|
||||
NBTTagCompound item = new NBTTagCompound();
|
||||
ItemStack stack = getUtil().getStack(Inoculator.SLOT_TARGET);
|
||||
if (stack != null) {
|
||||
stack.writeToNBT(item);
|
||||
nbt.setTag("item", item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncFromNBT(NBTTagCompound nbt) {
|
||||
if (nbt.hasKey("item")) {
|
||||
getUtil().setStack(Inoculator.SLOT_TARGET, ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("item")));
|
||||
} else {
|
||||
getUtil().setStack(Inoculator.SLOT_TARGET, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryUpdate() {
|
||||
if (!getUtil().isServer()) {
|
||||
return;
|
||||
}
|
||||
getUtil().refreshBlock();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package binnie.genetics.machine.inoculator;
|
||||
|
||||
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.genetics.api.IGene;
|
||||
import binnie.genetics.api.IItemSerum;
|
||||
import binnie.genetics.genetics.Engineering;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.IGenome;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ComponentInoculatorLogic extends ComponentProcessSetCost implements IProcess {
|
||||
private float bacteriaDrain;
|
||||
|
||||
public ComponentInoculatorLogic(Machine machine) {
|
||||
super(machine, 600000, 12000);
|
||||
bacteriaDrain = 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessLength() {
|
||||
return super.getProcessLength() * getNumberOfGenes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessEnergy() {
|
||||
return super.getProcessEnergy() * getNumberOfGenes();
|
||||
}
|
||||
|
||||
private int getNumberOfGenes() {
|
||||
ItemStack serum = getUtil().getStack(Inoculator.SLOT_SERUM_VIAL);
|
||||
if (serum == null) {
|
||||
return 1;
|
||||
}
|
||||
return Engineering.getGenes(serum).length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
int n = getNumberOfGenes();
|
||||
return "Inoculating with " + n + " gene" + ((n > 1) ? "s" : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (getUtil().isSlotEmpty(Inoculator.SLOT_TARGET)) {
|
||||
return new ErrorState.NoItem("No Individual to Inoculate", Inoculator.SLOT_TARGET);
|
||||
}
|
||||
if (getUtil().isSlotEmpty(Inoculator.SLOT_SERUM_VIAL)) {
|
||||
return new ErrorState.NoItem("No Serum", Inoculator.SLOT_SERUM_VIAL);
|
||||
}
|
||||
if (getUtil().isTankEmpty(Inoculator.TANK_VECTOR)) {
|
||||
return new ErrorState.InsufficientLiquid("Not enough liquid", Inoculator.TANK_VECTOR);
|
||||
}
|
||||
|
||||
ErrorState state = isValidSerum();
|
||||
if (state != null) {
|
||||
return state;
|
||||
}
|
||||
|
||||
ItemStack stack = getUtil().getStack(Inoculator.SLOT_SERUM_VIAL);
|
||||
if (stack != null && Engineering.getCharges(stack) == 0) {
|
||||
return new ErrorState("Empty Serum", "Serum is empty");
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
public ErrorState isValidSerum() {
|
||||
ItemStack serum = getUtil().getStack(Inoculator.SLOT_SERUM_VIAL);
|
||||
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");
|
||||
}
|
||||
if (!genes[0].getSpeciesRoot().isMember(target)) {
|
||||
return new ErrorState("Invalid Serum", "Mismatch of Serum Type and Target");
|
||||
}
|
||||
|
||||
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) {
|
||||
return new ErrorState("Defunct Serum", "Individual already possesses this allele");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
ItemStack serum = getUtil().getStack(Inoculator.SLOT_SERUM_VIAL);
|
||||
ItemStack target = getUtil().getStack(Inoculator.SLOT_TARGET);
|
||||
IIndividual ind = AlleleManager.alleleRegistry.getIndividual(target);
|
||||
if (!ind.isAnalyzed()) {
|
||||
ind.analyze();
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
ind.writeToNBT(nbttagcompound);
|
||||
target.setTagCompound(nbttagcompound);
|
||||
}
|
||||
|
||||
IGene[] genes = ((IItemSerum) serum.getItem()).getGenes(serum);
|
||||
for (IGene gene : genes) {
|
||||
Inoculator.setGene(gene, target, 0);
|
||||
Inoculator.setGene(gene, target, 1);
|
||||
}
|
||||
getUtil().damageItem(0, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
bacteriaDrain += 15.0f * getProgressPerTick() / 100.0f;
|
||||
if (bacteriaDrain >= 1.0f) {
|
||||
getUtil().drainTank(0, 1);
|
||||
bacteriaDrain--;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package binnie.genetics.machine.inoculator;
|
||||
|
||||
import binnie.genetics.api.IGene;
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.apiculture.IBeeRoot;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
public class Inoculator {
|
||||
public static final int SLOT_SERUM_VIAL = 0;
|
||||
public static final int[] SLOT_SERUM_RESERVE = new int[]{1, 2};
|
||||
public static final int[] SLOT_SERUM_EXPENDED = new int[]{3, 4};
|
||||
public static final int[] SLOT_RESERVE = new int[]{5, 6, 7, 8};
|
||||
public static final int SLOT_TARGET = 9;
|
||||
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 void setGene(IGene gene, ItemStack target, int chromoN) {
|
||||
int chromosomeID = gene.getChromosome().ordinal();
|
||||
if (chromosomeID >= EnumBeeChromosome.HUMIDITY.ordinal() && gene.getSpeciesRoot() instanceof IBeeRoot) {
|
||||
chromosomeID--;
|
||||
}
|
||||
|
||||
Class<? extends IAllele> cls = gene.getChromosome().getAlleleClass();
|
||||
if (!cls.isInstance(gene.getAllele())) {
|
||||
return;
|
||||
}
|
||||
|
||||
NBTTagCompound beeNBT = target.getTagCompound();
|
||||
NBTTagCompound genomeNBT = beeNBT.getCompoundTag("Genome");
|
||||
NBTTagList chromosomes = genomeNBT.getTagList("Chromosomes", 10);
|
||||
NBTTagCompound chromosomeNBT = chromosomes.getCompoundTagAt(chromosomeID);
|
||||
chromosomeNBT.setString("UID" + chromoN, gene.getAllele().getUID());
|
||||
target.setTagCompound(beeNBT);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package binnie.genetics.machine.inoculator;
|
||||
|
||||
import binnie.core.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
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.Validator;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.genetics.api.IItemSerum;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.genetics.Engineering;
|
||||
import binnie.genetics.item.GeneticLiquid;
|
||||
import binnie.genetics.machine.ComponentGeneticGUI;
|
||||
import binnie.genetics.machine.GeneticMachine;
|
||||
import binnie.genetics.machine.ModuleMachine;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class PackageInoculator extends GeneticMachine.PackageGeneticBase implements IMachineInformation {
|
||||
public PackageInoculator() {
|
||||
super("inoculator", GeneticsTexture.Inoculator, 0xe22235, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Inoculator);
|
||||
ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
InventorySlot slotSerumVial = inventory.addSlot(Inoculator.SLOT_SERUM_VIAL, "serum.active");
|
||||
slotSerumVial.forbidInteraction();
|
||||
slotSerumVial.setReadOnly();
|
||||
|
||||
SlotValidator serumValid = new SlotValidator(ModuleMachine.IconSerum) {
|
||||
@Override
|
||||
public boolean isValid(ItemStack itemStack) {
|
||||
return itemStack.getItem() instanceof IItemSerum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Serum Vials & Arrays";
|
||||
}
|
||||
};
|
||||
|
||||
slotSerumVial.setValidator(serumValid);
|
||||
|
||||
inventory.addSlotArray(Inoculator.SLOT_SERUM_RESERVE, "serum.input");
|
||||
for (InventorySlot slot : inventory.getSlots(Inoculator.SLOT_SERUM_RESERVE)) {
|
||||
slot.setValidator(serumValid);
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
|
||||
inventory.addSlotArray(Inoculator.SLOT_SERUM_EXPENDED, "serum.output");
|
||||
for (InventorySlot slot : inventory.getSlots(Inoculator.SLOT_SERUM_EXPENDED)) {
|
||||
slot.setValidator(serumValid);
|
||||
slot.setReadOnly();
|
||||
}
|
||||
|
||||
inventory.addSlotArray(Inoculator.SLOT_RESERVE, "input");
|
||||
for (InventorySlot slot : inventory.getSlots(Inoculator.SLOT_RESERVE)) {
|
||||
slot.forbidExtraction();
|
||||
slot.setValidator(new ValidatorIndividualInoculate());
|
||||
}
|
||||
|
||||
inventory.addSlot(Inoculator.SLOT_TARGET, "process");
|
||||
inventory.getSlot(Inoculator.SLOT_TARGET).setValidator(new ValidatorIndividualInoculate());
|
||||
inventory.getSlot(Inoculator.SLOT_TARGET).setReadOnly();
|
||||
inventory.getSlot(Inoculator.SLOT_TARGET).forbidInteraction();
|
||||
inventory.addSlotArray(Inoculator.SLOT_FINISHED, "output");
|
||||
for (InventorySlot slot : inventory.getSlots(Inoculator.SLOT_FINISHED)) {
|
||||
slot.setReadOnly();
|
||||
slot.forbidInsertion();
|
||||
slot.setValidator(new ValidatorIndividualInoculate());
|
||||
}
|
||||
|
||||
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() {
|
||||
@Override
|
||||
public boolean fufilled(ItemStack stack) {
|
||||
return Engineering.getCharges(stack) == 0;
|
||||
}
|
||||
});
|
||||
|
||||
transfer.addStorage(9, Inoculator.SLOT_FINISHED, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(ItemStack stack) {
|
||||
return stack != null
|
||||
&& transfer.getMachine().getMachineUtil().getStack(Inoculator.SLOT_SERUM_VIAL) != null
|
||||
&& transfer.getMachine().getInterface(ComponentInoculatorLogic.class).isValidSerum() != null;
|
||||
}
|
||||
});
|
||||
|
||||
new ComponentPowerReceptor(machine, 15000);
|
||||
new ComponentInoculatorLogic(machine);
|
||||
new ComponentInoculatorFX(machine);
|
||||
new ComponentTankContainer(machine)
|
||||
.addTank(Inoculator.TANK_VECTOR, "input", Inoculator.TANK_CAPACITY)
|
||||
.setValidator(new Validator<FluidStack>() {
|
||||
@Override
|
||||
public boolean isValid(FluidStack object) {
|
||||
return GeneticLiquid.BacteriaVector.get(1).isFluidEqual(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return GeneticLiquid.BacteriaVector.getName();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package binnie.genetics.machine.inoculator;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ValidatorIndividualInoculate extends SlotValidator {
|
||||
public ValidatorIndividualInoculate() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(ItemStack object) {
|
||||
ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(object);
|
||||
return root != null && Binnie.Genetics.getSystem(root).isDNAManipulable(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Inoculable Individual";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package binnie.genetics.machine.sequencer;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import binnie.core.machines.component.IRender;
|
||||
import binnie.core.resource.BinnieIcon;
|
||||
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 ComponentSequencerFX extends MachineComponent implements IRender.RandomDisplayTick, IRender.DisplayTick {
|
||||
public ComponentSequencerFX(IMachine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onRandomDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
if (!getUtil().getProcess().isInProgress()) {
|
||||
return;
|
||||
}
|
||||
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new EntityFX(world, x + 0.5, y + 1.2 + rand.nextDouble() * 0.2, z + 0.5, 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 = 0.0;
|
||||
particleMaxAge = 200;
|
||||
particleGravity = 0.0f;
|
||||
noClip = true;
|
||||
setRBGColorF(0.6f + rand.nextFloat() * 0.2f, 1.0f, 0.8f * rand.nextFloat() * 0.2f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
angle += 0.03;
|
||||
setPosition(axisX + 0.4 * Math.sin(angle), posY, axisZ + 0.4 * Math.cos(angle));
|
||||
motionY = 0.0;
|
||||
setAlphaF((float) Math.sin(3.14 * particleAge / particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
int ticks = (int) (world.getTotalWorldTime() % 16L);
|
||||
if (ticks == 0 && getUtil().getProcess().isInProgress()) {
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new EntityFX(world, x + 0.5, y + 1, z + 0.5, 0.0, 0.0, 0.0) {
|
||||
{
|
||||
motionX = 0.0;
|
||||
motionZ = 0.0;
|
||||
motionY = 0.012;
|
||||
particleMaxAge = 50;
|
||||
particleGravity = 0.0f;
|
||||
noClip = true;
|
||||
particleScale = 2.0f;
|
||||
|
||||
setParticleIcon((new BinnieIcon[]{
|
||||
Sequencer.fxSeqA,
|
||||
Sequencer.fxSeqG,
|
||||
Sequencer.fxSeqC,
|
||||
Sequencer.fxSeqT
|
||||
})[rand.nextInt(4)].getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
motionY = 0.012;
|
||||
if (particleAge > 40) {
|
||||
setAlphaF((50 - particleAge) / 10.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package binnie.genetics.machine.sequencer;
|
||||
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.inventory.ComponentInventoryTransfer;
|
||||
import binnie.core.machines.power.ComponentProcess;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.core.machines.power.IProcess;
|
||||
import binnie.genetics.genetics.GeneTracker;
|
||||
import binnie.genetics.genetics.SequencerItem;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ComponentSequencerLogic extends ComponentProcess implements IProcess, ComponentInventoryTransfer.ITransferRestockListener {
|
||||
public ComponentSequencerLogic(Machine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
public float getSequenceStrength() {
|
||||
ItemStack stack = getUtil().getStack(Sequencer.SLOT_TARGET_INDEX);
|
||||
if (stack == null) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
float mult = 1.0f - stack.getItemDamage() % 6 / 5.0f;
|
||||
return 1.0f - mult * mult * 0.75f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessLength() {
|
||||
return (int) (19200.0f * getSequenceStrength());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessEnergy() {
|
||||
return getProcessLength() * 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (getUtil().isSlotEmpty(Sequencer.SLOT_TARGET_INDEX)) {
|
||||
return new ErrorState.NoItem("No DNA sequence", Sequencer.SLOT_TARGET_INDEX);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (getMachine().getOwner() == null) {
|
||||
return new ErrorState("No Owner", "Replace this block to claim this machine");
|
||||
}
|
||||
if (getUtil().getSlotCharge(Sequencer.SLOT_DYE_INDEX) == 0.0f) {
|
||||
return new ErrorState.NoItem("Insufficient Dye", Sequencer.SLOT_DYE_INDEX);
|
||||
}
|
||||
|
||||
ItemStack stack = getUtil().getStack(Sequencer.SLOT_DONE_INDEX);
|
||||
if (stack != null && stack.stackSize >= 64) {
|
||||
return new ErrorState.NoSpace("No space for empty sequences", new int[]{Sequencer.SLOT_DONE_INDEX});
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRestock(int target) {
|
||||
onStartTask();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStartTask() {
|
||||
super.onStartTask();
|
||||
ItemStack item = getUtil().getStack(Sequencer.SLOT_TARGET_INDEX);
|
||||
SequencerItem seqItem = new SequencerItem(item);
|
||||
int seq = seqItem.sequenced;
|
||||
if (seq != 0) {
|
||||
setProgress(seq);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
updateSequence();
|
||||
SequencerItem seqItem = new SequencerItem(getUtil().getStack(Sequencer.SLOT_TARGET_INDEX));
|
||||
GeneTracker.getTracker(getMachine().getWorld(), getMachine().getOwner()).registerGene(seqItem.getGene());
|
||||
getUtil().decreaseStack(Sequencer.SLOT_TARGET_INDEX, 1);
|
||||
|
||||
if (getUtil().getStack(Sequencer.SLOT_DONE_INDEX) == null) {
|
||||
getUtil().setStack(Sequencer.SLOT_DONE_INDEX, GeneticsItems.EmptySequencer.get(1));
|
||||
} else {
|
||||
getUtil().decreaseStack(Sequencer.SLOT_DONE_INDEX, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
updateSequence();
|
||||
getUtil().useCharge(Sequencer.SLOT_DYE_INDEX, 0.4f * getProgressPerTick() / 100.0f);
|
||||
}
|
||||
|
||||
private void updateSequence() {
|
||||
int prog = (int) getProgress();
|
||||
ItemStack item = getUtil().getStack(Sequencer.SLOT_TARGET_INDEX);
|
||||
SequencerItem seqItem = new SequencerItem(item);
|
||||
int seq = seqItem.sequenced;
|
||||
if (prog != seq) {
|
||||
seqItem.sequenced = prog;
|
||||
seqItem.writeToItem(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package binnie.genetics.machine.sequencer;
|
||||
|
||||
import binnie.Binnie;
|
||||
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.InventorySlot;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import binnie.genetics.machine.ComponentGeneticGUI;
|
||||
import binnie.genetics.machine.GeneticMachine;
|
||||
import binnie.genetics.machine.ModuleMachine;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class PackageSequencer extends GeneticMachine.PackageGeneticBase implements IMachineInformation {
|
||||
private ComponentSequencerLogic logic;
|
||||
|
||||
public PackageSequencer() {
|
||||
super("sequencer", GeneticsTexture.Sequencer, 0xb7ff32, true);
|
||||
Sequencer.fxSeqA = Binnie.Resource.getBlockIcon(Genetics.instance, "fx/sequencer.a");
|
||||
Sequencer.fxSeqG = Binnie.Resource.getBlockIcon(Genetics.instance, "fx/sequencer.g");
|
||||
Sequencer.fxSeqT = Binnie.Resource.getBlockIcon(Genetics.instance, "fx/sequencer.t");
|
||||
Sequencer.fxSeqC = Binnie.Resource.getBlockIcon(Genetics.instance, "fx/sequencer.c");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Sequencer);
|
||||
ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
|
||||
InventorySlot slotDye = inventory.addSlot(Sequencer.SLOT_DYE_INDEX, "dye");
|
||||
slotDye.setValidator(new SlotValidator.Item(GeneticsItems.FluorescentDye.get(1), ModuleMachine.IconDye));
|
||||
slotDye.forbidExtraction();
|
||||
|
||||
inventory.addSlotArray(Sequencer.SLOT_RESERVE, "input");
|
||||
for (InventorySlot slot : inventory.getSlots(Sequencer.SLOT_RESERVE)) {
|
||||
slot.setValidator(new SlotValidatorUnsequenced());
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
|
||||
InventorySlot slotTarget = inventory.addSlot(Sequencer.SLOT_TARGET_INDEX, "process");
|
||||
slotTarget.setValidator(new SlotValidatorUnsequenced());
|
||||
slotTarget.setReadOnly();
|
||||
slotTarget.forbidInteraction();
|
||||
|
||||
InventorySlot slotDone = inventory.addSlot(Sequencer.SLOT_DONE_INDEX, "output");
|
||||
slotDone.setReadOnly();
|
||||
|
||||
ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Sequencer.SLOT_RESERVE, Sequencer.SLOT_TARGET_INDEX, 1);
|
||||
|
||||
new ComponentChargedSlots(machine).addCharge(Sequencer.SLOT_DYE_INDEX);
|
||||
new ComponentPowerReceptor(machine, 10000);
|
||||
new ComponentSequencerFX(machine);
|
||||
|
||||
logic = new ComponentSequencerLogic(machine);
|
||||
transfer.setTransferListener(logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package binnie.genetics.machine.sequencer;
|
||||
|
||||
import binnie.core.resource.BinnieIcon;
|
||||
|
||||
public class Sequencer {
|
||||
public static final int[] SLOT_RESERVE = new int[]{1, 2, 3, 4};
|
||||
public static final int SLOT_DYE_INDEX = 0;
|
||||
public static final int SLOT_TARGET_INDEX = 5;
|
||||
public static final int SLOT_DONE_INDEX = 6;
|
||||
|
||||
public static BinnieIcon fxSeqA;
|
||||
public static BinnieIcon fxSeqG;
|
||||
public static BinnieIcon fxSeqT;
|
||||
public static BinnieIcon fxSeqC;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package binnie.genetics.machine.sequencer;
|
||||
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.genetics.SequencerItem;
|
||||
import binnie.genetics.machine.ModuleMachine;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotValidatorUnsequenced extends SlotValidator {
|
||||
public SlotValidatorUnsequenced() {
|
||||
super(ModuleMachine.IconSequencer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(ItemStack itemStack) {
|
||||
if (itemStack.getItem() == Genetics.itemSequencer) {
|
||||
SequencerItem seq = new SequencerItem(itemStack);
|
||||
return seq.sequenced < 100;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Unsequenced DNA";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user