mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-20 04:10:07 +00:00
Localization and refactoring (#77)
* Some refactoring for bee production * Code cleanup * Code cleanup * Added some localization * Fix wrong dropped class * Added some localization * Added some localization * Added some localization * Fix wrong import
This commit is contained in:
1 parent
68bbe7710c
commit
1ea7b62e5f
157 files changed
+3240
-5045
No files matched your search
@@ -80,8 +80,8 @@ public class ControlGene extends Control implements IControlValue<IGene>, IToolt
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
if (isMouseOver() && canFill(Window.get(this).getHeldItemStack())) {
|
||||
CraftGUI.Render.solid(getArea(), -1);
|
||||
CraftGUI.Render.solid(getArea().inset(1), -12303292);
|
||||
CraftGUI.Render.solid(getArea(), 0xffffffff);
|
||||
CraftGUI.Render.solid(getArea().inset(1), 0xff444444);
|
||||
}
|
||||
|
||||
CraftGUI.Render.colour(-1);
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
package binnie.genetics.craftgui;
|
||||
|
||||
import binnie.core.craftgui.CraftGUI;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.geometry.IArea;
|
||||
import binnie.core.craftgui.geometry.IPoint;
|
||||
import binnie.core.craftgui.minecraft.control.ControlMachineProgress;
|
||||
|
||||
// TODO unused class?
|
||||
public class ControlProcessTemporary extends ControlMachineProgress {
|
||||
public ControlProcessTemporary(IWidget parent, int x, int y, int width, int height) {
|
||||
super(parent, x, y, null, null, null);
|
||||
setSize(new IPoint(width, height));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.Render.solid(getArea(), -4868683);
|
||||
float w = getSize().y() * progress / 100.0f;
|
||||
CraftGUI.Render.solid(new IArea(getArea().x(), getArea().y(), w, getArea().h()), -65536);
|
||||
}
|
||||
}
|
||||
@@ -10,21 +10,17 @@ import binnie.core.craftgui.minecraft.control.ControlSlot;
|
||||
import binnie.core.craftgui.minecraft.control.ControlSlotArray;
|
||||
import binnie.core.craftgui.resource.Texture;
|
||||
import binnie.core.craftgui.resource.minecraft.StandardTexture;
|
||||
import binnie.core.util.I18N;
|
||||
import binnie.extrabees.core.ExtraBeeTexture;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.machine.Acclimatiser;
|
||||
import binnie.genetics.machine.acclimatiser.Acclimatiser;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
public class WindowAcclimatiser extends WindowMachine {
|
||||
public static int[] slotReserve = new int[]{0, 1, 2, 3};
|
||||
public static int slotTarget = 4;
|
||||
public static int[] slotAcclimatiser = new int[]{5, 6, 7};
|
||||
public static int[] slotDone = new int[]{8, 9, 10, 11};
|
||||
|
||||
protected static Texture ProgressBase = new StandardTexture(64, 0, 130, 21, ExtraBeeTexture.GUIProgress.getTexture());
|
||||
protected static Texture Progress = new StandardTexture(64, 21, 130, 21, ExtraBeeTexture.GUIProgress.getTexture());
|
||||
protected static Texture progressBase = new StandardTexture(64, 0, 130, 21, ExtraBeeTexture.GUIProgress.getTexture());
|
||||
protected static Texture progress = new StandardTexture(64, 21, 130, 21, ExtraBeeTexture.GUIProgress.getTexture());
|
||||
|
||||
public WindowAcclimatiser(EntityPlayer player, IInventory inventory, Side side) {
|
||||
super(280, 198, player, inventory, side);
|
||||
@@ -36,15 +32,15 @@ public class WindowAcclimatiser extends WindowMachine {
|
||||
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
setTitle("Acclimatiser");
|
||||
int x = 16;
|
||||
setTitle(I18N.localise(Genetics.instance, "machine.labMachine.acclimatiser"));
|
||||
int x = 59;
|
||||
int y = 32;
|
||||
new ControlSlotArray(this, x, y, 2, 2).create(Acclimatiser.slotReserve);
|
||||
new ControlSlotArray(this, x, y, 2, 2).create(Acclimatiser.SLOT_RESERVE);
|
||||
x += 54;
|
||||
new ControlSlot(this, x + 18, y).assign(4);
|
||||
new ControlSlotArray(this, x, y + 18 + 18, 3, 1).create(Acclimatiser.slotAcclimatiser);
|
||||
new ControlSlotArray(this, x, y + 18 + 18, 3, 1).create(Acclimatiser.SLOT_ACCLIMATISER);
|
||||
x += 72;
|
||||
new ControlSlotArray(this, x, y, 2, 2).create(Acclimatiser.slotDone);
|
||||
new ControlSlotArray(this, x, y, 2, 2).create(Acclimatiser.SLOT_DONE);
|
||||
new ControlEnergyBar(this, 21, 115, 16, 60, Position.Bottom);
|
||||
new ControlErrorState(this, 181.0f, 83.0f);
|
||||
new ControlPlayerInventory(this);
|
||||
@@ -52,7 +48,7 @@ public class WindowAcclimatiser extends WindowMachine {
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Acclimatiser";
|
||||
return I18N.localise(Genetics.instance, "machine.labMachine.acclimatiser");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -62,6 +58,6 @@ public class WindowAcclimatiser extends WindowMachine {
|
||||
|
||||
@Override
|
||||
protected String getName() {
|
||||
return "Acclimatiser";
|
||||
return I18N.localise(Genetics.instance, "machine.labMachine.acclimatiser");
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ import binnie.core.craftgui.window.Panel;
|
||||
import binnie.extrabees.core.ExtraBeeTexture;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.machine.Analyser;
|
||||
import binnie.genetics.machine.analyser.Analyser;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -42,7 +42,7 @@ public class WindowAnalyser extends WindowMachine {
|
||||
WindowAnalyser.Progress = new StandardTexture(66, 51, 66, 40, GeneticsTexture.GUIProcess.getTexture());
|
||||
int x = 16;
|
||||
int y = 32;
|
||||
new ControlSlotArray(this, x, y, 2, 3).create(Analyser.slotReserve);
|
||||
new ControlSlotArray(this, x, y, 2, 3).create(Analyser.SLOT_RESERVE);
|
||||
x += 28;
|
||||
new ControlSlot(this, x, y + 54 + 8).assign(13);
|
||||
new ControlSlotCharge(this, x + 20, y + 54 + 8, 13).setColor(10040319);
|
||||
@@ -56,7 +56,7 @@ public class WindowAnalyser extends WindowMachine {
|
||||
new ControlSlot(this, x + 38 - 9, y + 25 - 9).assign(6);
|
||||
new ControlIconDisplay(this, x + 76 + 2, y + 18, GUIIcon.ArrowRight.getIcon());
|
||||
x += 96;
|
||||
new ControlSlotArray(this, x, y, 2, 3).create(Analyser.slotFinished);
|
||||
new ControlSlotArray(this, x, y, 2, 3).create(Analyser.SLOT_FINISHED);
|
||||
x += 52;
|
||||
setTitle("Analyser");
|
||||
new ControlPlayerInventory(this);
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
package binnie.genetics.craftgui;
|
||||
|
||||
import binnie.core.AbstractMod;
|
||||
import binnie.core.craftgui.minecraft.Window;
|
||||
import binnie.genetics.Genetics;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
// TODO unused class?
|
||||
public class WindowGeneProject extends Window {
|
||||
public WindowGeneProject(EntityPlayer player, IInventory inventory, Side side) {
|
||||
super(100.0f, 100.0f, player, inventory, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractMod getMod() {
|
||||
return Genetics.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getName() {
|
||||
return "GeneProjects";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
setTitle("Gene Projects");
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ import binnie.core.craftgui.resource.Texture;
|
||||
import binnie.core.craftgui.resource.minecraft.StandardTexture;
|
||||
import binnie.extrabees.core.ExtraBeeTexture;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.machine.Genepool;
|
||||
import binnie.genetics.machine.genepool.Genepool;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -41,7 +41,7 @@ public class WindowGenepool extends WindowMachine {
|
||||
int y = 32;
|
||||
new ControlLiquidTank(this, x, y).setTankID(1);
|
||||
x += 26;
|
||||
new ControlSlotArray(this, x, y + 3, 2, 3).create(Genepool.slotReserve);
|
||||
new ControlSlotArray(this, x, y + 3, 2, 3).create(Genepool.SLOT_RESERVE);
|
||||
x += 38;
|
||||
new ControlIconDisplay(this, x, y + 3 + 18 + 1, GUIIcon.ArrowRight.getIcon());
|
||||
x += 18;
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
package binnie.genetics.craftgui;
|
||||
|
||||
import binnie.core.AbstractMod;
|
||||
import binnie.core.craftgui.minecraft.Window;
|
||||
import binnie.genetics.Genetics;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
// TODO unused class?
|
||||
public class WindowGenomeAssembler extends WindowMachine {
|
||||
public WindowGenomeAssembler(EntityPlayer player, IInventory inventory, Side side) {
|
||||
super(320, 240, player, inventory, side);
|
||||
}
|
||||
|
||||
public static Window create(EntityPlayer player, IInventory inventory, Side side) {
|
||||
return new WindowGenomeAssembler(player, inventory, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Genome Assembler";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractMod getMod() {
|
||||
return Genetics.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getName() {
|
||||
return "GenomeAssembler";
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import binnie.core.craftgui.resource.Texture;
|
||||
import binnie.core.craftgui.resource.minecraft.StandardTexture;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.machine.Incubator;
|
||||
import binnie.genetics.machine.incubator.Incubator;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -40,7 +40,7 @@ public class WindowIncubator extends WindowMachine {
|
||||
int y = 32;
|
||||
new ControlLiquidTank(this, x, y).setTankID(0);
|
||||
x += 26;
|
||||
new ControlSlotArray(this, x, y + 3, 1, 3).create(Incubator.slotQueue);
|
||||
new ControlSlotArray(this, x, y + 3, 1, 3).create(Incubator.SLOT_QUEUE);
|
||||
x += 20;
|
||||
new ControlIconDisplay(this, x, y + 3 + 10, GUIIcon.ArrowRight.getIcon());
|
||||
x += 18;
|
||||
@@ -49,7 +49,7 @@ public class WindowIncubator extends WindowMachine {
|
||||
x += 40;
|
||||
new ControlIconDisplay(this, x, y + 3 + 10, GUIIcon.ArrowRight.getIcon());
|
||||
x += 18;
|
||||
new ControlSlotArray(this, x, y + 3, 1, 3).create(Incubator.slotOutput);
|
||||
new ControlSlotArray(this, x, y + 3, 1, 3).create(Incubator.SLOT_OUTPUT);
|
||||
x += 26;
|
||||
new ControlLiquidTank(this, x, y).setTankID(1);
|
||||
x += 34;
|
||||
|
||||
@@ -17,7 +17,7 @@ import binnie.core.craftgui.resource.Texture;
|
||||
import binnie.core.craftgui.resource.minecraft.StandardTexture;
|
||||
import binnie.extrabees.core.ExtraBeeTexture;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.machine.Isolator;
|
||||
import binnie.genetics.machine.isolator.Isolator;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -41,7 +41,7 @@ public class WindowIsolator extends WindowMachine {
|
||||
int y = 32;
|
||||
new ControlLiquidTank(this, x, y).setTankID(0);
|
||||
x += 26;
|
||||
new ControlSlotArray(this, x, y + 3, 1, 3).create(Isolator.slotReserve);
|
||||
new ControlSlotArray(this, x, y + 3, 1, 3).create(Isolator.SLOT_RESERVE);
|
||||
x += 20;
|
||||
new ControlIconDisplay(this, x, y + 3 + 1, GUIIcon.ArrowRight.getIcon());
|
||||
x += 18;
|
||||
@@ -57,7 +57,7 @@ public class WindowIsolator extends WindowMachine {
|
||||
x += 20;
|
||||
new ControlIconDisplay(this, x, y + 3 + 1, GUIIcon.ArrowRight.getIcon());
|
||||
x += 18;
|
||||
new ControlSlotArray(this, x, y + 3, 2, 3).create(Isolator.slotFinished);
|
||||
new ControlSlotArray(this, x, y + 3, 2, 3).create(Isolator.SLOT_FINISHED);
|
||||
new ControlEnergyBar(this, 260, 130, 16, 60, Position.Bottom);
|
||||
new ControlErrorState(this, 153.0f, 81.0f);
|
||||
new ControlPlayerInventory(this);
|
||||
|
||||
@@ -17,7 +17,7 @@ import binnie.core.craftgui.resource.Texture;
|
||||
import binnie.core.craftgui.resource.minecraft.StandardTexture;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.machine.Polymeriser;
|
||||
import binnie.genetics.machine.polymeriser.Polymeriser;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -42,7 +42,7 @@ public class WindowPolymeriser extends WindowMachine {
|
||||
super.initialiseClient();
|
||||
int x = 16;
|
||||
int y = 38;
|
||||
new ControlSlotArray(this, x, y, 1, 4).create(Polymeriser.slotSerumReserve);
|
||||
new ControlSlotArray(this, x, y, 1, 4).create(Polymeriser.SLOT_SERUM_RESERVE);
|
||||
new ControlIconDisplay(this, x + 18, y + 1, GUIIcon.ArrowRight.getIcon());
|
||||
x += 34;
|
||||
new ControlMachineProgress(this, x + 18, y - 6, WindowPolymeriser.ProgressBase, WindowPolymeriser.Progress, Position.Left);
|
||||
@@ -54,7 +54,7 @@ public class WindowPolymeriser extends WindowMachine {
|
||||
new ControlSlot(this, x + 30, y + 18 + 8).assign(1);
|
||||
new ControlSlotCharge(this, x + 30 + 20, y + 18 + 8, 1).setColor(16766976);
|
||||
x += 138;
|
||||
new ControlSlotArray(this, x, y + 9, 2, 2).create(Polymeriser.slotSerumFinished);
|
||||
new ControlSlotArray(this, x, y + 9, 2, 2).create(Polymeriser.SLOT_SERUM_FINISHED);
|
||||
ControlErrorState errorState = new ControlErrorState(this, 244.0f, 97.0f);
|
||||
new ControlPlayerInventory(this);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import binnie.core.craftgui.resource.minecraft.StandardTexture;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.machine.inoculator.Inoculator;
|
||||
import binnie.genetics.machine.Splicer;
|
||||
import binnie.genetics.machine.splicer.Splicer;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -39,8 +39,8 @@ public class WindowSplicer extends WindowMachine {
|
||||
setTitle("Splicer");
|
||||
int x = 16;
|
||||
new ControlSplicerProgress(this, 84.0f, 32.0f, w() - 172.0f, 102.0f);
|
||||
CraftGUIUtil.horizontalGrid(x, 62.0f, new ControlSlotArray(this, 0, 0, 2, 1).create(Splicer.slotSerumReserve), new ControlIconDisplay(this, 0.0f, 0.0f, GUIIcon.ArrowRight.getIcon()), new ControlSlot(this, 0.0f, 0.0f).assign(0));
|
||||
new ControlSlotArray(this, x + 12, 84, 2, 1).create(Splicer.slotSerumExpended);
|
||||
CraftGUIUtil.horizontalGrid(x, 62.0f, new ControlSlotArray(this, 0, 0, 2, 1).create(Splicer.SLOT_SERUM_RESERVE), new ControlIconDisplay(this, 0.0f, 0.0f, GUIIcon.ArrowRight.getIcon()), new ControlSlot(this, 0.0f, 0.0f).assign(0));
|
||||
new ControlSlotArray(this, x + 12, 84, 2, 1).create(Splicer.SLOT_SERUM_EXPENDED);
|
||||
new ControlIconDisplay(this, x + 12 + 36 + 4, 86.0f, GUIIcon.ArrowUpLeft.getIcon());
|
||||
new ControlEnergyBar(this, 196, 64, 60, 16, Position.Left);
|
||||
new ControlErrorState(this, 218.0f, 86.0f);
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
package binnie.genetics.genetics;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldSavedData;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
// TODO unused class?
|
||||
public class GeneProjectTracker extends WorldSavedData {
|
||||
Map<Integer, GeneProject> projects;
|
||||
Map<GameProfile, Set<Integer>> TeamInvites;
|
||||
|
||||
public GeneProjectTracker(String s) {
|
||||
super(s);
|
||||
projects = new HashMap<>();
|
||||
TeamInvites = new HashMap<>();
|
||||
}
|
||||
|
||||
public static GeneProjectTracker getTracker(World world) {
|
||||
String filename = "GeneProjectTracker.common";
|
||||
GeneProjectTracker tracker = (GeneProjectTracker) world.loadItemData(GeneProjectTracker.class, filename);
|
||||
if (tracker == null) {
|
||||
tracker = new GeneProjectTracker(filename);
|
||||
world.setItemData(filename, tracker);
|
||||
}
|
||||
return tracker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
}
|
||||
|
||||
public int createProject(String name, GameProfile leader) {
|
||||
int i;
|
||||
for (i = 1; projects.keySet().contains(i); ++i) {
|
||||
}
|
||||
GeneProject project = new GeneProject(i, name, leader);
|
||||
projects.put(i, project);
|
||||
markDirty();
|
||||
return i;
|
||||
}
|
||||
|
||||
public void removeProject(int id) {
|
||||
projects.remove(id);
|
||||
for (Map.Entry<GameProfile, Set<Integer>> entry : TeamInvites.entrySet()) {
|
||||
entry.getValue().remove(id);
|
||||
}
|
||||
markDirty();
|
||||
}
|
||||
|
||||
public void leaveProject(int id, GameProfile player) {
|
||||
GeneProject project = projects.get(id);
|
||||
if (project == null) {
|
||||
return;
|
||||
}
|
||||
project.removePlayer(player);
|
||||
if (project.isEmpty()) {
|
||||
removeProject(id);
|
||||
}
|
||||
markDirty();
|
||||
}
|
||||
|
||||
public void joinProject(int id, GameProfile player) {
|
||||
GeneProject project = projects.get(id);
|
||||
if (project == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
project.addPlayer(player);
|
||||
markDirty();
|
||||
}
|
||||
|
||||
public void reassignPlayer(int id, int id2, GameProfile player) {
|
||||
GeneProject project = projects.get(id);
|
||||
if (project == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
GeneProject project2 = projects.get(id2);
|
||||
if (project2 == null) {
|
||||
return;
|
||||
}
|
||||
leaveProject(id, player);
|
||||
joinProject(id2, player);
|
||||
}
|
||||
|
||||
public void renameProject(int id, String newName) {
|
||||
GeneProject project = projects.get(id);
|
||||
if (project != null) {
|
||||
project.setName(newName);
|
||||
}
|
||||
markDirty();
|
||||
}
|
||||
|
||||
public void invitePlayer(int id, GameProfile player) {
|
||||
if (!TeamInvites.containsKey(player)) {
|
||||
TeamInvites.put(player, new LinkedHashSet<>());
|
||||
}
|
||||
TeamInvites.get(player).add(id);
|
||||
markDirty();
|
||||
}
|
||||
|
||||
public void revokeInvite(int id, GameProfile player) {
|
||||
if (!TeamInvites.containsKey(player)) {
|
||||
TeamInvites.put(player, new LinkedHashSet<>());
|
||||
}
|
||||
TeamInvites.get(player).add(id);
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
package binnie.genetics.genetics;
|
||||
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IAlleleFloat;
|
||||
import forestry.api.genetics.IAlleleInteger;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeSet;
|
||||
|
||||
// TODO unused class?
|
||||
public class GeneticEngineeringSystem {
|
||||
static List<IAllele> speciesList;
|
||||
public Map<IChromosomeType, List<IAllele>> chromosomeMap;
|
||||
BreedingSystem breedingSystem;
|
||||
|
||||
public GeneticEngineeringSystem(BreedingSystem system) {
|
||||
chromosomeMap = new HashMap<>();
|
||||
breedingSystem = system;
|
||||
for (IIndividual indiv : breedingSystem.getSpeciesRoot().getIndividualTemplates()) {
|
||||
for (IChromosomeType chromosome : breedingSystem.getSpeciesRoot().getKaryotype()) {
|
||||
if (!chromosomeMap.containsKey(chromosome)) {
|
||||
chromosomeMap.put(chromosome, new ArrayList<>());
|
||||
}
|
||||
try {
|
||||
IAllele a1 = indiv.getGenome().getActiveAllele(chromosome);
|
||||
IAllele a2 = indiv.getGenome().getInactiveAllele(chromosome);
|
||||
if (a1 != null) {
|
||||
chromosomeMap.get(chromosome).add(a1);
|
||||
}
|
||||
if (a2 != null) {
|
||||
chromosomeMap.get(chromosome).add(a2);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (IChromosomeType chromosome2 : breedingSystem.getSpeciesRoot().getKaryotype()) {
|
||||
List<IAllele> alleles = getAlleles(chromosome2);
|
||||
TreeSet<IAllele> set = new TreeSet<IAllele>(new ComparatorAllele());
|
||||
set.addAll(alleles);
|
||||
List<IAllele> list = new ArrayList<IAllele>();
|
||||
list.addAll(set);
|
||||
chromosomeMap.put(chromosome2, list);
|
||||
}
|
||||
}
|
||||
|
||||
public List<IAllele> getAlleles(IChromosomeType chromosome) {
|
||||
return chromosomeMap.get(chromosome);
|
||||
}
|
||||
|
||||
public ISpeciesRoot getSpeciesRoot() {
|
||||
return breedingSystem.getSpeciesRoot();
|
||||
}
|
||||
|
||||
class ComparatorAllele implements Comparator<IAllele> {
|
||||
@Override
|
||||
public int compare(IAllele o1, IAllele o2) {
|
||||
if (o1 instanceof IAlleleFloat && o2 instanceof IAlleleFloat) {
|
||||
return Float.valueOf(((IAlleleFloat) o1).getValue()).compareTo(((IAlleleFloat) o2).getValue());
|
||||
}
|
||||
if (o1 instanceof IAlleleInteger && o2 instanceof IAlleleInteger) {
|
||||
return Integer.valueOf(((IAlleleInteger) o1).getValue()).compareTo(((IAlleleInteger) o2).getValue());
|
||||
}
|
||||
return o1.getUID().compareTo(o2.getUID());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ import binnie.core.genetics.BreedingSystem;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import binnie.genetics.machine.Analyser;
|
||||
import binnie.genetics.machine.analyser.Analyser;
|
||||
import binnie.genetics.machine.ModuleMachine;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import forestry.api.apiculture.IBee;
|
||||
|
||||
@@ -1,388 +0,0 @@
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.botany.api.EnumFlowerChromosome;
|
||||
import binnie.botany.gardening.Gardening;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.Mods;
|
||||
import binnie.core.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.core.genetics.Gene;
|
||||
import binnie.core.genetics.Tolerance;
|
||||
import binnie.core.machines.IMachine;
|
||||
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.core.machines.power.ComponentProcessIndefinate;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.machine.inoculator.Inoculator;
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.EnumTolerance;
|
||||
import forestry.api.genetics.IAlleleTolerance;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.IGenome;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.api.lepidopterology.EnumButterflyChromosome;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
public class Acclimatiser {
|
||||
public static int[] slotReserve = new int[]{0, 1, 2, 3};
|
||||
public static int[] slotAcclimatiser = new int[]{5, 6, 7};
|
||||
public static int[] slotDone = new int[]{8, 9, 10, 11};
|
||||
public static int slotTarget = 4;
|
||||
|
||||
protected static Map<ItemStack, Float> temperatureItems = new HashMap<>();
|
||||
protected static Map<ItemStack, Float> humidityItems = new HashMap<>();
|
||||
|
||||
private static List<ToleranceSystem> toleranceSystems = new ArrayList<>();
|
||||
|
||||
private static ToleranceSystem getToleranceSystem(ItemStack stack, ItemStack acclim) {
|
||||
ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack);
|
||||
if (root == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (ToleranceSystem system : Acclimatiser.toleranceSystems) {
|
||||
if (root.getUID().equals(system.uid) && system.type.hasEffect(acclim)) {
|
||||
return system;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void addTolerance(String uid, IChromosomeType chromosome, ToleranceType type) {
|
||||
Acclimatiser.toleranceSystems.add(new ToleranceSystem(uid, chromosome, type));
|
||||
}
|
||||
|
||||
public static float getTemperatureEffect(ItemStack item) {
|
||||
for (ItemStack stack : Acclimatiser.temperatureItems.keySet()) {
|
||||
if (stack.isItemEqual(item)) {
|
||||
return Acclimatiser.temperatureItems.get(stack);
|
||||
}
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
public static float getHumidityEffect(ItemStack item) {
|
||||
for (ItemStack stack : Acclimatiser.humidityItems.keySet()) {
|
||||
if (stack.isItemEqual(item)) {
|
||||
return Acclimatiser.humidityItems.get(stack);
|
||||
}
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
public static void addTemperatureItem(ItemStack itemStack, float amount) {
|
||||
if (itemStack == null) {
|
||||
return;
|
||||
}
|
||||
Acclimatiser.temperatureItems.put(itemStack, amount);
|
||||
}
|
||||
|
||||
public static void addHumidityItem(ItemStack itemStack, float amount) {
|
||||
if (itemStack == null) {
|
||||
return;
|
||||
}
|
||||
Acclimatiser.humidityItems.put(itemStack, amount);
|
||||
}
|
||||
|
||||
public static void setupRecipes() {
|
||||
if (BinnieCore.isApicultureActive()) {
|
||||
addTolerance(Binnie.Genetics.getBeeRoot().getUID(), EnumBeeChromosome.HUMIDITY_TOLERANCE, ToleranceType.Humidity);
|
||||
addTolerance(Binnie.Genetics.getBeeRoot().getUID(), EnumBeeChromosome.TEMPERATURE_TOLERANCE, ToleranceType.Temperature);
|
||||
}
|
||||
|
||||
if (BinnieCore.isLepidopteryActive()) {
|
||||
addTolerance(Binnie.Genetics.getButterflyRoot().getUID(), EnumButterflyChromosome.HUMIDITY_TOLERANCE, ToleranceType.Humidity);
|
||||
addTolerance(Binnie.Genetics.getButterflyRoot().getUID(), EnumButterflyChromosome.TEMPERATURE_TOLERANCE, ToleranceType.Temperature);
|
||||
}
|
||||
|
||||
if (BinnieCore.isBotanyActive()) {
|
||||
addTolerance(Binnie.Genetics.getFlowerRoot().getUID(), EnumFlowerChromosome.HUMIDITY_TOLERANCE, ToleranceType.Humidity);
|
||||
addTolerance(Binnie.Genetics.getFlowerRoot().getUID(), EnumFlowerChromosome.TEMPERATURE_TOLERANCE, ToleranceType.Temperature);
|
||||
addTolerance(Binnie.Genetics.getFlowerRoot().getUID(), EnumFlowerChromosome.PH_TOLERANCE, ToleranceType.PH);
|
||||
}
|
||||
|
||||
addTemperatureItem(new ItemStack(Items.blaze_powder), 0.5f);
|
||||
addTemperatureItem(new ItemStack(Items.blaze_rod), 0.75f);
|
||||
addTemperatureItem(new ItemStack(Items.lava_bucket), 0.75f);
|
||||
addTemperatureItem(new ItemStack(Items.snowball), -0.15f);
|
||||
addTemperatureItem(new ItemStack(Blocks.ice), -0.75f);
|
||||
addHumidityItem(new ItemStack(Items.water_bucket), 0.75f);
|
||||
addHumidityItem(new ItemStack(Blocks.sand), -0.15f);
|
||||
addTemperatureItem(Mods.Forestry.stack("canLava"), 0.75f);
|
||||
addTemperatureItem(Mods.Forestry.stack("refractoryLava"), 0.75f);
|
||||
addHumidityItem(Mods.Forestry.stack("canWater"), 0.75f);
|
||||
addHumidityItem(Mods.Forestry.stack("refractoryWater"), 0.75f);
|
||||
addHumidityItem(Mods.Forestry.stack("waxCapsuleWater"), 0.75f);
|
||||
}
|
||||
|
||||
public static boolean canAcclimatise(ItemStack stack, List<ItemStack> acclimatisers) {
|
||||
if (stack == null || acclimatisers.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (ItemStack acclim : acclimatisers) {
|
||||
if (canAcclimatise(stack, acclim)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean canAcclimatise(ItemStack stack, ItemStack acclim) {
|
||||
ToleranceSystem system = getToleranceSystem(stack, acclim);
|
||||
return system != null && system.canAlter(stack, acclim);
|
||||
}
|
||||
|
||||
public static ItemStack acclimatise(ItemStack stack, ItemStack acc) {
|
||||
ToleranceSystem system = getToleranceSystem(stack, acc);
|
||||
return system.alter(stack, acc);
|
||||
}
|
||||
|
||||
public static Tolerance alterTolerance(Tolerance tol, float effect) {
|
||||
int[] is = tol.getBounds();
|
||||
int[] range;
|
||||
if (effect < 0.0f) {
|
||||
range = new int[]{is[0] - 1, is[1]};
|
||||
} else {
|
||||
range = new int[]{is[0], is[1] + 1};
|
||||
}
|
||||
|
||||
if (range[0] < -5) {
|
||||
range[0] = -5;
|
||||
}
|
||||
if (range[1] > 5) {
|
||||
range[1] = 5;
|
||||
}
|
||||
|
||||
EnumTolerance[] up = {EnumTolerance.NONE, EnumTolerance.UP_1, EnumTolerance.UP_2, EnumTolerance.UP_3, EnumTolerance.UP_4, EnumTolerance.UP_5};
|
||||
EnumTolerance[] down = {EnumTolerance.NONE, EnumTolerance.DOWN_1, EnumTolerance.DOWN_2, EnumTolerance.DOWN_3, EnumTolerance.DOWN_4, EnumTolerance.DOWN_5};
|
||||
EnumTolerance[] both = {EnumTolerance.NONE, EnumTolerance.BOTH_1, EnumTolerance.BOTH_2, EnumTolerance.BOTH_3, EnumTolerance.BOTH_4, EnumTolerance.BOTH_5};
|
||||
|
||||
if (range[0] == 0) {
|
||||
return Tolerance.get(up[range[1]]);
|
||||
}
|
||||
if (range[1] == 0) {
|
||||
return Tolerance.get(down[-range[0]]);
|
||||
}
|
||||
|
||||
int avg = (int) ((-range[0] + range[1]) / 2.0f + 0.6f);
|
||||
return Tolerance.get(both[avg]);
|
||||
}
|
||||
|
||||
public enum ToleranceType {
|
||||
Temperature,
|
||||
Humidity,
|
||||
PH;
|
||||
|
||||
public float getEffect(ItemStack stack) {
|
||||
switch (this) {
|
||||
case Temperature:
|
||||
return Acclimatiser.getTemperatureEffect(stack);
|
||||
|
||||
case Humidity:
|
||||
return Acclimatiser.getHumidityEffect(stack);
|
||||
|
||||
case PH:
|
||||
if (Gardening.isAcidFertiliser(stack)) {
|
||||
return -0.5f * Gardening.getFertiliserStrength(stack);
|
||||
}
|
||||
if (Gardening.isAlkalineFertiliser(stack)) {
|
||||
return 0.5f * Gardening.getFertiliserStrength(stack);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
public boolean hasEffect(ItemStack stack) {
|
||||
return getEffect(stack) != 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public static class PackageAcclimatiser extends GeneticMachine.PackageGeneticBase implements IMachineInformation {
|
||||
public PackageAcclimatiser() {
|
||||
super("acclimatiser", GeneticsTexture.Acclimatiser, 0x966a49, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Acclimatiser);
|
||||
ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(4, "process");
|
||||
inventory.getSlot(4).setValidator(new SlotValidator.Individual());
|
||||
inventory.getSlot(4).setReadOnly();
|
||||
inventory.getSlot(4).forbidExtraction();
|
||||
|
||||
for (InventorySlot slot : inventory.addSlotArray(Acclimatiser.slotReserve, "input")) {
|
||||
slot.forbidExtraction();
|
||||
slot.setValidator(new SlotValidator.Individual());
|
||||
}
|
||||
|
||||
for (InventorySlot slot : inventory.addSlotArray(Acclimatiser.slotDone, "output")) {
|
||||
slot.setReadOnly();
|
||||
slot.setValidator(new SlotValidator.Individual());
|
||||
}
|
||||
|
||||
for (InventorySlot slot : inventory.addSlotArray(Acclimatiser.slotAcclimatiser, "acclimatiser")) {
|
||||
slot.setValidator(new ValidatorAcclimatiserItem());
|
||||
}
|
||||
|
||||
ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Acclimatiser.slotReserve, 4, 1);
|
||||
transfer.addStorage(4, Acclimatiser.slotDone, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(ItemStack stack) {
|
||||
return !Acclimatiser.canAcclimatise(stack, machine.getMachineUtil().getNonNullStacks(Acclimatiser.slotAcclimatiser));
|
||||
}
|
||||
});
|
||||
|
||||
new ComponentPowerReceptor(machine, 5000);
|
||||
new ComponentAcclimatiserLogic(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentAcclimatiserLogic extends ComponentProcessIndefinate {
|
||||
public ComponentAcclimatiserLogic(IMachine machine) {
|
||||
super(machine, 2.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (getUtil().getStack(4) == null) {
|
||||
return new ErrorState.NoItem("No Individual to Acclimatise", 4);
|
||||
}
|
||||
if (getUtil().getNonNullStacks(Acclimatiser.slotAcclimatiser).isEmpty()) {
|
||||
return new ErrorState.NoItem("No Acclimatising Items", Acclimatiser.slotAcclimatiser);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (!Acclimatiser.canAcclimatise(getUtil().getStack(4), getUtil().getNonNullStacks(Acclimatiser.slotAcclimatiser))) {
|
||||
return new ErrorState.InvalidItem("Cannot Acclimatise this individual with these items", 4);
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean inProgress() {
|
||||
return canWork() == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
super.onTickTask();
|
||||
if (getUtil().getRandom().nextInt(100) == 0) {
|
||||
attemptAcclimatisation();
|
||||
}
|
||||
}
|
||||
|
||||
protected void attemptAcclimatisation() {
|
||||
List<ItemStack> acclms = new ArrayList<ItemStack>();
|
||||
for (ItemStack s : getUtil().getNonNullStacks(Acclimatiser.slotAcclimatiser)) {
|
||||
if (Acclimatiser.canAcclimatise(getUtil().getStack(4), s)) {
|
||||
acclms.add(s);
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack acc = acclms.get(getUtil().getRandom().nextInt(acclms.size()));
|
||||
ItemStack acclimed = Acclimatiser.acclimatise(getUtil().getStack(4), acc);
|
||||
if (acclimed != null) {
|
||||
getUtil().setStack(4, acclimed);
|
||||
boolean removed = false;
|
||||
for (int i : Acclimatiser.slotAcclimatiser) {
|
||||
if (!removed && getUtil().getStack(i) != null && getUtil().getStack(i).isItemEqual(acc)) {
|
||||
getUtil().decreaseStack(i, 1);
|
||||
removed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ValidatorAcclimatiserItem extends SlotValidator {
|
||||
public ValidatorAcclimatiserItem() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(ItemStack stack) {
|
||||
for (ToleranceType type : ToleranceType.values()) {
|
||||
if (type.hasEffect(stack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Acclimatising Items";
|
||||
}
|
||||
}
|
||||
|
||||
private static class ToleranceSystem {
|
||||
String uid;
|
||||
IChromosomeType chromosomeOrdinal;
|
||||
ToleranceType type;
|
||||
|
||||
private ToleranceSystem(String uid, IChromosomeType chromosomeOrdinal, ToleranceType type) {
|
||||
this.uid = uid;
|
||||
this.chromosomeOrdinal = chromosomeOrdinal;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public boolean canAlter(ItemStack stack, ItemStack acclim) {
|
||||
IIndividual member = AlleleManager.alleleRegistry.getIndividual(stack);
|
||||
IGenome genome = member.getGenome();
|
||||
IAlleleTolerance tolAllele = (IAlleleTolerance) genome.getActiveAllele(chromosomeOrdinal);
|
||||
Tolerance tol = Tolerance.get(tolAllele.getValue());
|
||||
float effect = type.getEffect(acclim);
|
||||
return (effect > 0.0f && tol.getBounds()[1] < 5) || (effect < 0.0f && tol.getBounds()[0] > -5);
|
||||
}
|
||||
|
||||
public ItemStack alter(ItemStack stack, ItemStack acc) {
|
||||
Random rand = new Random();
|
||||
float effect = type.getEffect(acc);
|
||||
if (rand.nextFloat() > Math.abs(effect)) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
IIndividual member = AlleleManager.alleleRegistry.getIndividual(stack);
|
||||
IGenome genome = member.getGenome();
|
||||
IAlleleTolerance tolAllele = (IAlleleTolerance) genome.getActiveAllele(chromosomeOrdinal);
|
||||
Tolerance tol = Tolerance.get(tolAllele.getValue());
|
||||
Tolerance newTol = Acclimatiser.alterTolerance(tol, effect);
|
||||
if (rand.nextFloat() > 1.0f / (-newTol.getBounds()[0] + newTol.getBounds()[1])) {
|
||||
return stack;
|
||||
}
|
||||
ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack);
|
||||
Inoculator.setGene(new Gene(newTol.getAllele(), chromosomeOrdinal, root), stack, rand.nextInt(2));
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.SplicerPackage;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public enum AdvGeneticMachine implements IMachineType {
|
||||
Splicer(Splicer.PackageSplicer.class);
|
||||
Splicer(SplicerPackage.class);
|
||||
|
||||
protected Class<? extends MachinePackage> cls;
|
||||
|
||||
@@ -29,7 +30,7 @@ public enum AdvGeneticMachine implements IMachineType {
|
||||
return new ItemStack(Genetics.packageAdvGenetic.getBlock(), i, ordinal());
|
||||
}
|
||||
|
||||
public abstract static class PackageAdvGeneticBase extends GeneticMachine.PackageGeneticBase {
|
||||
public abstract static class PackageAdvGeneticBase extends PackageGeneticBase {
|
||||
protected PackageAdvGeneticBase(String uid, IBinnieTexture renderTexture, int flashColor, boolean powered) {
|
||||
super(uid, renderTexture, flashColor, powered);
|
||||
}
|
||||
|
||||
@@ -1,318 +0,0 @@
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.machines.component.IRender;
|
||||
import binnie.core.machines.inventory.ComponentChargedSlots;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.ComponentInventoryTransfer;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.machines.network.INetwork;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.core.machines.power.ComponentProcessSetCost;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.core.machines.power.IProcess;
|
||||
import binnie.genetics.api.IItemAnalysable;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Analyser {
|
||||
public static int[] slotReserve = new int[]{0, 1, 2, 3, 4, 5};
|
||||
public static int[] slotFinished = new int[]{7, 8, 9, 10, 11, 12};
|
||||
public static int slotTarget = 6;
|
||||
public static int slotDye = 13;
|
||||
|
||||
static {
|
||||
}
|
||||
|
||||
public static boolean isAnalysable(ItemStack stack) {
|
||||
IIndividual ind = AlleleManager.alleleRegistry.getIndividual(stack);
|
||||
return ind != null || stack.getItem() instanceof IItemAnalysable || Binnie.Genetics.getConversion(stack) != null;
|
||||
}
|
||||
|
||||
public static boolean isAnalysed(ItemStack stack) {
|
||||
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) {
|
||||
ItemStack conv = Binnie.Genetics.getConversionStack(stack);
|
||||
if (conv != null) {
|
||||
stack = conv;
|
||||
}
|
||||
|
||||
ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack);
|
||||
if (root != null) {
|
||||
IIndividual ind = root.getMember(stack);
|
||||
ind.analyze();
|
||||
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(Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Analyser);
|
||||
ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlotArray(Analyser.slotReserve, "input");
|
||||
for (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(ItemStack itemStack) {
|
||||
return itemStack.isItemEqual(GeneticsItems.DNADye.get(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "DNA Dye";
|
||||
}
|
||||
});
|
||||
|
||||
inventory.addSlotArray(Analyser.slotFinished, "output");
|
||||
for (InventorySlot slot : inventory.getSlots(Analyser.slotFinished)) {
|
||||
slot.forbidInsertion();
|
||||
slot.setReadOnly();
|
||||
}
|
||||
|
||||
ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Analyser.slotReserve, 6, 1);
|
||||
transfer.addStorage(6, Analyser.slotFinished, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(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);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentAnalyserLogic extends ComponentProcessSetCost implements IProcess {
|
||||
private static float DYE_PER_TICK = 0.002f;
|
||||
|
||||
public ComponentAnalyserLogic(Machine machine) {
|
||||
super(machine, 9000, 300);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (getUtil().isSlotEmpty(6)) {
|
||||
return new ErrorState.NoItem("No item to analyse", 6);
|
||||
}
|
||||
|
||||
boolean analysed = Analyser.isAnalysed(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 (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 = getUtil().getStack(6);
|
||||
itemStack = Analyser.analyse(itemStack);
|
||||
getInventory().setInventorySlotContents(6, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
getUtil().useCharge(13, 0.002f);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SlotValidatorUnanalysed extends SlotValidator {
|
||||
public SlotValidatorUnanalysed() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(ItemStack itemStack) {
|
||||
return Analyser.isAnalysable(itemStack) && !Analyser.isAnalysed(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Unanalysed Item";
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentAnalyserFX extends MachineComponent implements
|
||||
IRender.RandomDisplayTick,
|
||||
IRender.DisplayTick,
|
||||
IRender.Render,
|
||||
INetwork.TilePacketSync {
|
||||
private EntityItem dummyEntityItem;
|
||||
|
||||
public ComponentAnalyserFX(IMachine machine) {
|
||||
super(machine);
|
||||
dummyEntityItem = new EntityItem(null);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onRandomDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
if (rand.nextFloat() < 1.0f && getUtil().getProcess().isInProgress()) {
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new EntityFX(world, x + 0.5, y + 1.3 + rand.nextDouble() * 0.2, z + 0.5, 0.0, 0.0, 0.0) {
|
||||
double axisX = posX;
|
||||
double axisZ = posZ;
|
||||
double angle = rand.nextDouble() * 2.0 * 3.1415;
|
||||
|
||||
{
|
||||
axisX = 0.0;
|
||||
axisZ = 0.0;
|
||||
angle = 0.0;
|
||||
motionX = 0.05 * (rand.nextDouble() - 0.5);
|
||||
motionZ = 0.05 * (rand.nextDouble() - 0.5);
|
||||
motionY = 0.0;
|
||||
particleMaxAge = 25;
|
||||
particleGravity = 0.05f;
|
||||
noClip = true;
|
||||
setRBGColorF(0.6f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
setAlphaF((float) Math.cos(1.57 * particleAge / particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void renderInWorld(RenderItem renderItem, double x, double y, double z) {
|
||||
if (!getUtil().getProcess().isInProgress()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack stack = getUtil().getStack(6);
|
||||
dummyEntityItem.worldObj = getMachine().getWorld();
|
||||
dummyEntityItem.setEntityItemStack(stack);
|
||||
EntityItem dummyEntityItem = this.dummyEntityItem;
|
||||
dummyEntityItem.age++;
|
||||
this.dummyEntityItem.hoverStart = 0.0f;
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer player = BinnieCore.proxy.getPlayer();
|
||||
double dx = x + 0.5 - player.lastTickPosX;
|
||||
double dz = z + 0.5 - player.lastTickPosZ;
|
||||
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);
|
||||
renderItem.doRender(this.dummyEntityItem, 0.0, 0.0, 0.0, 0.0f, 0.0f);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncToNBT(NBTTagCompound nbt) {
|
||||
NBTTagCompound item = new NBTTagCompound();
|
||||
ItemStack stack = getUtil().getStack(6);
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
stack.writeToNBT(item);
|
||||
nbt.setTag("item", item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncFromNBT(NBTTagCompound nbt) {
|
||||
if (nbt.hasKey("item")) {
|
||||
getUtil().setStack(6, ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("item")));
|
||||
} else {
|
||||
getUtil().setStack(6, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryUpdate() {
|
||||
if (!getUtil().isServer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
IMachine machine = getMachine();
|
||||
TileEntity tile = machine.getTileEntity();
|
||||
machine.getWorld().markBlockForUpdate(tile.xCoord, tile.yCoord, tile.zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import binnie.core.machines.component.IInteraction;
|
||||
import binnie.core.machines.network.INetwork;
|
||||
import binnie.extrabees.ExtraBees;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.genetics.Genetics;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class ComponentGUIHolder extends MachineComponent implements INetwork.TilePacketSync, IInteraction.RightClick {
|
||||
private ItemStack stack;
|
||||
|
||||
public ComponentGUIHolder(IMachine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
public ItemStack getStack() {
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
if (nbttagcompound == null) {
|
||||
return;
|
||||
}
|
||||
stack = ItemStack.loadItemStackFromNBT(nbttagcompound.getCompoundTag("Item"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
if (stack != null) {
|
||||
stack.writeToNBT(nbt);
|
||||
}
|
||||
nbttagcompound.setTag("Item", nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncToNBT(NBTTagCompound nbt) {
|
||||
writeToNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncFromNBT(NBTTagCompound nbt) {
|
||||
readFromNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestruction() {
|
||||
super.onDestruction();
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
IMachine machine = getMachine();
|
||||
TileEntity tile = machine.getTileEntity();
|
||||
World world = machine.getWorld();
|
||||
Random rand = world.rand;
|
||||
float xOffset = rand.nextFloat() * 0.8f + 0.1f;
|
||||
float yOffset = rand.nextFloat() * 0.8f + 0.1f;
|
||||
float zOffset = rand.nextFloat() * 0.8f + 0.1f;
|
||||
if (stack.stackSize == 0) {
|
||||
stack.stackSize = 1;
|
||||
}
|
||||
|
||||
EntityItem entityitem = new EntityItem(world, tile.xCoord + xOffset, tile.yCoord + yOffset, tile.zCoord + zOffset, stack.copy());
|
||||
float accel = 0.05f;
|
||||
entityitem.motionX = (float) rand.nextGaussian() * accel;
|
||||
entityitem.motionY = (float) rand.nextGaussian() * accel + 0.2f;
|
||||
entityitem.motionZ = (float) rand.nextGaussian() * accel;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRightClick(World world, EntityPlayer player, int x, int y, int z) {
|
||||
if (BinnieCore.proxy.isSimulating(world) && player.getHeldItem() != null) {
|
||||
if (stack != null && player.getHeldItem().getItem() instanceof IToolWrench) {
|
||||
Random rand = world.rand;
|
||||
float f = 0.7f;
|
||||
double fOffset = (1.0f - f) * 0.5;
|
||||
double xOffset = rand.nextFloat() * f + fOffset;
|
||||
double yOffset = rand.nextFloat() * f + fOffset;
|
||||
double zOffset = rand.nextFloat() * f + fOffset;
|
||||
|
||||
EntityItem entityitem = new EntityItem(world, x + xOffset, y + yOffset, z + zOffset, stack);
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
stack = null;
|
||||
((IToolWrench) player.getHeldItem().getItem()).wrenchUsed(player, x, y, z);
|
||||
getUtil().refreshBlock();
|
||||
return;
|
||||
}
|
||||
|
||||
List<Item> validSelections = new ArrayList<>();
|
||||
if (BinnieCore.isBotanyActive()) {
|
||||
validSelections.add(Botany.database);
|
||||
}
|
||||
if (BinnieCore.isExtraBeesActive()) {
|
||||
validSelections.add(ExtraBees.dictionary);
|
||||
}
|
||||
if (BinnieCore.isExtraTreesActive()) {
|
||||
validSelections.add(ExtraTrees.itemDictionary);
|
||||
}
|
||||
if (BinnieCore.isLepidopteryActive()) {
|
||||
validSelections.add(ExtraTrees.itemDictionaryLepi);
|
||||
}
|
||||
|
||||
validSelections.add(Genetics.database);
|
||||
validSelections.add(Genetics.analyst);
|
||||
validSelections.add(Genetics.registry);
|
||||
validSelections.add(Genetics.masterRegistry);
|
||||
validSelections.add(BinnieCore.genesis);
|
||||
|
||||
if (stack == null && validSelections.contains(player.getHeldItem().getItem())) {
|
||||
stack = player.getHeldItem().copy();
|
||||
ItemStack heldItem = player.getHeldItem();
|
||||
heldItem.stackSize--;
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
return;
|
||||
}
|
||||
|
||||
if (stack != null && player.getHeldItem().getItem() instanceof IToolWrench) {
|
||||
stack.getItem().onItemRightClick(stack, world, player);
|
||||
}
|
||||
}
|
||||
|
||||
if (stack != null) {
|
||||
stack.getItem().onItemRightClick(stack, world, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ComponentGeneticGUI extends MachineComponent implements IInteraction.RightClick {
|
||||
GeneticsGUI id;
|
||||
public GeneticsGUI id;
|
||||
|
||||
public ComponentGeneticGUI(Machine machine, GeneticsGUI id) {
|
||||
super(machine);
|
||||
|
||||
@@ -1,265 +0,0 @@
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.inventory.ComponentInventory;
|
||||
import binnie.core.machines.inventory.SetList;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
// TODO unused class?
|
||||
public abstract class ComponentIndexerInventory<T> extends ComponentInventory implements IInventory {
|
||||
public int guiRefreshCounter;
|
||||
public List<Integer> sortedInventory;
|
||||
int indexerSize;
|
||||
List<ItemStack> indexerInventory;
|
||||
T sortingMode;
|
||||
boolean needsSorting;
|
||||
|
||||
public ComponentIndexerInventory(Machine machine) {
|
||||
super(machine);
|
||||
indexerSize = -1;
|
||||
guiRefreshCounter = 0;
|
||||
indexerInventory = new SetList<>();
|
||||
sortedInventory = new SetList<>();
|
||||
needsSorting = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
if (indexerSize > 0) {
|
||||
return indexerSize + 1;
|
||||
}
|
||||
return indexerInventory.size() + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int index) {
|
||||
if (index >= 0 && index < indexerInventory.size()) {
|
||||
return indexerInventory.get(index);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int index, int amount) {
|
||||
if (index >= 0) {
|
||||
ItemStack returnStack = getStackInSlot(index).copy();
|
||||
setInventorySlotContents(index, null);
|
||||
return returnStack;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int var1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
super.markDirty();
|
||||
guiRefreshCounter++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int index, ItemStack itemStack) {
|
||||
if (index >= 0 && index < indexerInventory.size()) {
|
||||
indexerInventory.set(index, itemStack);
|
||||
} else if (itemStack != null) {
|
||||
indexerInventory.add(itemStack);
|
||||
}
|
||||
needsSorting = true;
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer var1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
// ignored
|
||||
}
|
||||
|
||||
public T getMode() {
|
||||
return sortingMode;
|
||||
}
|
||||
|
||||
public void setMode(T mode) {
|
||||
sortingMode = mode;
|
||||
needsSorting = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
NBTTagList indexerNBT = new NBTTagList();
|
||||
for (ItemStack item : indexerInventory) {
|
||||
NBTTagCompound itemNBT = new NBTTagCompound();
|
||||
item.writeToNBT(itemNBT);
|
||||
indexerNBT.appendTag(itemNBT);
|
||||
}
|
||||
nbttagcompound.setTag("indexer", indexerNBT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
NBTTagList indexerNBT = nbttagcompound.getTagList("indexer", 10);
|
||||
indexerInventory.clear();
|
||||
for (int i = 0; i < indexerNBT.tagCount(); ++i) {
|
||||
NBTTagCompound itemNBT = indexerNBT.getCompoundTagAt(i);
|
||||
setInventorySlotContents(i, ItemStack.loadItemStackFromNBT(itemNBT));
|
||||
}
|
||||
needsSorting = true;
|
||||
markDirty();
|
||||
}
|
||||
|
||||
public abstract void Sort();
|
||||
|
||||
public static class ComponentApiaristIndexerInventory extends ComponentIndexerInventory<ComponentApiaristIndexerInventory.Mode> implements IInventory {
|
||||
public ComponentApiaristIndexerInventory(Machine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Sort() {
|
||||
int i = 0;
|
||||
while (i < indexerInventory.size()) {
|
||||
if (indexerInventory.get(i) == null) {
|
||||
indexerInventory.remove(i);
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
if (!needsSorting) {
|
||||
return;
|
||||
}
|
||||
needsSorting = false;
|
||||
++guiRefreshCounter;
|
||||
switch (sortingMode) {
|
||||
case Species:
|
||||
case Type: {
|
||||
class SpeciesList {
|
||||
public List<Integer> drones;
|
||||
public List<Integer> queens;
|
||||
public List<Integer> princesses;
|
||||
public List<ItemStack> bees;
|
||||
|
||||
SpeciesList() {
|
||||
drones = new ArrayList<>();
|
||||
queens = new ArrayList<>();
|
||||
princesses = new ArrayList<>();
|
||||
bees = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void add(ItemStack stack) {
|
||||
bees.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
Map<Integer, SpeciesList> speciesList = new HashMap<Integer, SpeciesList>();
|
||||
for (ItemStack itemStack : indexerInventory) {
|
||||
int species = itemStack.getItemDamage();
|
||||
if (!speciesList.containsKey(species)) {
|
||||
speciesList.put(species, new SpeciesList());
|
||||
}
|
||||
speciesList.get(species).add(itemStack);
|
||||
}
|
||||
|
||||
for (SpeciesList sortableList : speciesList.values()) {
|
||||
for (ItemStack beeStack : sortableList.bees) {
|
||||
if (Binnie.Genetics.getBeeRoot().isDrone(beeStack)) {
|
||||
sortableList.drones.add(indexerInventory.indexOf(beeStack));
|
||||
} else if (Binnie.Genetics.getBeeRoot().isMated(beeStack)) {
|
||||
sortableList.queens.add(indexerInventory.indexOf(beeStack));
|
||||
} else {
|
||||
sortableList.princesses.add(indexerInventory.indexOf(beeStack));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sortedInventory = new SetList<>();
|
||||
switch (sortingMode) {
|
||||
case Species:
|
||||
for (int j = 0; j < 1024; ++j) {
|
||||
if (speciesList.containsKey(j)) {
|
||||
sortedInventory.addAll(speciesList.get(j).queens);
|
||||
sortedInventory.addAll(speciesList.get(j).princesses);
|
||||
sortedInventory.addAll(speciesList.get(j).drones);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Type:
|
||||
for (int j = 0; j < 1024; ++j) {
|
||||
if (speciesList.containsKey(j)) {
|
||||
sortedInventory.addAll(speciesList.get(j).queens);
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < 1024; ++j) {
|
||||
if (speciesList.containsKey(j)) {
|
||||
sortedInventory.addAll(speciesList.get(j).princesses);
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < 1024; ++j) {
|
||||
if (speciesList.containsKey(j)) {
|
||||
sortedInventory.addAll(speciesList.get(j).drones);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
sortedInventory.clear();
|
||||
for (i = 0; i < indexerInventory.size(); ++i) {
|
||||
sortedInventory.add(i);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public enum Mode {
|
||||
None,
|
||||
Species,
|
||||
Type
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,222 +0,0 @@
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.machines.component.IRender;
|
||||
import binnie.core.machines.inventory.ComponentChargedSlots;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.ComponentInventoryTransfer;
|
||||
import binnie.core.machines.inventory.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.genetics.core.GeneticsGUI;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.item.GeneticLiquid;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Genepool {
|
||||
public static int slotBee = 0;
|
||||
public static int[] slotReserve;
|
||||
public static int tankDNA = 0;
|
||||
public static int tankEthanol = 1;
|
||||
public static int slotEnzyme = 7;
|
||||
|
||||
static {
|
||||
slotReserve = new int[]{1, 2, 3, 4, 5, 6};
|
||||
}
|
||||
|
||||
public static class PackageGenepool extends GeneticMachine.PackageGeneticBase implements IMachineInformation {
|
||||
public PackageGenepool() {
|
||||
super("genepool", GeneticsTexture.Genepool, 0xc134b6, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Genepool);
|
||||
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 (InventorySlot slot : inventory.getSlots(Genepool.slotReserve)) {
|
||||
slot.setValidator(new SlotValidator.Individual());
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
|
||||
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(FluidStack liquid) {
|
||||
return liquid.getFluid().getName() == "bioethanol";
|
||||
}
|
||||
});
|
||||
|
||||
ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Genepool.slotReserve, 0, 1);
|
||||
new ComponentPowerReceptor(machine, 1600);
|
||||
new ComponentGenepoolLogic(machine);
|
||||
ComponentChargedSlots chargedSlots = new ComponentChargedSlots(machine);
|
||||
chargedSlots.addCharge(7);
|
||||
new ComponentGenepoolFX(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentGenepoolLogic extends ComponentProcessSetCost implements IProcess {
|
||||
float enzymePerProcess;
|
||||
float ethanolPerProcess;
|
||||
private float ethanolDrain;
|
||||
|
||||
public ComponentGenepoolLogic(Machine machine) {
|
||||
super(machine, 8000, 400);
|
||||
enzymePerProcess = 0.25f;
|
||||
ethanolPerProcess = 50.0f;
|
||||
ethanolDrain = 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (getUtil().isSlotEmpty(0)) {
|
||||
return new ErrorState.NoItem("No Individual", 0);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (!getUtil().spaceInTank(0, getDNAAmount(getUtil().getStack(0)))) {
|
||||
return new ErrorState.NoSpace("Not enough room in Tank", new int[]{0});
|
||||
}
|
||||
if (!getUtil().liquidInTank(1, 1)) {
|
||||
return new ErrorState.InsufficientLiquid("Not enough Ethanol", 1);
|
||||
}
|
||||
if (getUtil().getSlotCharge(7) == 0.0f) {
|
||||
return new ErrorState.NoItem("Insufficient Enzyme", 7);
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
int amount = getDNAAmount(getUtil().getStack(0));
|
||||
getUtil().fillTank(0, GeneticLiquid.RawDNA.get(amount));
|
||||
getUtil().deleteStack(0);
|
||||
}
|
||||
|
||||
private int getDNAAmount(ItemStack stack) {
|
||||
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() {
|
||||
ethanolDrain += getDNAAmount(getUtil().getStack(0)) * 1.2f * getProgressPerTick() / 100.0f;
|
||||
if (ethanolDrain >= 1.0f) {
|
||||
getUtil().drainTank(1, 1);
|
||||
ethanolDrain--;
|
||||
}
|
||||
getMachine().getInterface(IChargedSlots.class).alterCharge(7, -enzymePerProcess * getProgressPerTick() / 100.0f);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentGenepoolFX extends MachineComponent implements IRender.RandomDisplayTick, IRender.DisplayTick {
|
||||
public ComponentGenepoolFX(IMachine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onRandomDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
if (rand.nextFloat() < 1.0f && getUtil().getProcess().isInProgress()) {
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new EntityFX(world, x + 0.3 + rand.nextDouble() * 0.4, y + 1, z + 0.3 + rand.nextDouble() * 0.4, 0.0, 0.0, 0.0) {
|
||||
double axisX = posX;
|
||||
double axisZ = posZ;
|
||||
double angle = rand.nextDouble() * 2.0 * 3.1415;
|
||||
|
||||
{
|
||||
axisX = 0.0;
|
||||
axisZ = 0.0;
|
||||
angle = 0.0;
|
||||
motionX = 0.0;
|
||||
motionZ = 0.0;
|
||||
motionY = rand.nextFloat() * 0.01;
|
||||
particleMaxAge = 25;
|
||||
particleGravity = 0.0f;
|
||||
noClip = true;
|
||||
setRBGColorF(0.4f + 0.6f * rand.nextFloat(), 0.6f * rand.nextFloat(), 0.6f + 0.4f * rand.nextFloat());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
setAlphaF((float) Math.cos(1.57 * particleAge / particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import binnie.core.machines.IMachineType;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.MachinePackage;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.resource.BinnieResource;
|
||||
import binnie.core.resource.IBinnieTexture;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.machine.inoculator.PackageInoculator;
|
||||
import binnie.genetics.machine.sequencer.PackageSequencer;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import binnie.genetics.machine.inoculator.InoculatorPackage;
|
||||
import binnie.genetics.machine.isolator.IsolatorPackage;
|
||||
import binnie.genetics.machine.polymeriser.PolymeriserPackage;
|
||||
import binnie.genetics.machine.sequencer.SequencerPackage;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public enum GeneticMachine implements IMachineType {
|
||||
Isolator(Isolator.PackageIsolator.class),
|
||||
Sequencer(PackageSequencer.class),
|
||||
Polymeriser(Polymeriser.PackagePolymeriser.class),
|
||||
Inoculator(PackageInoculator.class);
|
||||
Isolator(IsolatorPackage.class),
|
||||
Sequencer(SequencerPackage.class),
|
||||
Polymeriser(PolymeriserPackage.class),
|
||||
Inoculator(InoculatorPackage.class);
|
||||
|
||||
protected Class<? extends MachinePackage> clss;
|
||||
|
||||
@@ -38,25 +34,4 @@ public enum GeneticMachine implements IMachineType {
|
||||
public ItemStack get(int i) {
|
||||
return new ItemStack(Genetics.packageGenetic.getBlock(), i, ordinal());
|
||||
}
|
||||
|
||||
public abstract static class PackageGeneticBase extends MachinePackage {
|
||||
protected BinnieResource renderTexture;
|
||||
protected int colour;
|
||||
|
||||
protected PackageGeneticBase(String uid, IBinnieTexture renderTexture, int flashColor, boolean powered) {
|
||||
super(uid, powered);
|
||||
this.renderTexture = renderTexture.getTexture();
|
||||
colour = flashColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderMachine(Machine machine, double x, double y, double z, float partialTick, RenderBlocks renderer) {
|
||||
MachineRendererGenetics.instance.renderMachine(machine, colour, renderTexture, x, y, z, partialTick);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,345 +0,0 @@
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.MachineUtil;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.ComponentTankContainer;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.core.machines.power.ComponentProcessIndefinate;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.core.machines.power.IProcess;
|
||||
import binnie.core.machines.transfer.TransferRequest;
|
||||
import binnie.genetics.api.IIncubatorRecipe;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.item.GeneticLiquid;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class Incubator {
|
||||
public static int[] slotQueue = new int[]{0, 1, 2};
|
||||
public static int[] slotOutput = new int[]{4, 5, 6};
|
||||
public static int slotIncubator = 3;
|
||||
public static int tankInput = 0;
|
||||
public static int tankOutput = 1;
|
||||
private static List<IIncubatorRecipe> RECIPES = new ArrayList<>();
|
||||
|
||||
public static void addRecipes() {
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(Binnie.Liquid.getLiquidStack("water", 25), GeneticLiquid.GrowthMedium.get(25), 0.2f) {
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return GeneticsItems.GrowthMedium.get(1).isItemEqual(stack);
|
||||
}
|
||||
});
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticLiquid.GrowthMedium.get(25), GeneticLiquid.Bacteria.get(5), 0.2f) {
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return new ItemStack(Items.wheat).isItemEqual(stack);
|
||||
}
|
||||
});
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticLiquid.Bacteria.get(0), GeneticLiquid.Bacteria.get(5), 0.05f) {
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return GeneticsItems.GrowthMedium.get(1).isItemEqual(stack);
|
||||
}
|
||||
});
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticLiquid.Bacteria.get(2), null, 0.5f, 0.2f) {
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return stack.getItem() == Items.sugar;
|
||||
}
|
||||
}.setOutputStack(GeneticsItems.Enzyme.get(1)));
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticLiquid.BacteriaPoly.get(0), GeneticLiquid.BacteriaPoly.get(5), 0.05f) {
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return GeneticsItems.GrowthMedium.get(1).isItemEqual(stack);
|
||||
}
|
||||
});
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticLiquid.BacteriaVector.get(0), GeneticLiquid.BacteriaVector.get(5), 0.05f) {
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return GeneticsItems.GrowthMedium.get(1).isItemEqual(stack);
|
||||
}
|
||||
});
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticLiquid.Bacteria.get(10), GeneticLiquid.BacteriaPoly.get(10), 0.1f) {
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return new ItemStack(Items.dye, 1, 15).isItemEqual(stack);
|
||||
}
|
||||
});
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticLiquid.Bacteria.get(10), GeneticLiquid.BacteriaVector.get(10), 0.05f) {
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return new ItemStack(Items.blaze_powder).isItemEqual(stack);
|
||||
}
|
||||
});
|
||||
|
||||
if (BinnieCore.isApicultureActive()) {
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticLiquid.GrowthMedium.get(50), null, 1.0f, 0.05f) {
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return Binnie.Genetics.getBeeRoot().isMember(stack) && Binnie.Genetics.getBeeRoot().getType(stack) == EnumBeeType.LARVAE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getOutputStack(MachineUtil machine) {
|
||||
ItemStack larvae = machine.getStack(3);
|
||||
IBee bee = Binnie.Genetics.getBeeRoot().getMember(larvae);
|
||||
return Binnie.Genetics.getBeeRoot().getMemberStack(bee, EnumBeeType.DRONE.ordinal());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static class PackageIncubator extends GeneticMachine.PackageGeneticBase implements IMachineInformation {
|
||||
public PackageIncubator() {
|
||||
super("incubator", GeneticsTexture.Incubator, 16767313, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Incubator);
|
||||
ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlotArray(Incubator.slotQueue, "input");
|
||||
for (InventorySlot slot : inventory.getSlots(Incubator.slotQueue)) {
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
inventory.addSlot(3, "incubator");
|
||||
inventory.getSlot(3).forbidInteraction();
|
||||
inventory.getSlot(3).setReadOnly();
|
||||
inventory.addSlotArray(Incubator.slotOutput, "output");
|
||||
for (InventorySlot slot : inventory.getSlots(Incubator.slotOutput)) {
|
||||
slot.forbidInsertion();
|
||||
slot.setReadOnly();
|
||||
}
|
||||
new ComponentPowerReceptor(machine, 2000);
|
||||
ComponentTankContainer tanks = new ComponentTankContainer(machine);
|
||||
tanks.addTank(0, "input", 2000).forbidExtraction();
|
||||
tanks.addTank(1, "output", 2000).setReadOnly();
|
||||
new ComponentIncubatorLogic(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentIncubatorLogic extends ComponentProcessIndefinate implements IProcess {
|
||||
IIncubatorRecipe recipe;
|
||||
private Random rand;
|
||||
private boolean roomForOutput;
|
||||
|
||||
public ComponentIncubatorLogic(Machine machine) {
|
||||
super(machine, 2.0f);
|
||||
recipe = null;
|
||||
rand = new Random();
|
||||
roomForOutput = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (recipe == null) {
|
||||
return new ErrorState("No Recipe", "There is no valid recipe");
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (recipe != null) {
|
||||
if (!recipe.isInputLiquidSufficient(getUtil().getFluid(0))) {
|
||||
return new ErrorState.InsufficientLiquid("Not enough incubation liquid", 0);
|
||||
}
|
||||
if (!roomForOutput) {
|
||||
return new ErrorState.TankSpace("No room for output", 1);
|
||||
}
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
if (rand.nextInt(20) == 0 && recipe != null && rand.nextFloat() < recipe.getChance()) {
|
||||
recipe.doTask(getUtil());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inProgress() {
|
||||
return recipe != null;
|
||||
}
|
||||
|
||||
private IIncubatorRecipe getRecipe(ItemStack stack, FluidStack liquid) {
|
||||
for (IIncubatorRecipe recipe : Incubator.RECIPES) {
|
||||
boolean rightLiquid = recipe.isInputLiquid(liquid);
|
||||
boolean rightItem = recipe.isItemStack(stack);
|
||||
if (rightLiquid && rightItem) {
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryUpdate() {
|
||||
super.onInventoryUpdate();
|
||||
if (!getUtil().isServer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
FluidStack liquid = getUtil().getFluid(0);
|
||||
ItemStack incubator = getUtil().getStack(3);
|
||||
if (recipe != null && (incubator == null || liquid == null || !recipe.isInputLiquid(liquid) || !recipe.isItemStack(incubator))) {
|
||||
recipe = null;
|
||||
ItemStack leftover = new TransferRequest(incubator, getInventory()).setTargetSlots(Incubator.slotOutput).ignoreValidation().transfer(true);
|
||||
getUtil().setStack(3, leftover);
|
||||
}
|
||||
|
||||
if (recipe == null) {
|
||||
if (liquid == null) {
|
||||
return;
|
||||
}
|
||||
if (incubator != null) {
|
||||
IIncubatorRecipe recipe = getRecipe(incubator, liquid);
|
||||
if (recipe != null) {
|
||||
this.recipe = recipe;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
IIncubatorRecipe potential = null;
|
||||
int potentialSlot = 0;
|
||||
for (int slot : Incubator.slotQueue) {
|
||||
ItemStack stack = getUtil().getStack(slot);
|
||||
if (stack != null) {
|
||||
if (potential == null) {
|
||||
for (IIncubatorRecipe recipe2 : Incubator.RECIPES) {
|
||||
boolean rightLiquid = recipe2.isInputLiquid(liquid);
|
||||
boolean rightItem = recipe2.isItemStack(stack);
|
||||
if (rightLiquid && rightItem) {
|
||||
potential = recipe2;
|
||||
potentialSlot = slot;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (potential != null) {
|
||||
TransferRequest removal = new TransferRequest(incubator, getInventory()).setTargetSlots(Incubator.slotOutput).ignoreValidation();
|
||||
if (removal.transfer(false) == null) {
|
||||
recipe = potential;
|
||||
}
|
||||
removal.transfer(true);
|
||||
ItemStack stack2 = getUtil().getStack(potentialSlot);
|
||||
getUtil().setStack(potentialSlot, null);
|
||||
getUtil().setStack(3, stack2);
|
||||
}
|
||||
}
|
||||
|
||||
if (recipe != null) {
|
||||
roomForOutput = recipe.roomForOutput(getUtil());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private abstract static class IncubatorRecipe implements IIncubatorRecipe {
|
||||
protected FluidStack input;
|
||||
protected FluidStack output;
|
||||
protected float lossChance;
|
||||
protected ItemStack outputStack;
|
||||
protected float tickChance;
|
||||
|
||||
public IncubatorRecipe(FluidStack input, FluidStack output, float lossChance) {
|
||||
this(input, output, lossChance, 1.0f);
|
||||
}
|
||||
|
||||
public IncubatorRecipe(FluidStack input, FluidStack output, float lossChance, float chance) {
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
this.lossChance = lossChance;
|
||||
tickChance = chance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getChance() {
|
||||
return tickChance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInputLiquid(FluidStack liquid) {
|
||||
return liquid != null && input.isFluidEqual(liquid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInputLiquidSufficient(FluidStack liquid) {
|
||||
return liquid != null && liquid.amount >= 500;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doTask(MachineUtil machine) {
|
||||
machine.drainTank(0, input.amount);
|
||||
if (output != null) {
|
||||
machine.fillTank(1, output);
|
||||
}
|
||||
|
||||
outputStack = getOutputStack(machine);
|
||||
if (outputStack != null) {
|
||||
ItemStack output = outputStack.copy();
|
||||
TransferRequest product = new TransferRequest(output, machine.getInventory()).setTargetSlots(Incubator.slotOutput).ignoreValidation();
|
||||
product.transfer(true);
|
||||
}
|
||||
|
||||
Random rand = machine.getRandom();
|
||||
if (rand.nextFloat() < lossChance) {
|
||||
machine.decreaseStack(3, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public IncubatorRecipe setOutputStack(ItemStack stack) {
|
||||
outputStack = stack;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected ItemStack getOutputStack(MachineUtil util) {
|
||||
return outputStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean roomForOutput(MachineUtil machine) {
|
||||
if (output != null && !machine.isTankEmpty(1)) {
|
||||
if (!machine.getFluid(1).isFluidEqual(output)) {
|
||||
return false;
|
||||
}
|
||||
if (!machine.spaceInTank(1, output.amount)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack outputStack = getOutputStack(machine);
|
||||
if (outputStack != null) {
|
||||
ItemStack output = outputStack.copy();
|
||||
TransferRequest product = new TransferRequest(output, machine.getInventory()).setTargetSlots(Incubator.slotOutput).ignoreValidation();
|
||||
ItemStack leftover = product.transfer(false);
|
||||
return leftover == null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,276 +0,0 @@
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.craftgui.minecraft.IMachineInformation;
|
||||
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.genetics.core.GeneticsGUI;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import binnie.genetics.item.ItemSequence;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
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.EntityFX;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Isolator {
|
||||
public static int slotEnzyme = 0;
|
||||
public static int slotSequencerVial = 1;
|
||||
public static int[] slotReserve = new int[]{2, 3, 4};
|
||||
public static int[] slotFinished = new int[]{7, 8, 9, 10, 11, 12};
|
||||
public static int slotTarget = 5;
|
||||
public static int slotResult = 6;
|
||||
public static int tankEthanol = 0;
|
||||
|
||||
public static class PackageIsolator extends GeneticMachine.PackageGeneticBase implements IMachineInformation {
|
||||
public PackageIsolator() {
|
||||
super("isolator", GeneticsTexture.Isolator, 16740111, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Isolator);
|
||||
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 (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 (InventorySlot slot : inventory.getSlots(Isolator.slotFinished)) {
|
||||
slot.setReadOnly();
|
||||
slot.forbidInsertion();
|
||||
}
|
||||
|
||||
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(FluidStack liquid) {
|
||||
return liquid.getFluid().getName() == "bioethanol";
|
||||
}
|
||||
});
|
||||
|
||||
ComponentChargedSlots chargedSlots = new ComponentChargedSlots(machine);
|
||||
chargedSlots.addCharge(0);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentIsolatorLogic extends ComponentProcessSetCost implements IProcess {
|
||||
protected float enzymePerProcess;
|
||||
protected float ethanolPerProcess;
|
||||
|
||||
public ComponentIsolatorLogic(Machine machine) {
|
||||
super(machine, 192000, 4800);
|
||||
enzymePerProcess = 0.5f;
|
||||
ethanolPerProcess = 10.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (getUtil().isSlotEmpty(5)) {
|
||||
return new ErrorState.NoItem("No individual to isolate", 5);
|
||||
}
|
||||
if (!getUtil().isSlotEmpty(6)) {
|
||||
return new ErrorState.NoSpace("No room for DNA sequences", Isolator.slotFinished);
|
||||
}
|
||||
if (getUtil().isSlotEmpty(1)) {
|
||||
return new ErrorState.NoItem("No empty sequencer vials", 1);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (!getUtil().liquidInTank(0, (int) ethanolPerProcess)) {
|
||||
return new ErrorState.InsufficientLiquid("Insufficient ethanol", 0);
|
||||
}
|
||||
if (getUtil().getSlotCharge(0) == 0.0f) {
|
||||
return new ErrorState.NoItem("No enzyme", 0);
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
Random rand = getMachine().getWorld().rand;
|
||||
ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(getUtil().getStack(5));
|
||||
if (root == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
IIndividual individual = root.getMember(getUtil().getStack(5));
|
||||
if (individual == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
IAllele allele;
|
||||
IChromosomeType chromosome;
|
||||
Gene gene = null;
|
||||
if (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) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack serum = ItemSequence.create(gene);
|
||||
getUtil().setStack(6, serum);
|
||||
getUtil().decreaseStack(1, 1);
|
||||
if (rand.nextFloat() < 0.05f) {
|
||||
getUtil().decreaseStack(5, 1);
|
||||
}
|
||||
getUtil().drainTank(0, (int) ethanolPerProcess);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
getMachine().getInterface(IChargedSlots.class).alterCharge(0, -enzymePerProcess * getProgressPerTick() / 100.0f);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentIsolaterFX extends MachineComponent implements IRender.RandomDisplayTick, IRender.DisplayTick {
|
||||
public ComponentIsolaterFX(IMachine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onRandomDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
if (!getUtil().getProcess().isInProgress()) {
|
||||
return;
|
||||
}
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new EntityFX(world, x + 0.4 + 0.2 * rand.nextDouble(), y + 1.6, z + 0.4 + rand.nextDouble() * 0.2, 0.0, 0.0, 0.0) {
|
||||
double axisX = 0.0;
|
||||
double axisZ = 0.0;
|
||||
double angle = 0.0;
|
||||
|
||||
{
|
||||
motionX = 0.0;
|
||||
motionZ = 0.0;
|
||||
motionY = -0.012;
|
||||
particleMaxAge = 100;
|
||||
particleGravity = 0.0f;
|
||||
noClip = true;
|
||||
setRBGColorF(0.8f, 0.4f, 0.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
angle += 0.06;
|
||||
setAlphaF((float) Math.sin(3.14 * particleAge / particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
int tick = (int) (world.getTotalWorldTime() % 6L);
|
||||
if ((tick == 0 || tick == 5) && getUtil().getProcess().isInProgress()) {
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new EntityFX(world, x + 0.5, y + 1, z + 0.5, 0.0, 0.0, 0.0) {
|
||||
double axisX = posX;
|
||||
double axisZ = posZ;
|
||||
double angle = 0.7 + (int) (worldObj.getTotalWorldTime() % 2L) * 3.1415;
|
||||
|
||||
{
|
||||
axisX = 0.0;
|
||||
axisZ = 0.0;
|
||||
angle = 0.0;
|
||||
motionX = 0.0;
|
||||
motionZ = 0.0;
|
||||
motionY = 0.012;
|
||||
particleMaxAge = 100;
|
||||
particleGravity = 0.0f;
|
||||
noClip = true;
|
||||
setRBGColorF(0.8f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
angle += 0.06;
|
||||
setPosition(axisX + 0.26 * Math.sin(angle), posY, axisZ + 0.26 * Math.cos(angle));
|
||||
setAlphaF((float) Math.cos(1.57 * particleAge / particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +1,23 @@
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.IMachineType;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import binnie.core.machines.MachinePackage;
|
||||
import binnie.core.machines.component.IInteraction;
|
||||
import binnie.core.machines.network.INetwork;
|
||||
import binnie.extrabees.ExtraBees;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import binnie.genetics.machine.acclimatiser.AcclimatiserPackage;
|
||||
import binnie.genetics.machine.analyser.AnalyserPackage;
|
||||
import binnie.genetics.machine.genepool.GenepoolPackage;
|
||||
import binnie.genetics.machine.incubator.IncubatorPackage;
|
||||
import binnie.genetics.machine.lab.LabMachinePackage;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public enum LaboratoryMachine implements IMachineType {
|
||||
LabMachine(PackageLabMachine.class),
|
||||
Analyser(Analyser.PackageAnalyser.class),
|
||||
Incubator(Incubator.PackageIncubator.class),
|
||||
Genepool(Genepool.PackageGenepool.class),
|
||||
Acclimatiser(Acclimatiser.PackageAcclimatiser.class);
|
||||
LabMachine(LabMachinePackage.class),
|
||||
Analyser(AnalyserPackage.class),
|
||||
Incubator(IncubatorPackage.class),
|
||||
Genepool(GenepoolPackage.class),
|
||||
Acclimatiser(AcclimatiserPackage.class);
|
||||
|
||||
Class<? extends MachinePackage> clss;
|
||||
private Class<? extends MachinePackage> clss;
|
||||
|
||||
LaboratoryMachine(Class<? extends MachinePackage> clss) {
|
||||
this.clss = clss;
|
||||
@@ -53,145 +36,4 @@ public enum LaboratoryMachine implements IMachineType {
|
||||
public ItemStack get(int i) {
|
||||
return new ItemStack(Genetics.packageLabMachine.getBlock(), i, ordinal());
|
||||
}
|
||||
|
||||
public static class PackageLabMachine extends GeneticMachine.PackageGeneticBase {
|
||||
public PackageLabMachine() {
|
||||
super("labMachine", GeneticsTexture.LabMachine, 16777215, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(Machine machine) {
|
||||
new ComponentGUIHolder(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderMachine(Machine machine, double x, double y, double z, float partialTick, RenderBlocks renderer) {
|
||||
MachineRendererLab.instance.renderMachine(machine, colour, renderTexture, x, y, z, partialTick);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentGUIHolder extends MachineComponent implements INetwork.TilePacketSync, IInteraction.RightClick {
|
||||
private ItemStack stack;
|
||||
|
||||
public ComponentGUIHolder(IMachine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
public ItemStack getStack() {
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
if (nbttagcompound == null) {
|
||||
return;
|
||||
}
|
||||
stack = ItemStack.loadItemStackFromNBT(nbttagcompound.getCompoundTag("Item"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
if (stack != null) {
|
||||
stack.writeToNBT(nbt);
|
||||
}
|
||||
nbttagcompound.setTag("Item", nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncToNBT(NBTTagCompound nbt) {
|
||||
writeToNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncFromNBT(NBTTagCompound nbt) {
|
||||
readFromNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestruction() {
|
||||
super.onDestruction();
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
IMachine machine = getMachine();
|
||||
TileEntity tile = machine.getTileEntity();
|
||||
World world = machine.getWorld();
|
||||
Random rand = world.rand;
|
||||
float xOffset = rand.nextFloat() * 0.8f + 0.1f;
|
||||
float yOffset = rand.nextFloat() * 0.8f + 0.1f;
|
||||
float zOffset = rand.nextFloat() * 0.8f + 0.1f;
|
||||
if (stack.stackSize == 0) {
|
||||
stack.stackSize = 1;
|
||||
}
|
||||
|
||||
EntityItem entityitem = new EntityItem(world, tile.xCoord + xOffset, tile.yCoord + yOffset, tile.zCoord + zOffset, stack.copy());
|
||||
float accel = 0.05f;
|
||||
entityitem.motionX = (float) rand.nextGaussian() * accel;
|
||||
entityitem.motionY = (float) rand.nextGaussian() * accel + 0.2f;
|
||||
entityitem.motionZ = (float) rand.nextGaussian() * accel;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRightClick(World world, EntityPlayer player, int x, int y, int z) {
|
||||
if (BinnieCore.proxy.isSimulating(world) && player.getHeldItem() != null) {
|
||||
if (stack != null && player.getHeldItem().getItem() instanceof IToolWrench) {
|
||||
Random rand = world.rand;
|
||||
float f = 0.7f;
|
||||
double fOffset = (1.0f - f) * 0.5;
|
||||
double xOffset = rand.nextFloat() * f + fOffset;
|
||||
double yOffset = rand.nextFloat() * f + fOffset;
|
||||
double zOffset = rand.nextFloat() * f + fOffset;
|
||||
|
||||
EntityItem entityitem = new EntityItem(world, x + xOffset, y + yOffset, z + zOffset, stack);
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
stack = null;
|
||||
((IToolWrench) player.getHeldItem().getItem()).wrenchUsed(player, x, y, z);
|
||||
getUtil().refreshBlock();
|
||||
return;
|
||||
}
|
||||
|
||||
List<Item> validSelections = new ArrayList<>();
|
||||
if (BinnieCore.isBotanyActive()) {
|
||||
validSelections.add(Botany.database);
|
||||
}
|
||||
if (BinnieCore.isExtraBeesActive()) {
|
||||
validSelections.add(ExtraBees.dictionary);
|
||||
}
|
||||
if (BinnieCore.isExtraTreesActive()) {
|
||||
validSelections.add(ExtraTrees.itemDictionary);
|
||||
}
|
||||
if (BinnieCore.isLepidopteryActive()) {
|
||||
validSelections.add(ExtraTrees.itemDictionaryLepi);
|
||||
}
|
||||
|
||||
validSelections.add(Genetics.database);
|
||||
validSelections.add(Genetics.analyst);
|
||||
validSelections.add(Genetics.registry);
|
||||
validSelections.add(Genetics.masterRegistry);
|
||||
validSelections.add(BinnieCore.genesis);
|
||||
|
||||
if (stack == null && validSelections.contains(player.getHeldItem().getItem())) {
|
||||
stack = player.getHeldItem().copy();
|
||||
ItemStack heldItem = player.getHeldItem();
|
||||
heldItem.stackSize--;
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
return;
|
||||
}
|
||||
|
||||
if (stack != null && player.getHeldItem().getItem() instanceof IToolWrench) {
|
||||
stack.getItem().onItemRightClick(stack, world, player);
|
||||
}
|
||||
}
|
||||
|
||||
if (stack != null) {
|
||||
stack.getItem().onItemRightClick(stack, world, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,13 +13,10 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class MachineRendererGenetics {
|
||||
public static MachineRendererGenetics instance;
|
||||
|
||||
static {
|
||||
MachineRendererGenetics.instance = new MachineRendererGenetics();
|
||||
}
|
||||
public static MachineRendererGenetics instance = new MachineRendererGenetics();
|
||||
|
||||
public RenderItem customRenderItem;
|
||||
|
||||
private ModelMachine model;
|
||||
|
||||
public MachineRendererGenetics() {
|
||||
@@ -40,15 +37,6 @@ public class MachineRendererGenetics {
|
||||
|
||||
public void renderMachine(Machine machine, int colour, BinnieResource texture, double x, double y, double z, float var8) {
|
||||
GL11.glPushMatrix();
|
||||
int i1 = 0;
|
||||
int ix = machine.getTileEntity().xCoord;
|
||||
int iy = machine.getTileEntity().yCoord;
|
||||
int iz = machine.getTileEntity().zCoord;
|
||||
if (machine.getTileEntity() != null) {
|
||||
i1 = ix * iy * iz + ix * iy - ix * iz + iy * iz - ix + iy - iz;
|
||||
}
|
||||
|
||||
float phase = (float) Math.max(0.0, Math.sin((System.currentTimeMillis() + i1) * 0.003));
|
||||
GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5);
|
||||
GL11.glRotatef(180.0f, 0.0f, 0.0f, 1.0f);
|
||||
BinnieCore.proxy.bindTexture(texture);
|
||||
@@ -63,6 +51,7 @@ public class MachineRendererGenetics {
|
||||
render.renderInWorld(customRenderItem, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@@ -43,15 +43,9 @@ public class MachineRendererLab {
|
||||
|
||||
public void renderMachine(Machine machine, int colour, BinnieResource texture, double x, double y, double z, float var8) {
|
||||
GL11.glPushMatrix();
|
||||
int i1 = 0;
|
||||
int ix = machine.getTileEntity().xCoord;
|
||||
int iy = machine.getTileEntity().yCoord;
|
||||
int iz = machine.getTileEntity().zCoord;
|
||||
if (machine.getTileEntity() != null) {
|
||||
i1 = ix * iy * iz + ix * iy - ix * iz + iy * iz - ix + iy - iz;
|
||||
}
|
||||
|
||||
float phase = (float) Math.max(0.0, Math.sin((System.currentTimeMillis() + i1) * 0.003));
|
||||
GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5);
|
||||
GL11.glRotatef(180.0f, 0.0f, 0.0f, 1.0f);
|
||||
BinnieCore.proxy.bindTexture(texture);
|
||||
@@ -59,7 +53,7 @@ public class MachineRendererLab {
|
||||
model.render((float) x, (float) y, (float) z, 0.0625f, 0.0625f, 0.0625f);
|
||||
GL11.glPopMatrix();
|
||||
World world = machine.getWorld();
|
||||
LaboratoryMachine.ComponentGUIHolder holder = Machine.getInterface(LaboratoryMachine.ComponentGUIHolder.class, machine);
|
||||
ComponentGUIHolder holder = Machine.getInterface(ComponentGUIHolder.class, machine);
|
||||
|
||||
// TODO remove label
|
||||
Label_0591:
|
||||
@@ -91,6 +85,7 @@ public class MachineRendererLab {
|
||||
customRenderItem.doRender(dummyEntityItem, 0.0, 0.0, 0.0, 0.0f, 0.0f);
|
||||
GL11.glPopMatrix();
|
||||
int rot = 0;
|
||||
|
||||
for (EntityItem item : itemSides) {
|
||||
GL11.glPushMatrix();
|
||||
item.worldObj = world;
|
||||
|
||||
@@ -4,13 +4,13 @@ import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
|
||||
public class ModelMachine extends ModelBase {
|
||||
ModelRenderer base;
|
||||
ModelRenderer body;
|
||||
ModelRenderer arm1;
|
||||
ModelRenderer arm2;
|
||||
ModelRenderer arm3;
|
||||
ModelRenderer arm4;
|
||||
ModelRenderer top;
|
||||
private ModelRenderer base;
|
||||
private ModelRenderer body;
|
||||
private ModelRenderer arm1;
|
||||
private ModelRenderer arm2;
|
||||
private ModelRenderer arm3;
|
||||
private ModelRenderer arm4;
|
||||
private ModelRenderer top;
|
||||
|
||||
public ModelMachine() {
|
||||
textureWidth = 64;
|
||||
|
||||
@@ -8,6 +8,8 @@ import binnie.core.machines.inventory.ValidatorIcon;
|
||||
import binnie.genetics.CreativeTabGenetics;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import binnie.genetics.machine.acclimatiser.Acclimatiser;
|
||||
import binnie.genetics.machine.incubator.Incubator;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.MachinePackage;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.resource.BinnieResource;
|
||||
import binnie.core.resource.IBinnieTexture;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public abstract class PackageGeneticBase extends MachinePackage {
|
||||
protected BinnieResource renderTexture;
|
||||
protected int color;
|
||||
|
||||
protected PackageGeneticBase(String uid, IBinnieTexture renderTexture, int flashColor, boolean powered) {
|
||||
super(uid, powered);
|
||||
this.renderTexture = renderTexture.getTexture();
|
||||
color = flashColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderMachine(Machine machine, double x, double y, double z, float partialTick, RenderBlocks renderer) {
|
||||
MachineRendererGenetics.instance.renderMachine(machine, color, renderTexture, x, y, z, partialTick);
|
||||
}
|
||||
}
|
||||
@@ -1,291 +0,0 @@
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.machines.component.IRender;
|
||||
import binnie.core.machines.inventory.ComponentChargedSlots;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.ComponentInventoryTransfer;
|
||||
import binnie.core.machines.inventory.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.core.machines.power.ComponentProcessSetCost;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.core.machines.power.IProcess;
|
||||
import binnie.genetics.api.IItemChargable;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.genetics.Engineering;
|
||||
import binnie.genetics.item.GeneticLiquid;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Polymeriser {
|
||||
public static int tankBacteria = 0;
|
||||
public static int tankDNA = 1;
|
||||
public static int slotSerum = 0;
|
||||
public static int slotGold = 1;
|
||||
public static int[] slotSerumReserve = new int[]{2, 3, 4, 5};
|
||||
public static int[] slotSerumFinished = new int[]{6, 7, 8, 9};
|
||||
|
||||
public static class PackagePolymeriser extends GeneticMachine.PackageGeneticBase implements IMachineInformation {
|
||||
public PackagePolymeriser() {
|
||||
super("polymeriser", GeneticsTexture.Polymeriser, 58819, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Replicator);
|
||||
ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(1, "catalyst");
|
||||
inventory.getSlot(1).setValidator(new SlotValidator.Item(new ItemStack(Items.gold_nugget, 1), ModuleMachine.IconNugget));
|
||||
inventory.getSlot(1).forbidExtraction();
|
||||
|
||||
inventory.addSlot(0, "process");
|
||||
inventory.getSlot(0).setValidator(new SlotValidatorUnfilledSerum());
|
||||
inventory.getSlot(0).forbidInteraction();
|
||||
inventory.getSlot(0).setReadOnly();
|
||||
|
||||
for (InventorySlot slot : inventory.addSlotArray(Polymeriser.slotSerumReserve, "input")) {
|
||||
slot.setValidator(new SlotValidatorUnfilledSerum());
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
|
||||
for (InventorySlot slot : inventory.addSlotArray(Polymeriser.slotSerumFinished, "output")) {
|
||||
slot.setReadOnly();
|
||||
}
|
||||
|
||||
ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Polymeriser.slotSerumReserve, 0, 1);
|
||||
transfer.addStorage(0, Polymeriser.slotSerumFinished, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(ItemStack stack) {
|
||||
return !stack.isItemDamaged();
|
||||
}
|
||||
});
|
||||
|
||||
ComponentTankContainer tank = new ComponentTankContainer(machine);
|
||||
tank.addTank(0, "input", 1000);
|
||||
tank.getTankSlot(0).setValidator(new Validator<FluidStack>() {
|
||||
@Override
|
||||
public boolean isValid(FluidStack itemStack) {
|
||||
return GeneticLiquid.BacteriaPoly.get(1).isFluidEqual(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Polymerising Bacteria";
|
||||
}
|
||||
});
|
||||
|
||||
tank.addTank(1, "input", 1000);
|
||||
tank.getTankSlot(1).setValidator(new Validator<FluidStack>() {
|
||||
@Override
|
||||
public boolean isValid(FluidStack itemStack) {
|
||||
return GeneticLiquid.RawDNA.get(1).isFluidEqual(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Raw DNA";
|
||||
}
|
||||
});
|
||||
|
||||
new ComponentChargedSlots(machine).addCharge(1);
|
||||
new ComponentPowerReceptor(machine, 8000);
|
||||
new ComponentPolymeriserLogic(machine);
|
||||
new ComponentPolymeriserFX(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentPolymeriserLogic extends ComponentProcessSetCost implements IProcess {
|
||||
private static float chargePerProcess = 0.4f;
|
||||
|
||||
private float dnaDrain;
|
||||
private float bacteriaDrain;
|
||||
|
||||
public ComponentPolymeriserLogic(Machine machine) {
|
||||
super(machine, 96000, 2400);
|
||||
dnaDrain = 0.0f;
|
||||
bacteriaDrain = 0.0f;
|
||||
}
|
||||
|
||||
private float getCatalyst() {
|
||||
return (getUtil().getSlotCharge(1) > 0.0f) ? 0.2f : 1.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessLength() {
|
||||
return (int) (super.getProcessLength() * getNumberOfGenes() * getCatalyst());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessEnergy() {
|
||||
return (int) (super.getProcessEnergy() * getNumberOfGenes() * getCatalyst());
|
||||
}
|
||||
|
||||
private float getDNAPerProcess() {
|
||||
return getNumberOfGenes() * 50;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTickTask() {
|
||||
super.onTickTask();
|
||||
getUtil().useCharge(1, ComponentPolymeriserLogic.chargePerProcess * getProgressPerTick() / 100.0f);
|
||||
dnaDrain += getDNAPerProcess() * getProgressPerTick() / 100.0f;
|
||||
bacteriaDrain += 0.2f * getDNAPerProcess() * getProgressPerTick() / 100.0f;
|
||||
|
||||
if (dnaDrain >= 1.0f) {
|
||||
getUtil().drainTank(1, 1);
|
||||
dnaDrain--;
|
||||
}
|
||||
|
||||
if (bacteriaDrain >= 1.0f) {
|
||||
getUtil().drainTank(0, 1);
|
||||
bacteriaDrain--;
|
||||
}
|
||||
}
|
||||
|
||||
private int getNumberOfGenes() {
|
||||
ItemStack serum = getUtil().getStack(0);
|
||||
if (serum == null) {
|
||||
return 1;
|
||||
}
|
||||
return Engineering.getGenes(serum).length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
int n = getNumberOfGenes();
|
||||
return "Replicating " + n + " genes" + ((n > 1) ? "s" : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (getUtil().isSlotEmpty(0)) {
|
||||
return new ErrorState.NoItem("No item to replicate", 0);
|
||||
}
|
||||
if (!getUtil().getStack(0).isItemDamaged()) {
|
||||
return new ErrorState.InvalidItem("Item filled", 0);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (getUtil().getFluid(0) == null) {
|
||||
return new ErrorState.InsufficientLiquid("Insufficient Bacteria", 0);
|
||||
}
|
||||
if (getUtil().getFluid(1) == null) {
|
||||
return new ErrorState.InsufficientLiquid("Insufficient DNA", 1);
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
getUtil().damageItem(0, -1);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SlotValidatorUnfilledSerum extends SlotValidator {
|
||||
public SlotValidatorUnfilledSerum() {
|
||||
super(ModuleMachine.IconSerum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(ItemStack itemStack) {
|
||||
return itemStack.getItem() instanceof IItemChargable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Unfilled Serum";
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentPolymeriserFX extends MachineComponent implements IRender.RandomDisplayTick, IRender.DisplayTick {
|
||||
public ComponentPolymeriserFX(IMachine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onRandomDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
int tick = (int) (world.getTotalWorldTime() % 8L);
|
||||
if ((tick == 0 || tick == 3) && getUtil().getProcess().isInProgress()) {
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new EntityFX(world, x + 0.5, y + 1.8, z + 0.5, 0.0, 0.0, 0.0) {
|
||||
double axisX = posX;
|
||||
double axisZ = posZ;
|
||||
double angle = 0.7 + (int) (worldObj.getTotalWorldTime() % 2L) * 3.1415;
|
||||
|
||||
{
|
||||
axisX = 0.0;
|
||||
axisZ = 0.0;
|
||||
angle = 0.0;
|
||||
motionX = 0.0;
|
||||
motionZ = 0.0;
|
||||
motionY = -0.006;
|
||||
particleMaxAge = 140;
|
||||
particleGravity = 0.0f;
|
||||
noClip = true;
|
||||
setRBGColorF(0.8f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
angle += 0.1;
|
||||
motionY = -0.006;
|
||||
double dist = 0.2;
|
||||
if (particleAge > 60) {
|
||||
if (particleAge > 120) {
|
||||
dist = 0.1;
|
||||
} else {
|
||||
dist = 0.2 - 0.1 * ((particleAge - 60.0f) / 60.0f);
|
||||
}
|
||||
}
|
||||
|
||||
setPosition(axisX + dist * Math.sin(angle), posY, axisZ + dist * Math.cos(angle));
|
||||
if (particleAge <= 40) {
|
||||
setAlphaF(particleAge / 40.0f);
|
||||
}
|
||||
if (particleAge > 80) {
|
||||
setRBGColorF(particleRed + (0.0f - particleRed) / 10.0f, particleGreen + (1.0f - particleGreen) / 10.0f, particleBlue + (1.0f - particleBlue) / 10.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import binnie.core.machines.inventory.Validator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
// TODO unused class?
|
||||
public class SlotValidatorInoculatorCatalyst extends Validator<ItemStack> {
|
||||
@Override
|
||||
public boolean isValid(ItemStack itemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Inoculation Catalyst";
|
||||
}
|
||||
}
|
||||
@@ -1,446 +0,0 @@
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.machines.component.IRender;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.ComponentInventoryTransfer;
|
||||
import binnie.core.machines.inventory.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.genetics.api.IGene;
|
||||
import binnie.genetics.api.IItemSerum;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.genetics.Engineering;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.apiculture.IBeeRoot;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.IGenome;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.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.world.World;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Splicer {
|
||||
public static int slotSerumVial = 0;
|
||||
public static int[] slotSerumReserve = new int[]{1, 2};
|
||||
public static int[] slotSerumExpended = new int[]{3, 4};
|
||||
public static int[] slotReserve = new int[]{5, 6, 7, 8, 9};
|
||||
public static int slotTarget = 9;
|
||||
public static int[] slotFinished = new int[]{10, 11, 12, 13};
|
||||
|
||||
public static void setGene(IGene gene, ItemStack target, int chromoN) {
|
||||
int chromosomeID = gene.getChromosome().ordinal();
|
||||
if (chromosomeID >= EnumBeeChromosome.HUMIDITY.ordinal() && gene.getSpeciesRoot() instanceof IBeeRoot) {
|
||||
chromosomeID--;
|
||||
}
|
||||
|
||||
Class<? extends IAllele> cls = gene.getChromosome().getAlleleClass();
|
||||
if (!cls.isInstance(gene.getAllele())) {
|
||||
return;
|
||||
}
|
||||
|
||||
NBTTagCompound beeNBT = target.getTagCompound();
|
||||
NBTTagCompound genomeNBT = beeNBT.getCompoundTag("Genome");
|
||||
NBTTagList chromosomes = genomeNBT.getTagList("Chromosomes", 10);
|
||||
NBTTagCompound chromosomeNBT = chromosomes.getCompoundTagAt(chromosomeID);
|
||||
chromosomeNBT.setString("UID" + chromoN, gene.getAllele().getUID());
|
||||
target.setTagCompound(beeNBT);
|
||||
}
|
||||
|
||||
public static class PackageSplicer extends AdvGeneticMachine.PackageAdvGeneticBase implements IMachineInformation {
|
||||
public PackageSplicer() {
|
||||
super("splicer", GeneticsTexture.Splicer, 14819893, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Splicer);
|
||||
ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(0, "serum.active");
|
||||
inventory.getSlot(0).forbidInteraction();
|
||||
inventory.getSlot(0).setReadOnly();
|
||||
SlotValidator serumValid = new SlotValidator(ModuleMachine.IconSerum) {
|
||||
@Override
|
||||
public boolean isValid(ItemStack itemStack) {
|
||||
return itemStack.getItem() instanceof IItemSerum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Serum Vials & Arrays";
|
||||
}
|
||||
};
|
||||
|
||||
inventory.getSlot(0).setValidator(serumValid);
|
||||
inventory.addSlotArray(Splicer.slotSerumReserve, "serum.input");
|
||||
for (InventorySlot slot : inventory.getSlots(Splicer.slotSerumReserve)) {
|
||||
slot.setValidator(serumValid);
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
|
||||
inventory.addSlotArray(Splicer.slotSerumExpended, "serum.output");
|
||||
for (InventorySlot slot : inventory.getSlots(Splicer.slotSerumExpended)) {
|
||||
slot.setValidator(serumValid);
|
||||
slot.setReadOnly();
|
||||
}
|
||||
|
||||
inventory.addSlotArray(Splicer.slotReserve, "input");
|
||||
for (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 (InventorySlot slot : inventory.getSlots(Splicer.slotFinished)) {
|
||||
slot.setReadOnly();
|
||||
slot.forbidInsertion();
|
||||
slot.setValidator(new ValidatorIndividualInoculate());
|
||||
}
|
||||
|
||||
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(ItemStack stack) {
|
||||
return Engineering.getCharges(stack) == 0;
|
||||
}
|
||||
});
|
||||
transfer.addStorage(9, Splicer.slotFinished, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(ItemStack stack) {
|
||||
return stack != null
|
||||
&& transfer.getMachine().getMachineUtil().getStack(0) != null
|
||||
&& 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);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentSplicerLogic extends ComponentProcessSetCost implements IProcess {
|
||||
int nOfGenes;
|
||||
|
||||
public ComponentSplicerLogic(Machine machine) {
|
||||
super(machine, 12000000, 1200);
|
||||
nOfGenes = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessLength() {
|
||||
float n = 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 = getNumberOfGenes();
|
||||
if (n > 1.0f) {
|
||||
n = 1.0f + (n - 1.0f) * 0.5f;
|
||||
}
|
||||
return (int) (super.getProcessEnergy() * n);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryUpdate() {
|
||||
super.onInventoryUpdate();
|
||||
nOfGenes = getGenesToUse();
|
||||
}
|
||||
|
||||
protected int getGenesToUse() {
|
||||
ItemStack serum = getUtil().getStack(0);
|
||||
ItemStack target = getUtil().getStack(9);
|
||||
if (serum == null || target == null) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
IIndividual ind = AlleleManager.alleleRegistry.getIndividual(target);
|
||||
IGene[] genes = ((IItemSerum) serum.getItem()).getGenes(serum);
|
||||
if (ind.getGenome().getSpeciesRoot() != ((IItemSerum) serum.getItem()).getSpeciesRoot(serum)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for (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() {
|
||||
ItemStack serum = getUtil().getStack(0);
|
||||
if (serum == null) {
|
||||
return 1;
|
||||
}
|
||||
return Engineering.getGenes(serum).length;
|
||||
}
|
||||
|
||||
private int getNumberOfGenes() {
|
||||
return nOfGenes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
int n = getNumberOfGenes();
|
||||
int f = getFullNumberOfGenes();
|
||||
return "Splicing in " + n + ((f > 1) ? ("/" + f) : "") + " gene" + ((n > 1) ? "s" : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (getUtil().isSlotEmpty(9)) {
|
||||
return new ErrorState.NoItem("No Individual to Splice", 9);
|
||||
}
|
||||
if (getUtil().isSlotEmpty(0)) {
|
||||
return new ErrorState.NoItem("No Serum", 0);
|
||||
}
|
||||
|
||||
ErrorState state = isValidSerum();
|
||||
if (state != null) {
|
||||
return state;
|
||||
}
|
||||
|
||||
if (getUtil().getStack(0) != null && Engineering.getCharges(getUtil().getStack(0)) == 0) {
|
||||
return new ErrorState("Empty Serum", "Serum is empty");
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
public ErrorState isValidSerum() {
|
||||
ItemStack serum = getUtil().getStack(0);
|
||||
ItemStack target = getUtil().getStack(9);
|
||||
IGene[] genes = Engineering.getGenes(serum);
|
||||
if (genes.length == 0) {
|
||||
return new ErrorState("Invalid Serum", "Serum does not hold any genes");
|
||||
}
|
||||
if (!genes[0].getSpeciesRoot().isMember(target)) {
|
||||
return new ErrorState("Invalid Serum", "Mismatch of Serum Type and Target");
|
||||
}
|
||||
|
||||
IIndividual individual = genes[0].getSpeciesRoot().getMember(target);
|
||||
boolean hasAll = true;
|
||||
for (IGene gene : genes) {
|
||||
if (hasAll) {
|
||||
IGenome genome = individual.getGenome();
|
||||
IChromosomeType chromosome = gene.getChromosome();
|
||||
String geneAlleleUID = gene.getAllele().getUID();
|
||||
IAllele a = genome.getActiveAllele(chromosome);
|
||||
IAllele b = genome.getInactiveAllele(chromosome);
|
||||
hasAll = a.getUID().equals(geneAlleleUID)
|
||||
&& b.getUID().equals(geneAlleleUID);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasAll) {
|
||||
return new ErrorState("Defunct Serum", "Individual already possesses this allele");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
ItemStack serum = getUtil().getStack(0);
|
||||
ItemStack target = getUtil().getStack(9);
|
||||
IIndividual ind = AlleleManager.alleleRegistry.getIndividual(target);
|
||||
if (!ind.isAnalyzed()) {
|
||||
ind.analyze();
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
ind.writeToNBT(nbttagcompound);
|
||||
target.setTagCompound(nbttagcompound);
|
||||
}
|
||||
|
||||
IGene[] genes = ((IItemSerum) serum.getItem()).getGenes(serum);
|
||||
for (IGene gene : genes) {
|
||||
Splicer.setGene(gene, target, 0);
|
||||
Splicer.setGene(gene, target, 1);
|
||||
}
|
||||
getUtil().damageItem(0, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentSplicerFX extends MachineComponent implements
|
||||
IRender.RandomDisplayTick,
|
||||
IRender.DisplayTick,
|
||||
IRender.Render,
|
||||
INetwork.TilePacketSync {
|
||||
private EntityItem dummyEntityItem;
|
||||
|
||||
public ComponentSplicerFX(IMachine machine) {
|
||||
super(machine);
|
||||
dummyEntityItem = new EntityItem(null);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onRandomDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
int tick = (int) (world.getTotalWorldTime() % 3L);
|
||||
if (tick == 0 && getUtil().getProcess().isInProgress()) {
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new EntityFX(world, x + 0.5, y + 1.5, z + 0.5, 0.0, 0.0, 0.0) {
|
||||
double axisX = posX;
|
||||
double axisZ = posZ;
|
||||
double angle = (int) (worldObj.getTotalWorldTime() % 4L) * 0.5 * 3.1415;
|
||||
|
||||
{
|
||||
axisX = 0.0;
|
||||
axisZ = 0.0;
|
||||
angle = 0.0;
|
||||
motionX = 0.0;
|
||||
motionZ = 0.0;
|
||||
motionY = (rand.nextDouble() - 0.5) * 0.02;
|
||||
particleMaxAge = 240;
|
||||
particleGravity = 0.0f;
|
||||
noClip = true;
|
||||
setRBGColorF(0.3f + rand.nextFloat() * 0.5f, 0.3f + rand.nextFloat() * 0.5f, 0.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
double speed = 0.04;
|
||||
angle -= speed;
|
||||
double dist = 0.25 + 0.2 * Math.sin(particleAge / 50.0f);
|
||||
setPosition(axisX + dist * Math.sin(angle), posY, axisZ + dist * Math.cos(angle));
|
||||
setAlphaF((float) Math.cos(1.57 * particleAge / particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void renderInWorld(RenderItem renderItem, double x, double y, double z) {
|
||||
if (!getUtil().getProcess().isInProgress()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack stack = getUtil().getStack(9);
|
||||
dummyEntityItem.worldObj = getMachine().getWorld();
|
||||
dummyEntityItem.setEntityItemStack(stack);
|
||||
EntityItem dummyEntityItem = this.dummyEntityItem;
|
||||
dummyEntityItem.age++;
|
||||
this.dummyEntityItem.hoverStart = 0.0f;
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer player = BinnieCore.proxy.getPlayer();
|
||||
double dx = x + 0.5 - player.lastTickPosX;
|
||||
double dz = z + 0.5 - player.lastTickPosZ;
|
||||
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);
|
||||
renderItem.doRender(this.dummyEntityItem, 0.0, 0.0, 0.0, 0.0f, 0.0f);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncToNBT(NBTTagCompound nbt) {
|
||||
NBTTagCompound item = new NBTTagCompound();
|
||||
ItemStack stack = getUtil().getStack(9);
|
||||
if (stack != null) {
|
||||
stack.writeToNBT(item);
|
||||
nbt.setTag("item", item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncFromNBT(NBTTagCompound nbt) {
|
||||
if (nbt.hasKey("item")) {
|
||||
getUtil().setStack(9, ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("item")));
|
||||
} else {
|
||||
getUtil().setStack(9, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryUpdate() {
|
||||
if (!getUtil().isServer()) {
|
||||
return;
|
||||
}
|
||||
getUtil().refreshBlock();
|
||||
}
|
||||
}
|
||||
|
||||
public static class ValidatorIndividualInoculate extends SlotValidator {
|
||||
public ValidatorIndividualInoculate() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(ItemStack object) {
|
||||
ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(object);
|
||||
return root != null && Binnie.Genetics.getSystem(root).isDNAManipulable(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Splicable Individual";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
package binnie.genetics.machine.acclimatiser;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.botany.api.EnumFlowerChromosome;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.Mods;
|
||||
import binnie.core.genetics.Tolerance;
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.EnumTolerance;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.api.lepidopterology.EnumButterflyChromosome;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Acclimatiser {
|
||||
public static final int[] SLOT_RESERVE = new int[]{0, 1, 2, 3};
|
||||
public static final int[] SLOT_ACCLIMATISER = new int[]{5, 6, 7};
|
||||
public static final int[] SLOT_DONE = new int[]{8, 9, 10, 11};
|
||||
public static final int SLOT_TARGET = 4;
|
||||
|
||||
protected static Map<ItemStack, Float> temperatureItems = new HashMap<>();
|
||||
protected static Map<ItemStack, Float> humidityItems = new HashMap<>();
|
||||
|
||||
private static List<ToleranceSystem> toleranceSystems = new ArrayList<>();
|
||||
|
||||
private static ToleranceSystem getToleranceSystem(ItemStack stack, ItemStack acclim) {
|
||||
ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack);
|
||||
if (root == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (ToleranceSystem system : Acclimatiser.toleranceSystems) {
|
||||
if (root.getUID().equals(system.uid) && system.type.hasEffect(acclim)) {
|
||||
return system;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void addTolerance(String uid, IChromosomeType chromosome, ToleranceType type) {
|
||||
Acclimatiser.toleranceSystems.add(new ToleranceSystem(uid, chromosome, type));
|
||||
}
|
||||
|
||||
public static float getTemperatureEffect(ItemStack item) {
|
||||
for (ItemStack stack : Acclimatiser.temperatureItems.keySet()) {
|
||||
if (stack.isItemEqual(item)) {
|
||||
return Acclimatiser.temperatureItems.get(stack);
|
||||
}
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
public static float getHumidityEffect(ItemStack item) {
|
||||
for (ItemStack stack : Acclimatiser.humidityItems.keySet()) {
|
||||
if (stack.isItemEqual(item)) {
|
||||
return Acclimatiser.humidityItems.get(stack);
|
||||
}
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
public static void addTemperatureItem(ItemStack itemStack, float amount) {
|
||||
if (itemStack == null) {
|
||||
return;
|
||||
}
|
||||
Acclimatiser.temperatureItems.put(itemStack, amount);
|
||||
}
|
||||
|
||||
public static void addHumidityItem(ItemStack itemStack, float amount) {
|
||||
if (itemStack == null) {
|
||||
return;
|
||||
}
|
||||
Acclimatiser.humidityItems.put(itemStack, amount);
|
||||
}
|
||||
|
||||
public static void setupRecipes() {
|
||||
if (BinnieCore.isApicultureActive()) {
|
||||
addTolerance(Binnie.Genetics.getBeeRoot().getUID(), EnumBeeChromosome.HUMIDITY_TOLERANCE, ToleranceType.Humidity);
|
||||
addTolerance(Binnie.Genetics.getBeeRoot().getUID(), EnumBeeChromosome.TEMPERATURE_TOLERANCE, ToleranceType.Temperature);
|
||||
}
|
||||
|
||||
if (BinnieCore.isLepidopteryActive()) {
|
||||
addTolerance(Binnie.Genetics.getButterflyRoot().getUID(), EnumButterflyChromosome.HUMIDITY_TOLERANCE, ToleranceType.Humidity);
|
||||
addTolerance(Binnie.Genetics.getButterflyRoot().getUID(), EnumButterflyChromosome.TEMPERATURE_TOLERANCE, ToleranceType.Temperature);
|
||||
}
|
||||
|
||||
if (BinnieCore.isBotanyActive()) {
|
||||
addTolerance(Binnie.Genetics.getFlowerRoot().getUID(), EnumFlowerChromosome.HUMIDITY_TOLERANCE, ToleranceType.Humidity);
|
||||
addTolerance(Binnie.Genetics.getFlowerRoot().getUID(), EnumFlowerChromosome.TEMPERATURE_TOLERANCE, ToleranceType.Temperature);
|
||||
addTolerance(Binnie.Genetics.getFlowerRoot().getUID(), EnumFlowerChromosome.PH_TOLERANCE, ToleranceType.PH);
|
||||
}
|
||||
|
||||
addTemperatureItem(new ItemStack(Items.blaze_powder), 0.5f);
|
||||
addTemperatureItem(new ItemStack(Items.blaze_rod), 0.75f);
|
||||
addTemperatureItem(new ItemStack(Items.lava_bucket), 0.75f);
|
||||
addTemperatureItem(new ItemStack(Items.snowball), -0.15f);
|
||||
addTemperatureItem(new ItemStack(Blocks.ice), -0.75f);
|
||||
addHumidityItem(new ItemStack(Items.water_bucket), 0.75f);
|
||||
addHumidityItem(new ItemStack(Blocks.sand), -0.15f);
|
||||
addTemperatureItem(Mods.Forestry.stack("canLava"), 0.75f);
|
||||
addTemperatureItem(Mods.Forestry.stack("refractoryLava"), 0.75f);
|
||||
addHumidityItem(Mods.Forestry.stack("canWater"), 0.75f);
|
||||
addHumidityItem(Mods.Forestry.stack("refractoryWater"), 0.75f);
|
||||
addHumidityItem(Mods.Forestry.stack("waxCapsuleWater"), 0.75f);
|
||||
}
|
||||
|
||||
public static boolean canAcclimatise(ItemStack stack, List<ItemStack> acclimatisers) {
|
||||
if (stack == null || acclimatisers.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (ItemStack acclim : acclimatisers) {
|
||||
if (canAcclimatise(stack, acclim)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean canAcclimatise(ItemStack stack, ItemStack acclim) {
|
||||
ToleranceSystem system = getToleranceSystem(stack, acclim);
|
||||
return system != null && system.canAlter(stack, acclim);
|
||||
}
|
||||
|
||||
public static ItemStack acclimatise(ItemStack stack, ItemStack acc) {
|
||||
ToleranceSystem system = getToleranceSystem(stack, acc);
|
||||
return system.alter(stack, acc);
|
||||
}
|
||||
|
||||
public static Tolerance alterTolerance(Tolerance tol, float effect) {
|
||||
int[] is = tol.getBounds();
|
||||
int[] range;
|
||||
if (effect < 0.0f) {
|
||||
range = new int[]{is[0] - 1, is[1]};
|
||||
} else {
|
||||
range = new int[]{is[0], is[1] + 1};
|
||||
}
|
||||
|
||||
if (range[0] < -5) {
|
||||
range[0] = -5;
|
||||
}
|
||||
if (range[1] > 5) {
|
||||
range[1] = 5;
|
||||
}
|
||||
|
||||
EnumTolerance[] up = {
|
||||
EnumTolerance.NONE,
|
||||
EnumTolerance.UP_1,
|
||||
EnumTolerance.UP_2,
|
||||
EnumTolerance.UP_3,
|
||||
EnumTolerance.UP_4,
|
||||
EnumTolerance.UP_5
|
||||
};
|
||||
EnumTolerance[] down = {
|
||||
EnumTolerance.NONE,
|
||||
EnumTolerance.DOWN_1,
|
||||
EnumTolerance.DOWN_2,
|
||||
EnumTolerance.DOWN_3,
|
||||
EnumTolerance.DOWN_4,
|
||||
EnumTolerance.DOWN_5
|
||||
};
|
||||
EnumTolerance[] both = {
|
||||
EnumTolerance.NONE,
|
||||
EnumTolerance.BOTH_1,
|
||||
EnumTolerance.BOTH_2,
|
||||
EnumTolerance.BOTH_3,
|
||||
EnumTolerance.BOTH_4,
|
||||
EnumTolerance.BOTH_5
|
||||
};
|
||||
|
||||
if (range[0] == 0) {
|
||||
return Tolerance.get(up[range[1]]);
|
||||
}
|
||||
if (range[1] == 0) {
|
||||
return Tolerance.get(down[-range[0]]);
|
||||
}
|
||||
|
||||
int avg = (int) ((-range[0] + range[1]) / 2.0f + 0.6f);
|
||||
return Tolerance.get(both[avg]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package binnie.genetics.machine.acclimatiser;
|
||||
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.power.ComponentProcessIndefinate;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.core.util.I18N;
|
||||
import binnie.genetics.Genetics;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AcclimatiserComponentLogic extends ComponentProcessIndefinate {
|
||||
public AcclimatiserComponentLogic(IMachine machine) {
|
||||
super(machine, 2.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (getUtil().getStack(Acclimatiser.SLOT_TARGET) == null) {
|
||||
return new ErrorState.NoItem(
|
||||
I18N.localise(Genetics.instance, "machine.acclimatiser.error.noIndividual"),
|
||||
Acclimatiser.SLOT_TARGET
|
||||
);
|
||||
}
|
||||
if (getUtil().getNonNullStacks(Acclimatiser.SLOT_ACCLIMATISER).isEmpty()) {
|
||||
return new ErrorState.NoItem(
|
||||
I18N.localise(Genetics.instance, "machine.acclimatiser.error.noAcclimatizingItems"),
|
||||
Acclimatiser.SLOT_ACCLIMATISER
|
||||
);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (!Acclimatiser.canAcclimatise(getUtil().getStack(Acclimatiser.SLOT_TARGET), getUtil().getNonNullStacks(Acclimatiser.SLOT_ACCLIMATISER))) {
|
||||
return new ErrorState.InvalidItem(
|
||||
I18N.localise(Genetics.instance, "machine.acclimatiser.error.invalidAcclimatizingItems"),
|
||||
Acclimatiser.SLOT_TARGET
|
||||
);
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean inProgress() {
|
||||
return canWork() == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
super.onTickTask();
|
||||
if (getUtil().getRandom().nextInt(100) == 0) {
|
||||
attemptAcclimatisation();
|
||||
}
|
||||
}
|
||||
|
||||
protected void attemptAcclimatisation() {
|
||||
List<ItemStack> acclms = new ArrayList<>();
|
||||
for (ItemStack s : getUtil().getNonNullStacks(Acclimatiser.SLOT_ACCLIMATISER)) {
|
||||
if (Acclimatiser.canAcclimatise(getUtil().getStack(Acclimatiser.SLOT_TARGET), s)) {
|
||||
acclms.add(s);
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack acc = acclms.get(getUtil().getRandom().nextInt(acclms.size()));
|
||||
ItemStack acclimed = Acclimatiser.acclimatise(getUtil().getStack(Acclimatiser.SLOT_TARGET), acc);
|
||||
if (acclimed != null) {
|
||||
getUtil().setStack(Acclimatiser.SLOT_TARGET, acclimed);
|
||||
boolean removed = false;
|
||||
for (int i : Acclimatiser.SLOT_ACCLIMATISER) {
|
||||
if (!removed && getUtil().getStack(i) != null && getUtil().getStack(i).isItemEqual(acc)) {
|
||||
getUtil().decreaseStack(i, 1);
|
||||
removed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package binnie.genetics.machine.acclimatiser;
|
||||
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.util.I18N;
|
||||
import binnie.genetics.Genetics;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class AcclimatiserItemSlotValidator extends SlotValidator {
|
||||
public AcclimatiserItemSlotValidator() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(ItemStack stack) {
|
||||
for (ToleranceType type : ToleranceType.values()) {
|
||||
if (type.hasEffect(stack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return I18N.localise(Genetics.instance, "machine.acclimatiser.acclimatizingItems");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package binnie.genetics.machine.acclimatiser;
|
||||
|
||||
import binnie.core.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.ComponentInventoryTransfer;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.machine.ComponentGeneticGUI;
|
||||
import binnie.genetics.machine.PackageGeneticBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class AcclimatiserPackage extends PackageGeneticBase implements IMachineInformation {
|
||||
public AcclimatiserPackage() {
|
||||
super("acclimatiser", GeneticsTexture.Acclimatiser, 0x966a49, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Acclimatiser);
|
||||
ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
InventorySlot processSlot = inventory.addSlot(Acclimatiser.SLOT_TARGET, "process");
|
||||
processSlot.setValidator(new SlotValidator.Individual());
|
||||
processSlot.setReadOnly();
|
||||
processSlot.forbidExtraction();
|
||||
|
||||
for (InventorySlot slot : inventory.addSlotArray(Acclimatiser.SLOT_RESERVE, "input")) {
|
||||
slot.forbidExtraction();
|
||||
slot.setValidator(new SlotValidator.Individual());
|
||||
}
|
||||
|
||||
for (InventorySlot slot : inventory.addSlotArray(Acclimatiser.SLOT_DONE, "output")) {
|
||||
slot.setReadOnly();
|
||||
slot.setValidator(new SlotValidator.Individual());
|
||||
}
|
||||
|
||||
for (InventorySlot slot : inventory.addSlotArray(Acclimatiser.SLOT_ACCLIMATISER, "acclimatiser")) {
|
||||
slot.setValidator(new AcclimatiserItemSlotValidator());
|
||||
}
|
||||
|
||||
ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Acclimatiser.SLOT_RESERVE, Acclimatiser.SLOT_TARGET, 1);
|
||||
transfer.addStorage(Acclimatiser.SLOT_TARGET, Acclimatiser.SLOT_DONE, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(ItemStack stack) {
|
||||
return !Acclimatiser.canAcclimatise(stack, machine.getMachineUtil().getNonNullStacks(Acclimatiser.SLOT_ACCLIMATISER));
|
||||
}
|
||||
});
|
||||
|
||||
new ComponentPowerReceptor(machine, 5000);
|
||||
new AcclimatiserComponentLogic(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package binnie.genetics.machine.acclimatiser;
|
||||
|
||||
import binnie.core.genetics.Gene;
|
||||
import binnie.core.genetics.Tolerance;
|
||||
import binnie.genetics.machine.inoculator.Inoculator;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAlleleTolerance;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.IGenome;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
class ToleranceSystem {
|
||||
public String uid;
|
||||
public IChromosomeType chromosomeOrdinal;
|
||||
public ToleranceType type;
|
||||
|
||||
ToleranceSystem(String uid, IChromosomeType chromosomeOrdinal, ToleranceType type) {
|
||||
this.uid = uid;
|
||||
this.chromosomeOrdinal = chromosomeOrdinal;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public boolean canAlter(ItemStack stack, ItemStack acclim) {
|
||||
IIndividual member = AlleleManager.alleleRegistry.getIndividual(stack);
|
||||
IGenome genome = member.getGenome();
|
||||
IAlleleTolerance tolAllele = (IAlleleTolerance) genome.getActiveAllele(chromosomeOrdinal);
|
||||
Tolerance tol = Tolerance.get(tolAllele.getValue());
|
||||
float effect = type.getEffect(acclim);
|
||||
return (effect > 0.0f && tol.getBounds()[1] < 5) || (effect < 0.0f && tol.getBounds()[0] > -5);
|
||||
}
|
||||
|
||||
public ItemStack alter(ItemStack stack, ItemStack acc) {
|
||||
Random rand = new Random();
|
||||
float effect = type.getEffect(acc);
|
||||
if (rand.nextFloat() > Math.abs(effect)) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
IIndividual member = AlleleManager.alleleRegistry.getIndividual(stack);
|
||||
IGenome genome = member.getGenome();
|
||||
IAlleleTolerance tolAllele = (IAlleleTolerance) genome.getActiveAllele(chromosomeOrdinal);
|
||||
Tolerance tol = Tolerance.get(tolAllele.getValue());
|
||||
Tolerance newTol = Acclimatiser.alterTolerance(tol, effect);
|
||||
if (rand.nextFloat() > 1.0f / (-newTol.getBounds()[0] + newTol.getBounds()[1])) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack);
|
||||
Inoculator.setGene(new Gene(newTol.getAllele(), chromosomeOrdinal, root), stack, rand.nextInt(2));
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package binnie.genetics.machine.acclimatiser;
|
||||
|
||||
import binnie.botany.gardening.Gardening;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public enum ToleranceType {
|
||||
Temperature,
|
||||
Humidity,
|
||||
PH;
|
||||
|
||||
public float getEffect(ItemStack stack) {
|
||||
switch (this) {
|
||||
case Temperature:
|
||||
return Acclimatiser.getTemperatureEffect(stack);
|
||||
|
||||
case Humidity:
|
||||
return Acclimatiser.getHumidityEffect(stack);
|
||||
|
||||
case PH:
|
||||
if (Gardening.isAcidFertiliser(stack)) {
|
||||
return -0.5f * Gardening.getFertiliserStrength(stack);
|
||||
}
|
||||
if (Gardening.isAlkalineFertiliser(stack)) {
|
||||
return 0.5f * Gardening.getFertiliserStrength(stack);
|
||||
}
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
public boolean hasEffect(ItemStack stack) {
|
||||
return getEffect(stack) != 0.0f;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
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_FINISHED = new int[]{7, 8, 9, 10, 11, 12};
|
||||
public static final int SLOT_TARGET = 6;
|
||||
public static final int SLOT_DYE = 13;
|
||||
|
||||
public static boolean isAnalysable(ItemStack stack) {
|
||||
IIndividual ind = AlleleManager.alleleRegistry.getIndividual(stack);
|
||||
return ind != null
|
||||
|| stack.getItem() instanceof IItemAnalysable
|
||||
|| Binnie.Genetics.getConversion(stack) != null;
|
||||
}
|
||||
|
||||
public static boolean isAnalysed(ItemStack stack) {
|
||||
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) {
|
||||
ItemStack conv = Binnie.Genetics.getConversionStack(stack);
|
||||
if (conv != null) {
|
||||
stack = conv;
|
||||
}
|
||||
|
||||
ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack);
|
||||
if (root != null) {
|
||||
IIndividual ind = root.getMember(stack);
|
||||
ind.analyze();
|
||||
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,135 @@
|
||||
package binnie.genetics.machine.analyser;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import binnie.core.machines.component.IRender;
|
||||
import binnie.core.machines.network.INetwork;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class AnalyserComponentFX extends MachineComponent implements
|
||||
IRender.RandomDisplayTick,
|
||||
IRender.DisplayTick,
|
||||
IRender.Render,
|
||||
INetwork.TilePacketSync {
|
||||
private EntityItem dummyEntityItem;
|
||||
|
||||
public AnalyserComponentFX(IMachine machine) {
|
||||
super(machine);
|
||||
dummyEntityItem = new EntityItem(null);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onRandomDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
if (rand.nextFloat() < 1.0f && getUtil().getProcess().isInProgress()) {
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new EntityFX(world, x + 0.5, y + 1.3 + rand.nextDouble() * 0.2, z + 0.5, 0.0, 0.0, 0.0) {
|
||||
double axisX = posX;
|
||||
double axisZ = posZ;
|
||||
double angle = rand.nextDouble() * 2.0 * 3.1415;
|
||||
|
||||
{
|
||||
axisX = 0.0;
|
||||
axisZ = 0.0;
|
||||
angle = 0.0;
|
||||
motionX = 0.05 * (rand.nextDouble() - 0.5);
|
||||
motionZ = 0.05 * (rand.nextDouble() - 0.5);
|
||||
motionY = 0.0;
|
||||
particleMaxAge = 25;
|
||||
particleGravity = 0.05f;
|
||||
noClip = true;
|
||||
setRBGColorF(0.6f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
setAlphaF((float) Math.cos(1.57 * particleAge / particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void renderInWorld(RenderItem renderItem, double x, double y, double z) {
|
||||
if (!getUtil().getProcess().isInProgress()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack stack = getUtil().getStack(Analyser.SLOT_TARGET);
|
||||
dummyEntityItem.worldObj = getMachine().getWorld();
|
||||
dummyEntityItem.setEntityItemStack(stack);
|
||||
EntityItem dummyEntityItem = this.dummyEntityItem;
|
||||
dummyEntityItem.age++;
|
||||
this.dummyEntityItem.hoverStart = 0.0f;
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer player = BinnieCore.proxy.getPlayer();
|
||||
double dx = x + 0.5 - player.lastTickPosX;
|
||||
double dz = z + 0.5 - player.lastTickPosZ;
|
||||
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);
|
||||
renderItem.doRender(this.dummyEntityItem, 0.0, 0.0, 0.0, 0.0f, 0.0f);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncToNBT(NBTTagCompound nbt) {
|
||||
NBTTagCompound item = new NBTTagCompound();
|
||||
ItemStack stack = getUtil().getStack(Analyser.SLOT_TARGET);
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
stack.writeToNBT(item);
|
||||
nbt.setTag("item", item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncFromNBT(NBTTagCompound nbt) {
|
||||
if (nbt.hasKey("item")) {
|
||||
getUtil().setStack(Analyser.SLOT_TARGET, ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("item")));
|
||||
} else {
|
||||
getUtil().setStack(Analyser.SLOT_TARGET, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryUpdate() {
|
||||
if (!getUtil().isServer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
IMachine machine = getMachine();
|
||||
TileEntity tile = machine.getTileEntity();
|
||||
machine.getWorld().markBlockForUpdate(tile.xCoord, tile.yCoord, tile.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 net.minecraft.item.ItemStack;
|
||||
|
||||
public class AnalyserComponentLogic extends ComponentProcessSetCost implements IProcess {
|
||||
private static final float DYE_PER_TICK = 0.002f;
|
||||
|
||||
public AnalyserComponentLogic(Machine machine) {
|
||||
super(machine, 9000, 300);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (getUtil().isSlotEmpty(Analyser.SLOT_TARGET)) {
|
||||
return new ErrorState.NoItem("No item to analyse", Analyser.SLOT_TARGET);
|
||||
}
|
||||
|
||||
boolean analysed = Analyser.isAnalysed(getUtil().getStack(Analyser.SLOT_TARGET));
|
||||
if (analysed) {
|
||||
return new ErrorState.InvalidItem("Already Analysed", "Item has already been analysed", Analyser.SLOT_TARGET);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (getUtil().getSlotCharge(Analyser.SLOT_DYE) == 0.0f) {
|
||||
return new ErrorState.Item("Insufficient Dye", "Not enough DNA dye to analyse", new int[]{Analyser.SLOT_DYE});
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
ItemStack itemStack = getUtil().getStack(Analyser.SLOT_TARGET);
|
||||
itemStack = Analyser.analyse(itemStack);
|
||||
getInventory().setInventorySlotContents(Analyser.SLOT_TARGET, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
getUtil().useCharge(Analyser.SLOT_DYE, DYE_PER_TICK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package binnie.genetics.machine.analyser;
|
||||
|
||||
import binnie.core.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.machines.inventory.ComponentChargedSlots;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.ComponentInventoryTransfer;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.machine.ComponentGeneticGUI;
|
||||
import binnie.genetics.machine.PackageGeneticBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class AnalyserPackage extends PackageGeneticBase implements IMachineInformation {
|
||||
public AnalyserPackage() {
|
||||
super("analyser", GeneticsTexture.Analyser, 0x9800ff, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Analyser);
|
||||
ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlotArray(Analyser.SLOT_RESERVE, "input");
|
||||
for (InventorySlot slot : inventory.getSlots(Analyser.SLOT_RESERVE)) {
|
||||
slot.setValidator(new UnanalysedSlotValidator());
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
|
||||
InventorySlot targetSlot = inventory.addSlot(Analyser.SLOT_TARGET, "analyse");
|
||||
targetSlot.setValidator(new UnanalysedSlotValidator());
|
||||
targetSlot.setReadOnly();
|
||||
targetSlot.forbidInteraction();
|
||||
|
||||
InventorySlot dyeSlot = inventory.addSlot(Analyser.SLOT_DYE, "dye");
|
||||
dyeSlot.forbidExtraction();
|
||||
dyeSlot.setValidator(new DyeSlotValidator());
|
||||
|
||||
inventory.addSlotArray(Analyser.SLOT_FINISHED, "output");
|
||||
for (InventorySlot slot : inventory.getSlots(Analyser.SLOT_FINISHED)) {
|
||||
slot.forbidInsertion();
|
||||
slot.setReadOnly();
|
||||
}
|
||||
|
||||
ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Analyser.SLOT_RESERVE, Analyser.SLOT_TARGET, 1);
|
||||
transfer.addStorage(Analyser.SLOT_TARGET, Analyser.SLOT_FINISHED, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(ItemStack stack) {
|
||||
return Analyser.isAnalysed(stack);
|
||||
}
|
||||
});
|
||||
|
||||
new ComponentChargedSlots(machine).addCharge(Analyser.SLOT_DYE);
|
||||
new ComponentPowerReceptor(machine, 500);
|
||||
new AnalyserComponentLogic(machine);
|
||||
new AnalyserComponentFX(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package binnie.genetics.machine.analyser;
|
||||
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import binnie.genetics.machine.ModuleMachine;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class DyeSlotValidator extends SlotValidator {
|
||||
public DyeSlotValidator() {
|
||||
super(ModuleMachine.IconDye);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(ItemStack itemStack) {
|
||||
return itemStack.isItemEqual(GeneticsItems.DNADye.get(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "DNA Dye";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package binnie.genetics.machine.analyser;
|
||||
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class UnanalysedSlotValidator extends SlotValidator {
|
||||
public UnanalysedSlotValidator() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(ItemStack itemStack) {
|
||||
return Analyser.isAnalysable(itemStack)
|
||||
&& !Analyser.isAnalysed(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Unanalysed Item";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package binnie.genetics.machine.genepool;
|
||||
|
||||
import binnie.core.machines.inventory.TankValidator;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
class EthanolTankValidator extends TankValidator {
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Ethanol";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(FluidStack liquid) {
|
||||
return liquid.getFluid().getName().equals("bioethanol");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package binnie.genetics.machine.genepool;
|
||||
|
||||
public class Genepool {
|
||||
public static final int SLOT_BEE = 0;
|
||||
public static final int TANK_DNA = 0;
|
||||
public static final int TANK_ETHANOL = 1;
|
||||
public static final int SLOT_ENZYME = 7;
|
||||
public static final int[] SLOT_RESERVE = new int[]{1, 2, 3, 4, 5, 6};
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package binnie.genetics.machine.genepool;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import binnie.core.machines.component.IRender;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class GenepoolComponentFX extends MachineComponent implements IRender.RandomDisplayTick, IRender.DisplayTick {
|
||||
public GenepoolComponentFX(IMachine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onRandomDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
if (rand.nextFloat() < 1.0f && getUtil().getProcess().isInProgress()) {
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new EntityFX(world, x + 0.3 + rand.nextDouble() * 0.4, y + 1, z + 0.3 + rand.nextDouble() * 0.4, 0.0, 0.0, 0.0) {
|
||||
double axisX = posX;
|
||||
double axisZ = posZ;
|
||||
double angle = rand.nextDouble() * 2.0 * 3.1415;
|
||||
|
||||
{
|
||||
axisX = 0.0;
|
||||
axisZ = 0.0;
|
||||
angle = 0.0;
|
||||
motionX = 0.0;
|
||||
motionZ = 0.0;
|
||||
motionY = rand.nextFloat() * 0.01;
|
||||
particleMaxAge = 25;
|
||||
particleGravity = 0.0f;
|
||||
noClip = true;
|
||||
setRBGColorF(0.4f + 0.6f * rand.nextFloat(), 0.6f * rand.nextFloat(), 0.6f + 0.4f * rand.nextFloat());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
setAlphaF((float) Math.cos(1.57 * particleAge / particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package binnie.genetics.machine.genepool;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.inventory.IChargedSlots;
|
||||
import binnie.core.machines.power.ComponentProcessSetCost;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.core.machines.power.IProcess;
|
||||
import binnie.genetics.item.GeneticLiquid;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class GenepoolComponentLogic extends ComponentProcessSetCost implements IProcess {
|
||||
float enzymePerProcess;
|
||||
float ethanolPerProcess;
|
||||
private float ethanolDrain;
|
||||
|
||||
public GenepoolComponentLogic(Machine machine) {
|
||||
super(machine, 8000, 400);
|
||||
enzymePerProcess = 0.25f;
|
||||
ethanolPerProcess = 50.0f;
|
||||
ethanolDrain = 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (getUtil().isSlotEmpty(0)) {
|
||||
return new ErrorState.NoItem("No Individual", Genepool.SLOT_BEE);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (!getUtil().spaceInTank(Genepool.TANK_DNA, getDNAAmount(getUtil().getStack(Genepool.TANK_DNA)))) {
|
||||
return new ErrorState.NoSpace("Not enough room in Tank", new int[]{Genepool.TANK_DNA});
|
||||
}
|
||||
if (!getUtil().liquidInTank(1, 1)) {
|
||||
return new ErrorState.InsufficientLiquid("Not enough Ethanol", Genepool.TANK_ETHANOL);
|
||||
}
|
||||
if (getUtil().getSlotCharge(Genepool.SLOT_ENZYME) == 0.0f) {
|
||||
return new ErrorState.NoItem("Insufficient Enzyme", Genepool.SLOT_ENZYME);
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
int amount = getDNAAmount(getUtil().getStack(Genepool.TANK_DNA));
|
||||
getUtil().fillTank(Genepool.TANK_DNA, GeneticLiquid.RawDNA.get(amount));
|
||||
getUtil().deleteStack(Genepool.TANK_DNA);
|
||||
}
|
||||
|
||||
private int getDNAAmount(ItemStack stack) {
|
||||
ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack);
|
||||
if (root == null
|
||||
|| root != Binnie.Genetics.getBeeRoot()
|
||||
|| Binnie.Genetics.getBeeRoot().isDrone(stack)) {
|
||||
return 10;
|
||||
}
|
||||
if (Binnie.Genetics.getBeeRoot().isMated(stack)) {
|
||||
return 50;
|
||||
}
|
||||
return 30;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
ethanolDrain += getDNAAmount(getUtil().getStack(Genepool.TANK_DNA)) * 1.2f * getProgressPerTick() / 100.0f;
|
||||
if (ethanolDrain >= 1.0f) {
|
||||
getUtil().drainTank(Genepool.TANK_ETHANOL, 1);
|
||||
ethanolDrain--;
|
||||
}
|
||||
getMachine().getInterface(IChargedSlots.class).alterCharge(Genepool.SLOT_ENZYME, -enzymePerProcess * getProgressPerTick() / 100.0f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package binnie.genetics.machine.genepool;
|
||||
|
||||
import binnie.core.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.machines.inventory.ComponentChargedSlots;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.ComponentInventoryTransfer;
|
||||
import binnie.core.machines.inventory.ComponentTankContainer;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.machines.inventory.TankSlot;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import binnie.genetics.machine.ComponentGeneticGUI;
|
||||
import binnie.genetics.machine.ModuleMachine;
|
||||
import binnie.genetics.machine.PackageGeneticBase;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class GenepoolPackage extends PackageGeneticBase implements IMachineInformation {
|
||||
public GenepoolPackage() {
|
||||
super("genepool", GeneticsTexture.Genepool, 0xc134b6, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Genepool);
|
||||
ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
InventorySlot enzymeSlot = inventory.addSlot(Genepool.SLOT_ENZYME, "enzyme");
|
||||
enzymeSlot.setValidator(new SlotValidator.Item(GeneticsItems.Enzyme.get(1), ModuleMachine.IconEnzyme));
|
||||
enzymeSlot.forbidExtraction();
|
||||
|
||||
InventorySlot slotBee = inventory.addSlot(Genepool.SLOT_BEE, "process");
|
||||
slotBee.setValidator(new SlotValidator.Individual());
|
||||
slotBee.setReadOnly();
|
||||
slotBee.forbidExtraction();
|
||||
inventory.addSlotArray(Genepool.SLOT_RESERVE, "input");
|
||||
|
||||
for (InventorySlot slot : inventory.getSlots(Genepool.SLOT_RESERVE)) {
|
||||
slot.setValidator(new SlotValidator.Individual());
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
|
||||
ComponentTankContainer tanks = new ComponentTankContainer(machine);
|
||||
TankSlot dnaSlot = tanks.addTank(Genepool.TANK_DNA, "output", 2000);
|
||||
dnaSlot.setReadOnly();
|
||||
|
||||
TankSlot ethanolSlot = tanks.addTank(Genepool.TANK_ETHANOL, "input", 1000);
|
||||
ethanolSlot.forbidExtraction();
|
||||
ethanolSlot.setValidator(new EthanolTankValidator());
|
||||
|
||||
ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Genepool.SLOT_RESERVE, Genepool.SLOT_BEE, 1);
|
||||
new ComponentPowerReceptor(machine, 1600);
|
||||
new GenepoolComponentLogic(machine);
|
||||
ComponentChargedSlots chargedSlots = new ComponentChargedSlots(machine);
|
||||
chargedSlots.addCharge(Genepool.SLOT_ENZYME);
|
||||
new GenepoolComponentFX(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package binnie.genetics.machine.incubator;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.machines.MachineUtil;
|
||||
import binnie.genetics.api.IIncubatorRecipe;
|
||||
import binnie.genetics.item.GeneticLiquid;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Incubator {
|
||||
public static final int[] SLOT_QUEUE = new int[]{0, 1, 2};
|
||||
public static final int[] SLOT_OUTPUT = new int[]{4, 5, 6};
|
||||
public static final int SLOT_INCUBATOR = 3;
|
||||
public static final int TANK_INPUT = 0;
|
||||
public static final int TANK_OUTPUT = 1;
|
||||
public static final List<IIncubatorRecipe> RECIPES = new ArrayList<>();
|
||||
|
||||
public static void addRecipes() {
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(Binnie.Liquid.getLiquidStack("water", 25), GeneticLiquid.GrowthMedium.get(25), 0.2f) {
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return GeneticsItems.GrowthMedium.get(1).isItemEqual(stack);
|
||||
}
|
||||
});
|
||||
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticLiquid.GrowthMedium.get(25), GeneticLiquid.Bacteria.get(5), 0.2f) {
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return new ItemStack(Items.wheat).isItemEqual(stack);
|
||||
}
|
||||
});
|
||||
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticLiquid.Bacteria.get(0), GeneticLiquid.Bacteria.get(5), 0.05f) {
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return GeneticsItems.GrowthMedium.get(1).isItemEqual(stack);
|
||||
}
|
||||
});
|
||||
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticLiquid.Bacteria.get(2), null, 0.5f, 0.2f) {
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return stack.getItem() == Items.sugar;
|
||||
}
|
||||
}.setOutputStack(GeneticsItems.Enzyme.get(1)));
|
||||
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticLiquid.BacteriaPoly.get(0), GeneticLiquid.BacteriaPoly.get(5), 0.05f) {
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return GeneticsItems.GrowthMedium.get(1).isItemEqual(stack);
|
||||
}
|
||||
});
|
||||
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticLiquid.BacteriaVector.get(0), GeneticLiquid.BacteriaVector.get(5), 0.05f) {
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return GeneticsItems.GrowthMedium.get(1).isItemEqual(stack);
|
||||
}
|
||||
});
|
||||
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticLiquid.Bacteria.get(10), GeneticLiquid.BacteriaPoly.get(10), 0.1f) {
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return new ItemStack(Items.dye, 1, 15).isItemEqual(stack);
|
||||
}
|
||||
});
|
||||
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticLiquid.Bacteria.get(10), GeneticLiquid.BacteriaVector.get(10), 0.05f) {
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return new ItemStack(Items.blaze_powder).isItemEqual(stack);
|
||||
}
|
||||
});
|
||||
|
||||
if (BinnieCore.isApicultureActive()) {
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(GeneticLiquid.GrowthMedium.get(50), null, 1.0f, 0.05f) {
|
||||
@Override
|
||||
public boolean isItemStack(ItemStack stack) {
|
||||
return Binnie.Genetics.getBeeRoot().isMember(stack) && Binnie.Genetics.getBeeRoot().getType(stack) == EnumBeeType.LARVAE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getOutputStack(MachineUtil machine) {
|
||||
ItemStack larvae = machine.getStack(SLOT_INCUBATOR);
|
||||
IBee bee = Binnie.Genetics.getBeeRoot().getMember(larvae);
|
||||
return Binnie.Genetics.getBeeRoot().getMemberStack(bee, EnumBeeType.DRONE.ordinal());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package binnie.genetics.machine.incubator;
|
||||
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.power.ComponentProcessIndefinate;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.core.machines.power.IProcess;
|
||||
import binnie.core.machines.transfer.TransferRequest;
|
||||
import binnie.genetics.api.IIncubatorRecipe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class IncubatorComponentLogic extends ComponentProcessIndefinate implements IProcess {
|
||||
IIncubatorRecipe recipe;
|
||||
private Random rand;
|
||||
private boolean roomForOutput;
|
||||
|
||||
public IncubatorComponentLogic(Machine machine) {
|
||||
super(machine, 2.0f);
|
||||
recipe = null;
|
||||
rand = new Random();
|
||||
roomForOutput = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (recipe == null) {
|
||||
return new ErrorState("No Recipe", "There is no valid recipe");
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (recipe != null) {
|
||||
if (!recipe.isInputLiquidSufficient(getUtil().getFluid(Incubator.TANK_INPUT))) {
|
||||
return new ErrorState.InsufficientLiquid("Not enough incubation liquid", Incubator.TANK_INPUT);
|
||||
}
|
||||
if (!roomForOutput) {
|
||||
return new ErrorState.TankSpace("No room for output", Incubator.TANK_OUTPUT);
|
||||
}
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
if (rand.nextInt(20) == 0 && recipe != null && rand.nextFloat() < recipe.getChance()) {
|
||||
recipe.doTask(getUtil());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inProgress() {
|
||||
return recipe != null;
|
||||
}
|
||||
|
||||
private IIncubatorRecipe getRecipe(ItemStack stack, FluidStack liquid) {
|
||||
for (IIncubatorRecipe recipe : Incubator.RECIPES) {
|
||||
boolean rightLiquid = recipe.isInputLiquid(liquid);
|
||||
boolean rightItem = recipe.isItemStack(stack);
|
||||
if (rightLiquid && rightItem) {
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryUpdate() {
|
||||
super.onInventoryUpdate();
|
||||
if (!getUtil().isServer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
FluidStack liquid = getUtil().getFluid(Incubator.TANK_INPUT);
|
||||
ItemStack incubator = getUtil().getStack(Incubator.SLOT_INCUBATOR);
|
||||
if (recipe != null && (incubator == null || liquid == null || !recipe.isInputLiquid(liquid) || !recipe.isItemStack(incubator))) {
|
||||
recipe = null;
|
||||
ItemStack leftover = new TransferRequest(incubator, getInventory())
|
||||
.setTargetSlots(Incubator.SLOT_OUTPUT)
|
||||
.ignoreValidation()
|
||||
.transfer(true);
|
||||
getUtil().setStack(Incubator.SLOT_INCUBATOR, leftover);
|
||||
}
|
||||
|
||||
if (recipe == null) {
|
||||
if (liquid == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (incubator != null) {
|
||||
IIncubatorRecipe recipe = getRecipe(incubator, liquid);
|
||||
if (recipe != null) {
|
||||
this.recipe = recipe;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
IIncubatorRecipe potential = null;
|
||||
int potentialSlot = 0;
|
||||
for (int slot : Incubator.SLOT_QUEUE) {
|
||||
ItemStack stack = getUtil().getStack(slot);
|
||||
if (stack == null || potential != null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (IIncubatorRecipe recipe2 : Incubator.RECIPES) {
|
||||
boolean rightLiquid = recipe2.isInputLiquid(liquid);
|
||||
boolean rightItem = recipe2.isItemStack(stack);
|
||||
if (rightLiquid && rightItem) {
|
||||
potential = recipe2;
|
||||
potentialSlot = slot;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (potential != null) {
|
||||
TransferRequest removal = new TransferRequest(incubator, getInventory())
|
||||
.setTargetSlots(Incubator.SLOT_OUTPUT)
|
||||
.ignoreValidation();
|
||||
|
||||
if (removal.transfer(false) == null) {
|
||||
recipe = potential;
|
||||
}
|
||||
|
||||
removal.transfer(true);
|
||||
ItemStack stack2 = getUtil().getStack(potentialSlot);
|
||||
getUtil().setStack(potentialSlot, null);
|
||||
getUtil().setStack(Incubator.SLOT_INCUBATOR, stack2);
|
||||
}
|
||||
}
|
||||
|
||||
if (recipe != null) {
|
||||
roomForOutput = recipe.roomForOutput(getUtil());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package binnie.genetics.machine.incubator;
|
||||
|
||||
import binnie.core.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.ComponentTankContainer;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.machine.ComponentGeneticGUI;
|
||||
import binnie.genetics.machine.PackageGeneticBase;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class IncubatorPackage extends PackageGeneticBase implements IMachineInformation {
|
||||
public IncubatorPackage() {
|
||||
super("incubator", GeneticsTexture.Incubator, 0xffd951, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Incubator);
|
||||
ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlotArray(Incubator.SLOT_QUEUE, "input");
|
||||
for (InventorySlot slot : inventory.getSlots(Incubator.SLOT_QUEUE)) {
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
|
||||
InventorySlot incubatorSlot = inventory.addSlot(Incubator.SLOT_INCUBATOR, "incubator");
|
||||
incubatorSlot.forbidInteraction();
|
||||
incubatorSlot.setReadOnly();
|
||||
|
||||
inventory.addSlotArray(Incubator.SLOT_OUTPUT, "output");
|
||||
for (InventorySlot slot : inventory.getSlots(Incubator.SLOT_OUTPUT)) {
|
||||
slot.forbidInsertion();
|
||||
slot.setReadOnly();
|
||||
}
|
||||
|
||||
new ComponentPowerReceptor(machine, 2000);
|
||||
ComponentTankContainer tanks = new ComponentTankContainer(machine);
|
||||
tanks.addTank(Incubator.TANK_INPUT, "input", 2000).forbidExtraction();
|
||||
tanks.addTank(Incubator.TANK_OUTPUT, "output", 2000).setReadOnly();
|
||||
new IncubatorComponentLogic(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package binnie.genetics.machine.incubator;
|
||||
|
||||
import binnie.core.machines.MachineUtil;
|
||||
import binnie.core.machines.transfer.TransferRequest;
|
||||
import binnie.genetics.api.IIncubatorRecipe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public abstract class IncubatorRecipe implements IIncubatorRecipe {
|
||||
protected FluidStack input;
|
||||
protected FluidStack output;
|
||||
protected float lossChance;
|
||||
protected ItemStack outputStack;
|
||||
protected float tickChance;
|
||||
|
||||
public IncubatorRecipe(FluidStack input, FluidStack output, float lossChance) {
|
||||
this(input, output, lossChance, 1.0f);
|
||||
}
|
||||
|
||||
public IncubatorRecipe(FluidStack input, FluidStack output, float lossChance, float chance) {
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
this.lossChance = lossChance;
|
||||
tickChance = chance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getChance() {
|
||||
return tickChance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInputLiquid(FluidStack liquid) {
|
||||
return liquid != null && input.isFluidEqual(liquid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInputLiquidSufficient(FluidStack liquid) {
|
||||
return liquid != null && liquid.amount >= 500;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doTask(MachineUtil machine) {
|
||||
machine.drainTank(Incubator.TANK_INPUT, input.amount);
|
||||
if (output != null) {
|
||||
machine.fillTank(Incubator.TANK_OUTPUT, output);
|
||||
}
|
||||
|
||||
outputStack = getOutputStack(machine);
|
||||
if (outputStack != null) {
|
||||
ItemStack output = outputStack.copy();
|
||||
TransferRequest product = new TransferRequest(output, machine.getInventory())
|
||||
.setTargetSlots(Incubator.SLOT_OUTPUT)
|
||||
.ignoreValidation();
|
||||
product.transfer(true);
|
||||
}
|
||||
|
||||
Random rand = machine.getRandom();
|
||||
if (rand.nextFloat() < lossChance) {
|
||||
machine.decreaseStack(Incubator.SLOT_INCUBATOR, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public IncubatorRecipe setOutputStack(ItemStack stack) {
|
||||
outputStack = stack;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected ItemStack getOutputStack(MachineUtil util) {
|
||||
return outputStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean roomForOutput(MachineUtil machine) {
|
||||
if (output != null && !machine.isTankEmpty(Incubator.TANK_OUTPUT)) {
|
||||
if (!machine.getFluid(Incubator.TANK_OUTPUT).isFluidEqual(output)) {
|
||||
return false;
|
||||
}
|
||||
if (!machine.spaceInTank(Incubator.TANK_OUTPUT, output.amount)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack outputStack = getOutputStack(machine);
|
||||
if (outputStack != null) {
|
||||
ItemStack output = outputStack.copy();
|
||||
TransferRequest product = new TransferRequest(output, machine.getInventory())
|
||||
.setTargetSlots(Incubator.SLOT_OUTPUT)
|
||||
.ignoreValidation();
|
||||
ItemStack leftover = product.transfer(false);
|
||||
return leftover == null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package binnie.genetics.machine.inoculator;
|
||||
|
||||
import binnie.core.machines.inventory.Validator;
|
||||
import binnie.genetics.item.GeneticLiquid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
class BacteriaVectorValidator extends Validator<FluidStack> {
|
||||
@Override
|
||||
public boolean isValid(FluidStack object) {
|
||||
return GeneticLiquid.BacteriaVector.get(1).isFluidEqual(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return GeneticLiquid.BacteriaVector.getName();
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -6,8 +6,8 @@ import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ValidatorIndividualInoculate extends SlotValidator {
|
||||
public ValidatorIndividualInoculate() {
|
||||
public class IndividualInoculateValidator extends SlotValidator {
|
||||
public IndividualInoculateValidator() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
+2
-2
@@ -17,14 +17,14 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class ComponentInoculatorFX extends MachineComponent implements
|
||||
public class InoculatorComponentFX extends MachineComponent implements
|
||||
IRender.RandomDisplayTick,
|
||||
IRender.DisplayTick,
|
||||
IRender.Render,
|
||||
INetwork.TilePacketSync {
|
||||
private EntityItem dummyEntityItem;
|
||||
|
||||
public ComponentInoculatorFX(IMachine machine) {
|
||||
public InoculatorComponentFX(IMachine machine) {
|
||||
super(machine);
|
||||
dummyEntityItem = new EntityItem(null);
|
||||
}
|
||||
+3
-3
@@ -15,10 +15,10 @@ import forestry.api.genetics.IIndividual;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ComponentInoculatorLogic extends ComponentProcessSetCost implements IProcess {
|
||||
public class InoculatorComponentLogic extends ComponentProcessSetCost implements IProcess {
|
||||
private float bacteriaDrain;
|
||||
|
||||
public ComponentInoculatorLogic(Machine machine) {
|
||||
public InoculatorComponentLogic(Machine machine) {
|
||||
super(machine, 600000, 12000);
|
||||
bacteriaDrain = 0.0f;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ public class ComponentInoculatorLogic extends ComponentProcessSetCost implements
|
||||
Inoculator.setGene(gene, target, 0);
|
||||
Inoculator.setGene(gene, target, 1);
|
||||
}
|
||||
getUtil().damageItem(0, 1);
|
||||
getUtil().damageItem(Inoculator.SLOT_SERUM_VIAL, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
+13
-39
@@ -8,22 +8,17 @@ import binnie.core.machines.inventory.ComponentInventoryTransfer;
|
||||
import binnie.core.machines.inventory.ComponentTankContainer;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.machines.inventory.Validator;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.genetics.api.IItemSerum;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.genetics.Engineering;
|
||||
import binnie.genetics.item.GeneticLiquid;
|
||||
import binnie.genetics.machine.ComponentGeneticGUI;
|
||||
import binnie.genetics.machine.GeneticMachine;
|
||||
import binnie.genetics.machine.ModuleMachine;
|
||||
import binnie.genetics.machine.PackageGeneticBase;
|
||||
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() {
|
||||
public class InoculatorPackage extends PackageGeneticBase implements IMachineInformation {
|
||||
public InoculatorPackage() {
|
||||
super("inoculator", GeneticsTexture.Inoculator, 0xe22235, true);
|
||||
}
|
||||
|
||||
@@ -31,22 +26,11 @@ public class PackageInoculator extends GeneticMachine.PackageGeneticBase impleme
|
||||
public void createMachine(Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Inoculator);
|
||||
ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
SlotValidator serumValid = new SerumSlotValidator();
|
||||
|
||||
InventorySlot slotSerumVial = inventory.addSlot(Inoculator.SLOT_SERUM_VIAL, "serum.active");
|
||||
slotSerumVial.forbidInteraction();
|
||||
slotSerumVial.setReadOnly();
|
||||
|
||||
SlotValidator serumValid = new SlotValidator(ModuleMachine.IconSerum) {
|
||||
@Override
|
||||
public boolean isValid(ItemStack itemStack) {
|
||||
return itemStack.getItem() instanceof IItemSerum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Serum Vials & Arrays";
|
||||
}
|
||||
};
|
||||
|
||||
slotSerumVial.setValidator(serumValid);
|
||||
|
||||
inventory.addSlotArray(Inoculator.SLOT_SERUM_RESERVE, "serum.input");
|
||||
@@ -64,18 +48,18 @@ public class PackageInoculator extends GeneticMachine.PackageGeneticBase impleme
|
||||
inventory.addSlotArray(Inoculator.SLOT_RESERVE, "input");
|
||||
for (InventorySlot slot : inventory.getSlots(Inoculator.SLOT_RESERVE)) {
|
||||
slot.forbidExtraction();
|
||||
slot.setValidator(new ValidatorIndividualInoculate());
|
||||
slot.setValidator(new IndividualInoculateValidator());
|
||||
}
|
||||
|
||||
inventory.addSlot(Inoculator.SLOT_TARGET, "process");
|
||||
inventory.getSlot(Inoculator.SLOT_TARGET).setValidator(new ValidatorIndividualInoculate());
|
||||
inventory.getSlot(Inoculator.SLOT_TARGET).setValidator(new IndividualInoculateValidator());
|
||||
inventory.getSlot(Inoculator.SLOT_TARGET).setReadOnly();
|
||||
inventory.getSlot(Inoculator.SLOT_TARGET).forbidInteraction();
|
||||
inventory.addSlotArray(Inoculator.SLOT_FINISHED, "output");
|
||||
for (InventorySlot slot : inventory.getSlots(Inoculator.SLOT_FINISHED)) {
|
||||
slot.setReadOnly();
|
||||
slot.forbidInsertion();
|
||||
slot.setValidator(new ValidatorIndividualInoculate());
|
||||
slot.setValidator(new IndividualInoculateValidator());
|
||||
}
|
||||
|
||||
ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
@@ -92,27 +76,17 @@ public class PackageInoculator extends GeneticMachine.PackageGeneticBase impleme
|
||||
@Override
|
||||
public boolean fufilled(ItemStack stack) {
|
||||
return stack != null
|
||||
&& transfer.getMachine().getMachineUtil().getStack(Inoculator.SLOT_SERUM_VIAL) != null
|
||||
&& transfer.getMachine().getInterface(ComponentInoculatorLogic.class).isValidSerum() != null;
|
||||
&& transfer.getMachine().getMachineUtil().getStack(Inoculator.SLOT_SERUM_VIAL) != null
|
||||
&& transfer.getMachine().getInterface(InoculatorComponentLogic.class).isValidSerum() != null;
|
||||
}
|
||||
});
|
||||
|
||||
new ComponentPowerReceptor(machine, 15000);
|
||||
new ComponentInoculatorLogic(machine);
|
||||
new ComponentInoculatorFX(machine);
|
||||
new InoculatorComponentLogic(machine);
|
||||
new InoculatorComponentFX(machine);
|
||||
new ComponentTankContainer(machine)
|
||||
.addTank(Inoculator.TANK_VECTOR, "input", Inoculator.TANK_CAPACITY)
|
||||
.setValidator(new Validator<FluidStack>() {
|
||||
@Override
|
||||
public boolean isValid(FluidStack object) {
|
||||
return GeneticLiquid.BacteriaVector.get(1).isFluidEqual(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return GeneticLiquid.BacteriaVector.getName();
|
||||
}
|
||||
});
|
||||
.setValidator(new BacteriaVectorValidator());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,22 @@
|
||||
package binnie.genetics.machine.inoculator;
|
||||
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.genetics.api.IItemSerum;
|
||||
import binnie.genetics.machine.ModuleMachine;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
class SerumSlotValidator extends SlotValidator {
|
||||
public SerumSlotValidator() {
|
||||
super(ModuleMachine.IconSerum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(ItemStack itemStack) {
|
||||
return itemStack.getItem() instanceof IItemSerum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Serum Vials & Arrays";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package binnie.genetics.machine.isolator;
|
||||
|
||||
import binnie.core.machines.inventory.TankValidator;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
class EthanolTankValidator extends TankValidator {
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Ethanol";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(FluidStack liquid) {
|
||||
return liquid.getFluid().getName().equals("bioethanol");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,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_FINISHED = new int[]{7, 8, 9, 10, 11, 12};
|
||||
public static final int SLOT_TARGET = 5;
|
||||
public static final int SLOT_RESULT = 6;
|
||||
public static final int TANK_ETHANOL = 0;
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package binnie.genetics.machine.isolator;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import binnie.core.machines.component.IRender;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class IsolatorComponentFX extends MachineComponent implements IRender.RandomDisplayTick, IRender.DisplayTick {
|
||||
public IsolatorComponentFX(IMachine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onRandomDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
if (!getUtil().getProcess().isInProgress()) {
|
||||
return;
|
||||
}
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new EntityFX(world, x + 0.4 + 0.2 * rand.nextDouble(), y + 1.6, z + 0.4 + rand.nextDouble() * 0.2, 0.0, 0.0, 0.0) {
|
||||
double angle = 0.0;
|
||||
|
||||
{
|
||||
motionX = 0.0;
|
||||
motionZ = 0.0;
|
||||
motionY = -0.012;
|
||||
particleMaxAge = 100;
|
||||
particleGravity = 0.0f;
|
||||
noClip = true;
|
||||
setRBGColorF(0.8f, 0.4f, 0.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
angle += 0.06;
|
||||
setAlphaF((float) Math.sin(3.14 * particleAge / particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
int tick = (int) (world.getTotalWorldTime() % 6L);
|
||||
if ((tick != 0 && tick != 5) || !getUtil().getProcess().isInProgress()) {
|
||||
return;
|
||||
}
|
||||
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new EntityFX(world, x + 0.5, y + 1, z + 0.5, 0.0, 0.0, 0.0) {
|
||||
double axisX = posX;
|
||||
double axisZ = posZ;
|
||||
double angle = 0.7 + (int) (worldObj.getTotalWorldTime() % 2L) * 3.1415;
|
||||
|
||||
{
|
||||
axisX = 0.0;
|
||||
axisZ = 0.0;
|
||||
angle = 0.0;
|
||||
motionX = 0.0;
|
||||
motionZ = 0.0;
|
||||
motionY = 0.012;
|
||||
particleMaxAge = 100;
|
||||
particleGravity = 0.0f;
|
||||
noClip = true;
|
||||
setRBGColorF(0.8f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
angle += 0.06;
|
||||
setPosition(axisX + 0.26 * Math.sin(angle), posY, axisZ + 0.26 * Math.cos(angle));
|
||||
setAlphaF((float) Math.cos(1.57 * particleAge / particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package binnie.genetics.machine.isolator;
|
||||
|
||||
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.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;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class IsolatorComponentLogic extends ComponentProcessSetCost implements IProcess {
|
||||
protected float enzymePerProcess;
|
||||
protected float ethanolPerProcess;
|
||||
|
||||
public IsolatorComponentLogic(Machine machine) {
|
||||
super(machine, 192000, 4800);
|
||||
enzymePerProcess = 0.5f;
|
||||
ethanolPerProcess = 10.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (getUtil().isSlotEmpty(Isolator.SLOT_TARGET)) {
|
||||
return new ErrorState.NoItem("No individual to isolate", Isolator.SLOT_TARGET);
|
||||
}
|
||||
// TODO check slot id in validation
|
||||
if (!getUtil().isSlotEmpty(Isolator.SLOT_RESULT)) {
|
||||
return new ErrorState.NoSpace("No room for DNA sequences", Isolator.SLOT_FINISHED);
|
||||
}
|
||||
if (getUtil().isSlotEmpty(Isolator.SLOT_SEQUENCER_VIAL)) {
|
||||
return new ErrorState.NoItem("No empty sequencer vials", Isolator.SLOT_SEQUENCER_VIAL);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (!getUtil().liquidInTank(Isolator.TANK_ETHANOL, (int) ethanolPerProcess)) {
|
||||
return new ErrorState.InsufficientLiquid("Insufficient ethanol", Isolator.TANK_ETHANOL);
|
||||
}
|
||||
if (getUtil().getSlotCharge(Isolator.SLOT_ENZYME) == 0.0f) {
|
||||
return new ErrorState.NoItem("No enzyme", Isolator.SLOT_ENZYME);
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
Random rand = getMachine().getWorld().rand;
|
||||
ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(getUtil().getStack(Isolator.SLOT_TARGET));
|
||||
if (root == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
IIndividual individual = root.getMember(getUtil().getStack(Isolator.SLOT_TARGET));
|
||||
if (individual == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
IAllele allele;
|
||||
IChromosomeType chromosome;
|
||||
Gene gene = null;
|
||||
if (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) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack serum = ItemSequence.create(gene);
|
||||
getUtil().setStack(Isolator.SLOT_RESULT, serum);
|
||||
getUtil().decreaseStack(Isolator.SLOT_SEQUENCER_VIAL, 1);
|
||||
if (rand.nextFloat() < 0.05f) {
|
||||
getUtil().decreaseStack(Isolator.SLOT_TARGET, 1);
|
||||
}
|
||||
getUtil().drainTank(Isolator.TANK_ETHANOL, (int) ethanolPerProcess);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
getMachine().getInterface(IChargedSlots.class)
|
||||
.alterCharge(Isolator.SLOT_ENZYME, -enzymePerProcess * getProgressPerTick() / 100.0f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package binnie.genetics.machine.isolator;
|
||||
|
||||
import binnie.core.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.machines.inventory.ComponentChargedSlots;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.ComponentInventoryTransfer;
|
||||
import binnie.core.machines.inventory.ComponentTankContainer;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import binnie.genetics.machine.ComponentGeneticGUI;
|
||||
import binnie.genetics.machine.ModuleMachine;
|
||||
import binnie.genetics.machine.PackageGeneticBase;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class IsolatorPackage extends PackageGeneticBase implements IMachineInformation {
|
||||
public IsolatorPackage() {
|
||||
super("isolator", GeneticsTexture.Isolator, 0xff6f0f, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Isolator);
|
||||
ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
InventorySlot enzymeSlot = inventory.addSlot(Isolator.SLOT_ENZYME, "enzyme");
|
||||
enzymeSlot.setValidator(new SlotValidator.Item(GeneticsItems.Enzyme.get(1), ModuleMachine.IconEnzyme));
|
||||
enzymeSlot.forbidExtraction();
|
||||
|
||||
InventorySlot vialSlot = inventory.addSlot(Isolator.SLOT_SEQUENCER_VIAL, "sequencervial");
|
||||
vialSlot.setValidator(new SlotValidator.Item(GeneticsItems.EmptySequencer.get(1), ModuleMachine.IconSequencer));
|
||||
vialSlot.forbidExtraction();
|
||||
|
||||
inventory.addSlotArray(Isolator.SLOT_RESERVE, "input");
|
||||
for (InventorySlot slot : inventory.getSlots(Isolator.SLOT_RESERVE)) {
|
||||
slot.setValidator(new SlotValidator.Individual());
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
|
||||
InventorySlot targetSlot = inventory.addSlot(Isolator.SLOT_TARGET, "process");
|
||||
targetSlot.setValidator(new SlotValidator.Individual());
|
||||
targetSlot.setReadOnly();
|
||||
targetSlot.forbidInteraction();
|
||||
|
||||
InventorySlot resultSlot = inventory.addSlot(Isolator.SLOT_RESULT, "output");
|
||||
resultSlot.setReadOnly();
|
||||
resultSlot.forbidInteraction();
|
||||
|
||||
inventory.addSlotArray(Isolator.SLOT_FINISHED, "output");
|
||||
for (InventorySlot slot : inventory.getSlots(Isolator.SLOT_FINISHED)) {
|
||||
slot.setReadOnly();
|
||||
slot.forbidInsertion();
|
||||
}
|
||||
|
||||
ComponentTankContainer tanks = new ComponentTankContainer(machine);
|
||||
tanks.addTank(Isolator.TANK_ETHANOL, "input", 1000);
|
||||
tanks.getTankSlot(Isolator.TANK_ETHANOL).setValidator(new EthanolTankValidator());
|
||||
|
||||
ComponentChargedSlots chargedSlots = new ComponentChargedSlots(machine);
|
||||
chargedSlots.addCharge(Isolator.SLOT_ENZYME);
|
||||
|
||||
ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Isolator.SLOT_RESERVE, Isolator.SLOT_TARGET, 1);
|
||||
transfer.addStorage(Isolator.SLOT_RESULT, Isolator.SLOT_FINISHED);
|
||||
new ComponentPowerReceptor(machine, 20000);
|
||||
new IsolatorComponentLogic(machine);
|
||||
new IsolatorComponentFX(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package binnie.genetics.machine.lab;
|
||||
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.machine.ComponentGUIHolder;
|
||||
import binnie.genetics.machine.MachineRendererLab;
|
||||
import binnie.genetics.machine.PackageGeneticBase;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
|
||||
public class LabMachinePackage extends PackageGeneticBase {
|
||||
public LabMachinePackage() {
|
||||
super("labMachine", GeneticsTexture.LabMachine, 0xffffff, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(Machine machine) {
|
||||
new ComponentGUIHolder(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderMachine(Machine machine, double x, double y, double z, float partialTick, RenderBlocks renderer) {
|
||||
MachineRendererLab.instance.renderMachine(machine, color, renderTexture, x, y, z, partialTick);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package binnie.genetics.machine.polymeriser;
|
||||
|
||||
public class Polymeriser {
|
||||
public static final int TANK_BACTERIA = 0;
|
||||
public static final int TANK_DNA = 1;
|
||||
public static final int SLOT_SERUM = 0;
|
||||
public static final int SLOT_GOLD = 1;
|
||||
public static final int[] SLOT_SERUM_RESERVE = new int[]{2, 3, 4, 5};
|
||||
public static final int[] SLOT_SERUM_FINISHED = new int[]{6, 7, 8, 9};
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package binnie.genetics.machine.polymeriser;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import binnie.core.machines.component.IRender;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class PolymeriserComponentFX extends MachineComponent implements IRender.RandomDisplayTick, IRender.DisplayTick {
|
||||
public PolymeriserComponentFX(IMachine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onRandomDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
int tick = (int) (world.getTotalWorldTime() % 8L);
|
||||
if ((tick == 0 || tick == 3) && getUtil().getProcess().isInProgress()) {
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new EntityFX(world, x + 0.5, y + 1.8, z + 0.5, 0.0, 0.0, 0.0) {
|
||||
double axisX = posX;
|
||||
double axisZ = posZ;
|
||||
double angle = 0.7 + (int) (worldObj.getTotalWorldTime() % 2L) * 3.1415;
|
||||
|
||||
{
|
||||
axisX = 0.0;
|
||||
axisZ = 0.0;
|
||||
angle = 0.0;
|
||||
motionX = 0.0;
|
||||
motionZ = 0.0;
|
||||
motionY = -0.006;
|
||||
particleMaxAge = 140;
|
||||
particleGravity = 0.0f;
|
||||
noClip = true;
|
||||
setRBGColorF(0.8f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
angle += 0.1;
|
||||
motionY = -0.006;
|
||||
double dist = 0.2;
|
||||
if (particleAge > 60) {
|
||||
if (particleAge > 120) {
|
||||
dist = 0.1;
|
||||
} else {
|
||||
dist = 0.2 - 0.1 * ((particleAge - 60.0f) / 60.0f);
|
||||
}
|
||||
}
|
||||
|
||||
setPosition(axisX + dist * Math.sin(angle), posY, axisZ + dist * Math.cos(angle));
|
||||
if (particleAge <= 40) {
|
||||
setAlphaF(particleAge / 40.0f);
|
||||
}
|
||||
if (particleAge > 80) {
|
||||
setRBGColorF(particleRed + (0.0f - particleRed) / 10.0f, particleGreen + (1.0f - particleGreen) / 10.0f, particleBlue + (1.0f - particleBlue) / 10.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package binnie.genetics.machine.polymeriser;
|
||||
|
||||
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.Engineering;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class PolymeriserComponentLogic extends ComponentProcessSetCost implements IProcess {
|
||||
private static float chargePerProcess = 0.4f;
|
||||
|
||||
private float dnaDrain;
|
||||
private float bacteriaDrain;
|
||||
|
||||
public PolymeriserComponentLogic(Machine machine) {
|
||||
super(machine, 96000, 2400);
|
||||
dnaDrain = 0.0f;
|
||||
bacteriaDrain = 0.0f;
|
||||
}
|
||||
|
||||
private float getCatalyst() {
|
||||
return (getUtil().getSlotCharge(1) > 0.0f) ? 0.2f : 1.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessLength() {
|
||||
return (int) (super.getProcessLength() * getNumberOfGenes() * getCatalyst());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessEnergy() {
|
||||
return (int) (super.getProcessEnergy() * getNumberOfGenes() * getCatalyst());
|
||||
}
|
||||
|
||||
private float getDNAPerProcess() {
|
||||
return getNumberOfGenes() * 50;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTickTask() {
|
||||
super.onTickTask();
|
||||
getUtil().useCharge(Polymeriser.SLOT_GOLD, PolymeriserComponentLogic.chargePerProcess * getProgressPerTick() / 100.0f);
|
||||
dnaDrain += getDNAPerProcess() * getProgressPerTick() / 100.0f;
|
||||
bacteriaDrain += 0.2f * getDNAPerProcess() * getProgressPerTick() / 100.0f;
|
||||
|
||||
if (dnaDrain >= 1.0f) {
|
||||
getUtil().drainTank(Polymeriser.TANK_DNA, 1);
|
||||
dnaDrain--;
|
||||
}
|
||||
|
||||
if (bacteriaDrain >= 1.0f) {
|
||||
getUtil().drainTank(Polymeriser.TANK_BACTERIA, 1);
|
||||
bacteriaDrain--;
|
||||
}
|
||||
}
|
||||
|
||||
private int getNumberOfGenes() {
|
||||
ItemStack serum = getUtil().getStack(Polymeriser.SLOT_SERUM);
|
||||
if (serum == null) {
|
||||
return 1;
|
||||
}
|
||||
return Engineering.getGenes(serum).length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
int n = getNumberOfGenes();
|
||||
return "Replicating " + n + " genes" + ((n > 1) ? "s" : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (getUtil().isSlotEmpty(Polymeriser.SLOT_SERUM)) {
|
||||
return new ErrorState.NoItem("No item to replicate", Polymeriser.SLOT_SERUM);
|
||||
}
|
||||
if (!getUtil().getStack(Polymeriser.SLOT_SERUM).isItemDamaged()) {
|
||||
return new ErrorState.InvalidItem("Item filled", Polymeriser.SLOT_SERUM);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (getUtil().getFluid(Polymeriser.TANK_BACTERIA) == null) {
|
||||
return new ErrorState.InsufficientLiquid("Insufficient Bacteria", Polymeriser.TANK_BACTERIA);
|
||||
}
|
||||
if (getUtil().getFluid(Polymeriser.TANK_DNA) == null) {
|
||||
return new ErrorState.InsufficientLiquid("Insufficient DNA", Polymeriser.TANK_DNA);
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
getUtil().damageItem(Polymeriser.SLOT_SERUM, -1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package binnie.genetics.machine.polymeriser;
|
||||
|
||||
import binnie.core.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.machines.inventory.ComponentChargedSlots;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.ComponentInventoryTransfer;
|
||||
import binnie.core.machines.inventory.ComponentTankContainer;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.machines.inventory.Validator;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.genetics.item.GeneticLiquid;
|
||||
import binnie.genetics.machine.ComponentGeneticGUI;
|
||||
import binnie.genetics.machine.ModuleMachine;
|
||||
import binnie.genetics.machine.PackageGeneticBase;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class PolymeriserPackage extends PackageGeneticBase implements IMachineInformation {
|
||||
public PolymeriserPackage() {
|
||||
super("polymeriser", GeneticsTexture.Polymeriser, 0x00e5c3, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Replicator);
|
||||
ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
InventorySlot goldSlot = inventory.addSlot(Polymeriser.SLOT_GOLD, "catalyst");
|
||||
goldSlot.setValidator(new SlotValidator.Item(new ItemStack(Items.gold_nugget, 1), ModuleMachine.IconNugget));
|
||||
goldSlot.forbidExtraction();
|
||||
|
||||
InventorySlot serumSlot = inventory.addSlot(Polymeriser.SLOT_SERUM, "process");
|
||||
serumSlot.setValidator(new UnfilledSerumSlotValidator());
|
||||
serumSlot.forbidInteraction();
|
||||
serumSlot.setReadOnly();
|
||||
|
||||
for (InventorySlot slot : inventory.addSlotArray(Polymeriser.SLOT_SERUM_RESERVE, "input")) {
|
||||
slot.setValidator(new UnfilledSerumSlotValidator());
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
|
||||
for (InventorySlot slot : inventory.addSlotArray(Polymeriser.SLOT_SERUM_FINISHED, "output")) {
|
||||
slot.setReadOnly();
|
||||
}
|
||||
|
||||
ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Polymeriser.SLOT_SERUM_RESERVE, Polymeriser.SLOT_SERUM, 1);
|
||||
transfer.addStorage(Polymeriser.SLOT_SERUM, Polymeriser.SLOT_SERUM_FINISHED, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(ItemStack stack) {
|
||||
return !stack.isItemDamaged();
|
||||
}
|
||||
});
|
||||
|
||||
ComponentTankContainer tank = new ComponentTankContainer(machine);
|
||||
tank.addTank(Polymeriser.TANK_BACTERIA, "input", 1000);
|
||||
tank.getTankSlot(Polymeriser.TANK_BACTERIA).setValidator(new Validator<FluidStack>() {
|
||||
@Override
|
||||
public boolean isValid(FluidStack itemStack) {
|
||||
return GeneticLiquid.BacteriaPoly.get(1).isFluidEqual(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Polymerising Bacteria";
|
||||
}
|
||||
});
|
||||
|
||||
tank.addTank(Polymeriser.TANK_DNA, "input", 1000);
|
||||
tank.getTankSlot(Polymeriser.TANK_DNA).setValidator(new Validator<FluidStack>() {
|
||||
@Override
|
||||
public boolean isValid(FluidStack itemStack) {
|
||||
return GeneticLiquid.RawDNA.get(1).isFluidEqual(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Raw DNA";
|
||||
}
|
||||
});
|
||||
|
||||
new ComponentChargedSlots(machine).addCharge(Polymeriser.SLOT_GOLD);
|
||||
new ComponentPowerReceptor(machine, 8000);
|
||||
new PolymeriserComponentLogic(machine);
|
||||
new PolymeriserComponentFX(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package binnie.genetics.machine.polymeriser;
|
||||
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.genetics.api.IItemChargable;
|
||||
import binnie.genetics.machine.ModuleMachine;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class UnfilledSerumSlotValidator extends SlotValidator {
|
||||
public UnfilledSerumSlotValidator() {
|
||||
super(ModuleMachine.IconSerum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(ItemStack itemStack) {
|
||||
return itemStack.getItem() instanceof IItemChargable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Unfilled Serum";
|
||||
}
|
||||
}
|
||||
+37
-35
@@ -12,8 +12,8 @@ import net.minecraft.world.World;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class ComponentSequencerFX extends MachineComponent implements IRender.RandomDisplayTick, IRender.DisplayTick {
|
||||
public ComponentSequencerFX(IMachine machine) {
|
||||
public class SequencerComponentFX extends MachineComponent implements IRender.RandomDisplayTick, IRender.DisplayTick {
|
||||
public SequencerComponentFX(IMachine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@@ -62,39 +62,41 @@ public class ComponentSequencerFX extends MachineComponent implements IRender.Ra
|
||||
@Override
|
||||
public void onDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
int ticks = (int) (world.getTotalWorldTime() % 16L);
|
||||
if (ticks == 0 && getUtil().getProcess().isInProgress()) {
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new EntityFX(world, x + 0.5, y + 1, z + 0.5, 0.0, 0.0, 0.0) {
|
||||
{
|
||||
motionX = 0.0;
|
||||
motionZ = 0.0;
|
||||
motionY = 0.012;
|
||||
particleMaxAge = 50;
|
||||
particleGravity = 0.0f;
|
||||
noClip = true;
|
||||
particleScale = 2.0f;
|
||||
|
||||
setParticleIcon((new BinnieIcon[]{
|
||||
Sequencer.fxSeqA,
|
||||
Sequencer.fxSeqG,
|
||||
Sequencer.fxSeqC,
|
||||
Sequencer.fxSeqT
|
||||
})[rand.nextInt(4)].getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
motionY = 0.012;
|
||||
if (particleAge > 40) {
|
||||
setAlphaF((50 - particleAge) / 10.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
if (ticks != 0 || !getUtil().getProcess().isInProgress()) {
|
||||
return;
|
||||
}
|
||||
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new EntityFX(world, x + 0.5, y + 1, z + 0.5, 0.0, 0.0, 0.0) {
|
||||
{
|
||||
motionX = 0.0;
|
||||
motionZ = 0.0;
|
||||
motionY = 0.012;
|
||||
particleMaxAge = 50;
|
||||
particleGravity = 0.0f;
|
||||
noClip = true;
|
||||
particleScale = 2.0f;
|
||||
|
||||
setParticleIcon((new BinnieIcon[]{
|
||||
Sequencer.fxSeqA,
|
||||
Sequencer.fxSeqG,
|
||||
Sequencer.fxSeqC,
|
||||
Sequencer.fxSeqT
|
||||
})[rand.nextInt(4)].getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
motionY = 0.012;
|
||||
if (particleAge > 40) {
|
||||
setAlphaF((50 - particleAge) / 10.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -10,8 +10,8 @@ import binnie.genetics.genetics.SequencerItem;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ComponentSequencerLogic extends ComponentProcess implements IProcess, ComponentInventoryTransfer.ITransferRestockListener {
|
||||
public ComponentSequencerLogic(Machine machine) {
|
||||
public class SequencerComponentLogic extends ComponentProcess implements IProcess, ComponentInventoryTransfer.ITransferRestockListener {
|
||||
public SequencerComponentLogic(Machine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
+8
-8
@@ -15,14 +15,14 @@ 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 binnie.genetics.machine.PackageGeneticBase;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class PackageSequencer extends GeneticMachine.PackageGeneticBase implements IMachineInformation {
|
||||
private ComponentSequencerLogic logic;
|
||||
public class SequencerPackage extends PackageGeneticBase implements IMachineInformation {
|
||||
private SequencerComponentLogic logic;
|
||||
|
||||
public PackageSequencer() {
|
||||
public SequencerPackage() {
|
||||
super("sequencer", GeneticsTexture.Sequencer, 0xb7ff32, true);
|
||||
Sequencer.fxSeqA = Binnie.Resource.getBlockIcon(Genetics.instance, "fx/sequencer.a");
|
||||
Sequencer.fxSeqG = Binnie.Resource.getBlockIcon(Genetics.instance, "fx/sequencer.g");
|
||||
@@ -41,12 +41,12 @@ public class PackageSequencer extends GeneticMachine.PackageGeneticBase implemen
|
||||
|
||||
inventory.addSlotArray(Sequencer.SLOT_RESERVE, "input");
|
||||
for (InventorySlot slot : inventory.getSlots(Sequencer.SLOT_RESERVE)) {
|
||||
slot.setValidator(new SlotValidatorUnsequenced());
|
||||
slot.setValidator(new UnsequencedSlotValidator());
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
|
||||
InventorySlot slotTarget = inventory.addSlot(Sequencer.SLOT_TARGET_INDEX, "process");
|
||||
slotTarget.setValidator(new SlotValidatorUnsequenced());
|
||||
slotTarget.setValidator(new UnsequencedSlotValidator());
|
||||
slotTarget.setReadOnly();
|
||||
slotTarget.forbidInteraction();
|
||||
|
||||
@@ -58,9 +58,9 @@ public class PackageSequencer extends GeneticMachine.PackageGeneticBase implemen
|
||||
|
||||
new ComponentChargedSlots(machine).addCharge(Sequencer.SLOT_DYE_INDEX);
|
||||
new ComponentPowerReceptor(machine, 10000);
|
||||
new ComponentSequencerFX(machine);
|
||||
new SequencerComponentFX(machine);
|
||||
|
||||
logic = new ComponentSequencerLogic(machine);
|
||||
logic = new SequencerComponentLogic(machine);
|
||||
transfer.setTransferListener(logic);
|
||||
}
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@ import binnie.genetics.genetics.SequencerItem;
|
||||
import binnie.genetics.machine.ModuleMachine;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotValidatorUnsequenced extends SlotValidator {
|
||||
public SlotValidatorUnsequenced() {
|
||||
public class UnsequencedSlotValidator extends SlotValidator {
|
||||
public UnsequencedSlotValidator() {
|
||||
super(ModuleMachine.IconSequencer);
|
||||
}
|
||||
|
||||
@@ -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 IndividualInoculateValidator extends SlotValidator {
|
||||
public IndividualInoculateValidator() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(ItemStack object) {
|
||||
ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(object);
|
||||
return root != null && Binnie.Genetics.getSystem(root).isDNAManipulable(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Splicable Individual";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package binnie.genetics.machine.splicer;
|
||||
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.genetics.api.IItemSerum;
|
||||
import binnie.genetics.machine.ModuleMachine;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
class SerumSlotValidator extends SlotValidator {
|
||||
public SerumSlotValidator() {
|
||||
super(ModuleMachine.IconSerum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(ItemStack itemStack) {
|
||||
return itemStack.getItem() instanceof IItemSerum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Serum Vials & Arrays";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
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(IGene gene, ItemStack target, int chromoN) {
|
||||
int chromosomeID = gene.getChromosome().ordinal();
|
||||
if (chromosomeID >= EnumBeeChromosome.HUMIDITY.ordinal() && gene.getSpeciesRoot() instanceof IBeeRoot) {
|
||||
chromosomeID--;
|
||||
}
|
||||
|
||||
Class<? extends IAllele> cls = gene.getChromosome().getAlleleClass();
|
||||
if (!cls.isInstance(gene.getAllele())) {
|
||||
return;
|
||||
}
|
||||
|
||||
NBTTagCompound beeNBT = target.getTagCompound();
|
||||
NBTTagCompound genomeNBT = beeNBT.getCompoundTag("Genome");
|
||||
NBTTagList chromosomes = genomeNBT.getTagList("Chromosomes", 10);
|
||||
NBTTagCompound chromosomeNBT = chromosomes.getCompoundTagAt(chromosomeID);
|
||||
chromosomeNBT.setString("UID" + chromoN, gene.getAllele().getUID());
|
||||
target.setTagCompound(beeNBT);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package binnie.genetics.machine.splicer;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import binnie.core.machines.component.IRender;
|
||||
import binnie.core.machines.network.INetwork;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class SplicerComponentFX extends MachineComponent implements
|
||||
IRender.RandomDisplayTick,
|
||||
IRender.DisplayTick,
|
||||
IRender.Render,
|
||||
INetwork.TilePacketSync {
|
||||
private EntityItem dummyEntityItem;
|
||||
|
||||
public SplicerComponentFX(IMachine machine) {
|
||||
super(machine);
|
||||
dummyEntityItem = new EntityItem(null);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onRandomDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
int tick = (int) (world.getTotalWorldTime() % 3L);
|
||||
if (tick != 0 || !getUtil().getProcess().isInProgress()) {
|
||||
return;
|
||||
}
|
||||
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new EntityFX(world, x + 0.5, y + 1.5, z + 0.5, 0.0, 0.0, 0.0) {
|
||||
double axisX = posX;
|
||||
double axisZ = posZ;
|
||||
double angle = (int) (worldObj.getTotalWorldTime() % 4L) * 0.5 * 3.1415;
|
||||
|
||||
{
|
||||
axisX = 0.0;
|
||||
axisZ = 0.0;
|
||||
angle = 0.0;
|
||||
motionX = 0.0;
|
||||
motionZ = 0.0;
|
||||
motionY = (rand.nextDouble() - 0.5) * 0.02;
|
||||
particleMaxAge = 240;
|
||||
particleGravity = 0.0f;
|
||||
noClip = true;
|
||||
setRBGColorF(0.3f + rand.nextFloat() * 0.5f, 0.3f + rand.nextFloat() * 0.5f, 0.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
double speed = 0.04;
|
||||
angle -= speed;
|
||||
double dist = 0.25 + 0.2 * Math.sin(particleAge / 50.0f);
|
||||
setPosition(axisX + dist * Math.sin(angle), posY, axisZ + dist * Math.cos(angle));
|
||||
setAlphaF((float) Math.cos(1.57 * particleAge / particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void renderInWorld(RenderItem renderItem, double x, double y, double z) {
|
||||
if (!getUtil().getProcess().isInProgress()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack stack = getUtil().getStack(Splicer.SLOT_TARGET);
|
||||
dummyEntityItem.worldObj = getMachine().getWorld();
|
||||
dummyEntityItem.setEntityItemStack(stack);
|
||||
EntityItem dummyEntityItem = this.dummyEntityItem;
|
||||
dummyEntityItem.age++;
|
||||
this.dummyEntityItem.hoverStart = 0.0f;
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(180.0f, 0.0f, 0.0f, 1.0f);
|
||||
GL11.glTranslatef(0.0f, -0.25f, 0.0f);
|
||||
renderItem.doRender(this.dummyEntityItem, 0.0, 0.0, 0.0, 0.0f, 0.0f);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncToNBT(NBTTagCompound nbt) {
|
||||
NBTTagCompound item = new NBTTagCompound();
|
||||
ItemStack stack = getUtil().getStack(Splicer.SLOT_TARGET);
|
||||
if (stack != null) {
|
||||
stack.writeToNBT(item);
|
||||
nbt.setTag("item", item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncFromNBT(NBTTagCompound nbt) {
|
||||
if (nbt.hasKey("item")) {
|
||||
getUtil().setStack(Splicer.SLOT_TARGET, ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("item")));
|
||||
} else {
|
||||
getUtil().setStack(Splicer.SLOT_TARGET, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryUpdate() {
|
||||
if (!getUtil().isServer()) {
|
||||
return;
|
||||
}
|
||||
getUtil().refreshBlock();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
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.IChromosomeType;
|
||||
import forestry.api.genetics.IGenome;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class SplicerComponentLogic extends ComponentProcessSetCost implements IProcess {
|
||||
public int nOfGenes;
|
||||
|
||||
public SplicerComponentLogic(Machine machine) {
|
||||
super(machine, 12000000, 1200);
|
||||
nOfGenes = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessLength() {
|
||||
float n = 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 = getNumberOfGenes();
|
||||
if (n > 1.0f) {
|
||||
n = 1.0f + (n - 1.0f) * 0.5f;
|
||||
}
|
||||
return (int) (super.getProcessEnergy() * n);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryUpdate() {
|
||||
super.onInventoryUpdate();
|
||||
nOfGenes = getGenesToUse();
|
||||
}
|
||||
|
||||
protected int getGenesToUse() {
|
||||
ItemStack serum = getUtil().getStack(Splicer.SLOT_SERUM_VIAL);
|
||||
ItemStack target = getUtil().getStack(Splicer.SLOT_TARGET);
|
||||
if (serum == null || target == null) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
IIndividual ind = AlleleManager.alleleRegistry.getIndividual(target);
|
||||
IGene[] genes = ((IItemSerum) serum.getItem()).getGenes(serum);
|
||||
if (ind.getGenome().getSpeciesRoot() != ((IItemSerum) serum.getItem()).getSpeciesRoot(serum)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for (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() {
|
||||
ItemStack serum = getUtil().getStack(Splicer.SLOT_SERUM_VIAL);
|
||||
if (serum == null) {
|
||||
return 1;
|
||||
}
|
||||
return Engineering.getGenes(serum).length;
|
||||
}
|
||||
|
||||
private int getNumberOfGenes() {
|
||||
return nOfGenes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
int n = getNumberOfGenes();
|
||||
int f = getFullNumberOfGenes();
|
||||
return "Splicing in " + n + ((f > 1) ? ("/" + f) : "") + " gene" + ((n > 1) ? "s" : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (getUtil().isSlotEmpty(Splicer.SLOT_TARGET)) {
|
||||
return new ErrorState.NoItem("No Individual to Splice", Splicer.SLOT_TARGET);
|
||||
}
|
||||
if (getUtil().isSlotEmpty(Splicer.SLOT_SERUM_VIAL)) {
|
||||
return new ErrorState.NoItem("No Serum", Splicer.SLOT_SERUM_VIAL);
|
||||
}
|
||||
|
||||
ErrorState state = isValidSerum();
|
||||
if (state != null) {
|
||||
return state;
|
||||
}
|
||||
|
||||
if (getUtil().getStack(0) != null && Engineering.getCharges(getUtil().getStack(Splicer.SLOT_SERUM_VIAL)) == 0) {
|
||||
return new ErrorState("Empty Serum", "Serum is empty");
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
public ErrorState isValidSerum() {
|
||||
ItemStack serum = getUtil().getStack(Splicer.SLOT_SERUM_VIAL);
|
||||
ItemStack target = getUtil().getStack(Splicer.SLOT_TARGET);
|
||||
IGene[] genes = Engineering.getGenes(serum);
|
||||
if (genes.length == 0) {
|
||||
return new ErrorState("Invalid Serum", "Serum does not hold any genes");
|
||||
}
|
||||
if (!genes[0].getSpeciesRoot().isMember(target)) {
|
||||
return new ErrorState("Invalid Serum", "Mismatch of Serum Type and Target");
|
||||
}
|
||||
|
||||
IIndividual individual = genes[0].getSpeciesRoot().getMember(target);
|
||||
boolean hasAll = true;
|
||||
for (IGene gene : genes) {
|
||||
if (hasAll) {
|
||||
IGenome genome = individual.getGenome();
|
||||
IChromosomeType chromosome = gene.getChromosome();
|
||||
String geneAlleleUID = gene.getAllele().getUID();
|
||||
IAllele a = genome.getActiveAllele(chromosome);
|
||||
IAllele b = genome.getInactiveAllele(chromosome);
|
||||
hasAll = a.getUID().equals(geneAlleleUID)
|
||||
&& b.getUID().equals(geneAlleleUID);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasAll) {
|
||||
return new ErrorState("Defunct Serum", "Individual already possesses this allele");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
ItemStack serum = getUtil().getStack(Splicer.SLOT_SERUM_VIAL);
|
||||
ItemStack target = getUtil().getStack(Splicer.SLOT_TARGET);
|
||||
IIndividual ind = AlleleManager.alleleRegistry.getIndividual(target);
|
||||
if (!ind.isAnalyzed()) {
|
||||
ind.analyze();
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
ind.writeToNBT(nbttagcompound);
|
||||
target.setTagCompound(nbttagcompound);
|
||||
}
|
||||
|
||||
IGene[] genes = ((IItemSerum) serum.getItem()).getGenes(serum);
|
||||
for (IGene gene : genes) {
|
||||
Splicer.setGene(gene, target, 0);
|
||||
Splicer.setGene(gene, target, 1);
|
||||
}
|
||||
getUtil().damageItem(Splicer.SLOT_SERUM_VIAL, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package binnie.genetics.machine.splicer;
|
||||
|
||||
import binnie.core.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.ComponentInventoryTransfer;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
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 net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class SplicerPackage extends AdvGeneticMachine.PackageAdvGeneticBase implements IMachineInformation {
|
||||
public SplicerPackage() {
|
||||
super("splicer", GeneticsTexture.Splicer, 0xe22235, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Splicer);
|
||||
ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
SlotValidator serumValid = new SerumSlotValidator();
|
||||
|
||||
InventorySlot serumSlot = inventory.addSlot(Splicer.SLOT_SERUM_VIAL, "serum.active");
|
||||
serumSlot.forbidInteraction();
|
||||
serumSlot.setReadOnly();
|
||||
serumSlot.setValidator(serumValid);
|
||||
|
||||
inventory.addSlotArray(Splicer.SLOT_SERUM_RESERVE, "serum.input");
|
||||
for (InventorySlot slot : inventory.getSlots(Splicer.SLOT_SERUM_RESERVE)) {
|
||||
slot.setValidator(serumValid);
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
|
||||
inventory.addSlotArray(Splicer.SLOT_SERUM_EXPENDED, "serum.output");
|
||||
for (InventorySlot slot : inventory.getSlots(Splicer.SLOT_SERUM_EXPENDED)) {
|
||||
slot.setValidator(serumValid);
|
||||
slot.setReadOnly();
|
||||
}
|
||||
|
||||
inventory.addSlotArray(Splicer.SLOT_RESERVE, "input");
|
||||
for (InventorySlot slot : inventory.getSlots(Splicer.SLOT_RESERVE)) {
|
||||
slot.forbidExtraction();
|
||||
slot.setValidator(new IndividualInoculateValidator());
|
||||
}
|
||||
|
||||
InventorySlot targetSlot = inventory.addSlot(Splicer.SLOT_TARGET, "process");
|
||||
targetSlot.setValidator(new IndividualInoculateValidator());
|
||||
targetSlot.setReadOnly();
|
||||
targetSlot.forbidInteraction();
|
||||
|
||||
inventory.addSlotArray(Splicer.SLOT_FINISHED, "output");
|
||||
for (InventorySlot slot : inventory.getSlots(Splicer.SLOT_FINISHED)) {
|
||||
slot.setReadOnly();
|
||||
slot.forbidInsertion();
|
||||
slot.setValidator(new IndividualInoculateValidator());
|
||||
}
|
||||
|
||||
ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Splicer.SLOT_RESERVE, Splicer.SLOT_TARGET, 1);
|
||||
transfer.addRestock(Splicer.SLOT_SERUM_RESERVE, Splicer.SLOT_SERUM_VIAL);
|
||||
transfer.addStorage(Splicer.SLOT_SERUM_VIAL, Splicer.SLOT_SERUM_EXPENDED, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(ItemStack stack) {
|
||||
return Engineering.getCharges(stack) == 0;
|
||||
}
|
||||
});
|
||||
transfer.addStorage(Splicer.SLOT_TARGET, Splicer.SLOT_FINISHED, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(ItemStack stack) {
|
||||
return stack != null
|
||||
&& transfer.getMachine().getMachineUtil().getStack(Splicer.SLOT_SERUM_VIAL) != null
|
||||
&& transfer.getMachine().getInterface(SplicerComponentLogic.class).isValidSerum() != null;
|
||||
}
|
||||
});
|
||||
|
||||
new ComponentPowerReceptor(machine, 20000);
|
||||
new SplicerComponentLogic(machine);
|
||||
new SplicerComponentFX(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user