mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-28 07:56:01 +00:00
Clean Up
This commit is contained in:
1 parent
84d8ad9144
commit
154207f60f
77 files changed
+2116
-1987
No files matched your search
@@ -29,8 +29,8 @@ import binnie.craftgui.resource.minecraft.CraftGUITexture;
|
||||
import binnie.craftgui.window.Panel;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import binnie.genetics.machine.Analyser;
|
||||
import binnie.genetics.machine.ModuleMachine;
|
||||
import binnie.genetics.machine.analyser.Analyser;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
@@ -84,7 +84,7 @@ public class WindowAnalyst extends Window {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getName() {
|
||||
protected String getBackgroundTextureName() {
|
||||
return "Analyst";
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,11 @@ import binnie.core.machines.IMachineType;
|
||||
import binnie.core.machines.MachinePackage;
|
||||
import binnie.core.resource.IBinnieTexture;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.machine.splicer.PackageSplicer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public enum AdvGeneticMachine implements IMachineType {
|
||||
Splicer(Splicer.PackageSplicer.class);
|
||||
Splicer(PackageSplicer.class);
|
||||
|
||||
Class<? extends MachinePackage> clss;
|
||||
|
||||
|
||||
@@ -1,296 +0,0 @@
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.BinnieCore;
|
||||
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.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.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.genetics.api.IItemAnalysable;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Analyser {
|
||||
public static final int[] slotReserve = new int[]{0, 1, 2, 3, 4, 5};
|
||||
public static final int slotTarget = 6;
|
||||
public static final int[] slotFinished = new int[]{7, 8, 9, 10, 11, 12};
|
||||
public static final int slotDye = 13;
|
||||
|
||||
public static boolean isAnalysable(final ItemStack stack) {
|
||||
final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(stack);
|
||||
return ind != null || stack.getItem() instanceof IItemAnalysable || Binnie.Genetics.getConversion(stack) != null;
|
||||
}
|
||||
|
||||
public static boolean isAnalysed(final ItemStack stack) {
|
||||
final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(stack);
|
||||
if (ind != null) {
|
||||
return ind.isAnalyzed();
|
||||
}
|
||||
return stack.getItem() instanceof IItemAnalysable && ((IItemAnalysable) stack.getItem()).isAnalysed(stack);
|
||||
}
|
||||
|
||||
public static ItemStack analyse(ItemStack stack) {
|
||||
final ItemStack conv = Binnie.Genetics.getConversionStack(stack);
|
||||
if (conv != null) {
|
||||
stack = conv;
|
||||
}
|
||||
final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack);
|
||||
if (root != null) {
|
||||
final IIndividual ind = root.getMember(stack);
|
||||
ind.analyze();
|
||||
final NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
ind.writeToNBT(nbttagcompound);
|
||||
stack.setTagCompound(nbttagcompound);
|
||||
return stack;
|
||||
}
|
||||
if (stack.getItem() instanceof IItemAnalysable) {
|
||||
return ((IItemAnalysable) stack.getItem()).analyse(stack);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
public static class PackageAnalyser extends GeneticMachine.PackageGeneticBase implements IMachineInformation {
|
||||
public PackageAnalyser() {
|
||||
super("analyser", GeneticsTexture.Analyser, 9961727, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Analyser);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlotArray(Analyser.slotReserve, "input");
|
||||
for (final InventorySlot slot : inventory.getSlots(Analyser.slotReserve)) {
|
||||
slot.setValidator(new SlotValidatorUnanalysed());
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
inventory.addSlot(6, "analyse");
|
||||
inventory.getSlot(6).setValidator(new SlotValidatorUnanalysed());
|
||||
inventory.getSlot(6).setReadOnly();
|
||||
inventory.getSlot(6).forbidInteraction();
|
||||
inventory.addSlot(13, "dye");
|
||||
inventory.getSlot(13).forbidExtraction();
|
||||
inventory.getSlot(13).setValidator(new SlotValidator(ModuleMachine.IconDye) {
|
||||
@Override
|
||||
public boolean isValid(final ItemStack itemStack) {
|
||||
return itemStack.isItemEqual(GeneticsItems.DNADye.get(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "DNA Dye";
|
||||
}
|
||||
});
|
||||
inventory.addSlotArray(Analyser.slotFinished, "output");
|
||||
for (final InventorySlot slot : inventory.getSlots(Analyser.slotFinished)) {
|
||||
slot.forbidInsertion();
|
||||
slot.setReadOnly();
|
||||
}
|
||||
final ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Analyser.slotReserve, 6, 1);
|
||||
transfer.addStorage(6, Analyser.slotFinished, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(final ItemStack stack) {
|
||||
return Analyser.isAnalysed(stack);
|
||||
}
|
||||
});
|
||||
new ComponentChargedSlots(machine).addCharge(13);
|
||||
new ComponentPowerReceptor(machine, 500);
|
||||
new ComponentAnalyserLogic(machine);
|
||||
new ComponentAnalyserFX(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentAnalyserLogic extends ComponentProcessSetCost implements IProcess {
|
||||
private static final float DYE_PER_TICK = 0.002f;
|
||||
|
||||
public ComponentAnalyserLogic(final Machine machine) {
|
||||
super(machine, 9000, 300);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isSlotEmpty(6)) {
|
||||
return new ErrorState.NoItem("No item to analyse", 6);
|
||||
}
|
||||
final boolean analysed = Analyser.isAnalysed(this.getUtil().getStack(6));
|
||||
if (analysed) {
|
||||
return new ErrorState.InvalidItem("Already Analysed", "Item has already been analysed", 6);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (this.getUtil().getSlotCharge(13) == 0.0f) {
|
||||
return new ErrorState.Item("Insufficient Dye", "Not enough DNA dye to analyse", new int[]{13});
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
ItemStack itemStack = this.getUtil().getStack(6);
|
||||
itemStack = Analyser.analyse(itemStack);
|
||||
this.getInventory().setInventorySlotContents(6, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
this.getUtil().useCharge(13, 0.002f);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SlotValidatorUnanalysed extends SlotValidator {
|
||||
public SlotValidatorUnanalysed() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final ItemStack itemStack) {
|
||||
return Analyser.isAnalysable(itemStack) && !Analyser.isAnalysed(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Unanalysed Item";
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentAnalyserFX extends MachineComponent implements IRender.DisplayTick, IRender.Render, INetwork.TilePacketSync {
|
||||
private final EntityItem dummyEntityItem;
|
||||
|
||||
public ComponentAnalyserFX(final IMachine machine) {
|
||||
super(machine);
|
||||
this.dummyEntityItem = new EntityItem(machine.getWorld());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(World world, BlockPos pos, Random rand) {
|
||||
if (rand.nextFloat() < 1.0f && this.getUtil().getProcess().isInProgress()) {
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new Particle(world, pos.getX() + 0.5, pos.getY() + 1.3 + rand.nextDouble() * 0.2, pos.getZ() + 0.5, 0.0, 0.0, 0.0) {
|
||||
double axisX = this.posX;
|
||||
double axisZ = this.posZ;
|
||||
double angle = this.rand.nextDouble() * 2.0 * 3.1415;
|
||||
|
||||
{
|
||||
this.axisX = 0.0;
|
||||
this.axisZ = 0.0;
|
||||
this.angle = 0.0;
|
||||
this.motionX = 0.05 * (this.rand.nextDouble() - 0.5);
|
||||
this.motionZ = 0.05 * (this.rand.nextDouble() - 0.5);
|
||||
this.motionY = 0.0;
|
||||
this.particleMaxAge = 25;
|
||||
this.particleGravity = 0.05f;
|
||||
this.field_190017_n = true;
|
||||
this.setRBGColorF(0.6f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
this.setAlphaF((float) Math.cos(1.57 * this.particleAge / this.particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void renderInWorld(final double x, final double y, final double z) {
|
||||
if (!this.getUtil().getProcess().isInProgress()) {
|
||||
return;
|
||||
}
|
||||
final ItemStack stack = this.getUtil().getStack(6);
|
||||
this.dummyEntityItem.worldObj = this.getMachine().getWorld();
|
||||
this.dummyEntityItem.setEntityItemStack(stack);
|
||||
final EntityItem dummyEntityItem = this.dummyEntityItem;
|
||||
dummyEntityItem.setAgeToCreativeDespawnTime(); //++dummyEntityItem.age;
|
||||
this.dummyEntityItem.hoverStart = 0.0f;
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
final EntityPlayer player = BinnieCore.proxy.getPlayer();
|
||||
final double dx = x + 0.5 - player.lastTickPosX;
|
||||
final double dz = z + 0.5 - player.lastTickPosZ;
|
||||
final double t = Math.atan2(dz, dx) * 180.0 / 3.1415;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(180.0f, 0.0f, 0.0f, 1.0f);
|
||||
GL11.glTranslatef(0.0f, -0.2f, 0.0f);
|
||||
BinnieCore.proxy.getMinecraftInstance().getRenderItem().renderItem(dummyEntityItem.getEntityItem(), ItemCameraTransforms.TransformType.FIXED);//doRender(this.dummyEntityItem.getEntityItem(), 0.0, 0.0, 0.0, 0.0f, 0.0f);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncToNBT(final NBTTagCompound nbt) {
|
||||
final NBTTagCompound item = new NBTTagCompound();
|
||||
final ItemStack stack = this.getUtil().getStack(6);
|
||||
if (stack != null) {
|
||||
stack.writeToNBT(item);
|
||||
nbt.setTag("item", item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncFromNBT(final NBTTagCompound nbt) {
|
||||
if (nbt.hasKey("item")) {
|
||||
this.getUtil().setStack(6, ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("item")));
|
||||
} else {
|
||||
this.getUtil().setStack(6, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryUpdate() {
|
||||
if (this.getUtil().isServer()) {
|
||||
//TODO fix update
|
||||
//this.getMachine().getWorld().markBlockForUpdate(this.getMachine().getTileEntity().xCoord, this.getMachine().getTileEntity().yCoord, this.getMachine().getTileEntity().zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,214 +0,0 @@
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.BinnieCore;
|
||||
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.ComponentTankContainer;
|
||||
import binnie.core.machines.inventory.IChargedSlots;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.machines.inventory.TankValidator;
|
||||
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.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.item.GeneticLiquid;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Genepool {
|
||||
public static final int slotBee = 0;
|
||||
public static final int[] slotReserve = new int[]{1, 2, 3, 4, 5, 6};
|
||||
public static final int tankDNA = 0;
|
||||
public static final int tankEthanol = 1;
|
||||
public static final int slotEnzyme = 7;
|
||||
|
||||
public static class PackageGenepool extends GeneticMachine.PackageGeneticBase implements IMachineInformation {
|
||||
public PackageGenepool() {
|
||||
super("genepool", GeneticsTexture.Genepool, 12661942, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Genepool);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(7, "enzyme");
|
||||
inventory.getSlot(7).setValidator(new SlotValidator.Item(GeneticsItems.Enzyme.get(1), ModuleMachine.IconEnzyme));
|
||||
inventory.getSlot(7).forbidExtraction();
|
||||
inventory.addSlot(0, "process");
|
||||
inventory.getSlot(0).setValidator(new SlotValidator.Individual());
|
||||
inventory.getSlot(0).setReadOnly();
|
||||
inventory.getSlot(0).forbidExtraction();
|
||||
inventory.addSlotArray(Genepool.slotReserve, "input");
|
||||
for (final InventorySlot slot : inventory.getSlots(Genepool.slotReserve)) {
|
||||
slot.setValidator(new SlotValidator.Individual());
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
final ComponentTankContainer tanks = new ComponentTankContainer(machine);
|
||||
tanks.addTank(0, "output", 2000);
|
||||
tanks.getTankSlot(0).setReadOnly();
|
||||
tanks.addTank(1, "input", 1000);
|
||||
tanks.getTankSlot(1).forbidExtraction();
|
||||
tanks.getTankSlot(1).setValidator(new TankValidator() {
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Ethanol";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final FluidStack stack) {
|
||||
return "bio.ethanol".equals(stack.getFluid().getName());
|
||||
}
|
||||
});
|
||||
final ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Genepool.slotReserve, 0, 1);
|
||||
new ComponentPowerReceptor(machine, 1600);
|
||||
new ComponentGenepoolLogic(machine);
|
||||
final ComponentChargedSlots chargedSlots = new ComponentChargedSlots(machine);
|
||||
chargedSlots.addCharge(7);
|
||||
new ComponentGenepoolFX(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentGenepoolLogic extends ComponentProcessSetCost implements IProcess {
|
||||
float enzymePerProcess;
|
||||
float ethanolPerProcess;
|
||||
private float ethanolDrain;
|
||||
|
||||
public ComponentGenepoolLogic(final Machine machine) {
|
||||
super(machine, 8000, 400);
|
||||
this.enzymePerProcess = 0.25f;
|
||||
this.ethanolPerProcess = 50.0f;
|
||||
this.ethanolDrain = 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isSlotEmpty(0)) {
|
||||
return new ErrorState.NoItem("No Individual", 0);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (!this.getUtil().spaceInTank(0, this.getDNAAmount(this.getUtil().getStack(0)))) {
|
||||
return new ErrorState.NoSpace("Not enough room in Tank", new int[]{0});
|
||||
}
|
||||
if (!this.getUtil().liquidInTank(1, 1)) {
|
||||
return new ErrorState.InsufficientLiquid("Not enough Ethanol", 1);
|
||||
}
|
||||
if (this.getUtil().getSlotCharge(7) == 0.0f) {
|
||||
return new ErrorState.NoItem("Insufficient Enzyme", 7);
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
final int amount = this.getDNAAmount(this.getUtil().getStack(0));
|
||||
this.getUtil().fillTank(0, GeneticLiquid.RawDNA.get(amount));
|
||||
this.getUtil().deleteStack(0);
|
||||
}
|
||||
|
||||
private int getDNAAmount(final ItemStack stack) {
|
||||
final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack);
|
||||
if (root == null) {
|
||||
return 10;
|
||||
}
|
||||
if (root != Binnie.Genetics.getBeeRoot()) {
|
||||
return 10;
|
||||
}
|
||||
if (Binnie.Genetics.getBeeRoot().isDrone(stack)) {
|
||||
return 10;
|
||||
}
|
||||
if (Binnie.Genetics.getBeeRoot().isMated(stack)) {
|
||||
return 50;
|
||||
}
|
||||
return 30;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
this.ethanolDrain += this.getDNAAmount(this.getUtil().getStack(0)) * 1.2f * this.getProgressPerTick() / 100.0f;
|
||||
if (this.ethanolDrain >= 1.0f) {
|
||||
this.getUtil().drainTank(1, 1);
|
||||
--this.ethanolDrain;
|
||||
}
|
||||
this.getMachine().getInterface(IChargedSlots.class).alterCharge(7, -this.enzymePerProcess * this.getProgressPerTick() / 100.0f);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentGenepoolFX extends MachineComponent implements IRender.DisplayTick {
|
||||
public ComponentGenepoolFX(final IMachine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(World world, BlockPos pos, Random rand) {
|
||||
if (rand.nextFloat() < 1.0f && this.getUtil().getProcess().isInProgress()) {
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new Particle(world, pos.getX() + 0.3 + rand.nextDouble() * 0.4, pos.getY() + 1, pos.getZ() + 0.3 + rand.nextDouble() * 0.4, 0.0, 0.0, 0.0) {
|
||||
double axisX = this.posX;
|
||||
double axisZ = this.posZ;
|
||||
double angle = this.rand.nextDouble() * 2.0 * 3.1415;
|
||||
|
||||
{
|
||||
this.axisX = 0.0;
|
||||
this.axisZ = 0.0;
|
||||
this.angle = 0.0;
|
||||
this.motionX = 0.0;
|
||||
this.motionZ = 0.0;
|
||||
this.motionY = this.rand.nextFloat() * 0.01;
|
||||
this.particleMaxAge = 25;
|
||||
this.particleGravity = 0.0f;
|
||||
this.field_190017_n = true;
|
||||
this.setRBGColorF(0.4f + 0.6f * this.rand.nextFloat(), 0.6f * this.rand.nextFloat(), 0.6f + 0.4f * this.rand.nextFloat());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
this.setAlphaF((float) Math.cos(1.57 * this.particleAge / this.particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,15 +7,18 @@ 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.isolator.PackageIsolator;
|
||||
import binnie.genetics.machine.polymeriser.PackagePolymeriser;
|
||||
import binnie.genetics.machine.sequencer.PackageSequencer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public enum GeneticMachine implements IMachineType {
|
||||
Isolator(Isolator.PackageIsolator.class),
|
||||
Sequencer(Sequencer.PackageSequencer.class),
|
||||
Isolator(PackageIsolator.class),
|
||||
Sequencer(PackageSequencer.class),
|
||||
Polymeriser(PackagePolymeriser.class),
|
||||
Inoculator(Inoculator.PackageInoculator.class);
|
||||
Inoculator(PackageInoculator.class);
|
||||
|
||||
Class<? extends MachinePackage> clss;
|
||||
|
||||
|
||||
@@ -1,404 +0,0 @@
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.BinnieCore;
|
||||
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.craftgui.minecraft.IMachineInformation;
|
||||
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 forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.apiculture.IBeeRoot;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Inoculator {
|
||||
public static final int slotSerumVial = 0;
|
||||
public static final int[] slotSerumReserve = new int[]{1, 2};
|
||||
public static final int[] slotSerumExpended = new int[]{3, 4};
|
||||
public static final int[] slotReserve = new int[]{5, 6, 7, 8};
|
||||
public static final int slotTarget = 9;
|
||||
public static final int[] slotFinished = new int[]{10, 11, 12, 13};
|
||||
public static final int tankVector = 0;
|
||||
|
||||
public static void setGene(final IGene gene, final ItemStack target, final int chromoN) {
|
||||
int chromosomeID;
|
||||
final int chromosome = chromosomeID = gene.getChromosome().ordinal();
|
||||
if (chromosomeID >= EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal() && gene.getSpeciesRoot() instanceof IBeeRoot) {
|
||||
--chromosomeID;
|
||||
}
|
||||
final Class<? extends IAllele> cls = gene.getChromosome().getAlleleClass();
|
||||
if (!cls.isInstance(gene.getAllele())) {
|
||||
return;
|
||||
}
|
||||
final NBTTagCompound beeNBT = target.getTagCompound();
|
||||
final NBTTagCompound genomeNBT = beeNBT.getCompoundTag("Genome");
|
||||
final NBTTagList chromosomes = genomeNBT.getTagList("Chromosomes", 10);
|
||||
final 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, 14819893, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Inoculator);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(0, "serum.active");
|
||||
inventory.getSlot(0).forbidInteraction();
|
||||
inventory.getSlot(0).setReadOnly();
|
||||
final SlotValidator serumValid = new SlotValidator(ModuleMachine.iconSerum) {
|
||||
@Override
|
||||
public boolean isValid(final ItemStack itemStack) {
|
||||
return itemStack.getItem() instanceof IItemSerum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Serum Vials & Arrays";
|
||||
}
|
||||
};
|
||||
inventory.getSlot(0).setValidator(serumValid);
|
||||
inventory.addSlotArray(Inoculator.slotSerumReserve, "serum.input");
|
||||
for (final InventorySlot slot : inventory.getSlots(Inoculator.slotSerumReserve)) {
|
||||
slot.setValidator(serumValid);
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
inventory.addSlotArray(Inoculator.slotSerumExpended, "serum.output");
|
||||
for (final InventorySlot slot : inventory.getSlots(Inoculator.slotSerumExpended)) {
|
||||
slot.setValidator(serumValid);
|
||||
slot.setReadOnly();
|
||||
}
|
||||
inventory.addSlotArray(Inoculator.slotReserve, "input");
|
||||
for (final InventorySlot slot : inventory.getSlots(Inoculator.slotReserve)) {
|
||||
slot.forbidExtraction();
|
||||
slot.setValidator(new ValidatorIndividualInoculate());
|
||||
}
|
||||
inventory.addSlot(9, "process");
|
||||
inventory.getSlot(9).setValidator(new ValidatorIndividualInoculate());
|
||||
inventory.getSlot(9).setReadOnly();
|
||||
inventory.getSlot(9).forbidInteraction();
|
||||
inventory.addSlotArray(Inoculator.slotFinished, "output");
|
||||
for (final InventorySlot slot : inventory.getSlots(Inoculator.slotFinished)) {
|
||||
slot.setReadOnly();
|
||||
slot.forbidInsertion();
|
||||
slot.setValidator(new ValidatorIndividualInoculate());
|
||||
}
|
||||
final ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Inoculator.slotReserve, 9, 1);
|
||||
transfer.addRestock(Inoculator.slotSerumReserve, 0);
|
||||
transfer.addStorage(0, Inoculator.slotSerumExpended, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(final ItemStack stack) {
|
||||
return Engineering.getCharges(stack) == 0;
|
||||
}
|
||||
});
|
||||
transfer.addStorage(9, Inoculator.slotFinished, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(final ItemStack stack) {
|
||||
return stack != null && this.transfer.getMachine().getMachineUtil().getStack(0) != null && this.transfer.getMachine().getInterface(ComponentInoculatorLogic.class).isValidSerum() != null;
|
||||
}
|
||||
});
|
||||
new ComponentPowerReceptor(machine, 15000);
|
||||
new ComponentInoculatorLogic(machine);
|
||||
new ComponentInoculatorFX(machine);
|
||||
new ComponentTankContainer(machine).addTank(0, "input", 1000).setValidator(new Validator<FluidStack>() {
|
||||
@Override
|
||||
public boolean isValid(final 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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentInoculatorLogic extends ComponentProcessSetCost implements IProcess {
|
||||
private float bacteriaDrain;
|
||||
|
||||
@Override
|
||||
public int getProcessLength() {
|
||||
return super.getProcessLength() * this.getNumberOfGenes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessEnergy() {
|
||||
return super.getProcessEnergy() * this.getNumberOfGenes();
|
||||
}
|
||||
|
||||
private int getNumberOfGenes() {
|
||||
final ItemStack serum = this.getUtil().getStack(0);
|
||||
if (serum == null) {
|
||||
return 1;
|
||||
}
|
||||
return Engineering.getGenes(serum).length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
final int n = this.getNumberOfGenes();
|
||||
return "Inoculating with " + n + " gene" + ((n > 1) ? "s" : "");
|
||||
}
|
||||
|
||||
public ComponentInoculatorLogic(final Machine machine) {
|
||||
super(machine, 600000, 12000);
|
||||
this.bacteriaDrain = 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isSlotEmpty(9)) {
|
||||
return new ErrorState.NoItem("No Individual to Inoculate", 9);
|
||||
}
|
||||
if (this.getUtil().isSlotEmpty(0)) {
|
||||
return new ErrorState.NoItem("No Serum", 0);
|
||||
}
|
||||
final ErrorState state = this.isValidSerum();
|
||||
if (state != null) {
|
||||
return state;
|
||||
}
|
||||
if (this.getUtil().getStack(0) != null && Engineering.getCharges(this.getUtil().getStack(0)) == 0) {
|
||||
return new ErrorState("Empty Serum", "Serum is empty");
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
public ErrorState isValidSerum() {
|
||||
final ItemStack serum = this.getUtil().getStack(0);
|
||||
final ItemStack target = this.getUtil().getStack(9);
|
||||
final 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");
|
||||
}
|
||||
final IIndividual individual = genes[0].getSpeciesRoot().getMember(target);
|
||||
boolean hasAll = true;
|
||||
for (final IGene gene : genes) {
|
||||
if (hasAll) {
|
||||
final IAllele a = individual.getGenome().getActiveAllele(gene.getChromosome());
|
||||
final IAllele b = individual.getGenome().getInactiveAllele(gene.getChromosome());
|
||||
hasAll = (hasAll && a.getUID().equals(gene.getAllele().getUID()) && b.getUID().equals(gene.getAllele().getUID()));
|
||||
}
|
||||
}
|
||||
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();
|
||||
final ItemStack serum = this.getUtil().getStack(0);
|
||||
final ItemStack target = this.getUtil().getStack(9);
|
||||
final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(target);
|
||||
if (!ind.isAnalyzed()) {
|
||||
ind.analyze();
|
||||
final NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
ind.writeToNBT(nbttagcompound);
|
||||
target.setTagCompound(nbttagcompound);
|
||||
}
|
||||
final IGene[] arr$;
|
||||
final IGene[] genes = arr$ = ((IItemSerum) serum.getItem()).getGenes(serum);
|
||||
for (final IGene gene : arr$) {
|
||||
Inoculator.setGene(gene, target, 0);
|
||||
Inoculator.setGene(gene, target, 1);
|
||||
}
|
||||
this.getUtil().damageItem(0, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
this.bacteriaDrain += 15.0f * this.getProgressPerTick() / 100.0f;
|
||||
if (this.bacteriaDrain >= 1.0f) {
|
||||
this.getUtil().drainTank(0, 1);
|
||||
--this.bacteriaDrain;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentInoculatorFX extends MachineComponent implements IRender.DisplayTick, IRender.Render, INetwork.TilePacketSync {
|
||||
private final EntityItem dummyEntityItem;
|
||||
|
||||
public ComponentInoculatorFX(final IMachine machine) {
|
||||
super(machine);
|
||||
this.dummyEntityItem = new EntityItem(null);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(World world, BlockPos pos, Random rand) {
|
||||
final int tick = (int) (world.getTotalWorldTime() % 3L);
|
||||
if (tick == 0 && this.getUtil().getProcess().isInProgress()) {
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new Particle(world, pos.getX() + 0.5, pos.getY() + 0.92, pos.getZ() + 0.5, 0.0, 0.0, 0.0) {
|
||||
double axisX = this.posX;
|
||||
double axisZ = this.posZ;
|
||||
double angle = (int) (this.worldObj.getTotalWorldTime() % 4L) * 0.5 * 3.1415;
|
||||
|
||||
{
|
||||
this.axisX = 0.0;
|
||||
this.axisZ = 0.0;
|
||||
this.angle = 0.0;
|
||||
this.motionX = 0.0;
|
||||
this.motionZ = 0.0;
|
||||
this.motionY = 0.007 + this.rand.nextDouble() * 0.002;
|
||||
this.particleMaxAge = 240;
|
||||
this.particleGravity = 0.0f;
|
||||
this.field_190017_n = true;
|
||||
this.setRBGColorF(0.8f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
double speed = 5.0E-4;
|
||||
if (this.particleAge > 60) {
|
||||
speed += (this.particleAge - 60) / 4000.0f;
|
||||
}
|
||||
this.angle += speed;
|
||||
final double dist = 0.27;
|
||||
this.setPosition(this.axisX + dist * Math.sin(this.angle), this.posY, this.axisZ + dist * Math.cos(this.angle));
|
||||
this.setAlphaF((float) Math.cos(1.57 * this.particleAge / this.particleMaxAge));
|
||||
if (this.particleAge > 40) {
|
||||
this.setRBGColorF(this.particleRed + (1.0f - this.particleRed) / 10.0f, this.particleGreen + (0.0f - this.particleGreen) / 10.0f, this.particleBlue + (0.0f - this.particleBlue) / 10.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void renderInWorld(final double x, final double y, final double z) {
|
||||
if (!this.getUtil().getProcess().isInProgress()) {
|
||||
return;
|
||||
}
|
||||
final ItemStack stack = this.getUtil().getStack(9);
|
||||
this.dummyEntityItem.worldObj = this.getMachine().getWorld();
|
||||
this.dummyEntityItem.setEntityItemStack(stack);
|
||||
final EntityItem dummyEntityItem = this.dummyEntityItem;
|
||||
dummyEntityItem.setAgeToCreativeDespawnTime(); // ++dummyEntityItem.age;
|
||||
this.dummyEntityItem.hoverStart = 0.0f;
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
final EntityPlayer player = BinnieCore.proxy.getPlayer();
|
||||
final double dx = x + 0.5 - player.lastTickPosX;
|
||||
final double dz = z + 0.5 - player.lastTickPosZ;
|
||||
final double t = Math.atan2(dz, dx) * 180.0 / 3.1415;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(180.0f, 0.0f, 0.0f, 1.0f);
|
||||
GL11.glTranslatef(0.0f, -0.25f, 0.0f);
|
||||
BinnieCore.proxy.getMinecraftInstance().getRenderItem().renderItem(this.dummyEntityItem.getEntityItem(), ItemCameraTransforms.TransformType.FIXED); //, 0.0, 0.0, 0.0, 0.0f, 0.0f);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncToNBT(final NBTTagCompound nbt) {
|
||||
final NBTTagCompound item = new NBTTagCompound();
|
||||
final ItemStack stack = this.getUtil().getStack(9);
|
||||
if (stack != null) {
|
||||
stack.writeToNBT(item);
|
||||
nbt.setTag("item", item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncFromNBT(final NBTTagCompound nbt) {
|
||||
if (nbt.hasKey("item")) {
|
||||
this.getUtil().setStack(9, ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("item")));
|
||||
} else {
|
||||
this.getUtil().setStack(9, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryUpdate() {
|
||||
if (!this.getUtil().isServer()) {
|
||||
return;
|
||||
}
|
||||
this.getUtil().refreshBlock();
|
||||
}
|
||||
}
|
||||
|
||||
public static class ValidatorIndividualInoculate extends SlotValidator {
|
||||
public ValidatorIndividualInoculate() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final ItemStack object) {
|
||||
final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(object);
|
||||
return root != null && Binnie.Genetics.getSystem(root).isDNAManipulable(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Inoculable Individual";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,272 +0,0 @@
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.genetics.Gene;
|
||||
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.ComponentTankContainer;
|
||||
import binnie.core.machines.inventory.IChargedSlots;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.machines.inventory.TankValidator;
|
||||
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.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import binnie.genetics.item.ItemSequence;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
|
||||
public class Isolator {
|
||||
public static final int slotEnzyme = 0;
|
||||
public static final int slotSequencerVial = 1;
|
||||
public static final int[] slotReserve = new int[]{2, 3, 4};
|
||||
public static final int slotTarget = 5;
|
||||
public static final int slotResult = 6;
|
||||
public static final int[] slotFinished = new int[]{7, 8, 9, 10, 11, 12};
|
||||
public static final int tankEthanol = 0;
|
||||
|
||||
public static class PackageIsolator extends GeneticMachine.PackageGeneticBase implements IMachineInformation {
|
||||
public PackageIsolator() {
|
||||
super("isolator", GeneticsTexture.Isolator, 16740111, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Isolator);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(0, "enzyme");
|
||||
inventory.getSlot(0).setValidator(new SlotValidator.Item(GeneticsItems.Enzyme.get(1), ModuleMachine.IconEnzyme));
|
||||
inventory.getSlot(0).forbidExtraction();
|
||||
inventory.addSlot(1, "sequencervial");
|
||||
inventory.getSlot(1).setValidator(new SlotValidator.Item(GeneticsItems.EmptySequencer.get(1), ModuleMachine.IconSequencer));
|
||||
inventory.getSlot(1).forbidExtraction();
|
||||
inventory.addSlotArray(Isolator.slotReserve, "input");
|
||||
for (final InventorySlot slot : inventory.getSlots(Isolator.slotReserve)) {
|
||||
slot.setValidator(new SlotValidator.Individual());
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
inventory.addSlot(5, "process");
|
||||
inventory.getSlot(5).setValidator(new SlotValidator.Individual());
|
||||
inventory.getSlot(5).setReadOnly();
|
||||
inventory.getSlot(5).forbidInteraction();
|
||||
inventory.addSlot(6, "output");
|
||||
inventory.getSlot(6).setReadOnly();
|
||||
inventory.getSlot(6).forbidInteraction();
|
||||
inventory.addSlotArray(Isolator.slotFinished, "output");
|
||||
for (final InventorySlot slot : inventory.getSlots(Isolator.slotFinished)) {
|
||||
slot.setReadOnly();
|
||||
slot.forbidInsertion();
|
||||
}
|
||||
final ComponentTankContainer tanks = new ComponentTankContainer(machine);
|
||||
tanks.addTank(0, "input", 1000);
|
||||
tanks.getTankSlot(0).setValidator(new TankValidator() {
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Ethanol";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final FluidStack stack) {
|
||||
return Objects.equals(stack.getFluid().getName(), "bioethanol");
|
||||
}
|
||||
});
|
||||
final ComponentChargedSlots chargedSlots = new ComponentChargedSlots(machine);
|
||||
chargedSlots.addCharge(0);
|
||||
final ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Isolator.slotReserve, 5, 1);
|
||||
transfer.addStorage(6, Isolator.slotFinished);
|
||||
new ComponentPowerReceptor(machine, 20000);
|
||||
new ComponentIsolatorLogic(machine);
|
||||
new ComponentIsolaterFX(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentIsolatorLogic extends ComponentProcessSetCost implements IProcess {
|
||||
float enzymePerProcess;
|
||||
float ethanolPerProcess;
|
||||
|
||||
public ComponentIsolatorLogic(final Machine machine) {
|
||||
super(machine, 192000, 4800);
|
||||
this.enzymePerProcess = 0.5f;
|
||||
this.ethanolPerProcess = 10.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isSlotEmpty(5)) {
|
||||
return new ErrorState.NoItem("No individual to isolate", 5);
|
||||
}
|
||||
if (!this.getUtil().isSlotEmpty(6)) {
|
||||
return new ErrorState.NoSpace("No room for DNA sequences", Isolator.slotFinished);
|
||||
}
|
||||
if (this.getUtil().isSlotEmpty(1)) {
|
||||
return new ErrorState.NoItem("No empty sequencer vials", 1);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (!this.getUtil().liquidInTank(0, (int) this.ethanolPerProcess)) {
|
||||
return new ErrorState.InsufficientLiquid("Insufficient ethanol", 0);
|
||||
}
|
||||
if (this.getUtil().getSlotCharge(0) == 0.0f) {
|
||||
return new ErrorState.NoItem("No enzyme", 0);
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
final Random rand = this.getMachine().getWorld().rand;
|
||||
final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(this.getUtil().getStack(5));
|
||||
if (root == null) {
|
||||
return;
|
||||
}
|
||||
final IIndividual individual = root.getMember(this.getUtil().getStack(5));
|
||||
if (individual == null) {
|
||||
return;
|
||||
}
|
||||
IAllele allele = null;
|
||||
IChromosomeType chromosome = null;
|
||||
Gene gene = null;
|
||||
if (this.getMachine().getWorld().rand.nextFloat() < 2.0f) {
|
||||
while (gene == null) {
|
||||
try {
|
||||
chromosome = root.getKaryotype()[rand.nextInt(root.getKaryotype().length)];
|
||||
allele = (rand.nextBoolean() ? individual.getGenome().getActiveAllele(chromosome) : individual.getGenome().getInactiveAllele(chromosome));
|
||||
gene = Gene.create(allele, chromosome, root);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
final ItemStack serum = ItemSequence.create(gene);
|
||||
this.getUtil().setStack(6, serum);
|
||||
this.getUtil().decreaseStack(1, 1);
|
||||
if (rand.nextFloat() < 0.05f) {
|
||||
this.getUtil().decreaseStack(5, 1);
|
||||
}
|
||||
this.getUtil().drainTank(0, (int) this.ethanolPerProcess);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
this.getMachine().getInterface(IChargedSlots.class).alterCharge(0, -this.enzymePerProcess * this.getProgressPerTick() / 100.0f);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentIsolaterFX extends MachineComponent implements IRender.RandomDisplayTick, IRender.DisplayTick {
|
||||
public ComponentIsolaterFX(final IMachine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onRandomDisplayTick(World world, BlockPos pos, Random rand) {
|
||||
if (!this.getUtil().getProcess().isInProgress()) {
|
||||
return;
|
||||
}
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new Particle(world, pos.getX() + 0.4 + 0.2 * rand.nextDouble(), pos.getY() + 1.6, pos.getZ() + 0.4 + rand.nextDouble() * 0.2, 0.0, 0.0, 0.0) {
|
||||
double axisX = 0.0;
|
||||
double axisZ = 0.0;
|
||||
double angle = 0.0;
|
||||
|
||||
{
|
||||
this.motionX = 0.0;
|
||||
this.motionZ = 0.0;
|
||||
this.motionY = -0.012;
|
||||
this.particleMaxAge = 100;
|
||||
this.particleGravity = 0.0f;
|
||||
this.field_190017_n = true;
|
||||
this.setRBGColorF(0.8f, 0.4f, 0.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
this.angle += 0.06;
|
||||
this.setAlphaF((float) Math.sin(3.14 * this.particleAge / this.particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(World world, BlockPos pos, Random rand) {
|
||||
final int tick = (int) (world.getTotalWorldTime() % 6L);
|
||||
if ((tick == 0 || tick == 5) && this.getUtil().getProcess().isInProgress()) {
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new Particle(world, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 0.0, 0.0, 0.0) {
|
||||
double axisX = this.posX;
|
||||
double axisZ = this.posZ;
|
||||
double angle = 0.7 + (int) (this.worldObj.getTotalWorldTime() % 2L) * 3.1415;
|
||||
|
||||
{
|
||||
this.axisX = 0.0;
|
||||
this.axisZ = 0.0;
|
||||
this.angle = 0.0;
|
||||
this.motionX = 0.0;
|
||||
this.motionZ = 0.0;
|
||||
this.motionY = 0.012;
|
||||
this.particleMaxAge = 100;
|
||||
this.particleGravity = 0.0f;
|
||||
this.field_190017_n = true;
|
||||
this.setRBGColorF(0.8f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
this.angle += 0.06;
|
||||
this.setPosition(this.axisX + 0.26 * Math.sin(this.angle), this.posY, this.axisZ + 0.26 * Math.cos(this.angle));
|
||||
this.setAlphaF((float) Math.cos(1.57 * this.particleAge / this.particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@ import binnie.core.machines.network.INetwork;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.machine.acclimatiser.PackageAcclimatiser;
|
||||
import binnie.genetics.machine.analyser.PackageAnalyser;
|
||||
import binnie.genetics.machine.genepool.PackageGenepool;
|
||||
import binnie.genetics.machine.incubator.PackageIncubator;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -20,9 +22,9 @@ import net.minecraft.world.World;
|
||||
|
||||
public enum LaboratoryMachine implements IMachineType {
|
||||
LabMachine(PackageLabMachine.class),
|
||||
Analyser(Analyser.PackageAnalyser.class),
|
||||
Analyser(PackageAnalyser.class),
|
||||
Incubator(PackageIncubator.class),
|
||||
Genepool(Genepool.PackageGenepool.class),
|
||||
Genepool(PackageGenepool.class),
|
||||
Acclimatiser(PackageAcclimatiser.class);
|
||||
|
||||
Class<? extends MachinePackage> clss;
|
||||
|
||||
@@ -18,11 +18,11 @@ import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
|
||||
public class ModuleMachine implements IInitializable {
|
||||
static ValidatorIcon IconSequencer;
|
||||
public static ValidatorIcon IconSequencer;
|
||||
public static ValidatorIcon iconSerum;
|
||||
static ValidatorIcon IconEnzyme;
|
||||
public static ValidatorIcon IconEnzyme;
|
||||
public static ValidatorIcon IconDye;
|
||||
static ValidatorIcon IconBacteria;
|
||||
public static ValidatorIcon IconBacteria;
|
||||
public static ValidatorIcon IconNugget;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,285 +0,0 @@
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.BinnieCore;
|
||||
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.craftgui.minecraft.IMachineInformation;
|
||||
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 net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Sequencer {
|
||||
public static final int slotDye = 0;
|
||||
public static final int[] slotReserve = new int[]{1, 2, 3, 4};
|
||||
public static final int slotTarget = 5;
|
||||
public static final int slotDone = 6;
|
||||
public static BinnieIcon fxSeqA;
|
||||
public static BinnieIcon fxSeqG;
|
||||
public static BinnieIcon fxSeqT;
|
||||
public static BinnieIcon fxSeqC;
|
||||
|
||||
public static class PackageSequencer extends GeneticMachine.PackageGeneticBase implements IMachineInformation {
|
||||
public PackageSequencer() {
|
||||
super("sequencer", GeneticsTexture.Sequencer, 12058418, 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(final Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Sequencer);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(0, "dye");
|
||||
inventory.getSlot(0).setValidator(new SlotValidator.Item(GeneticsItems.FluorescentDye.get(1), ModuleMachine.IconDye));
|
||||
inventory.getSlot(0).forbidExtraction();
|
||||
inventory.addSlotArray(Sequencer.slotReserve, "input");
|
||||
for (final InventorySlot slot : inventory.getSlots(Sequencer.slotReserve)) {
|
||||
slot.setValidator(new SlotValidatorUnsequenced());
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
inventory.addSlot(5, "process");
|
||||
inventory.getSlot(5).setValidator(new SlotValidatorUnsequenced());
|
||||
inventory.getSlot(5).setReadOnly();
|
||||
inventory.getSlot(5).forbidInteraction();
|
||||
inventory.addSlot(6, "output");
|
||||
inventory.getSlot(6).setReadOnly();
|
||||
final ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Sequencer.slotReserve, 5, 1);
|
||||
new ComponentChargedSlots(machine).addCharge(0);
|
||||
new ComponentPowerReceptor(machine, 10000);
|
||||
new ComponentSequencerLogic(machine);
|
||||
new ComponentSequencerFX(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentSequencerLogic extends ComponentProcess implements IProcess {
|
||||
public ComponentSequencerLogic(final Machine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
public float getSequenceStrength() {
|
||||
final ItemStack stack = this.getUtil().getStack(5);
|
||||
if (stack == null) {
|
||||
return 1.0f;
|
||||
}
|
||||
final float mult = 1.0f - stack.getItemDamage() % 6 / 5.0f;
|
||||
return 1.0f - mult * mult * 0.75f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessLength() {
|
||||
return (int) (19200.0f * this.getSequenceStrength());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessEnergy() {
|
||||
return this.getProcessLength() * 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isSlotEmpty(5)) {
|
||||
return new ErrorState.NoItem("No DNA sequence", 5);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (this.getMachine().getOwner() == null) {
|
||||
return new ErrorState("No Owner", "Replace this block to claim this machine");
|
||||
}
|
||||
if (this.getUtil().getSlotCharge(0) == 0.0f) {
|
||||
return new ErrorState.NoItem("Insufficient Dye", 0);
|
||||
}
|
||||
if (this.getUtil().getStack(6) != null && this.getUtil().getStack(6).stackSize >= 64) {
|
||||
return new ErrorState.NoSpace("No space for empty sequences", new int[]{6});
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStartTask() {
|
||||
super.onStartTask();
|
||||
final ItemStack item = this.getUtil().getStack(5);
|
||||
final SequencerItem seqItem = new SequencerItem(item);
|
||||
final int seq = seqItem.sequenced;
|
||||
if (seq != 0) {
|
||||
this.setProgress(seq);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
this.updateSequence();
|
||||
final SequencerItem seqItem = new SequencerItem(this.getUtil().getStack(5));
|
||||
GeneTracker.getTracker(this.getMachine().getWorld(), this.getMachine().getOwner()).registerGene(seqItem.getGene());
|
||||
this.getUtil().decreaseStack(5, 1);
|
||||
if (this.getUtil().getStack(6) == null) {
|
||||
this.getUtil().setStack(6, GeneticsItems.EmptySequencer.get(1));
|
||||
} else {
|
||||
this.getUtil().decreaseStack(6, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
this.updateSequence();
|
||||
this.getUtil().useCharge(0, 0.4f * this.getProgressPerTick() / 100.0f);
|
||||
}
|
||||
|
||||
private void updateSequence() {
|
||||
final int prog = (int) this.getProgress();
|
||||
final ItemStack item = this.getUtil().getStack(5);
|
||||
final SequencerItem seqItem = new SequencerItem(item);
|
||||
final 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(final IMachine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onRandomDisplayTick(World world, BlockPos pos, Random rand) {
|
||||
if (!this.getUtil().getProcess().isInProgress()) {
|
||||
return;
|
||||
}
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new Particle(world, pos.getX() + 0.5, pos.getY() + 1.2 + rand.nextDouble() * 0.2, pos.getZ() + 0.5, 0.0, 0.0, 0.0) {
|
||||
double axisX = this.posX;
|
||||
double axisZ = this.posZ;
|
||||
double angle = this.rand.nextDouble() * 2.0 * 3.1415;
|
||||
|
||||
{
|
||||
this.axisX = 0.0;
|
||||
this.axisZ = 0.0;
|
||||
this.angle = 0.0;
|
||||
this.motionX = 0.0;
|
||||
this.motionZ = 0.0;
|
||||
this.motionY = 0.0;
|
||||
this.particleMaxAge = 200;
|
||||
this.particleGravity = 0.0f;
|
||||
this.field_190017_n = true;
|
||||
this.setRBGColorF(0.6f + this.rand.nextFloat() * 0.2f, 1.0f, 0.8f * this.rand.nextFloat() * 0.2f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
this.angle += 0.03;
|
||||
this.setPosition(this.axisX + 0.4 * Math.sin(this.angle), this.posY, this.axisZ + 0.4 * Math.cos(this.angle));
|
||||
this.motionY = 0.0;
|
||||
this.setAlphaF((float) Math.sin(3.14 * this.particleAge / this.particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(World world, BlockPos pos, Random rand) {
|
||||
final int ticks = (int) (world.getTotalWorldTime() % 16L);
|
||||
if (ticks == 0 && this.getUtil().getProcess().isInProgress()) {
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new Particle(world, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 0.0, 0.0, 0.0) {
|
||||
double axisX = 0.0;
|
||||
double axisZ = 0.0;
|
||||
double angle = 0.0;
|
||||
|
||||
{
|
||||
this.motionX = 0.0;
|
||||
this.motionZ = 0.0;
|
||||
this.motionY = 0.012;
|
||||
this.particleMaxAge = 50;
|
||||
this.particleGravity = 0.0f;
|
||||
this.field_190017_n = true;
|
||||
this.particleScale = 2.0f;
|
||||
//TODO: Add sprites
|
||||
//this.setParticleIcon((new BinnieIcon[] { Sequencer.fxSeqA, Sequencer.fxSeqG, Sequencer.fxSeqC, Sequencer.fxSeqT })[this.rand.nextInt(4)].getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
this.motionY = 0.012;
|
||||
if (this.particleAge > 40) {
|
||||
this.setAlphaF((50 - this.particleAge) / 10.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class SlotValidatorUnsequenced extends SlotValidator {
|
||||
public SlotValidatorUnsequenced() {
|
||||
super(ModuleMachine.IconSequencer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final ItemStack itemStack) {
|
||||
if (itemStack.getItem() == Genetics.itemSequencer) {
|
||||
final SequencerItem seq = new SequencerItem(itemStack);
|
||||
return seq.sequenced < 100;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Unsequenced DNA";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,418 +0,0 @@
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.BinnieCore;
|
||||
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.InventorySlot;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
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.craftgui.minecraft.IMachineInformation;
|
||||
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 forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.apiculture.IBeeRoot;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Splicer {
|
||||
public static final int slotSerumVial = 0;
|
||||
public static final int[] slotSerumReserve = new int[]{1, 2};
|
||||
public static final int[] slotSerumExpended = new int[]{3, 4};
|
||||
public static final int[] slotReserve = new int[]{5, 6, 7, 8, 9};
|
||||
public static final int slotTarget = 9;
|
||||
public static final int[] slotFinished = new int[]{10, 11, 12, 13};
|
||||
|
||||
public static void setGene(final IGene gene, final ItemStack target, final int chromoN) {
|
||||
int chromosomeID;
|
||||
final int chromosome = chromosomeID = gene.getChromosome().ordinal();
|
||||
if (chromosomeID >= EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal() && gene.getSpeciesRoot() instanceof IBeeRoot) {
|
||||
--chromosomeID;
|
||||
}
|
||||
final Class<? extends IAllele> cls = gene.getChromosome().getAlleleClass();
|
||||
if (!cls.isInstance(gene.getAllele())) {
|
||||
return;
|
||||
}
|
||||
final NBTTagCompound beeNBT = target.getTagCompound();
|
||||
final NBTTagCompound genomeNBT = beeNBT.getCompoundTag("Genome");
|
||||
final NBTTagList chromosomes = genomeNBT.getTagList("Chromosomes", 10);
|
||||
final NBTTagCompound chromosomeNBT = chromosomes.getCompoundTagAt(chromosomeID);
|
||||
chromosomeNBT.setString("UID" + chromoN, gene.getAllele().getUID());
|
||||
target.setTagCompound(beeNBT);
|
||||
}
|
||||
|
||||
public static class PackageSplicer extends AdvGeneticMachine.PackageAdvGeneticBase implements IMachineInformation {
|
||||
public PackageSplicer() {
|
||||
super("splicer", GeneticsTexture.Splicer, 14819893, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Splicer);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(0, "serum.active");
|
||||
inventory.getSlot(0).forbidInteraction();
|
||||
inventory.getSlot(0).setReadOnly();
|
||||
final SlotValidator serumValid = new SlotValidator(ModuleMachine.iconSerum) {
|
||||
@Override
|
||||
public boolean isValid(final ItemStack itemStack) {
|
||||
return itemStack.getItem() instanceof IItemSerum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Serum Vials & Arrays";
|
||||
}
|
||||
};
|
||||
inventory.getSlot(0).setValidator(serumValid);
|
||||
inventory.addSlotArray(Splicer.slotSerumReserve, "serum.input");
|
||||
for (final InventorySlot slot : inventory.getSlots(Splicer.slotSerumReserve)) {
|
||||
slot.setValidator(serumValid);
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
inventory.addSlotArray(Splicer.slotSerumExpended, "serum.output");
|
||||
for (final InventorySlot slot : inventory.getSlots(Splicer.slotSerumExpended)) {
|
||||
slot.setValidator(serumValid);
|
||||
slot.setReadOnly();
|
||||
}
|
||||
inventory.addSlotArray(Splicer.slotReserve, "input");
|
||||
for (final InventorySlot slot : inventory.getSlots(Splicer.slotReserve)) {
|
||||
slot.forbidExtraction();
|
||||
slot.setValidator(new ValidatorIndividualInoculate());
|
||||
}
|
||||
inventory.addSlot(9, "process");
|
||||
inventory.getSlot(9).setValidator(new ValidatorIndividualInoculate());
|
||||
inventory.getSlot(9).setReadOnly();
|
||||
inventory.getSlot(9).forbidInteraction();
|
||||
inventory.addSlotArray(Splicer.slotFinished, "output");
|
||||
for (final InventorySlot slot : inventory.getSlots(Splicer.slotFinished)) {
|
||||
slot.setReadOnly();
|
||||
slot.forbidInsertion();
|
||||
slot.setValidator(new ValidatorIndividualInoculate());
|
||||
}
|
||||
final ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Splicer.slotReserve, 9, 1);
|
||||
transfer.addRestock(Splicer.slotSerumReserve, 0);
|
||||
transfer.addStorage(0, Splicer.slotSerumExpended, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(final ItemStack stack) {
|
||||
return Engineering.getCharges(stack) == 0;
|
||||
}
|
||||
});
|
||||
transfer.addStorage(9, Splicer.slotFinished, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(final ItemStack stack) {
|
||||
return stack != null && this.transfer.getMachine().getMachineUtil().getStack(0) != null && this.transfer.getMachine().getInterface(ComponentSplicerLogic.class).isValidSerum() != null;
|
||||
}
|
||||
});
|
||||
new ComponentPowerReceptor(machine, 20000);
|
||||
new ComponentSplicerLogic(machine);
|
||||
new ComponentSplicerFX(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentSplicerLogic extends ComponentProcessSetCost implements IProcess {
|
||||
int nOfGenes;
|
||||
|
||||
@Override
|
||||
public int getProcessLength() {
|
||||
float n = this.getNumberOfGenes();
|
||||
if (n > 1.0f) {
|
||||
n = 1.0f + (n - 1.0f) * 0.5f;
|
||||
}
|
||||
// Fix for / by 0
|
||||
int temp = (int) (super.getProcessLength() * n);
|
||||
return temp != 0 ? temp : 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessEnergy() {
|
||||
float n = this.getNumberOfGenes();
|
||||
if (n > 1.0f) {
|
||||
n = 1.0f + (n - 1.0f) * 0.5f;
|
||||
}
|
||||
return (int) (super.getProcessEnergy() * n);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryUpdate() {
|
||||
super.onInventoryUpdate();
|
||||
this.nOfGenes = this.getGenesToUse();
|
||||
}
|
||||
|
||||
protected int getGenesToUse() {
|
||||
final ItemStack serum = this.getUtil().getStack(0);
|
||||
final ItemStack target = this.getUtil().getStack(9);
|
||||
if (serum == null || target == null) {
|
||||
return 1;
|
||||
}
|
||||
final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(target);
|
||||
final IGene[] genes = ((IItemSerum) serum.getItem()).getGenes(serum);
|
||||
if (ind.getGenome().getSpeciesRoot() != ((IItemSerum) serum.getItem()).getSpeciesRoot(serum)) {
|
||||
return 1;
|
||||
}
|
||||
int i = 0;
|
||||
for (final IGene gene : genes) {
|
||||
if (ind.getGenome().getActiveAllele(gene.getChromosome()) != gene.getAllele() || ind.getGenome().getInactiveAllele(gene.getChromosome()) != gene.getAllele()) {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
return (i < 1) ? 1 : i;
|
||||
}
|
||||
|
||||
private int getFullNumberOfGenes() {
|
||||
final ItemStack serum = this.getUtil().getStack(0);
|
||||
if (serum == null) {
|
||||
return 1;
|
||||
}
|
||||
return Engineering.getGenes(serum).length;
|
||||
}
|
||||
|
||||
private int getNumberOfGenes() {
|
||||
return this.nOfGenes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
final int n = this.getNumberOfGenes();
|
||||
final int f = this.getFullNumberOfGenes();
|
||||
return "Splicing in " + n + ((f > 1) ? ("/" + f) : "") + " gene" + ((n > 1) ? "s" : "");
|
||||
}
|
||||
|
||||
public ComponentSplicerLogic(final Machine machine) {
|
||||
super(machine, 12000000, 1200);
|
||||
this.nOfGenes = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isSlotEmpty(9)) {
|
||||
return new ErrorState.NoItem("No Individual to Splice", 9);
|
||||
}
|
||||
if (this.getUtil().isSlotEmpty(0)) {
|
||||
return new ErrorState.NoItem("No Serum", 0);
|
||||
}
|
||||
final ErrorState state = this.isValidSerum();
|
||||
if (state != null) {
|
||||
return state;
|
||||
}
|
||||
if (this.getUtil().getStack(0) != null && Engineering.getCharges(this.getUtil().getStack(0)) == 0) {
|
||||
return new ErrorState("Empty Serum", "Serum is empty");
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
public ErrorState isValidSerum() {
|
||||
final ItemStack serum = this.getUtil().getStack(0);
|
||||
final ItemStack target = this.getUtil().getStack(9);
|
||||
final 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");
|
||||
}
|
||||
final IIndividual individual = genes[0].getSpeciesRoot().getMember(target);
|
||||
boolean hasAll = true;
|
||||
for (final IGene gene : genes) {
|
||||
if (hasAll) {
|
||||
final IAllele a = individual.getGenome().getActiveAllele(gene.getChromosome());
|
||||
final IAllele b = individual.getGenome().getInactiveAllele(gene.getChromosome());
|
||||
hasAll = (hasAll && a.getUID().equals(gene.getAllele().getUID()) && b.getUID().equals(gene.getAllele().getUID()));
|
||||
}
|
||||
}
|
||||
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();
|
||||
final ItemStack serum = this.getUtil().getStack(0);
|
||||
final ItemStack target = this.getUtil().getStack(9);
|
||||
final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(target);
|
||||
if (!ind.isAnalyzed()) {
|
||||
ind.analyze();
|
||||
final NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
ind.writeToNBT(nbttagcompound);
|
||||
target.setTagCompound(nbttagcompound);
|
||||
}
|
||||
final IGene[] arr$;
|
||||
final IGene[] genes = arr$ = ((IItemSerum) serum.getItem()).getGenes(serum);
|
||||
for (final IGene gene : arr$) {
|
||||
Splicer.setGene(gene, target, 0);
|
||||
Splicer.setGene(gene, target, 1);
|
||||
}
|
||||
this.getUtil().damageItem(0, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentSplicerFX extends MachineComponent implements IRender.DisplayTick, IRender.Render, INetwork.TilePacketSync {
|
||||
private final EntityItem dummyEntityItem;
|
||||
|
||||
public ComponentSplicerFX(final IMachine machine) {
|
||||
super(machine);
|
||||
this.dummyEntityItem = new EntityItem(machine.getWorld());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(World world, BlockPos pos, Random rand) {
|
||||
final int tick = (int) (world.getTotalWorldTime() % 3L);
|
||||
if (tick == 0 && this.getUtil().getProcess().isInProgress()) {
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new Particle(world, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, 0.0, 0.0, 0.0) {
|
||||
double axisX = this.posX;
|
||||
double axisZ = this.posZ;
|
||||
double angle = (int) (this.worldObj.getTotalWorldTime() % 4L) * 0.5 * 3.1415;
|
||||
|
||||
{
|
||||
this.axisX = 0.0;
|
||||
this.axisZ = 0.0;
|
||||
this.angle = 0.0;
|
||||
this.motionX = 0.0;
|
||||
this.motionZ = 0.0;
|
||||
this.motionY = (this.rand.nextDouble() - 0.5) * 0.02;
|
||||
this.particleMaxAge = 240;
|
||||
this.particleGravity = 0.0f;
|
||||
this.field_190017_n = true;
|
||||
this.setRBGColorF(0.3f + this.rand.nextFloat() * 0.5f, 0.3f + this.rand.nextFloat() * 0.5f, 0.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
final double speed = 0.04;
|
||||
this.angle -= speed;
|
||||
final double dist = 0.25 + 0.2 * Math.sin(this.particleAge / 50.0f);
|
||||
this.setPosition(this.axisX + dist * Math.sin(this.angle), this.posY, this.axisZ + dist * Math.cos(this.angle));
|
||||
this.setAlphaF((float) Math.cos(1.57 * this.particleAge / this.particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void renderInWorld(double x, final double y, final double z) {
|
||||
if (!this.getUtil().getProcess().isInProgress()) {
|
||||
return;
|
||||
}
|
||||
final ItemStack stack = this.getUtil().getStack(9);
|
||||
this.dummyEntityItem.worldObj = this.getMachine().getWorld();
|
||||
this.dummyEntityItem.setEntityItemStack(stack);
|
||||
final EntityItem dummyEntityItem = this.dummyEntityItem;
|
||||
dummyEntityItem.setAgeToCreativeDespawnTime(); //++dummyEntityItem.age;
|
||||
this.dummyEntityItem.hoverStart = 0.0f;
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
final EntityPlayer player = BinnieCore.proxy.getPlayer();
|
||||
final double dx = x + 0.5 - player.lastTickPosX;
|
||||
final double dz = z + 0.5 - player.lastTickPosZ;
|
||||
final double t = Math.atan2(dz, dx) * 180.0 / 3.1415;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(180.0f, 0.0f, 0.0f, 1.0f);
|
||||
GL11.glTranslatef(0.0f, -0.25f, 0.0f);
|
||||
BinnieCore.proxy.getMinecraftInstance().getRenderItem().renderItem(dummyEntityItem.getEntityItem(), ItemCameraTransforms.TransformType.FIXED);//doRender(this.dummyEntityItem, 0.0, 0.0, 0.0, 0.0f, 0.0f);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncToNBT(final NBTTagCompound nbt) {
|
||||
final NBTTagCompound item = new NBTTagCompound();
|
||||
final ItemStack stack = this.getUtil().getStack(9);
|
||||
if (stack != null) {
|
||||
stack.writeToNBT(item);
|
||||
nbt.setTag("item", item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncFromNBT(final NBTTagCompound nbt) {
|
||||
if (nbt.hasKey("item")) {
|
||||
this.getUtil().setStack(9, ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("item")));
|
||||
} else {
|
||||
this.getUtil().setStack(9, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryUpdate() {
|
||||
if (!this.getUtil().isServer()) {
|
||||
return;
|
||||
}
|
||||
this.getUtil().refreshBlock();
|
||||
}
|
||||
}
|
||||
|
||||
public static class ValidatorIndividualInoculate extends SlotValidator {
|
||||
public ValidatorIndividualInoculate() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final ItemStack object) {
|
||||
final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(object);
|
||||
return root != null && Binnie.Genetics.getSystem(root).isDNAManipulable(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Splicable Individual";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,10 +24,10 @@ public class PackageAcclimatiser extends GeneticMachine.PackageGeneticBase imple
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Acclimatiser);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(4, "process");
|
||||
inventory.getSlot(4).setValidator(new SlotValidator.Individual());
|
||||
inventory.getSlot(4).setReadOnly();
|
||||
inventory.getSlot(4).forbidExtraction();
|
||||
InventorySlot slotTarget = inventory.addSlot(Acclimatiser.SLOT_TARGET, "process");
|
||||
slotTarget.setValidator(new SlotValidator.Individual());
|
||||
slotTarget.setReadOnly();
|
||||
slotTarget.forbidExtraction();
|
||||
for (final InventorySlot slot : inventory.addSlotArray(Acclimatiser.SLOT_RESERVE, "input")) {
|
||||
slot.forbidExtraction();
|
||||
slot.setValidator(new SlotValidator.Individual());
|
||||
@@ -40,8 +40,8 @@ public class PackageAcclimatiser extends GeneticMachine.PackageGeneticBase imple
|
||||
slot.setValidator(new ValidatorAcclimatiserItem());
|
||||
}
|
||||
final ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Acclimatiser.SLOT_RESERVE, 4, 1);
|
||||
transfer.addStorage(4, Acclimatiser.SLOT_DRONE, new ComponentInventoryTransfer.Condition() {
|
||||
transfer.addRestock(Acclimatiser.SLOT_RESERVE, Acclimatiser.SLOT_TARGET, 1);
|
||||
transfer.addStorage(Acclimatiser.SLOT_TARGET, Acclimatiser.SLOT_DRONE, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(final ItemStack stack) {
|
||||
return !Acclimatiser.canAcclimatise(stack, machine.getMachineUtil().getNonNullStacks(Acclimatiser.SLOT_ACCLIMATISER));
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.util.Random;
|
||||
|
||||
import binnie.core.genetics.Gene;
|
||||
import binnie.core.genetics.Tolerance;
|
||||
import binnie.genetics.machine.Inoculator;
|
||||
import binnie.genetics.machine.inoculator.Inoculator;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAlleleTolerance;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package binnie.genetics.machine.analyser;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.genetics.api.IItemAnalysable;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class Analyser {
|
||||
public static final int[] SLOT_RESERVE = new int[]{0, 1, 2, 3, 4, 5};
|
||||
public static final int SLOT_TARGET = 6;
|
||||
public static final int[] SLOT_FINISHED = new int[]{7, 8, 9, 10, 11, 12};
|
||||
public static final int SLOT_DYE = 13;
|
||||
|
||||
public static boolean isAnalysable(final ItemStack stack) {
|
||||
final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(stack);
|
||||
return ind != null || stack.getItem() instanceof IItemAnalysable || Binnie.Genetics.getConversion(stack) != null;
|
||||
}
|
||||
|
||||
public static boolean isAnalysed(final ItemStack stack) {
|
||||
final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(stack);
|
||||
if (ind != null) {
|
||||
return ind.isAnalyzed();
|
||||
}
|
||||
return stack.getItem() instanceof IItemAnalysable && ((IItemAnalysable) stack.getItem()).isAnalysed(stack);
|
||||
}
|
||||
|
||||
public static ItemStack analyse(ItemStack stack) {
|
||||
final ItemStack conv = Binnie.Genetics.getConversionStack(stack);
|
||||
if (conv != null) {
|
||||
stack = conv;
|
||||
}
|
||||
final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack);
|
||||
if (root != null) {
|
||||
final IIndividual ind = root.getMember(stack);
|
||||
ind.analyze();
|
||||
final NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
ind.writeToNBT(nbttagcompound);
|
||||
stack.setTagCompound(nbttagcompound);
|
||||
return stack;
|
||||
}
|
||||
if (stack.getItem() instanceof IItemAnalysable) {
|
||||
return ((IItemAnalysable) stack.getItem()).analyse(stack);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package binnie.genetics.machine.analyser;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
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 net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class AnalyserFX extends MachineComponent implements IRender.DisplayTick, IRender.Render, INetwork.TilePacketSync {
|
||||
private final EntityItem dummyEntityItem;
|
||||
|
||||
public AnalyserFX(final IMachine machine) {
|
||||
super(machine);
|
||||
this.dummyEntityItem = new EntityItem(machine.getWorld());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(World world, BlockPos pos, Random rand) {
|
||||
if (rand.nextFloat() < 1.0f && this.getUtil().getProcess().isInProgress()) {
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new Particle(world, pos.getX() + 0.5, pos.getY() + 1.3 + rand.nextDouble() * 0.2, pos.getZ() + 0.5, 0.0, 0.0, 0.0) {
|
||||
double axisX = this.posX;
|
||||
double axisZ = this.posZ;
|
||||
double angle = this.rand.nextDouble() * 2.0 * 3.1415;
|
||||
|
||||
{
|
||||
this.axisX = 0.0;
|
||||
this.axisZ = 0.0;
|
||||
this.angle = 0.0;
|
||||
this.motionX = 0.05 * (this.rand.nextDouble() - 0.5);
|
||||
this.motionZ = 0.05 * (this.rand.nextDouble() - 0.5);
|
||||
this.motionY = 0.0;
|
||||
this.particleMaxAge = 25;
|
||||
this.particleGravity = 0.05f;
|
||||
this.field_190017_n = true;
|
||||
this.setRBGColorF(0.6f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
this.setAlphaF((float) Math.cos(1.57 * this.particleAge / this.particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void renderInWorld(final double x, final double y, final double z) {
|
||||
if (!this.getUtil().getProcess().isInProgress()) {
|
||||
return;
|
||||
}
|
||||
final ItemStack stack = this.getUtil().getStack(6);
|
||||
this.dummyEntityItem.worldObj = this.getMachine().getWorld();
|
||||
this.dummyEntityItem.setEntityItemStack(stack);
|
||||
final EntityItem dummyEntityItem = this.dummyEntityItem;
|
||||
dummyEntityItem.setAgeToCreativeDespawnTime(); //++dummyEntityItem.age;
|
||||
this.dummyEntityItem.hoverStart = 0.0f;
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
final EntityPlayer player = BinnieCore.proxy.getPlayer();
|
||||
final double dx = x + 0.5 - player.lastTickPosX;
|
||||
final double dz = z + 0.5 - player.lastTickPosZ;
|
||||
final double t = Math.atan2(dz, dx) * 180.0 / 3.1415;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(180.0f, 0.0f, 0.0f, 1.0f);
|
||||
GL11.glTranslatef(0.0f, -0.2f, 0.0f);
|
||||
BinnieCore.proxy.getMinecraftInstance().getRenderItem().renderItem(dummyEntityItem.getEntityItem(), ItemCameraTransforms.TransformType.FIXED);//doRender(this.dummyEntityItem.getEntityItem(), 0.0, 0.0, 0.0, 0.0f, 0.0f);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncToNBT(final NBTTagCompound nbt) {
|
||||
final NBTTagCompound item = new NBTTagCompound();
|
||||
final ItemStack stack = this.getUtil().getStack(6);
|
||||
if (stack != null) {
|
||||
stack.writeToNBT(item);
|
||||
nbt.setTag("item", item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncFromNBT(final NBTTagCompound nbt) {
|
||||
if (nbt.hasKey("item")) {
|
||||
this.getUtil().setStack(6, ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("item")));
|
||||
} else {
|
||||
this.getUtil().setStack(6, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryUpdate() {
|
||||
if (this.getUtil().isServer()) {
|
||||
//TODO fix update
|
||||
//this.getMachine().getWorld().markBlockForUpdate(this.getMachine().getTileEntity().xCoord, this.getMachine().getTileEntity().yCoord, this.getMachine().getTileEntity().zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package binnie.genetics.machine.analyser;
|
||||
|
||||
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.Genetics;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class AnalyserLogic extends ComponentProcessSetCost implements IProcess {
|
||||
private static final float DYE_PER_TICK = 0.002f;
|
||||
|
||||
public AnalyserLogic(final Machine machine) {
|
||||
super(machine, 9000, 300);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isSlotEmpty(Analyser.SLOT_TARGET)) {
|
||||
return new ErrorState.NoItem("No item to analyse", Analyser.SLOT_TARGET);
|
||||
}
|
||||
final boolean analysed = Analyser.isAnalysed(this.getUtil().getStack(Analyser.SLOT_TARGET));
|
||||
if (analysed) {
|
||||
return new ErrorState.InvalidItem(Genetics.proxy.localise("machine.labMachine.analyser.already.analysed"), Genetics.proxy.localise("machine.labMachine.analyser.already.analysed.info"), Analyser.SLOT_TARGET);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (this.getUtil().getSlotCharge(Analyser.SLOT_DYE) == 0.0f) {
|
||||
return new ErrorState.Item(Genetics.proxy.localise("machine.labMachine.analyser.insufficient.dye"), Genetics.proxy.localise("machine.labMachine.analyser.insufficient.dye.info"), new int[]{13});
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
ItemStack itemStack = this.getUtil().getStack(Analyser.SLOT_TARGET);
|
||||
itemStack = Analyser.analyse(itemStack);
|
||||
this.getInventory().setInventorySlotContents(Analyser.SLOT_TARGET, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
this.getUtil().useCharge(Analyser.SLOT_DYE, 0.002f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package binnie.genetics.machine.analyser;
|
||||
|
||||
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.craftgui.minecraft.IMachineInformation;
|
||||
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.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class PackageAnalyser extends GeneticMachine.PackageGeneticBase implements IMachineInformation {
|
||||
public PackageAnalyser() {
|
||||
super("analyser", GeneticsTexture.Analyser, 9961727, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Analyser);
|
||||
ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
for (InventorySlot slot : inventory.addSlotArray(Analyser.SLOT_RESERVE, "input")) {
|
||||
slot.setValidator(new SlotValidatorUnanalysed());
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
InventorySlot slotTarget = inventory.addSlot(Analyser.SLOT_TARGET, "analyse");
|
||||
slotTarget.setValidator(new SlotValidatorUnanalysed());
|
||||
slotTarget.setReadOnly();
|
||||
slotTarget.forbidInteraction();
|
||||
InventorySlot slotDye = inventory.addSlot(Analyser.SLOT_DYE, "dye");
|
||||
slotDye.forbidExtraction();
|
||||
slotDye.setValidator(new SlotValidator(ModuleMachine.IconDye) {
|
||||
@Override
|
||||
public boolean isValid(final ItemStack itemStack) {
|
||||
return itemStack.isItemEqual(GeneticsItems.DNADye.get(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "DNA Dye";
|
||||
}
|
||||
});
|
||||
for (InventorySlot slot : inventory.addSlotArray(Analyser.SLOT_FINISHED, "output")) {
|
||||
slot.forbidInsertion();
|
||||
slot.setReadOnly();
|
||||
}
|
||||
ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Analyser.SLOT_RESERVE, 6, 1);
|
||||
transfer.addStorage(6, Analyser.SLOT_FINISHED, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(final ItemStack stack) {
|
||||
return Analyser.isAnalysed(stack);
|
||||
}
|
||||
});
|
||||
new ComponentChargedSlots(machine).addCharge(13);
|
||||
new ComponentPowerReceptor(machine, 500);
|
||||
new AnalyserLogic(machine);
|
||||
new AnalyserFX(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package binnie.genetics.machine.analyser;
|
||||
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotValidatorUnanalysed extends SlotValidator {
|
||||
public SlotValidatorUnanalysed() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final ItemStack itemStack) {
|
||||
return Analyser.isAnalysable(itemStack) && !Analyser.isAnalysed(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Unanalysed Item";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package binnie.genetics.machine.genepool;
|
||||
|
||||
public class Genepool {
|
||||
public static final int SLOT_BEE = 0;
|
||||
public static final int[] SLOT_RESERVE = new int[]{1, 2, 3, 4, 5, 6};
|
||||
public static final int SLOT_ENZYME = 7;
|
||||
public static final int TANK_DNA = 0;
|
||||
public static final int TANK_ETHANOL = 1;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package binnie.genetics.machine.genepool;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import binnie.core.machines.component.IRender;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class GenepoolFX extends MachineComponent implements IRender.DisplayTick {
|
||||
public GenepoolFX(final IMachine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(World world, BlockPos pos, Random rand) {
|
||||
if (rand.nextFloat() < 1.0f && this.getUtil().getProcess().isInProgress()) {
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new Particle(world, pos.getX() + 0.3 + rand.nextDouble() * 0.4, pos.getY() + 1, pos.getZ() + 0.3 + rand.nextDouble() * 0.4, 0.0, 0.0, 0.0) {
|
||||
double axisX = this.posX;
|
||||
double axisZ = this.posZ;
|
||||
double angle = this.rand.nextDouble() * 2.0 * 3.1415;
|
||||
|
||||
{
|
||||
this.axisX = 0.0;
|
||||
this.axisZ = 0.0;
|
||||
this.angle = 0.0;
|
||||
this.motionX = 0.0;
|
||||
this.motionZ = 0.0;
|
||||
this.motionY = this.rand.nextFloat() * 0.01;
|
||||
this.particleMaxAge = 25;
|
||||
this.particleGravity = 0.0f;
|
||||
this.field_190017_n = true;
|
||||
this.setRBGColorF(0.4f + 0.6f * this.rand.nextFloat(), 0.6f * this.rand.nextFloat(), 0.6f + 0.4f * this.rand.nextFloat());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
this.setAlphaF((float) Math.cos(1.57 * this.particleAge / this.particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
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.Genetics;
|
||||
import binnie.genetics.item.GeneticLiquid;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class GenepoolLogic extends ComponentProcessSetCost implements IProcess {
|
||||
float enzymePerProcess;
|
||||
float ethanolPerProcess;
|
||||
private float ethanolDrain;
|
||||
|
||||
public GenepoolLogic(final Machine machine) {
|
||||
super(machine, 8000, 400);
|
||||
this.enzymePerProcess = 0.25f;
|
||||
this.ethanolPerProcess = 50.0f;
|
||||
this.ethanolDrain = 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isSlotEmpty(Genepool.SLOT_BEE)) {
|
||||
return new ErrorState.NoItem(Genetics.proxy.localise("machine.labMachine.genepool.no.individual"), Genepool.SLOT_BEE);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (!this.getUtil().spaceInTank(Genepool.TANK_DNA, this.getDNAAmount(this.getUtil().getStack(0)))) {
|
||||
return new ErrorState.NoSpace(Genetics.proxy.localise("machine.labMachine.genepool.no.room"), new int[]{0});
|
||||
}
|
||||
if (!this.getUtil().liquidInTank(Genepool.TANK_ETHANOL, 1)) {
|
||||
return new ErrorState.InsufficientLiquid(Genetics.proxy.localise("machine.labMachine.genepool.not.enough.ethanol"), Genepool.TANK_ETHANOL);
|
||||
}
|
||||
if (this.getUtil().getSlotCharge(Genepool.SLOT_ENZYME) == 0.0f) {
|
||||
return new ErrorState.NoItem(Genetics.proxy.localise("machine.labMachine.genepool.insufficient.enzyme"), Genepool.SLOT_ENZYME);
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
final int amount = this.getDNAAmount(this.getUtil().getStack(Genepool.SLOT_BEE));
|
||||
this.getUtil().fillTank(Genepool.TANK_DNA, GeneticLiquid.RawDNA.get(amount));
|
||||
this.getUtil().deleteStack(Genepool.SLOT_BEE);
|
||||
}
|
||||
|
||||
private int getDNAAmount(final ItemStack stack) {
|
||||
final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack);
|
||||
if (root == null) {
|
||||
return 10;
|
||||
}
|
||||
if (root != Binnie.Genetics.getBeeRoot()) {
|
||||
return 10;
|
||||
}
|
||||
if (Binnie.Genetics.getBeeRoot().isDrone(stack)) {
|
||||
return 10;
|
||||
}
|
||||
if (Binnie.Genetics.getBeeRoot().isMated(stack)) {
|
||||
return 50;
|
||||
}
|
||||
return 30;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
this.ethanolDrain += this.getDNAAmount(this.getUtil().getStack(Genepool.SLOT_BEE)) * 1.2f * this.getProgressPerTick() / 100.0f;
|
||||
if (this.ethanolDrain >= 1.0f) {
|
||||
this.getUtil().drainTank(1, 1);
|
||||
--this.ethanolDrain;
|
||||
}
|
||||
this.getMachine().getInterface(IChargedSlots.class).alterCharge(Genepool.SLOT_ENZYME, -this.enzymePerProcess * this.getProgressPerTick() / 100.0f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package binnie.genetics.machine.genepool;
|
||||
|
||||
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.inventory.TankValidator;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.craftgui.minecraft.IMachineInformation;
|
||||
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;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class PackageGenepool extends GeneticMachine.PackageGeneticBase implements IMachineInformation {
|
||||
public PackageGenepool() {
|
||||
super("genepool", GeneticsTexture.Genepool, 12661942, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Genepool);
|
||||
ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
InventorySlot slotEnzyme = inventory.addSlot(Genepool.SLOT_ENZYME, "enzyme");
|
||||
slotEnzyme.setValidator(new SlotValidator.Item(GeneticsItems.Enzyme.get(1), ModuleMachine.IconEnzyme));
|
||||
slotEnzyme.forbidExtraction();
|
||||
InventorySlot slotProcess = inventory.addSlot(Genepool.SLOT_BEE, "process");
|
||||
slotProcess.setValidator(new SlotValidator.Individual());
|
||||
slotProcess.setReadOnly();
|
||||
slotProcess.forbidExtraction();
|
||||
for (InventorySlot slot : inventory.addSlotArray(Genepool.SLOT_RESERVE, "input")) {
|
||||
slot.setValidator(new SlotValidator.Individual());
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
ComponentTankContainer tanks = new ComponentTankContainer(machine);
|
||||
TankSlot tankDNA = tanks.addTank(Genepool.TANK_DNA, "output", 2000);
|
||||
tankDNA.setReadOnly();
|
||||
TankSlot tankEthanol = tanks.addTank(Genepool.TANK_ETHANOL, "input", 1000);
|
||||
tankEthanol.forbidExtraction();
|
||||
tankEthanol.setValidator(new TankValidator() {
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Ethanol";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final FluidStack stack) {
|
||||
return "bio.ethanol".equals(stack.getFluid().getName());
|
||||
}
|
||||
});
|
||||
ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Genepool.SLOT_RESERVE, Genepool.SLOT_BEE, 1);
|
||||
new ComponentPowerReceptor(machine, 1600);
|
||||
new GenepoolLogic(machine);
|
||||
ComponentChargedSlots chargedSlots = new ComponentChargedSlots(machine);
|
||||
chargedSlots.addCharge(Genepool.SLOT_ENZYME);
|
||||
new GenepoolFX(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
}
|
||||
@@ -35,11 +35,11 @@ public class IncubatorLogic extends ComponentProcessIndefinate implements IProce
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (this.recipe != null) {
|
||||
if (!this.recipe.isInputLiquidSufficient(this.getUtil().getFluid(0))) {
|
||||
return new ErrorState.InsufficientLiquid("Not enough incubation liquid", 0);
|
||||
if (!this.recipe.isInputLiquidSufficient(this.getUtil().getFluid(Incubator.TANK_INPUT))) {
|
||||
return new ErrorState.InsufficientLiquid(Genetics.proxy.localise("machine.labMachine.incubator.no.liquid"), Incubator.TANK_INPUT);
|
||||
}
|
||||
if (!this.roomForOutput) {
|
||||
return new ErrorState.TankSpace("No room for output", 1);
|
||||
return new ErrorState.TankSpace(Genetics.proxy.localise("machine.labMachine.incubator.no.room"), Incubator.TANK_OUTPUT);
|
||||
}
|
||||
}
|
||||
return super.canProgress();
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
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_VEKTOR = 0;
|
||||
|
||||
public static void setGene(final IGene gene, final ItemStack target, final int chromoN) {
|
||||
int chromosomeID;
|
||||
final int chromosome = chromosomeID = gene.getChromosome().ordinal();
|
||||
if (chromosomeID >= EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal() && gene.getSpeciesRoot() instanceof IBeeRoot) {
|
||||
--chromosomeID;
|
||||
}
|
||||
final Class<? extends IAllele> cls = gene.getChromosome().getAlleleClass();
|
||||
if (!cls.isInstance(gene.getAllele())) {
|
||||
return;
|
||||
}
|
||||
final NBTTagCompound beeNBT = target.getTagCompound();
|
||||
final NBTTagCompound genomeNBT = beeNBT.getCompoundTag("Genome");
|
||||
final NBTTagList chromosomes = genomeNBT.getTagList("Chromosomes", 10);
|
||||
final NBTTagCompound chromosomeNBT = chromosomes.getCompoundTagAt(chromosomeID);
|
||||
chromosomeNBT.setString("UID" + chromoN, gene.getAllele().getUID());
|
||||
target.setTagCompound(beeNBT);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package binnie.genetics.machine.inoculator;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
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 net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class InoculatorFX extends MachineComponent implements IRender.DisplayTick, IRender.Render, INetwork.TilePacketSync {
|
||||
private final EntityItem dummyEntityItem;
|
||||
|
||||
public InoculatorFX(final IMachine machine) {
|
||||
super(machine);
|
||||
this.dummyEntityItem = new EntityItem(null);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(World world, BlockPos pos, Random rand) {
|
||||
final int tick = (int) (world.getTotalWorldTime() % 3L);
|
||||
if (tick == 0 && this.getUtil().getProcess().isInProgress()) {
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new Particle(world, pos.getX() + 0.5, pos.getY() + 0.92, pos.getZ() + 0.5, 0.0, 0.0, 0.0) {
|
||||
double axisX = this.posX;
|
||||
double axisZ = this.posZ;
|
||||
double angle = (int) (this.worldObj.getTotalWorldTime() % 4L) * 0.5 * 3.1415;
|
||||
|
||||
{
|
||||
this.axisX = 0.0;
|
||||
this.axisZ = 0.0;
|
||||
this.angle = 0.0;
|
||||
this.motionX = 0.0;
|
||||
this.motionZ = 0.0;
|
||||
this.motionY = 0.007 + this.rand.nextDouble() * 0.002;
|
||||
this.particleMaxAge = 240;
|
||||
this.particleGravity = 0.0f;
|
||||
this.field_190017_n = true;
|
||||
this.setRBGColorF(0.8f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
double speed = 5.0E-4;
|
||||
if (this.particleAge > 60) {
|
||||
speed += (this.particleAge - 60) / 4000.0f;
|
||||
}
|
||||
this.angle += speed;
|
||||
final double dist = 0.27;
|
||||
this.setPosition(this.axisX + dist * Math.sin(this.angle), this.posY, this.axisZ + dist * Math.cos(this.angle));
|
||||
this.setAlphaF((float) Math.cos(1.57 * this.particleAge / this.particleMaxAge));
|
||||
if (this.particleAge > 40) {
|
||||
this.setRBGColorF(this.particleRed + (1.0f - this.particleRed) / 10.0f, this.particleGreen + (0.0f - this.particleGreen) / 10.0f, this.particleBlue + (0.0f - this.particleBlue) / 10.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void renderInWorld(final double x, final double y, final double z) {
|
||||
if (!this.getUtil().getProcess().isInProgress()) {
|
||||
return;
|
||||
}
|
||||
final ItemStack stack = this.getUtil().getStack(9);
|
||||
this.dummyEntityItem.worldObj = this.getMachine().getWorld();
|
||||
this.dummyEntityItem.setEntityItemStack(stack);
|
||||
final EntityItem dummyEntityItem = this.dummyEntityItem;
|
||||
dummyEntityItem.setAgeToCreativeDespawnTime(); // ++dummyEntityItem.age;
|
||||
this.dummyEntityItem.hoverStart = 0.0f;
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
final EntityPlayer player = BinnieCore.proxy.getPlayer();
|
||||
final double dx = x + 0.5 - player.lastTickPosX;
|
||||
final double dz = z + 0.5 - player.lastTickPosZ;
|
||||
final double t = Math.atan2(dz, dx) * 180.0 / 3.1415;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(180.0f, 0.0f, 0.0f, 1.0f);
|
||||
GL11.glTranslatef(0.0f, -0.25f, 0.0f);
|
||||
BinnieCore.proxy.getMinecraftInstance().getRenderItem().renderItem(this.dummyEntityItem.getEntityItem(), ItemCameraTransforms.TransformType.FIXED); //, 0.0, 0.0, 0.0, 0.0f, 0.0f);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncToNBT(final NBTTagCompound nbt) {
|
||||
final NBTTagCompound item = new NBTTagCompound();
|
||||
final ItemStack stack = this.getUtil().getStack(9);
|
||||
if (stack != null) {
|
||||
stack.writeToNBT(item);
|
||||
nbt.setTag("item", item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncFromNBT(final NBTTagCompound nbt) {
|
||||
if (nbt.hasKey("item")) {
|
||||
this.getUtil().setStack(9, ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("item")));
|
||||
} else {
|
||||
this.getUtil().setStack(9, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryUpdate() {
|
||||
if (!this.getUtil().isServer()) {
|
||||
return;
|
||||
}
|
||||
this.getUtil().refreshBlock();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
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.Genetics;
|
||||
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.IIndividual;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class InoculatorLogic extends ComponentProcessSetCost implements IProcess {
|
||||
private float bacteriaDrain;
|
||||
|
||||
@Override
|
||||
public int getProcessLength() {
|
||||
return super.getProcessLength() * this.getNumberOfGenes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessEnergy() {
|
||||
return super.getProcessEnergy() * this.getNumberOfGenes();
|
||||
}
|
||||
|
||||
private int getNumberOfGenes() {
|
||||
final ItemStack serum = this.getUtil().getStack(0);
|
||||
if (serum == null) {
|
||||
return 1;
|
||||
}
|
||||
return Engineering.getGenes(serum).length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
final int n = this.getNumberOfGenes();
|
||||
return "Inoculating with " + n + " gene" + ((n > 1) ? "s" : "");
|
||||
}
|
||||
|
||||
public InoculatorLogic(final Machine machine) {
|
||||
super(machine, 600000, 12000);
|
||||
this.bacteriaDrain = 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isSlotEmpty(Inoculator.SLOT_TARGET)) {
|
||||
return new ErrorState.NoItem(Genetics.proxy.localise("machine.machine.inoculator.no.individual"), Inoculator.SLOT_TARGET);
|
||||
}
|
||||
if (this.getUtil().isSlotEmpty(Inoculator.SLOT_SERUM_VIAL)) {
|
||||
return new ErrorState.NoItem(Genetics.proxy.localise("machine.machine.inoculator.no.serum"), Inoculator.SLOT_SERUM_VIAL);
|
||||
}
|
||||
final ErrorState state = this.isValidSerum();
|
||||
if (state != null) {
|
||||
return state;
|
||||
}
|
||||
if (this.getUtil().getStack(0) != null && Engineering.getCharges(this.getUtil().getStack(Inoculator.SLOT_SERUM_VIAL)) == 0) {
|
||||
return new ErrorState(Genetics.proxy.localise("machine.machine.inoculator.empty.serum"), Genetics.proxy.localise("machine.machine.inoculator.empty.serum.info"));
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
public ErrorState isValidSerum() {
|
||||
final ItemStack serum = this.getUtil().getStack(Inoculator.SLOT_SERUM_VIAL);
|
||||
final ItemStack target = this.getUtil().getStack(Inoculator.SLOT_TARGET);
|
||||
final IGene[] genes = Engineering.getGenes(serum);
|
||||
if (genes.length == 0) {
|
||||
return new ErrorState(Genetics.proxy.localise("machine.machine.inoculator.invalid.serum"), Genetics.proxy.localise("machine.machine.inoculator.invalid.serum.no.genes"));
|
||||
}
|
||||
if (!genes[0].getSpeciesRoot().isMember(target)) {
|
||||
return new ErrorState(Genetics.proxy.localise("machine.machine.inoculator.invalid.serum"), Genetics.proxy.localise("machine.machine.inoculator.invalid.serum.mismatch"));
|
||||
}
|
||||
final IIndividual individual = genes[0].getSpeciesRoot().getMember(target);
|
||||
boolean hasAll = true;
|
||||
for (final IGene gene : genes) {
|
||||
if (hasAll) {
|
||||
final IAllele a = individual.getGenome().getActiveAllele(gene.getChromosome());
|
||||
final IAllele b = individual.getGenome().getInactiveAllele(gene.getChromosome());
|
||||
hasAll = (hasAll && a.getUID().equals(gene.getAllele().getUID()) && b.getUID().equals(gene.getAllele().getUID()));
|
||||
}
|
||||
}
|
||||
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();
|
||||
final ItemStack serum = this.getUtil().getStack(Inoculator.SLOT_SERUM_VIAL);
|
||||
final ItemStack target = this.getUtil().getStack(Inoculator.SLOT_TARGET);
|
||||
final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(target);
|
||||
if (!ind.isAnalyzed()) {
|
||||
ind.analyze();
|
||||
final NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
ind.writeToNBT(nbttagcompound);
|
||||
target.setTagCompound(nbttagcompound);
|
||||
}
|
||||
final IGene[] arr$;
|
||||
final IGene[] genes = arr$ = ((IItemSerum) serum.getItem()).getGenes(serum);
|
||||
for (final IGene gene : arr$) {
|
||||
Inoculator.setGene(gene, target, 0);
|
||||
Inoculator.setGene(gene, target, 1);
|
||||
}
|
||||
this.getUtil().damageItem(Inoculator.SLOT_SERUM_VIAL, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
this.bacteriaDrain += 15.0f * this.getProgressPerTick() / 100.0f;
|
||||
if (this.bacteriaDrain >= 1.0f) {
|
||||
this.getUtil().drainTank(Inoculator.TANK_VEKTOR, 1);
|
||||
--this.bacteriaDrain;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package binnie.genetics.machine.inoculator;
|
||||
|
||||
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.craftgui.minecraft.IMachineInformation;
|
||||
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, 14819893, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Inoculator);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
InventorySlot slotSerumVial = inventory.addSlot(Inoculator.SLOT_SERUM_VIAL, "serum.active");
|
||||
slotSerumVial.forbidInteraction();
|
||||
slotSerumVial.setReadOnly();
|
||||
final SlotValidator serumValid = new SlotValidator(ModuleMachine.iconSerum) {
|
||||
@Override
|
||||
public boolean isValid(final ItemStack itemStack) {
|
||||
return itemStack.getItem() instanceof IItemSerum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Serum Vials & Arrays";
|
||||
}
|
||||
};
|
||||
slotSerumVial.setValidator(serumValid);
|
||||
for (InventorySlot slot : inventory.addSlotArray(Inoculator.SLOT_SERUM_RESERVE, "serum.input")) {
|
||||
slot.setValidator(serumValid);
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
for (InventorySlot slot : inventory.addSlotArray(Inoculator.SLOT_SERUM_EXPENDED, "serum.output")) {
|
||||
slot.setValidator(serumValid);
|
||||
slot.setReadOnly();
|
||||
}
|
||||
for (InventorySlot slot : inventory.addSlotArray(Inoculator.SLOT_RESERVE, "input")) {
|
||||
slot.forbidExtraction();
|
||||
slot.setValidator(new ValidatorIndividualInoculate());
|
||||
}
|
||||
InventorySlot slotTarget = inventory.addSlot(Inoculator.SLOT_TARGET, "process");
|
||||
slotTarget.setValidator(new ValidatorIndividualInoculate());
|
||||
slotTarget.setReadOnly();
|
||||
slotTarget.forbidInteraction();
|
||||
for (final InventorySlot slot : inventory.addSlotArray(Inoculator.SLOT_FINISHED, "output")) {
|
||||
slot.setReadOnly();
|
||||
slot.forbidInsertion();
|
||||
slot.setValidator(new ValidatorIndividualInoculate());
|
||||
}
|
||||
final ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Inoculator.SLOT_RESERVE, 9, 1);
|
||||
transfer.addRestock(Inoculator.SLOT_SERUM_RESERVE, 0);
|
||||
transfer.addStorage(Inoculator.SLOT_SERUM_VIAL, Inoculator.SLOT_SERUM_EXPENDED, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(final ItemStack stack) {
|
||||
return Engineering.getCharges(stack) == 0;
|
||||
}
|
||||
});
|
||||
transfer.addStorage(Inoculator.SLOT_TARGET, Inoculator.SLOT_FINISHED, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(final ItemStack stack) {
|
||||
return stack != null && this.transfer.getMachine().getMachineUtil().getStack(Inoculator.SLOT_SERUM_VIAL) != null && this.transfer.getMachine().getInterface(InoculatorLogic.class).isValidSerum() != null;
|
||||
}
|
||||
});
|
||||
new ComponentPowerReceptor(machine, 15000);
|
||||
new InoculatorLogic(machine);
|
||||
new InoculatorFX(machine);
|
||||
new ComponentTankContainer(machine).addTank(Inoculator.TANK_VEKTOR, "input", 1000).setValidator(new Validator<FluidStack>() {
|
||||
@Override
|
||||
public boolean isValid(final 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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
}
|
||||
@@ -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(final ItemStack object) {
|
||||
final 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,93 @@
|
||||
package binnie.genetics.machine.isolator;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import binnie.core.machines.component.IRender;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class IsolaterFX extends MachineComponent implements IRender.RandomDisplayTick, IRender.DisplayTick {
|
||||
public IsolaterFX(final IMachine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onRandomDisplayTick(World world, BlockPos pos, Random rand) {
|
||||
if (!this.getUtil().getProcess().isInProgress()) {
|
||||
return;
|
||||
}
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new Particle(world, pos.getX() + 0.4 + 0.2 * rand.nextDouble(), pos.getY() + 1.6, pos.getZ() + 0.4 + rand.nextDouble() * 0.2, 0.0, 0.0, 0.0) {
|
||||
double axisX = 0.0;
|
||||
double axisZ = 0.0;
|
||||
double angle = 0.0;
|
||||
|
||||
{
|
||||
this.motionX = 0.0;
|
||||
this.motionZ = 0.0;
|
||||
this.motionY = -0.012;
|
||||
this.particleMaxAge = 100;
|
||||
this.particleGravity = 0.0f;
|
||||
this.field_190017_n = true;
|
||||
this.setRBGColorF(0.8f, 0.4f, 0.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
this.angle += 0.06;
|
||||
this.setAlphaF((float) Math.sin(3.14 * this.particleAge / this.particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(World world, BlockPos pos, Random rand) {
|
||||
final int tick = (int) (world.getTotalWorldTime() % 6L);
|
||||
if ((tick == 0 || tick == 5) && this.getUtil().getProcess().isInProgress()) {
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new Particle(world, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 0.0, 0.0, 0.0) {
|
||||
double axisX = this.posX;
|
||||
double axisZ = this.posZ;
|
||||
double angle = 0.7 + (int) (this.worldObj.getTotalWorldTime() % 2L) * 3.1415;
|
||||
|
||||
{
|
||||
this.axisX = 0.0;
|
||||
this.axisZ = 0.0;
|
||||
this.angle = 0.0;
|
||||
this.motionX = 0.0;
|
||||
this.motionZ = 0.0;
|
||||
this.motionY = 0.012;
|
||||
this.particleMaxAge = 100;
|
||||
this.particleGravity = 0.0f;
|
||||
this.field_190017_n = true;
|
||||
this.setRBGColorF(0.8f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
this.angle += 0.06;
|
||||
this.setPosition(this.axisX + 0.26 * Math.sin(this.angle), this.posY, this.axisZ + 0.26 * Math.cos(this.angle));
|
||||
this.setAlphaF((float) Math.cos(1.57 * this.particleAge / this.particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package binnie.genetics.machine.isolator;
|
||||
|
||||
public class Isolator {
|
||||
public static final int SLOT_ENZYME = 0;
|
||||
public static final int SLOT_SEQUENCER_VIAL = 1;
|
||||
public static final int[] SLOT_RESERVE = new int[]{2, 3, 4};
|
||||
public static final int SLOT_TARGET = 5;
|
||||
public static final int SLOT_RESULUT = 6;
|
||||
public static final int[] SLOT_FINISHED = new int[]{7, 8, 9, 10, 11, 12};
|
||||
public static final int TANK_ETHANOL = 0;
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package binnie.genetics.machine.isolator;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import binnie.core.genetics.Gene;
|
||||
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.Genetics;
|
||||
import binnie.genetics.item.ItemSequence;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class IsolatorLogic extends ComponentProcessSetCost implements IProcess {
|
||||
float enzymePerProcess;
|
||||
float ethanolPerProcess;
|
||||
|
||||
public IsolatorLogic(final Machine machine) {
|
||||
super(machine, 192000, 4800);
|
||||
this.enzymePerProcess = 0.5f;
|
||||
this.ethanolPerProcess = 10.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isSlotEmpty(Isolator.SLOT_TARGET)) {
|
||||
return new ErrorState.NoItem(Genetics.proxy.localise("machine.machine.isolator.no.individual"), Isolator.SLOT_TARGET);
|
||||
}
|
||||
if (!this.getUtil().isSlotEmpty(Isolator.SLOT_RESULUT)) {
|
||||
return new ErrorState.NoSpace(Genetics.proxy.localise("machine.machine.isolator.no.room"), Isolator.SLOT_FINISHED);
|
||||
}
|
||||
if (this.getUtil().isSlotEmpty(Isolator.SLOT_SEQUENCER_VIAL)) {
|
||||
return new ErrorState.NoItem(Genetics.proxy.localise("machine.machine.isolator.no.empty.sequencer"), Isolator.SLOT_SEQUENCER_VIAL);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (!this.getUtil().liquidInTank(Isolator.TANK_ETHANOL, (int) this.ethanolPerProcess)) {
|
||||
return new ErrorState.InsufficientLiquid(Genetics.proxy.localise("machine.machine.isolator.insufficient.ethanol"), Isolator.TANK_ETHANOL);
|
||||
}
|
||||
if (this.getUtil().getSlotCharge(Isolator.SLOT_ENZYME) == 0.0f) {
|
||||
return new ErrorState.NoItem(Genetics.proxy.localise("machine.machine.isolator.no.enzyme"), Isolator.SLOT_ENZYME);
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
final Random rand = this.getMachine().getWorld().rand;
|
||||
final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(this.getUtil().getStack(5));
|
||||
if (root == null) {
|
||||
return;
|
||||
}
|
||||
final IIndividual individual = root.getMember(this.getUtil().getStack(5));
|
||||
if (individual == null) {
|
||||
return;
|
||||
}
|
||||
IAllele allele = null;
|
||||
IChromosomeType chromosome = null;
|
||||
Gene gene = null;
|
||||
if (this.getMachine().getWorld().rand.nextFloat() < 2.0f) {
|
||||
while (gene == null) {
|
||||
try {
|
||||
chromosome = root.getKaryotype()[rand.nextInt(root.getKaryotype().length)];
|
||||
allele = (rand.nextBoolean() ? individual.getGenome().getActiveAllele(chromosome) : individual.getGenome().getInactiveAllele(chromosome));
|
||||
gene = Gene.create(allele, chromosome, root);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
final ItemStack serum = ItemSequence.create(gene);
|
||||
this.getUtil().setStack(Isolator.SLOT_RESULUT, serum);
|
||||
this.getUtil().decreaseStack(Isolator.SLOT_SEQUENCER_VIAL, 1);
|
||||
if (rand.nextFloat() < 0.05f) {
|
||||
this.getUtil().decreaseStack(Isolator.SLOT_TARGET, 1);
|
||||
}
|
||||
this.getUtil().drainTank(Isolator.TANK_ETHANOL, (int) this.ethanolPerProcess);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
this.getMachine().getInterface(IChargedSlots.class).alterCharge(Isolator.SLOT_ENZYME, -this.enzymePerProcess * this.getProgressPerTick() / 100.0f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package binnie.genetics.machine.isolator;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
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.TankValidator;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.craftgui.minecraft.IMachineInformation;
|
||||
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;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class PackageIsolator extends GeneticMachine.PackageGeneticBase implements IMachineInformation {
|
||||
public PackageIsolator() {
|
||||
super("isolator", GeneticsTexture.Isolator, 16740111, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Isolator);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
InventorySlot slotEnzyme = inventory.addSlot(Isolator.SLOT_ENZYME, "enzyme");
|
||||
slotEnzyme.setValidator(new SlotValidator.Item(GeneticsItems.Enzyme.get(1), ModuleMachine.IconEnzyme));
|
||||
slotEnzyme.forbidExtraction();
|
||||
InventorySlot slotSequencer= inventory.addSlot(Isolator.SLOT_SEQUENCER_VIAL, "sequencervial");
|
||||
slotSequencer.setValidator(new SlotValidator.Item(GeneticsItems.EmptySequencer.get(1), ModuleMachine.IconSequencer));
|
||||
slotSequencer.forbidExtraction();
|
||||
for (InventorySlot slot : inventory.addSlotArray(Isolator.SLOT_RESERVE, "input")) {
|
||||
slot.setValidator(new SlotValidator.Individual());
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
InventorySlot slotTarget = inventory.addSlot(Isolator.SLOT_TARGET, "process");
|
||||
slotTarget.setValidator(new SlotValidator.Individual());
|
||||
slotTarget.setReadOnly();
|
||||
slotTarget.forbidInteraction();
|
||||
InventorySlot slotResulut = inventory.addSlot(Isolator.SLOT_RESULUT, "output");
|
||||
slotResulut.setReadOnly();
|
||||
slotResulut.forbidInteraction();
|
||||
for (final InventorySlot slot : inventory.addSlotArray(Isolator.SLOT_FINISHED, "output")) {
|
||||
slot.setReadOnly();
|
||||
slot.forbidInsertion();
|
||||
}
|
||||
final ComponentTankContainer tanks = new ComponentTankContainer(machine);
|
||||
tanks.addTank(Isolator.TANK_ETHANOL, "input", 1000).setValidator(new TankValidator() {
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Ethanol";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final FluidStack stack) {
|
||||
return Objects.equals(stack.getFluid().getName(), "bioethanol");
|
||||
}
|
||||
});
|
||||
final ComponentChargedSlots chargedSlots = new ComponentChargedSlots(machine);
|
||||
chargedSlots.addCharge(Isolator.SLOT_ENZYME);
|
||||
final ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Isolator.SLOT_RESERVE, Isolator.SLOT_TARGET, 1);
|
||||
transfer.addStorage(Isolator.SLOT_RESULUT, Isolator.SLOT_FINISHED);
|
||||
new ComponentPowerReceptor(machine, 20000);
|
||||
new IsolatorLogic(machine);
|
||||
new IsolaterFX(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package binnie.genetics.machine.sequencer;
|
||||
|
||||
import binnie.Binnie;
|
||||
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.craftgui.minecraft.IMachineInformation;
|
||||
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 {
|
||||
public PackageSequencer() {
|
||||
super("sequencer", GeneticsTexture.Sequencer, 12058418, 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(final Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Sequencer);
|
||||
ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
InventorySlot slotDye = inventory.addSlot(Sequencer.SLOT_DYE, "dye");
|
||||
slotDye.setValidator(new SlotValidator.Item(GeneticsItems.FluorescentDye.get(1), ModuleMachine.IconDye));
|
||||
slotDye.forbidExtraction();
|
||||
for (InventorySlot slot : inventory.addSlotArray(Sequencer.SLOT_RESERVE, "input")) {
|
||||
slot.setValidator(new SlotValidatorUnsequenced());
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
InventorySlot slotTarget = inventory.addSlot(Sequencer.SLOT_TARGET, "process");
|
||||
slotTarget.setValidator(new SlotValidatorUnsequenced());
|
||||
slotTarget.setReadOnly();
|
||||
slotTarget.forbidInteraction();
|
||||
InventorySlot slotDrone = inventory.addSlot(Sequencer.SLOT_DRONE, "output");
|
||||
slotDrone.setReadOnly();
|
||||
ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Sequencer.SLOT_RESERVE, Sequencer.SLOT_TARGET, 1);
|
||||
new ComponentChargedSlots(machine).addCharge(0);
|
||||
new ComponentPowerReceptor(machine, 10000);
|
||||
new SequencerLogic(machine);
|
||||
new SequencerFX(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package binnie.genetics.machine.sequencer;
|
||||
|
||||
import binnie.core.resource.BinnieIcon;
|
||||
|
||||
public class Sequencer {
|
||||
public static final int SLOT_DYE = 0;
|
||||
public static final int[] SLOT_RESERVE = new int[]{1, 2, 3, 4};
|
||||
public static final int SLOT_TARGET = 5;
|
||||
public static final int SLOT_DRONE = 6;
|
||||
public static BinnieIcon fxSeqA;
|
||||
public static BinnieIcon fxSeqG;
|
||||
public static BinnieIcon fxSeqT;
|
||||
public static BinnieIcon fxSeqC;
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package binnie.genetics.machine.sequencer;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import binnie.core.machines.component.IRender;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SequencerFX extends MachineComponent implements IRender.RandomDisplayTick, IRender.DisplayTick {
|
||||
public SequencerFX(final IMachine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onRandomDisplayTick(World world, BlockPos pos, Random rand) {
|
||||
if (!this.getUtil().getProcess().isInProgress()) {
|
||||
return;
|
||||
}
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new Particle(world, pos.getX() + 0.5, pos.getY() + 1.2 + rand.nextDouble() * 0.2, pos.getZ() + 0.5, 0.0, 0.0, 0.0) {
|
||||
double axisX = this.posX;
|
||||
double axisZ = this.posZ;
|
||||
double angle = this.rand.nextDouble() * 2.0 * 3.1415;
|
||||
|
||||
{
|
||||
this.axisX = 0.0;
|
||||
this.axisZ = 0.0;
|
||||
this.angle = 0.0;
|
||||
this.motionX = 0.0;
|
||||
this.motionZ = 0.0;
|
||||
this.motionY = 0.0;
|
||||
this.particleMaxAge = 200;
|
||||
this.particleGravity = 0.0f;
|
||||
this.field_190017_n = true;
|
||||
this.setRBGColorF(0.6f + this.rand.nextFloat() * 0.2f, 1.0f, 0.8f * this.rand.nextFloat() * 0.2f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
this.angle += 0.03;
|
||||
this.setPosition(this.axisX + 0.4 * Math.sin(this.angle), this.posY, this.axisZ + 0.4 * Math.cos(this.angle));
|
||||
this.motionY = 0.0;
|
||||
this.setAlphaF((float) Math.sin(3.14 * this.particleAge / this.particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(World world, BlockPos pos, Random rand) {
|
||||
final int ticks = (int) (world.getTotalWorldTime() % 16L);
|
||||
if (ticks == 0 && this.getUtil().getProcess().isInProgress()) {
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new Particle(world, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 0.0, 0.0, 0.0) {
|
||||
double axisX = 0.0;
|
||||
double axisZ = 0.0;
|
||||
double angle = 0.0;
|
||||
|
||||
{
|
||||
this.motionX = 0.0;
|
||||
this.motionZ = 0.0;
|
||||
this.motionY = 0.012;
|
||||
this.particleMaxAge = 50;
|
||||
this.particleGravity = 0.0f;
|
||||
this.field_190017_n = true;
|
||||
this.particleScale = 2.0f;
|
||||
//TODO: Add sprites
|
||||
//this.setParticleIcon((new BinnieIcon[] { Sequencer.fxSeqA, Sequencer.fxSeqG, Sequencer.fxSeqC, Sequencer.fxSeqT })[this.rand.nextInt(4)].getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
this.motionY = 0.012;
|
||||
if (this.particleAge > 40) {
|
||||
this.setAlphaF((50 - this.particleAge) / 10.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package binnie.genetics.machine.sequencer;
|
||||
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.power.ComponentProcess;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.core.machines.power.IProcess;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.genetics.GeneTracker;
|
||||
import binnie.genetics.genetics.SequencerItem;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SequencerLogic extends ComponentProcess implements IProcess {
|
||||
public SequencerLogic(final Machine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
public float getSequenceStrength() {
|
||||
final ItemStack stack = this.getUtil().getStack(Sequencer.SLOT_TARGET);
|
||||
if (stack == null) {
|
||||
return 1.0f;
|
||||
}
|
||||
final float mult = 1.0f - stack.getItemDamage() % 6 / 5.0f;
|
||||
return 1.0f - mult * mult * 0.75f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessLength() {
|
||||
return (int) (19200.0f * this.getSequenceStrength());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessEnergy() {
|
||||
return this.getProcessLength() * 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isSlotEmpty(Sequencer.SLOT_TARGET)) {
|
||||
return new ErrorState.NoItem(Genetics.proxy.localise("machine.machine.sequencer.no.dna"), 5);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (this.getMachine().getOwner() == null) {
|
||||
return new ErrorState(Genetics.proxy.localise("machine.machine.sequencer.no.owner"), Genetics.proxy.localise("machine.machine.sequencer.no.owner.info"));
|
||||
}
|
||||
if (this.getUtil().getSlotCharge(Sequencer.SLOT_DYE) == 0.0f) {
|
||||
return new ErrorState.NoItem(Genetics.proxy.localise("machine.machine.sequencer.insufficient.dye"), Sequencer.SLOT_DYE);
|
||||
}
|
||||
if (this.getUtil().getStack(Sequencer.SLOT_DRONE) != null && this.getUtil().getStack(Sequencer.SLOT_DRONE).stackSize >= 64) {
|
||||
return new ErrorState.NoSpace(Genetics.proxy.localise("machine.machine.sequencer.no.space"), new int[]{Sequencer.SLOT_DRONE});
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStartTask() {
|
||||
super.onStartTask();
|
||||
final ItemStack item = this.getUtil().getStack(Sequencer.SLOT_TARGET);
|
||||
final SequencerItem seqItem = new SequencerItem(item);
|
||||
final int seq = seqItem.sequenced;
|
||||
if (seq != 0) {
|
||||
this.setProgress(seq);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
this.updateSequence();
|
||||
final SequencerItem seqItem = new SequencerItem(this.getUtil().getStack(Sequencer.SLOT_TARGET));
|
||||
GeneTracker.getTracker(this.getMachine().getWorld(), this.getMachine().getOwner()).registerGene(seqItem.getGene());
|
||||
this.getUtil().decreaseStack(Sequencer.SLOT_TARGET, 1);
|
||||
if (this.getUtil().getStack(Sequencer.SLOT_DRONE) == null) {
|
||||
this.getUtil().setStack(Sequencer.SLOT_DRONE, GeneticsItems.EmptySequencer.get(1));
|
||||
} else {
|
||||
this.getUtil().decreaseStack(Sequencer.SLOT_DRONE, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
this.updateSequence();
|
||||
this.getUtil().useCharge(Sequencer.SLOT_DYE, 0.4f * this.getProgressPerTick() / 100.0f);
|
||||
}
|
||||
|
||||
private void updateSequence() {
|
||||
final int prog = (int) this.getProgress();
|
||||
final ItemStack item = this.getUtil().getStack(Sequencer.SLOT_TARGET);
|
||||
final SequencerItem seqItem = new SequencerItem(item);
|
||||
final int seq = seqItem.sequenced;
|
||||
if (prog != seq) {
|
||||
seqItem.sequenced = prog;
|
||||
seqItem.writeToItem(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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(final ItemStack itemStack) {
|
||||
if (itemStack.getItem() == Genetics.itemSequencer) {
|
||||
final SequencerItem seq = new SequencerItem(itemStack);
|
||||
return seq.sequenced < 100;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Unsequenced DNA";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package binnie.genetics.machine.splicer;
|
||||
|
||||
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.InventorySlot;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.genetics.api.IItemSerum;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.genetics.Engineering;
|
||||
import binnie.genetics.machine.AdvGeneticMachine;
|
||||
import binnie.genetics.machine.ComponentGeneticGUI;
|
||||
import binnie.genetics.machine.ModuleMachine;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class PackageSplicer extends AdvGeneticMachine.PackageAdvGeneticBase implements IMachineInformation {
|
||||
public PackageSplicer() {
|
||||
super("splicer", GeneticsTexture.Splicer, 14819893, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Splicer);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
InventorySlot slotSerumVial = inventory.addSlot(Splicer.SLOT_SERUM_VIAL, "serum.active");
|
||||
slotSerumVial.forbidInteraction();
|
||||
slotSerumVial.setReadOnly();
|
||||
final SlotValidator serumValid = new SlotValidator(ModuleMachine.iconSerum) {
|
||||
@Override
|
||||
public boolean isValid(final ItemStack itemStack) {
|
||||
return itemStack.getItem() instanceof IItemSerum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Serum Vials & Arrays";
|
||||
}
|
||||
};
|
||||
slotSerumVial.setValidator(serumValid);
|
||||
for (InventorySlot slot : inventory.addSlotArray(Splicer.SLOT_SERUM_RESERVE, "serum.input")) {
|
||||
slot.setValidator(serumValid);
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
for (InventorySlot slot : inventory.addSlotArray(Splicer.SLOT_SERUM_EXPENDED, "serum.output")) {
|
||||
slot.setValidator(serumValid);
|
||||
slot.setReadOnly();
|
||||
}
|
||||
for (InventorySlot slot : inventory.addSlotArray(Splicer.SLOT_RESERVE, "input")) {
|
||||
slot.forbidExtraction();
|
||||
slot.setValidator(new ValidatorIndividualInoculate());
|
||||
}
|
||||
InventorySlot slotTarget = inventory.addSlot(Splicer.SLOT_TARGET, "process");
|
||||
slotTarget.setValidator(new ValidatorIndividualInoculate());
|
||||
slotTarget.setReadOnly();
|
||||
slotTarget.forbidInteraction();
|
||||
for (InventorySlot slot : inventory.addSlotArray(Splicer.SLOT_FINISHED, "output")) {
|
||||
slot.setReadOnly();
|
||||
slot.forbidInsertion();
|
||||
slot.setValidator(new ValidatorIndividualInoculate());
|
||||
}
|
||||
final ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Splicer.SLOT_RESERVE, 9, 1);
|
||||
transfer.addRestock(Splicer.SLOT_SERUM_RESERVE, 0);
|
||||
transfer.addStorage(Splicer.SLOT_SERUM_VIAL, Splicer.SLOT_SERUM_EXPENDED, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(final ItemStack stack) {
|
||||
return Engineering.getCharges(stack) == 0;
|
||||
}
|
||||
});
|
||||
transfer.addStorage(Splicer.SLOT_TARGET, Splicer.SLOT_FINISHED, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(final ItemStack stack) {
|
||||
return stack != null && this.transfer.getMachine().getMachineUtil().getStack(0) != null && this.transfer.getMachine().getInterface(SplicerLogic.class).isValidSerum() != null;
|
||||
}
|
||||
});
|
||||
new ComponentPowerReceptor(machine, 20000);
|
||||
new SplicerLogic(machine);
|
||||
new SplicerFX(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package binnie.genetics.machine.splicer;
|
||||
|
||||
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 Splicer {
|
||||
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, 9};
|
||||
public static final int SLOT_TARGET = 9;
|
||||
public static final int[] SLOT_FINISHED = new int[]{10, 11, 12, 13};
|
||||
|
||||
public static void setGene(final IGene gene, final ItemStack target, final int chromoN) {
|
||||
int chromosomeID;
|
||||
final int chromosome = chromosomeID = gene.getChromosome().ordinal();
|
||||
if (chromosomeID >= EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal() && gene.getSpeciesRoot() instanceof IBeeRoot) {
|
||||
--chromosomeID;
|
||||
}
|
||||
final Class<? extends IAllele> cls = gene.getChromosome().getAlleleClass();
|
||||
if (!cls.isInstance(gene.getAllele())) {
|
||||
return;
|
||||
}
|
||||
final NBTTagCompound beeNBT = target.getTagCompound();
|
||||
final NBTTagCompound genomeNBT = beeNBT.getCompoundTag("Genome");
|
||||
final NBTTagList chromosomes = genomeNBT.getTagList("Chromosomes", 10);
|
||||
final NBTTagCompound chromosomeNBT = chromosomes.getCompoundTagAt(chromosomeID);
|
||||
chromosomeNBT.setString("UID" + chromoN, gene.getAllele().getUID());
|
||||
target.setTagCompound(beeNBT);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package binnie.genetics.machine.splicer;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
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 net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class SplicerFX extends MachineComponent implements IRender.DisplayTick, IRender.Render, INetwork.TilePacketSync {
|
||||
private final EntityItem dummyEntityItem;
|
||||
|
||||
public SplicerFX(final IMachine machine) {
|
||||
super(machine);
|
||||
this.dummyEntityItem = new EntityItem(machine.getWorld());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(World world, BlockPos pos, Random rand) {
|
||||
final int tick = (int) (world.getTotalWorldTime() % 3L);
|
||||
if (tick == 0 && this.getUtil().getProcess().isInProgress()) {
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new Particle(world, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, 0.0, 0.0, 0.0) {
|
||||
double axisX = this.posX;
|
||||
double axisZ = this.posZ;
|
||||
double angle = (int) (this.worldObj.getTotalWorldTime() % 4L) * 0.5 * 3.1415;
|
||||
|
||||
{
|
||||
this.axisX = 0.0;
|
||||
this.axisZ = 0.0;
|
||||
this.angle = 0.0;
|
||||
this.motionX = 0.0;
|
||||
this.motionZ = 0.0;
|
||||
this.motionY = (this.rand.nextDouble() - 0.5) * 0.02;
|
||||
this.particleMaxAge = 240;
|
||||
this.particleGravity = 0.0f;
|
||||
this.field_190017_n = true;
|
||||
this.setRBGColorF(0.3f + this.rand.nextFloat() * 0.5f, 0.3f + this.rand.nextFloat() * 0.5f, 0.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
final double speed = 0.04;
|
||||
this.angle -= speed;
|
||||
final double dist = 0.25 + 0.2 * Math.sin(this.particleAge / 50.0f);
|
||||
this.setPosition(this.axisX + dist * Math.sin(this.angle), this.posY, this.axisZ + dist * Math.cos(this.angle));
|
||||
this.setAlphaF((float) Math.cos(1.57 * this.particleAge / this.particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void renderInWorld(double x, final double y, final double z) {
|
||||
if (!this.getUtil().getProcess().isInProgress()) {
|
||||
return;
|
||||
}
|
||||
final ItemStack stack = this.getUtil().getStack(9);
|
||||
this.dummyEntityItem.worldObj = this.getMachine().getWorld();
|
||||
this.dummyEntityItem.setEntityItemStack(stack);
|
||||
final EntityItem dummyEntityItem = this.dummyEntityItem;
|
||||
dummyEntityItem.setAgeToCreativeDespawnTime(); //++dummyEntityItem.age;
|
||||
this.dummyEntityItem.hoverStart = 0.0f;
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
final EntityPlayer player = BinnieCore.proxy.getPlayer();
|
||||
final double dx = x + 0.5 - player.lastTickPosX;
|
||||
final double dz = z + 0.5 - player.lastTickPosZ;
|
||||
final double t = Math.atan2(dz, dx) * 180.0 / 3.1415;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(180.0f, 0.0f, 0.0f, 1.0f);
|
||||
GL11.glTranslatef(0.0f, -0.25f, 0.0f);
|
||||
BinnieCore.proxy.getMinecraftInstance().getRenderItem().renderItem(dummyEntityItem.getEntityItem(), ItemCameraTransforms.TransformType.FIXED);//doRender(this.dummyEntityItem, 0.0, 0.0, 0.0, 0.0f, 0.0f);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncToNBT(final NBTTagCompound nbt) {
|
||||
final NBTTagCompound item = new NBTTagCompound();
|
||||
final ItemStack stack = this.getUtil().getStack(9);
|
||||
if (stack != null) {
|
||||
stack.writeToNBT(item);
|
||||
nbt.setTag("item", item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncFromNBT(final NBTTagCompound nbt) {
|
||||
if (nbt.hasKey("item")) {
|
||||
this.getUtil().setStack(9, ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("item")));
|
||||
} else {
|
||||
this.getUtil().setStack(9, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryUpdate() {
|
||||
if (!this.getUtil().isServer()) {
|
||||
return;
|
||||
}
|
||||
this.getUtil().refreshBlock();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
package binnie.genetics.machine.splicer;
|
||||
|
||||
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.IIndividual;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class SplicerLogic extends ComponentProcessSetCost implements IProcess {
|
||||
int nOfGenes;
|
||||
|
||||
@Override
|
||||
public int getProcessLength() {
|
||||
float n = this.getNumberOfGenes();
|
||||
if (n > 1.0f) {
|
||||
n = 1.0f + (n - 1.0f) * 0.5f;
|
||||
}
|
||||
// Fix for / by 0
|
||||
int temp = (int) (super.getProcessLength() * n);
|
||||
return temp != 0 ? temp : 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessEnergy() {
|
||||
float n = this.getNumberOfGenes();
|
||||
if (n > 1.0f) {
|
||||
n = 1.0f + (n - 1.0f) * 0.5f;
|
||||
}
|
||||
return (int) (super.getProcessEnergy() * n);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryUpdate() {
|
||||
super.onInventoryUpdate();
|
||||
this.nOfGenes = this.getGenesToUse();
|
||||
}
|
||||
|
||||
protected int getGenesToUse() {
|
||||
final ItemStack serum = this.getUtil().getStack(0);
|
||||
final ItemStack target = this.getUtil().getStack(9);
|
||||
if (serum == null || target == null) {
|
||||
return 1;
|
||||
}
|
||||
final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(target);
|
||||
final IGene[] genes = ((IItemSerum) serum.getItem()).getGenes(serum);
|
||||
if (ind.getGenome().getSpeciesRoot() != ((IItemSerum) serum.getItem()).getSpeciesRoot(serum)) {
|
||||
return 1;
|
||||
}
|
||||
int i = 0;
|
||||
for (final IGene gene : genes) {
|
||||
if (ind.getGenome().getActiveAllele(gene.getChromosome()) != gene.getAllele() || ind.getGenome().getInactiveAllele(gene.getChromosome()) != gene.getAllele()) {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
return (i < 1) ? 1 : i;
|
||||
}
|
||||
|
||||
private int getFullNumberOfGenes() {
|
||||
final ItemStack serum = this.getUtil().getStack(0);
|
||||
if (serum == null) {
|
||||
return 1;
|
||||
}
|
||||
return Engineering.getGenes(serum).length;
|
||||
}
|
||||
|
||||
private int getNumberOfGenes() {
|
||||
return this.nOfGenes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
final int n = this.getNumberOfGenes();
|
||||
final int f = this.getFullNumberOfGenes();
|
||||
return "Splicing in " + n + ((f > 1) ? ("/" + f) : "") + " gene" + ((n > 1) ? "s" : "");
|
||||
}
|
||||
|
||||
public SplicerLogic(final Machine machine) {
|
||||
super(machine, 12000000, 1200);
|
||||
this.nOfGenes = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isSlotEmpty(9)) {
|
||||
return new ErrorState.NoItem("No Individual to Splice", 9);
|
||||
}
|
||||
if (this.getUtil().isSlotEmpty(0)) {
|
||||
return new ErrorState.NoItem("No Serum", 0);
|
||||
}
|
||||
final ErrorState state = this.isValidSerum();
|
||||
if (state != null) {
|
||||
return state;
|
||||
}
|
||||
if (this.getUtil().getStack(0) != null && Engineering.getCharges(this.getUtil().getStack(0)) == 0) {
|
||||
return new ErrorState("Empty Serum", "Serum is empty");
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
public ErrorState isValidSerum() {
|
||||
final ItemStack serum = this.getUtil().getStack(0);
|
||||
final ItemStack target = this.getUtil().getStack(9);
|
||||
final 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");
|
||||
}
|
||||
final IIndividual individual = genes[0].getSpeciesRoot().getMember(target);
|
||||
boolean hasAll = true;
|
||||
for (final IGene gene : genes) {
|
||||
if (hasAll) {
|
||||
final IAllele a = individual.getGenome().getActiveAllele(gene.getChromosome());
|
||||
final IAllele b = individual.getGenome().getInactiveAllele(gene.getChromosome());
|
||||
hasAll = (hasAll && a.getUID().equals(gene.getAllele().getUID()) && b.getUID().equals(gene.getAllele().getUID()));
|
||||
}
|
||||
}
|
||||
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();
|
||||
final ItemStack serum = this.getUtil().getStack(0);
|
||||
final ItemStack target = this.getUtil().getStack(9);
|
||||
final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(target);
|
||||
if (!ind.isAnalyzed()) {
|
||||
ind.analyze();
|
||||
final NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
ind.writeToNBT(nbttagcompound);
|
||||
target.setTagCompound(nbttagcompound);
|
||||
}
|
||||
final IGene[] arr$;
|
||||
final IGene[] genes = arr$ = ((IItemSerum) serum.getItem()).getGenes(serum);
|
||||
for (final IGene gene : arr$) {
|
||||
Splicer.setGene(gene, target, 0);
|
||||
Splicer.setGene(gene, target, 1);
|
||||
}
|
||||
this.getUtil().damageItem(0, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package binnie.genetics.machine.splicer;
|
||||
|
||||
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(final ItemStack object) {
|
||||
final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(object);
|
||||
return root != null && Binnie.Genetics.getSystem(root).isDNAManipulable(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Splicable Individual";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user