mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-23 21:49:49 +00:00
port to forestry 4.2
This commit is contained in:
1 parent
dbc5c1a564
commit
f969f63b66
3697 files changed
+78372
No files matched your search
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import binnie.extrabees.ExtraBees;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
|
||||
public class CreativeTabGenetics extends CreativeTabs
|
||||
{
|
||||
public static CreativeTabs instance;
|
||||
|
||||
@Override
|
||||
public ItemStack getIconItemStack() {
|
||||
return GeneticsItems.EmptySerum.get(1);
|
||||
}
|
||||
|
||||
public CreativeTabGenetics() {
|
||||
super("Genetics");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTranslatedTabLabel() {
|
||||
return this.getTabLabel();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getTabLabel() {
|
||||
return ExtraBees.proxy.localise("tab.genetics");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Item getTabIconItem() {
|
||||
return null;
|
||||
}
|
||||
|
||||
static {
|
||||
CreativeTabGenetics.instance = new CreativeTabGenetics();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.network.BinniePacketHandler;
|
||||
import binnie.core.proxy.IProxyCore;
|
||||
import binnie.genetics.core.GeneticsPacket;
|
||||
import binnie.core.network.IPacketID;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.core.gui.IBinnieGUID;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import binnie.genetics.machine.ModuleMachine;
|
||||
import binnie.genetics.item.ModuleItem;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import binnie.genetics.item.ItemAnalyst;
|
||||
import binnie.genetics.item.ItemDatabase;
|
||||
import binnie.core.machines.MachineGroup;
|
||||
import net.minecraft.item.Item;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import binnie.genetics.proxy.Proxy;
|
||||
import binnie.genetics.item.ItemSerumArray;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import binnie.core.AbstractMod;
|
||||
|
||||
@Mod(modid = "Genetics", name = "Genetics", useMetadata = true, dependencies = "after:BinnieCore")
|
||||
public class Genetics extends AbstractMod
|
||||
{
|
||||
public static ItemSerumArray itemSerumArray;
|
||||
@Mod.Instance("Genetics")
|
||||
public static Genetics instance;
|
||||
@SidedProxy(clientSide = "binnie.genetics.proxy.ProxyClient", serverSide = "binnie.genetics.proxy.ProxyServer")
|
||||
public static Proxy proxy;
|
||||
public static String channel;
|
||||
public static Item itemGenetics;
|
||||
public static Item itemSerum;
|
||||
public static Item itemSequencer;
|
||||
public static MachineGroup packageGenetic;
|
||||
public static MachineGroup packageAdvGenetic;
|
||||
public static MachineGroup packageLabMachine;
|
||||
public static ItemDatabase database;
|
||||
public static ItemAnalyst analyst;
|
||||
public static Item registry;
|
||||
public static Item masterRegistry;
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(final FMLPreInitializationEvent evt) {
|
||||
this.addModule(new ModuleItem());
|
||||
this.addModule(new ModuleMachine());
|
||||
this.preInit();
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(final FMLInitializationEvent evt) {
|
||||
this.init();
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void postInit(final FMLPostInitializationEvent evt) {
|
||||
this.postInit();
|
||||
}
|
||||
|
||||
public Genetics() {
|
||||
Genetics.instance = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinnieGUID[] getGUIDs() {
|
||||
return GeneticsGUI.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacketID[] getPacketIDs() {
|
||||
return GeneticsPacket.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChannel() {
|
||||
return "GEN";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IProxyCore getProxy() {
|
||||
return Genetics.proxy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModID() {
|
||||
return "genetics";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BinniePacketHandler> getPacketHandler() {
|
||||
return PacketHandler.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return BinnieCore.isGeneticsActive();
|
||||
}
|
||||
|
||||
static {
|
||||
Genetics.itemSerumArray = null;
|
||||
Genetics.channel = "GEN";
|
||||
}
|
||||
|
||||
public static class PacketHandler extends BinniePacketHandler
|
||||
{
|
||||
public PacketHandler() {
|
||||
super(Genetics.instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.api;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.core.INBTTagable;
|
||||
|
||||
public interface IGene extends INBTTagable
|
||||
{
|
||||
IChromosomeType getChromosome();
|
||||
|
||||
String getName();
|
||||
|
||||
ISpeciesRoot getSpeciesRoot();
|
||||
|
||||
IAllele getAllele();
|
||||
|
||||
NBTTagCompound getNBTTagCompound();
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.api;
|
||||
|
||||
import binnie.core.machines.MachineUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public interface IIncubatorRecipe
|
||||
{
|
||||
boolean isInputLiquid(final FluidStack p0);
|
||||
|
||||
boolean isInputLiquidSufficient(final FluidStack p0);
|
||||
|
||||
boolean isItemStack(final ItemStack p0);
|
||||
|
||||
void doTask(final MachineUtil p0);
|
||||
|
||||
float getChance();
|
||||
|
||||
boolean roomForOutput(final MachineUtil p0);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.api;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IItemAnalysable
|
||||
{
|
||||
boolean isAnalysed(final ItemStack p0);
|
||||
|
||||
ItemStack analyse(final ItemStack p0);
|
||||
|
||||
@Deprecated
|
||||
float getAnalyseTimeMult(final ItemStack p0);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.api;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IItemChargable
|
||||
{
|
||||
int getCharges(final ItemStack p0);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.api;
|
||||
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IItemSerum extends IItemChargable
|
||||
{
|
||||
IGene[] getGenes(final ItemStack p0);
|
||||
|
||||
ISpeciesRoot getSpeciesRoot(final ItemStack p0);
|
||||
|
||||
IGene getGene(final ItemStack p0, final int p1);
|
||||
|
||||
ItemStack addGene(final ItemStack p0, final IGene p1);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.config;
|
||||
|
||||
import binnie.core.mod.config.ConfigFile;
|
||||
|
||||
@ConfigFile(filename = "/config/forestry/genetics/main.conf")
|
||||
public class ConfigurationMain
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.core;
|
||||
|
||||
import binnie.craftgui.genetics.machine.WindowSplicer;
|
||||
import binnie.craftgui.genetics.machine.WindowAcclimatiser;
|
||||
import binnie.craftgui.genetics.machine.WindowIncubator;
|
||||
import binnie.craftgui.genetics.machine.WindowAnalyser;
|
||||
import binnie.craftgui.genetics.machine.WindowInoculator;
|
||||
import binnie.craftgui.genetics.machine.WindowPolymeriser;
|
||||
import binnie.craftgui.genetics.machine.WindowSequencer;
|
||||
import binnie.craftgui.genetics.machine.WindowIsolator;
|
||||
import binnie.craftgui.genetics.machine.WindowGenepool;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import binnie.craftgui.genetics.machine.WindowGeneBankNEI;
|
||||
import binnie.craftgui.genetics.machine.WindowGeneBank;
|
||||
import net.minecraft.world.World;
|
||||
import java.lang.reflect.Constructor;
|
||||
import binnie.genetics.gui.WindowAnalyst;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.core.gui.IBinnieGUID;
|
||||
|
||||
public enum GeneticsGUI implements IBinnieGUID
|
||||
{
|
||||
Genepool(WindowGenepool.class),
|
||||
Isolator(WindowIsolator.class),
|
||||
Sequencer(WindowSequencer.class),
|
||||
Replicator(WindowPolymeriser.class),
|
||||
Inoculator(WindowInoculator.class),
|
||||
GeneBank(WindowGeneBank.class),
|
||||
Analyser(WindowAnalyser.class),
|
||||
Incubator(WindowIncubator.class),
|
||||
Database(WindowGeneBank.class),
|
||||
DatabaseNEI(WindowGeneBankNEI.class),
|
||||
Acclimatiser(WindowAcclimatiser.class),
|
||||
Splicer(WindowSplicer.class),
|
||||
Analyst,
|
||||
Registry,
|
||||
MasterRegistry;
|
||||
|
||||
Class<? extends Window> windowClass;
|
||||
|
||||
private GeneticsGUI()
|
||||
{
|
||||
}
|
||||
|
||||
private GeneticsGUI(final Class window) {
|
||||
this.windowClass = window;
|
||||
}
|
||||
|
||||
public Window getWindow(final EntityPlayer player, final IInventory object, final Side side) throws Exception {
|
||||
switch (this) {
|
||||
case Analyst: {
|
||||
return new WindowAnalyst(player, null, side, false, false);
|
||||
}
|
||||
case MasterRegistry: {
|
||||
return new WindowAnalyst(player, null, side, true, true);
|
||||
}
|
||||
case Registry: {
|
||||
return new WindowAnalyst(player, null, side, true, false);
|
||||
}
|
||||
default: {
|
||||
final Constructor constr = this.windowClass.getConstructor(EntityPlayer.class, IInventory.class, Side.class);
|
||||
return (Window) constr.newInstance(player, object, side);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Window getWindow(final EntityPlayer player, final World world, final int x, final int y, final int z, final Side side) {
|
||||
Window window = null;
|
||||
final TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
IInventory object = null;
|
||||
if (tileEntity instanceof IInventory) {
|
||||
object = (IInventory) tileEntity;
|
||||
}
|
||||
try {
|
||||
if (this == GeneticsGUI.Database || this == GeneticsGUI.GeneBank) {
|
||||
window = WindowGeneBank.create(player, object, side);
|
||||
}
|
||||
else if (this == GeneticsGUI.DatabaseNEI) {
|
||||
window = WindowGeneBankNEI.create(player, object, side);
|
||||
}
|
||||
else {
|
||||
window = this.getWindow(player, object, side);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return window;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.core;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import binnie.genetics.genetics.GeneTracker;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.network.packet.MessageNBT;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import binnie.core.network.packet.MessageBinnie;
|
||||
import binnie.core.network.IPacketID;
|
||||
|
||||
public enum GeneticsPacket implements IPacketID
|
||||
{
|
||||
GeneTrackerSync;
|
||||
|
||||
@Override
|
||||
public void onMessage(final MessageBinnie message, final MessageContext context) {
|
||||
if (this == GeneticsPacket.GeneTrackerSync && context.side == Side.CLIENT) {
|
||||
final MessageNBT packet = new MessageNBT(message);
|
||||
final EntityPlayer player = BinnieCore.proxy.getPlayer();
|
||||
GeneTracker tracker = null;
|
||||
tracker = GeneTracker.getTracker(BinnieCore.proxy.getWorld(), player.getGameProfile());
|
||||
if (tracker != null) {
|
||||
tracker.readFromNBT(packet.getTagCompound());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.core;
|
||||
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.Binnie;
|
||||
import binnie.core.resource.BinnieResource;
|
||||
import binnie.core.resource.BinnieIcon;
|
||||
import binnie.core.resource.ResourceType;
|
||||
import binnie.core.resource.IBinnieTexture;
|
||||
|
||||
public enum GeneticsTexture implements IBinnieTexture
|
||||
{
|
||||
GeneticMachine(ResourceType.Tile, "GeneticMachine"),
|
||||
Genepool(ResourceType.Tile, "Genepool"),
|
||||
Incubator(ResourceType.Tile, "Incubator"),
|
||||
GUIProcess(ResourceType.GUI, "process"),
|
||||
GUIProcess2(ResourceType.GUI, "process2"),
|
||||
Isolator(ResourceType.Tile, "Isolator"),
|
||||
Sequencer(ResourceType.Tile, "Sequencer"),
|
||||
Polymeriser(ResourceType.Tile, "Polymeriser"),
|
||||
Inoculator(ResourceType.Tile, "Inoculator"),
|
||||
Analyser(ResourceType.Tile, "Analyser"),
|
||||
MachineGlow(ResourceType.Tile, "MachineGlow"),
|
||||
GeneBank(ResourceType.Tile, "GeneBank"),
|
||||
LabMachine(ResourceType.Tile, "LabMachine"),
|
||||
Acclimatiser(ResourceType.Tile, "Acclimatiser"),
|
||||
Splicer(ResourceType.Tile, "Splicer");
|
||||
|
||||
String texture;
|
||||
ResourceType type;
|
||||
public static BinnieIcon dnaIcon;
|
||||
|
||||
private GeneticsTexture(final ResourceType base, final String texture) {
|
||||
this.texture = texture;
|
||||
this.type = base;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BinnieResource getTexture() {
|
||||
return Binnie.Resource.getPNG(Genetics.instance, this.type, this.texture);
|
||||
}
|
||||
|
||||
static {
|
||||
GeneticsTexture.dnaIcon = Binnie.Resource.getItemIcon(Genetics.instance, "dna");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.genetics;
|
||||
|
||||
import binnie.genetics.api.IItemChargable;
|
||||
import binnie.genetics.item.ItemSerumArray;
|
||||
import binnie.genetics.item.ItemSerum;
|
||||
import binnie.genetics.api.IGene;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.api.IItemSerum;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class Engineering
|
||||
{
|
||||
public static boolean isGeneAcceptor(final ItemStack stack) {
|
||||
if (stack == null) {
|
||||
return false;
|
||||
}
|
||||
if (stack.getItem() instanceof IItemSerum) {
|
||||
return ((IItemSerum) stack.getItem()).getCharges(stack) == 0;
|
||||
}
|
||||
return stack.getItem() == Genetics.itemGenetics && (stack.getItemDamage() == GeneticsItems.EmptySerum.ordinal() || stack.getItemDamage() == GeneticsItems.EmptyGenome.ordinal());
|
||||
}
|
||||
|
||||
public static boolean canAcceptGene(final ItemStack stack, final IGene gene) {
|
||||
if (stack.getItem() instanceof ItemSerum) {
|
||||
return true;
|
||||
}
|
||||
if (stack.getItem() instanceof IItemSerum) {
|
||||
return ((IItemSerum) stack.getItem()).getSpeciesRoot(stack) == gene.getSpeciesRoot();
|
||||
}
|
||||
return isGeneAcceptor(stack);
|
||||
}
|
||||
|
||||
public static IGene getGene(final ItemStack stack, final int chromosome) {
|
||||
if (stack.getItem() instanceof IItemSerum) {
|
||||
return ((IItemSerum) stack.getItem()).getGene(stack, chromosome);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ItemStack addGene(final ItemStack stack, final IGene gene) {
|
||||
if (stack.getItem() instanceof IItemSerum) {
|
||||
((IItemSerum) stack.getItem()).addGene(stack, gene);
|
||||
}
|
||||
if (stack.getItem() == Genetics.itemGenetics && stack.getItemDamage() == GeneticsItems.EmptySerum.ordinal()) {
|
||||
return ItemSerum.create(gene);
|
||||
}
|
||||
if (stack.getItem() == Genetics.itemGenetics && stack.getItemDamage() == GeneticsItems.EmptyGenome.ordinal()) {
|
||||
return ItemSerumArray.create(gene);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
public static IGene[] getGenes(final ItemStack serum) {
|
||||
if (serum.getItem() instanceof IItemSerum) {
|
||||
return ((IItemSerum) serum.getItem()).getGenes(serum);
|
||||
}
|
||||
if (serum.getItem() == Genetics.itemSequencer) {
|
||||
return new IGene[] { new SequencerItem(serum).gene };
|
||||
}
|
||||
return new IGene[0];
|
||||
}
|
||||
|
||||
public static int getCharges(final ItemStack serum) {
|
||||
return ((IItemChargable) serum.getItem()).getCharges(serum);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.genetics;
|
||||
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import binnie.core.genetics.Gene;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import binnie.Binnie;
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import binnie.core.BinnieCore;
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.genetics.api.IGene;
|
||||
import java.util.List;
|
||||
import forestry.api.core.INBTTagable;
|
||||
|
||||
public class GeneArrayItem implements INBTTagable, IGeneItem
|
||||
{
|
||||
List<IGene> genes;
|
||||
|
||||
public GeneArrayItem(final ItemStack stack) {
|
||||
this.genes = new ArrayList<IGene>();
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
this.readFromNBT(stack.getTagCompound());
|
||||
}
|
||||
|
||||
public GeneArrayItem(final IGene gene) {
|
||||
this.genes = new ArrayList<IGene>();
|
||||
this.addGene(gene);
|
||||
}
|
||||
|
||||
public GeneArrayItem() {
|
||||
this.genes = new ArrayList<IGene>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColour(final int renderPass) {
|
||||
if (renderPass == 2) {
|
||||
return this.getBreedingSystem().getColour();
|
||||
}
|
||||
return 16777215;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getInfo(final List list) {
|
||||
final List<Object> totalList = new ArrayList<Object>();
|
||||
for (final IGene gene : this.genes) {
|
||||
final String chromosomeName = this.getBreedingSystem().getChromosomeName(gene.getChromosome());
|
||||
totalList.add("§6" + chromosomeName + "§7: " + gene.getName());
|
||||
}
|
||||
if (totalList.size() < 4 || BinnieCore.proxy.isShiftDown()) {
|
||||
list.addAll(totalList);
|
||||
}
|
||||
else {
|
||||
list.add(totalList.get(0));
|
||||
list.add(totalList.get(1));
|
||||
list.add(totalList.size() - 2 + " more genes. Hold shift to display.");
|
||||
}
|
||||
}
|
||||
|
||||
public BreedingSystem getBreedingSystem() {
|
||||
if (this.genes.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
final BreedingSystem system = Binnie.Genetics.getSystem(this.genes.get(0).getSpeciesRoot().getUID());
|
||||
return (system == null) ? Binnie.Genetics.getActiveSystems().iterator().next() : system;
|
||||
}
|
||||
|
||||
public List<IGene> getGenes() {
|
||||
return this.genes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound nbt) {
|
||||
this.genes.clear();
|
||||
if (nbt != null) {
|
||||
final NBTTagList list = nbt.getTagList("genes", 10);
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
final Gene gene = Gene.create(list.getCompoundTagAt(i));
|
||||
this.genes.add(gene);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound nbt) {
|
||||
if (this.genes.size() == 0) {
|
||||
return;
|
||||
}
|
||||
final NBTTagList list = new NBTTagList();
|
||||
for (final IGene gene : this.genes) {
|
||||
final NBTTagCompound geneNBT = gene.getNBTTagCompound();
|
||||
list.appendTag(geneNBT);
|
||||
}
|
||||
nbt.setTag("genes", list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISpeciesRoot getSpeciesRoot() {
|
||||
if (this.genes.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
return this.genes.get(0).getSpeciesRoot();
|
||||
}
|
||||
|
||||
public IGene getGene(final int chromosome) {
|
||||
for (final IGene gene : this.genes) {
|
||||
if (gene.getChromosome().ordinal() == chromosome) {
|
||||
return gene;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToItem(final ItemStack stack) {
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
final NBTTagCompound nbt = stack.hasTagCompound() ? stack.getTagCompound() : new NBTTagCompound();
|
||||
this.writeToNBT(nbt);
|
||||
stack.setTagCompound(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGene(final IGene gene) {
|
||||
if (this.getGene(gene.getChromosome().ordinal()) != null) {
|
||||
this.genes.remove(this.getGene(gene.getChromosome().ordinal()));
|
||||
}
|
||||
this.genes.add(gene);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.genetics;
|
||||
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import binnie.core.genetics.Gene;
|
||||
import binnie.Binnie;
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import java.util.List;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.genetics.api.IGene;
|
||||
import forestry.api.core.INBTTagable;
|
||||
|
||||
public class GeneItem implements INBTTagable, IGeneItem
|
||||
{
|
||||
IGene gene;
|
||||
|
||||
public GeneItem(final ItemStack stack) {
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
this.readFromNBT(stack.getTagCompound());
|
||||
}
|
||||
|
||||
public GeneItem(final IGene gene) {
|
||||
this.gene = gene;
|
||||
}
|
||||
|
||||
public boolean isCorrupted() {
|
||||
return this.gene == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToItem(final ItemStack stack) {
|
||||
if (this.gene == null || stack == null) {
|
||||
return;
|
||||
}
|
||||
final NBTTagCompound nbt = stack.hasTagCompound() ? stack.getTagCompound() : new NBTTagCompound();
|
||||
this.writeToNBT(nbt);
|
||||
stack.setTagCompound(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColour(final int renderPass) {
|
||||
if (renderPass == 2 && this.getBreedingSystem() != null) {
|
||||
return this.getBreedingSystem().getColour();
|
||||
}
|
||||
return 16777215;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getInfo(final List list) {
|
||||
final String chromosomeName = this.getBreedingSystem().getChromosomeName(this.gene.getChromosome());
|
||||
list.add("§6" + chromosomeName + "§7: " + this.gene.getName());
|
||||
}
|
||||
|
||||
public BreedingSystem getBreedingSystem() {
|
||||
if (this.gene == null) {
|
||||
return null;
|
||||
}
|
||||
return Binnie.Genetics.getSystem(this.gene.getSpeciesRoot().getUID());
|
||||
}
|
||||
|
||||
public IGene getGene() {
|
||||
return this.gene;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound nbt) {
|
||||
if (nbt != null) {
|
||||
this.gene = Gene.create(nbt.getCompoundTag("gene"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound nbt) {
|
||||
if (this.gene == null) {
|
||||
return;
|
||||
}
|
||||
final NBTTagCompound geneNBT = this.gene.getNBTTagCompound();
|
||||
nbt.setTag("gene", geneNBT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISpeciesRoot getSpeciesRoot() {
|
||||
return this.gene.getSpeciesRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGene(final IGene gene) {
|
||||
this.gene = gene;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.genetics;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
public class GeneProject
|
||||
{
|
||||
int id;
|
||||
String name;
|
||||
GameProfile leader;
|
||||
List<GameProfile> members;
|
||||
|
||||
public GeneProject(final int id, final String name, final GameProfile leader) {
|
||||
this.id = 0;
|
||||
this.leader = null;
|
||||
this.members = new ArrayList<GameProfile>();
|
||||
this.setID(id);
|
||||
this.setName(name);
|
||||
this.setLeader(leader);
|
||||
}
|
||||
|
||||
public int getID() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setID(final int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public GameProfile getLeader() {
|
||||
return this.leader;
|
||||
}
|
||||
|
||||
public void setLeader(final GameProfile leader) {
|
||||
this.addPlayer(this.leader = leader);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this.members.isEmpty();
|
||||
}
|
||||
|
||||
public void addPlayer(final GameProfile player) {
|
||||
if (!this.members.contains(player)) {
|
||||
this.members.add(player);
|
||||
}
|
||||
if (this.leader == null) {
|
||||
this.leader = player;
|
||||
}
|
||||
}
|
||||
|
||||
public void removePlayer(final GameProfile player) {
|
||||
if (player == this.leader) {
|
||||
throw new RuntimeException("Can't remove leader of a Gene Project");
|
||||
}
|
||||
this.members.remove(player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.genetics;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import java.util.Map;
|
||||
import net.minecraft.world.WorldSavedData;
|
||||
|
||||
public class GeneProjectTracker extends WorldSavedData
|
||||
{
|
||||
Map<Integer, GeneProject> projects;
|
||||
Map<GameProfile, Set<Integer>> TeamInvites;
|
||||
|
||||
public GeneProjectTracker(final String s) {
|
||||
super(s);
|
||||
this.projects = new HashMap<Integer, GeneProject>();
|
||||
this.TeamInvites = new HashMap<GameProfile, Set<Integer>>();
|
||||
}
|
||||
|
||||
public static GeneProjectTracker getTracker(final World world) {
|
||||
final 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(final NBTTagCompound nbt) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound nbt) {
|
||||
}
|
||||
|
||||
public int createProject(final String name, final GameProfile leader) {
|
||||
int i;
|
||||
for (i = 1; this.projects.keySet().contains(i); ++i) {
|
||||
}
|
||||
final GeneProject project = new GeneProject(i, name, leader);
|
||||
this.projects.put(i, project);
|
||||
this.markDirty();
|
||||
return i;
|
||||
}
|
||||
|
||||
public void removeProject(final int id) {
|
||||
this.projects.remove(id);
|
||||
for (final Map.Entry<GameProfile, Set<Integer>> entry : this.TeamInvites.entrySet()) {
|
||||
entry.getValue().remove(id);
|
||||
}
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
public void leaveProject(final int id, final GameProfile player) {
|
||||
final GeneProject project = this.projects.get(id);
|
||||
if (project == null) {
|
||||
return;
|
||||
}
|
||||
project.removePlayer(player);
|
||||
if (project.isEmpty()) {
|
||||
this.removeProject(id);
|
||||
}
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
public void joinProject(final int id, final GameProfile player) {
|
||||
final GeneProject project = this.projects.get(id);
|
||||
if (project == null) {
|
||||
return;
|
||||
}
|
||||
project.addPlayer(player);
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
public void reassignPlayer(final int id, final int id2, final GameProfile player) {
|
||||
final GeneProject project = this.projects.get(id);
|
||||
if (project == null) {
|
||||
return;
|
||||
}
|
||||
final GeneProject project2 = this.projects.get(id2);
|
||||
if (project2 == null) {
|
||||
return;
|
||||
}
|
||||
this.leaveProject(id, player);
|
||||
this.joinProject(id2, player);
|
||||
}
|
||||
|
||||
public void renameProject(final int id, final String newName) {
|
||||
final GeneProject project = this.projects.get(id);
|
||||
if (project != null) {
|
||||
project.setName(newName);
|
||||
}
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
public void invitePlayer(final int id, final GameProfile player) {
|
||||
if (!this.TeamInvites.containsKey(player)) {
|
||||
this.TeamInvites.put(player, new LinkedHashSet<Integer>());
|
||||
}
|
||||
this.TeamInvites.get(player).add(id);
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
public void revokeInvite(final int id, final GameProfile player) {
|
||||
if (!this.TeamInvites.containsKey(player)) {
|
||||
this.TeamInvites.put(player, new LinkedHashSet<Integer>());
|
||||
}
|
||||
this.TeamInvites.get(player).add(id);
|
||||
this.markDirty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.genetics;
|
||||
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import binnie.core.genetics.Gene;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import binnie.core.network.packet.MessageNBT;
|
||||
import binnie.genetics.core.GeneticsPacket;
|
||||
import binnie.genetics.Genetics;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import binnie.genetics.api.IGene;
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.world.WorldSavedData;
|
||||
|
||||
public class GeneTracker extends WorldSavedData
|
||||
{
|
||||
private ArrayList<IGene> discoveredGenes;
|
||||
GameProfile username;
|
||||
|
||||
public GeneTracker(final String s, final GameProfile username) {
|
||||
super(s);
|
||||
this.discoveredGenes = new ArrayList<IGene>();
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public GeneTracker(final String s) {
|
||||
super(s);
|
||||
this.discoveredGenes = new ArrayList<IGene>();
|
||||
}
|
||||
|
||||
protected static GeneTracker getCommonTracker(final EntityPlayer player) {
|
||||
return getTracker(player.worldObj, null);
|
||||
}
|
||||
|
||||
public static GeneTracker getTracker(final World world, final GameProfile player) {
|
||||
final String filename = "GeneTracker." + ((player == null) ? "common" : player.getId());
|
||||
GeneTracker tracker = (GeneTracker) world.loadItemData(GeneTracker.class, filename);
|
||||
if (tracker == null) {
|
||||
tracker = new GeneTracker(filename, player);
|
||||
world.setItemData(filename, tracker);
|
||||
}
|
||||
else {
|
||||
tracker.username = player;
|
||||
}
|
||||
return tracker;
|
||||
}
|
||||
|
||||
public void synchToPlayer(final EntityPlayer player) {
|
||||
final NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
this.writeToNBT(nbttagcompound);
|
||||
Genetics.proxy.sendToPlayer(new MessageNBT(GeneticsPacket.GeneTrackerSync.ordinal(), nbttagcompound), player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound nbt) {
|
||||
for (final ISpeciesRoot root : AlleleManager.alleleRegistry.getSpeciesRoot().values()) {
|
||||
if (!nbt.hasKey(root.getUID())) {
|
||||
continue;
|
||||
}
|
||||
final NBTTagCompound nbtRoot = nbt.getCompoundTag(root.getUID());
|
||||
for (final IChromosomeType chromo : root.getKaryotype()) {
|
||||
if (nbtRoot.hasKey("" + chromo.ordinal())) {
|
||||
final NBTTagList nbtChromo = nbtRoot.getTagList("" + chromo.ordinal(), 8);
|
||||
for (int i = 0; i < nbtChromo.tagCount(); ++i) {
|
||||
final String uid = nbtChromo.getStringTagAt(i);
|
||||
final IAllele allele = AlleleManager.alleleRegistry.getAllele(uid);
|
||||
final Gene gene = new Gene(allele, chromo, root);
|
||||
if (allele != null && !this.discoveredGenes.contains(gene)) {
|
||||
this.discoveredGenes.add(gene);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound nbt) {
|
||||
for (final ISpeciesRoot root : AlleleManager.alleleRegistry.getSpeciesRoot().values()) {
|
||||
final NBTTagCompound nbtRoot = new NBTTagCompound();
|
||||
for (final IChromosomeType chromo : root.getKaryotype()) {
|
||||
final NBTTagList nbtChromo = new NBTTagList();
|
||||
for (final IGene gene : this.discoveredGenes) {
|
||||
if (gene.getSpeciesRoot() == root && gene.getChromosome() == chromo) {
|
||||
nbtChromo.appendTag(new NBTTagString(gene.getAllele().getUID()));
|
||||
}
|
||||
}
|
||||
nbtRoot.setTag("" + chromo.ordinal(), nbtChromo);
|
||||
}
|
||||
nbt.setTag(root.getUID(), nbtRoot);
|
||||
}
|
||||
}
|
||||
|
||||
public void registerGene(final IGene iGene) {
|
||||
if (!this.discoveredGenes.contains(iGene)) {
|
||||
this.discoveredGenes.add(iGene);
|
||||
}
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
public int getGenesSequenced() {
|
||||
return this.discoveredGenes.size();
|
||||
}
|
||||
|
||||
public boolean isSequenced(final Gene gene) {
|
||||
return this.discoveredGenes.contains(gene);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.genetics;
|
||||
|
||||
import forestry.api.genetics.IAlleleInteger;
|
||||
import forestry.api.genetics.IAlleleFloat;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import java.util.Comparator;
|
||||
import java.util.TreeSet;
|
||||
import java.util.ArrayList;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import java.util.HashMap;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import java.util.List;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import java.util.Map;
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
|
||||
public class GeneticEngineeringSystem
|
||||
{
|
||||
BreedingSystem breedingSystem;
|
||||
public Map<IChromosomeType, List<IAllele>> chromosomeMap;
|
||||
static List<IAllele> speciesList;
|
||||
|
||||
public GeneticEngineeringSystem(final BreedingSystem system) {
|
||||
this.chromosomeMap = new HashMap<IChromosomeType, List<IAllele>>();
|
||||
this.breedingSystem = system;
|
||||
for (final IIndividual indiv : this.breedingSystem.getSpeciesRoot().getIndividualTemplates()) {
|
||||
for (final IChromosomeType chromosome : this.breedingSystem.getSpeciesRoot().getKaryotype()) {
|
||||
if (!this.chromosomeMap.containsKey(chromosome)) {
|
||||
this.chromosomeMap.put(chromosome, new ArrayList<IAllele>());
|
||||
}
|
||||
try {
|
||||
final IAllele a1 = indiv.getGenome().getActiveAllele(chromosome);
|
||||
final IAllele a2 = indiv.getGenome().getInactiveAllele(chromosome);
|
||||
if (a1 != null) {
|
||||
this.chromosomeMap.get(chromosome).add(a1);
|
||||
}
|
||||
if (a2 != null) {
|
||||
this.chromosomeMap.get(chromosome).add(a2);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (final IChromosomeType chromosome2 : this.breedingSystem.getSpeciesRoot().getKaryotype()) {
|
||||
final List<IAllele> alleles = this.getAlleles(chromosome2);
|
||||
final TreeSet<IAllele> set = new TreeSet<IAllele>(new ComparatorAllele());
|
||||
set.addAll(alleles);
|
||||
final List<IAllele> list = new ArrayList<IAllele>();
|
||||
list.addAll(set);
|
||||
this.chromosomeMap.put(chromosome2, list);
|
||||
}
|
||||
}
|
||||
|
||||
public List<IAllele> getAlleles(final IChromosomeType chromosome) {
|
||||
return this.chromosomeMap.get(chromosome);
|
||||
}
|
||||
|
||||
public ISpeciesRoot getSpeciesRoot() {
|
||||
return this.breedingSystem.getSpeciesRoot();
|
||||
}
|
||||
|
||||
class ComparatorAllele implements Comparator<IAllele>
|
||||
{
|
||||
@Override
|
||||
public int compare(final IAllele o1, final IAllele o2) {
|
||||
if (o1 instanceof IAlleleFloat && o2 instanceof IAlleleFloat) {
|
||||
return Float.valueOf(((IAlleleFloat) o1).getValue()).compareTo(Float.valueOf(((IAlleleFloat) o2).getValue()));
|
||||
}
|
||||
if (o1 instanceof IAlleleInteger && o2 instanceof IAlleleInteger) {
|
||||
return Integer.valueOf(((IAlleleInteger) o1).getValue()).compareTo(Integer.valueOf(((IAlleleInteger) o2).getValue()));
|
||||
}
|
||||
return o1.getUID().compareTo(o2.getUID());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.genetics;
|
||||
|
||||
import binnie.genetics.api.IGene;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import java.util.List;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
|
||||
public interface IGeneItem
|
||||
{
|
||||
ISpeciesRoot getSpeciesRoot();
|
||||
|
||||
void getInfo(final List p0);
|
||||
|
||||
int getColour(final int p0);
|
||||
|
||||
void writeToItem(final ItemStack p0);
|
||||
|
||||
void addGene(final IGene p0);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.genetics;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import binnie.genetics.api.IGene;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SequencerItem extends GeneItem
|
||||
{
|
||||
public int sequenced;
|
||||
public boolean analysed;
|
||||
|
||||
public SequencerItem(final ItemStack stack) {
|
||||
super(stack);
|
||||
}
|
||||
|
||||
public SequencerItem(final IGene gene) {
|
||||
super(gene);
|
||||
this.sequenced = 0;
|
||||
this.analysed = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
this.sequenced = nbt.getByte("seq");
|
||||
this.analysed = nbt.getBoolean("ana");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setByte("seq", (byte) this.sequenced);
|
||||
nbt.setBoolean("ana", this.analysed);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.gui;
|
||||
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import binnie.botany.api.EnumFlowerStage;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import binnie.craftgui.minecraft.control.ControlIconDisplay;
|
||||
import binnie.craftgui.botany.ControlColourDisplay;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import binnie.botany.api.IFlower;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public class AnalystPageAppearance extends ControlAnalystPage
|
||||
{
|
||||
public AnalystPageAppearance(final IWidget parent, final IArea area, final IFlower ind) {
|
||||
super(parent, area);
|
||||
this.setColour(3355443);
|
||||
int y = 4;
|
||||
final IAlleleSpecies species = ind.getGenome().getPrimary();
|
||||
new ControlTextCentered(this, y, "§nAppearance").setColour(this.getColour());
|
||||
y += 12;
|
||||
final ControlColourDisplay a = new ControlColourDisplay(this, this.w() / 2.0f - 28.0f, y);
|
||||
a.setValue(ind.getGenome().getPrimaryColor());
|
||||
a.addTooltip("Primary Petal Colour");
|
||||
final ControlColourDisplay b = new ControlColourDisplay(this, this.w() / 2.0f - 8.0f, y);
|
||||
b.setValue(ind.getGenome().getSecondaryColor());
|
||||
b.addTooltip("Secondary Petal Colour");
|
||||
final ControlColourDisplay c = new ControlColourDisplay(this, this.w() / 2.0f + 12.0f, y);
|
||||
c.setValue(ind.getGenome().getStemColor());
|
||||
c.addTooltip("Stem Colour");
|
||||
y += 26;
|
||||
final int sections = ind.getGenome().getType().getSections();
|
||||
final int w = (sections > 1) ? 50 : 100;
|
||||
new ControlIconDisplay(this, (this.w() - w) / 2.0f, y - ((sections == 1) ? 0 : 0), null) {
|
||||
@Override
|
||||
public void onRenderForeground() {
|
||||
GL11.glPushMatrix();
|
||||
final float scale = w / 16.0f;
|
||||
final float dy = (sections > 1) ? 16.0f : 0.0f;
|
||||
GL11.glScalef(scale, scale, 1.0f);
|
||||
CraftGUI.Render.colour(ind.getGenome().getStemColor().getColor(false));
|
||||
if (sections > 1) {
|
||||
CraftGUI.Render.iconBlock(new IPoint(0.0f, 0.0f), ind.getGenome().getType().getStem(EnumFlowerStage.FLOWER, true, 1));
|
||||
}
|
||||
CraftGUI.Render.iconBlock(new IPoint(0.0f, dy), ind.getGenome().getType().getStem(EnumFlowerStage.FLOWER, true, 0));
|
||||
CraftGUI.Render.colour(ind.getGenome().getPrimaryColor().getColor(false));
|
||||
if (sections > 1) {
|
||||
CraftGUI.Render.iconBlock(new IPoint(0.0f, 0.0f), ind.getGenome().getType().getPetalIcon(EnumFlowerStage.FLOWER, true, 1));
|
||||
}
|
||||
CraftGUI.Render.iconBlock(new IPoint(0.0f, dy), ind.getGenome().getType().getPetalIcon(EnumFlowerStage.FLOWER, true, 0));
|
||||
CraftGUI.Render.colour(ind.getGenome().getSecondaryColor().getColor(false));
|
||||
if (sections > 1) {
|
||||
CraftGUI.Render.iconBlock(new IPoint(0.0f, 0.0f), ind.getGenome().getType().getVariantIcon(EnumFlowerStage.FLOWER, true, 1));
|
||||
}
|
||||
CraftGUI.Render.iconBlock(new IPoint(0.0f, dy), ind.getGenome().getType().getVariantIcon(EnumFlowerStage.FLOWER, true, 0));
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Appearance";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.gui;
|
||||
|
||||
import forestry.api.lepidopterology.IAlleleButterflyEffect;
|
||||
import forestry.api.apiculture.IAlleleBeeEffect;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.lepidopterology.EnumButterflyChromosome;
|
||||
import binnie.Binnie;
|
||||
import forestry.api.lepidopterology.IButterfly;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
import binnie.craftgui.core.geometry.TextJustification;
|
||||
import binnie.core.BinnieCore;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public class AnalystPageBehaviour extends ControlAnalystPage
|
||||
{
|
||||
public AnalystPageBehaviour(final IWidget parent, final IArea area, final IIndividual ind) {
|
||||
super(parent, area);
|
||||
this.setColour(6684723);
|
||||
int y = 4;
|
||||
new ControlTextCentered(this, y, "§nBehaviour").setColour(this.getColour());
|
||||
y += 12;
|
||||
if (ind instanceof IBee) {
|
||||
final IBee bee = (IBee) ind;
|
||||
y += 8;
|
||||
final int fertility = bee.getGenome().getFlowering();
|
||||
new ControlTextCentered(this, y, "Pollinates nearby\n" + bee.getGenome().getFlowerProvider().getDescription()).setColour(this.getColour());
|
||||
y += 20;
|
||||
new ControlTextCentered(this, y, "§oEvery " + this.getTimeString(PluginApiculture.ticksPerBeeWorkCycle * 100.0f / fertility)).setColour(this.getColour());
|
||||
y += 22;
|
||||
final IAlleleBeeEffect effect = bee.getGenome().getEffect();
|
||||
final int[] t = bee.getGenome().getTerritory();
|
||||
if (!effect.getUID().contains("None")) {
|
||||
final String effectDesc = BinnieCore.proxy.localiseOrBlank("allele." + effect.getUID() + ".desc");
|
||||
final String loc = effectDesc.equals("") ? ("Effect: " + effect.getName()) : effectDesc;
|
||||
new ControlText(this, new IArea(4.0f, y, this.w() - 8.0f, 0.0f), loc, TextJustification.TopCenter).setColour(this.getColour());
|
||||
y += (int) (CraftGUI.Render.textHeight(loc, this.w() - 8.0f) + 1.0f);
|
||||
new ControlTextCentered(this, y, "§oWithin " + (int) (t[0] / 2.0f) + " blocks").setColour(this.getColour());
|
||||
y += 22;
|
||||
}
|
||||
new ControlTextCentered(this, y, "Territory: §o" + t[0] + "x" + t[1] + "x" + t[2]).setColour(this.getColour());
|
||||
y += 22;
|
||||
}
|
||||
if (ind instanceof IButterfly) {
|
||||
final IButterfly bee2 = (IButterfly) ind;
|
||||
new ControlTextCentered(this, y, "§oMetabolism: " + Binnie.Genetics.mothBreedingSystem.getAlleleName(EnumButterflyChromosome.METABOLISM, ind.getGenome().getActiveAllele(EnumButterflyChromosome.METABOLISM))).setColour(this.getColour());
|
||||
y += 20;
|
||||
new ControlTextCentered(this, y, "Pollinates nearby\n" + bee2.getGenome().getFlowerProvider().getDescription()).setColour(this.getColour());
|
||||
y += 20;
|
||||
new ControlTextCentered(this, y, "§oEvery " + this.getTimeString(1500.0f)).setColour(this.getColour());
|
||||
y += 22;
|
||||
final IAlleleButterflyEffect effect2 = bee2.getGenome().getEffect();
|
||||
if (!effect2.getUID().contains("None")) {
|
||||
final String effectDesc2 = BinnieCore.proxy.localiseOrBlank("allele." + effect2.getUID() + ".desc");
|
||||
final String loc2 = effectDesc2.equals("") ? ("Effect: " + effect2.getName()) : effectDesc2;
|
||||
new ControlText(this, new IArea(4.0f, y, this.w() - 8.0f, 0.0f), loc2, TextJustification.TopCenter).setColour(this.getColour());
|
||||
y += (int) (CraftGUI.Render.textHeight(loc2, this.w() - 8.0f) + 1.0f);
|
||||
y += 22;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Behaviour";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.gui;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.botany.api.IFlower;
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.arboriculture.EnumTreeChromosome;
|
||||
import binnie.Binnie;
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.lepidopterology.IButterfly;
|
||||
import binnie.craftgui.minecraft.control.ControlIconDisplay;
|
||||
import binnie.genetics.item.ModuleItem;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public class AnalystPageBiology extends ControlAnalystPage
|
||||
{
|
||||
public AnalystPageBiology(final IWidget parent, final IArea area, final IIndividual ind) {
|
||||
super(parent, area);
|
||||
this.setColour(26214);
|
||||
int y = 4;
|
||||
new ControlTextCentered(this, y, "§nBiology").setColour(this.getColour());
|
||||
y += 12;
|
||||
if (ind instanceof IBee) {
|
||||
final IBee bee = (IBee) ind;
|
||||
if (bee.getGenome().getNocturnal()) {
|
||||
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f, y, ModuleItem.iconAllDay.getIcon()).addTooltip("Active all day and night");
|
||||
}
|
||||
else if (bee.getGenome().getPrimary().isNocturnal()) {
|
||||
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f, y, ModuleItem.iconNight.getIcon()).addTooltip("Active at night");
|
||||
}
|
||||
else {
|
||||
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f, y, ModuleItem.iconDaytime.getIcon()).addTooltip("Active during the day");
|
||||
}
|
||||
if (!bee.getGenome().getTolerantFlyer()) {
|
||||
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f + 24.0f, y, ModuleItem.iconNoRain.getIcon()).addTooltip("Cannot work during rain");
|
||||
}
|
||||
else {
|
||||
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f + 24.0f, y, ModuleItem.iconRain.getIcon()).addTooltip("Can work during rain");
|
||||
}
|
||||
if (bee.getGenome().getCaveDwelling()) {
|
||||
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f + 48.0f, y, ModuleItem.iconNoSky.getIcon()).addTooltip("Can work underground");
|
||||
}
|
||||
else {
|
||||
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f + 48.0f, y, ModuleItem.iconSky.getIcon()).addTooltip("Cannot work underground");
|
||||
}
|
||||
y += 30;
|
||||
}
|
||||
else if (ind instanceof IButterfly) {
|
||||
final IButterfly moth = (IButterfly) ind;
|
||||
if (moth.getGenome().getNocturnal()) {
|
||||
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f, y, ModuleItem.iconAllDay.getIcon()).addTooltip("Active all day and night");
|
||||
}
|
||||
else if (moth.getGenome().getPrimary().isNocturnal()) {
|
||||
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f, y, ModuleItem.iconNight.getIcon()).addTooltip("Active at night");
|
||||
}
|
||||
else {
|
||||
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f, y, ModuleItem.iconDaytime.getIcon()).addTooltip("Active during the day");
|
||||
}
|
||||
if (!moth.getGenome().getTolerantFlyer()) {
|
||||
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f + 24.0f, y, ModuleItem.iconNoRain.getIcon()).addTooltip("Cannot work during rain");
|
||||
}
|
||||
else {
|
||||
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f + 24.0f, y, ModuleItem.iconRain.getIcon()).addTooltip("Can work during rain");
|
||||
}
|
||||
if (moth.getGenome().getFireResist()) {
|
||||
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f + 48.0f, y, ModuleItem.iconNoFire.getIcon()).addTooltip("Nonflammable");
|
||||
}
|
||||
else {
|
||||
new ControlIconDisplay(this, (this.w() - 64.0f) / 2.0f + 48.0f, y, ModuleItem.iconFire.getIcon()).addTooltip("Flammable");
|
||||
}
|
||||
y += 30;
|
||||
}
|
||||
else if (ind instanceof ITree) {
|
||||
new ControlTextCentered(this, y, "§oSappiness: " + Binnie.Genetics.treeBreedingSystem.getAlleleName(EnumTreeChromosome.SAPPINESS, ind.getGenome().getActiveAllele(EnumTreeChromosome.SAPPINESS))).setColour(this.getColour());
|
||||
y += 20;
|
||||
}
|
||||
else {
|
||||
y += 10;
|
||||
}
|
||||
if (ind instanceof IBee) {
|
||||
final IBee bee = (IBee) ind;
|
||||
final int fertility = bee.getGenome().getFertility();
|
||||
new ControlTextCentered(this, y, "§l" + fertility + "§r drone" + ((fertility > 1) ? "s" : "") + " per hive").setColour(this.getColour());
|
||||
y += 22;
|
||||
final int lifespan = bee.getGenome().getLifespan() * PluginApiculture.ticksPerBeeWorkCycle;
|
||||
new ControlTextCentered(this, y, "Average Lifespan").setColour(this.getColour());
|
||||
y += 12;
|
||||
new ControlTextCentered(this, y, "§l" + this.getMCDayString(lifespan * (bee.getGenome().getNocturnal() ? 1.0f : 2.0f))).setColour(this.getColour());
|
||||
y += 22;
|
||||
}
|
||||
if (ind instanceof IButterfly) {
|
||||
final IButterfly bee2 = (IButterfly) ind;
|
||||
final int fertility = bee2.getGenome().getFertility();
|
||||
new ControlTextCentered(this, y, "Lays §l" + fertility + "§r caterpillar" + ((fertility > 1) ? "s" : "") + " before dying").setColour(this.getColour());
|
||||
y += 32;
|
||||
final float caterpillarMatureTime = 1365.3999f * Math.round(bee2.getGenome().getLifespan() / (bee2.getGenome().getFertility() * 2));
|
||||
new ControlTextCentered(this, y, "Caterpillar Gestation").setColour(this.getColour());
|
||||
y += 12;
|
||||
new ControlTextCentered(this, y, "§l" + this.getMCDayString(caterpillarMatureTime)).setColour(this.getColour());
|
||||
y += 22;
|
||||
final int speed = (int) (20.0f * bee2.getGenome().getSpeed());
|
||||
new ControlTextCentered(this, y, "Flight Speed").setColour(this.getColour());
|
||||
y += 12;
|
||||
new ControlTextCentered(this, y, "§l" + speed + "§r blocks per second").setColour(this.getColour());
|
||||
y += 22;
|
||||
}
|
||||
if (ind instanceof ITree) {
|
||||
final ITree tree = (ITree) ind;
|
||||
final int fertility = (int) (1.0f / tree.getGenome().getFertility());
|
||||
new ControlTextCentered(this, y, "1 Sapling per §l" + fertility + "§r leave" + ((fertility > 1) ? "s" : "")).setColour(this.getColour());
|
||||
y += 22;
|
||||
final float butterflySpawn = 1365.3999f / (tree.getGenome().getSappiness() * tree.getGenome().getYield() * 0.5f);
|
||||
new ControlTextCentered(this, y, "Butterfies spawn every\n" + this.getTimeString(butterflySpawn) + " per leaf").setColour(this.getColour());
|
||||
y += 34;
|
||||
new ControlTextCentered(this, y, "Plant Types").setColour(this.getColour());
|
||||
y += 12;
|
||||
for (final EnumPlantType type : tree.getGenome().getPlantTypes()) {
|
||||
new ControlTextCentered(this, y, "§o" + type.name()).setColour(this.getColour());
|
||||
y += 12;
|
||||
}
|
||||
}
|
||||
if (ind instanceof IFlower) {
|
||||
final IFlower flower = (IFlower) ind;
|
||||
final float butterflySpawn2 = 1365.3999f / (flower.getGenome().getSappiness() * 0.2f);
|
||||
new ControlTextCentered(this, y, "Butterfies spawn every\n" + this.getTimeString(butterflySpawn2)).setColour(this.getColour());
|
||||
y += 30;
|
||||
float CHANCE_DISPERSAL = 0.8f;
|
||||
CHANCE_DISPERSAL += 0.2f * flower.getGenome().getFertility();
|
||||
float CHANCE_POLLINATE = 0.6f;
|
||||
CHANCE_POLLINATE += 0.25f * flower.getGenome().getFertility();
|
||||
final float CHANCE_SELFPOLLINATE = 0.2f * CHANCE_POLLINATE;
|
||||
if (CHANCE_DISPERSAL > 1.0f) {
|
||||
CHANCE_DISPERSAL = 1.0f;
|
||||
}
|
||||
if (CHANCE_POLLINATE > 1.0f) {
|
||||
CHANCE_POLLINATE = 1.0f;
|
||||
}
|
||||
final float dispersalTime = 1365.3999f / CHANCE_DISPERSAL;
|
||||
final float pollinateTime = 1365.3999f / CHANCE_POLLINATE;
|
||||
final float lifespan2 = flower.getMaxAge() * 20.0f * 68.27f / flower.getGenome().getAgeChance();
|
||||
float floweringLifespan = (flower.getMaxAge() - 1) * 20.0f * 68.27f / flower.getGenome().getAgeChance();
|
||||
floweringLifespan -= 1365.3999f;
|
||||
new ControlTextCentered(this, y, "Average Lifespan").setColour(this.getColour());
|
||||
y += 12;
|
||||
new ControlTextCentered(this, y, "§l" + this.getMCDayString(lifespan2)).setColour(this.getColour());
|
||||
y += 22;
|
||||
new ControlTextCentered(this, y, "Seed Dispersal").setColour(this.getColour());
|
||||
y += 12;
|
||||
new ControlTextCentered(this, y, "§o" + (int) (floweringLifespan / dispersalTime) + " per lifetime").setColour(this.getColour());
|
||||
y += 22;
|
||||
new ControlTextCentered(this, y, "Pollination").setColour(this.getColour());
|
||||
y += 12;
|
||||
new ControlTextCentered(this, y, "§o" + (int) (floweringLifespan / pollinateTime) + " per lifetime").setColour(this.getColour());
|
||||
y += 22;
|
||||
}
|
||||
this.setSize(new IPoint(this.w(), y));
|
||||
}
|
||||
|
||||
private String getMCDayString(final float time) {
|
||||
final float seconds = time / 20.0f;
|
||||
final float minutes = seconds / 60.0f;
|
||||
final float days = minutes / 20.0f;
|
||||
final DecimalFormat df = new DecimalFormat("#.0");
|
||||
return df.format(days) + " MC days";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Biology";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.gui;
|
||||
|
||||
import java.util.List;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import binnie.core.genetics.Tolerance;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import java.util.ArrayList;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
import binnie.craftgui.core.geometry.TextJustification;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import forestry.api.lepidopterology.EnumButterflyChromosome;
|
||||
import forestry.api.lepidopterology.IButterfly;
|
||||
import binnie.botany.api.EnumFlowerChromosome;
|
||||
import binnie.botany.api.IFlower;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.genetics.IAlleleTolerance;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.genetics.EnumTolerance;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public class AnalystPageClimate extends ControlAnalystPage
|
||||
{
|
||||
public AnalystPageClimate(final IWidget parent, final IArea area, final IIndividual ind) {
|
||||
super(parent, area);
|
||||
this.setColour(26163);
|
||||
final EnumTemperature temp = ind.getGenome().getPrimary().getTemperature();
|
||||
EnumTolerance tempTol = EnumTolerance.NONE;
|
||||
final EnumHumidity humid = ind.getGenome().getPrimary().getHumidity();
|
||||
EnumTolerance humidTol = EnumTolerance.NONE;
|
||||
if (ind instanceof IBee) {
|
||||
tempTol = ((IAlleleTolerance) ind.getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE)).getValue();
|
||||
humidTol = ((IAlleleTolerance) ind.getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE)).getValue();
|
||||
}
|
||||
if (ind instanceof IFlower) {
|
||||
tempTol = ((IAlleleTolerance) ind.getGenome().getActiveAllele(EnumFlowerChromosome.TEMPERATURE_TOLERANCE)).getValue();
|
||||
humidTol = EnumTolerance.BOTH_5;
|
||||
}
|
||||
if (ind instanceof IButterfly) {
|
||||
tempTol = ((IAlleleTolerance) ind.getGenome().getActiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE)).getValue();
|
||||
humidTol = ((IAlleleTolerance) ind.getGenome().getActiveAllele(EnumButterflyChromosome.HUMIDITY_TOLERANCE)).getValue();
|
||||
}
|
||||
int y = 4;
|
||||
new ControlTextCentered(this, y, "§nClimate").setColour(this.getColour());
|
||||
y += 16;
|
||||
new ControlText(this, new IArea(4.0f, y, this.w() - 8.0f, 14.0f), "Temp. Tolerance", TextJustification.MiddleCenter).setColour(this.getColour());
|
||||
y += 12;
|
||||
this.createTemperatureBar(this, (this.w() - 100.0f) / 2.0f, y, 100.0f, 10.0f, temp, tempTol);
|
||||
y += 16;
|
||||
if (!(ind instanceof IFlower)) {
|
||||
new ControlText(this, new IArea(4.0f, y, this.w() - 8.0f, 14.0f), "Humidity Tolerance", TextJustification.MiddleCenter).setColour(this.getColour());
|
||||
y += 12;
|
||||
this.createHumidity(this, (this.w() - 100.0f) / 2.0f, y, 100.0f, 10.0f, humid, humidTol);
|
||||
y += 16;
|
||||
}
|
||||
new ControlText(this, new IArea(4.0f, y, this.w() - 8.0f, 14.0f), "Biomes", TextJustification.MiddleCenter).setColour(this.getColour());
|
||||
y += 12;
|
||||
final List<BiomeGenBase> biomes = new ArrayList<BiomeGenBase>();
|
||||
for (final BiomeGenBase biome : BiomeGenBase.getBiomeGenArray()) {
|
||||
if (biome != null) {
|
||||
if (BiomeDictionary.isBiomeRegistered(biome)) {
|
||||
if (biome != BiomeGenBase.frozenOcean) {
|
||||
if (Tolerance.canTolerate(temp, EnumTemperature.getFromBiome(biome), tempTol)) {
|
||||
if (Tolerance.canTolerate(humid, EnumHumidity.getFromValue(biome.rainfall), humidTol)) {
|
||||
boolean match = false;
|
||||
for (final BiomeGenBase eBiome : biomes) {
|
||||
if (biome.biomeName.contains(eBiome.biomeName) && EnumHumidity.getFromValue(eBiome.rainfall) == EnumHumidity.getFromValue(biome.rainfall) && EnumTemperature.getFromBiome(eBiome) == EnumTemperature.getFromBiome(biome)) {
|
||||
match = true;
|
||||
}
|
||||
}
|
||||
if (!match) {
|
||||
biomes.add(biome);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
final int maxBiomePerLine = (int) ((this.w() + 2.0f - 16.0f) / 18.0f);
|
||||
final float biomeListX = (this.w() - (Math.min(maxBiomePerLine, biomes.size()) * 18 - 2)) / 2.0f;
|
||||
int dx = 0;
|
||||
int dy = 0;
|
||||
for (final BiomeGenBase biome2 : biomes) {
|
||||
new ControlBiome(this, biomeListX + dx, y + dy, 16.0f, 16.0f, biome2);
|
||||
dx += 18;
|
||||
if (dx >= 18 * maxBiomePerLine) {
|
||||
dx = 0;
|
||||
dy += 18;
|
||||
}
|
||||
}
|
||||
this.setSize(new IPoint(this.w(), y + dy + 18 + 8));
|
||||
}
|
||||
|
||||
protected void createTemperatureBar(final IWidget parent, final float x, final float y, final float w, final float h, final EnumTemperature value, final EnumTolerance tol) {
|
||||
new ControlToleranceBar<EnumTemperature>(parent, x, y, w, h, EnumTemperature.class) {
|
||||
@Override
|
||||
protected String getName(final EnumTemperature value) {
|
||||
return value.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getColour(final EnumTemperature value) {
|
||||
return (new int[] { 65531, 7912447, 5242672, 16776960, 16753152, 16711680 })[value.ordinal() - 1];
|
||||
}
|
||||
}.setValues(value, tol);
|
||||
}
|
||||
|
||||
protected void createHumidity(final IWidget parent, final float x, final float y, final float w, final float h, final EnumHumidity value, final EnumTolerance tol) {
|
||||
new ControlToleranceBar<EnumHumidity>(parent, x, y, w, h, EnumHumidity.class) {
|
||||
@Override
|
||||
protected String getName(final EnumHumidity value) {
|
||||
return value.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getColour(final EnumHumidity value) {
|
||||
return (new int[] { 16770979, 1769216, 3177727 })[value.ordinal()];
|
||||
}
|
||||
}.setValues(value, tol);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Climate";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.gui;
|
||||
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import binnie.craftgui.controls.scroll.ControlScrollBar;
|
||||
import binnie.craftgui.core.geometry.TextJustification;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
import binnie.craftgui.controls.listbox.ControlListBox;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.arboriculture.EnumTreeChromosome;
|
||||
import binnie.craftgui.window.Panel;
|
||||
import binnie.craftgui.minecraft.MinecraftGUI;
|
||||
import binnie.craftgui.resource.minecraft.CraftGUITexture;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import java.util.Collection;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import java.util.ArrayList;
|
||||
import binnie.craftgui.controls.ControlTextEdit;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.controls.scroll.ControlScrollableContent;
|
||||
|
||||
public class AnalystPageDatabase extends ControlAnalystPage
|
||||
{
|
||||
ControlScrollableContent scroll;
|
||||
boolean isMaster;
|
||||
|
||||
public AnalystPageDatabase(final IWidget parent, final IArea area, final BreedingSystem system, final boolean isMaster) {
|
||||
super(parent, area);
|
||||
this.scroll = null;
|
||||
this.isMaster = isMaster;
|
||||
final int cOfSystem = system.getColour();
|
||||
final int cr = (0xFF0000 & cOfSystem) >> 16;
|
||||
final int cg = (0xFF00 & cOfSystem) >> 8;
|
||||
final int cb = 0xFF & cOfSystem;
|
||||
float brightness = 0.1f * cb / 255.0f + 0.35f * cr / 255.0f + 0.55f * cg / 255.0f;
|
||||
brightness = 0.3f / brightness;
|
||||
if (brightness > 1.0f) {
|
||||
brightness = 1.0f;
|
||||
}
|
||||
final int newColour = (int) (cr * brightness) * 65536 + (int) (cg * brightness) * 256 + (int) (cb * brightness);
|
||||
this.setColour(newColour);
|
||||
int y = 4;
|
||||
new ControlTextCentered(this, y, "§nRegistry").setColour(this.getColour());
|
||||
y += 16;
|
||||
new ControlTextEdit(this, 20.0f, y, this.w() - 40.0f, 16.0f) {
|
||||
@Override
|
||||
public void onTextEdit(final String value) {
|
||||
final Collection<IAlleleSpecies> options = new ArrayList<IAlleleSpecies>();
|
||||
AnalystPageDatabase.this.getSpecies(system);
|
||||
for (final IAlleleSpecies species : AnalystPageDatabase.this.getSpecies(system)) {
|
||||
if (value != null) {
|
||||
if (value != "") {
|
||||
if (!species.getName().toLowerCase().contains(value.toLowerCase())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
options.add(species);
|
||||
}
|
||||
AnalystPageDatabase.this.scroll.deleteAllChildren();
|
||||
AnalystPageDatabase.this.scroll.setScrollableContent(AnalystPageDatabase.this.getItemScrollList(system, options));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.Render.colour(5592405);
|
||||
CraftGUI.Render.texture(CraftGUITexture.TabSolid, this.getArea().inset(1));
|
||||
CraftGUI.Render.colour(AnalystPageDatabase.this.getColour());
|
||||
CraftGUI.Render.texture(CraftGUITexture.TabOutline, this.getArea());
|
||||
super.renderTextField();
|
||||
}
|
||||
};
|
||||
y += 22;
|
||||
new Panel(this, 3.0f, y - 1, this.w() - 6.0f, this.h() - y - 8.0f + 2.0f, MinecraftGUI.PanelType.TabOutline).setColour(this.getColour());
|
||||
final boolean textView = false;
|
||||
final Collection<IAlleleSpecies> options = this.getSpecies(system);
|
||||
for (final IAlleleSpecies species : options) {
|
||||
final String height = system.getAlleleName(EnumTreeChromosome.HEIGHT, system.getIndividual(species.getUID()).getGenome().getActiveAllele(EnumTreeChromosome.HEIGHT));
|
||||
final String fertility = system.getAlleleName(EnumTreeChromosome.FERTILITY, system.getIndividual(species.getUID()).getGenome().getActiveAllele(EnumTreeChromosome.FERTILITY));
|
||||
final String yield = system.getAlleleName(EnumTreeChromosome.YIELD, system.getIndividual(species.getUID()).getGenome().getActiveAllele(EnumTreeChromosome.YIELD));
|
||||
final String sappiness = system.getAlleleName(EnumTreeChromosome.SAPPINESS, system.getIndividual(species.getUID()).getGenome().getActiveAllele(EnumTreeChromosome.SAPPINESS));
|
||||
final String maturation = system.getAlleleName(EnumTreeChromosome.MATURATION, system.getIndividual(species.getUID()).getGenome().getActiveAllele(EnumTreeChromosome.MATURATION));
|
||||
}
|
||||
if (textView) {
|
||||
this.scroll = new ControlListBox<IAlleleSpecies>(this, 4.0f, y, this.w() - 8.0f, this.h() - y - 8.0f - 20.0f, 0.0f) {
|
||||
@Override
|
||||
public void initialise() {
|
||||
super.initialise();
|
||||
this.setOptions(options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWidget createOption(final IAlleleSpecies v, final int y) {
|
||||
return new Control(this.getContent(), 0.0f, y, this.w(), 12.0f) {
|
||||
IAlleleSpecies value = v;
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.Render.text(this.getArea(), TextJustification.MiddleCenter, this.value.getName(), 16777215);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
else {
|
||||
(this.scroll = new ControlScrollableContent(this, 4.0f, y, this.w() - 8.0f, this.h() - y - 8.0f, 0.0f)).setScrollableContent(this.getItemScrollList(system, options));
|
||||
}
|
||||
new ControlScrollBar(this, this.scroll.x() + this.scroll.w() - 6.0f, this.scroll.y() + 3.0f, 3.0f, this.scroll.h() - 6.0f, this.scroll) {
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
if (!this.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
CraftGUI.Render.gradientRect(this.getArea(), 1140850688 + AnalystPageDatabase.this.getColour(), 1140850688 + AnalystPageDatabase.this.getColour());
|
||||
CraftGUI.Render.solid(this.getRenderArea(), AnalystPageDatabase.this.getColour());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private IWidget getItemScrollList(final BreedingSystem system, final Collection<IAlleleSpecies> options) {
|
||||
return new Control(this.scroll, 0.0f, 0.0f, this.scroll.w(), this.scroll.h()) {
|
||||
@Override
|
||||
public void initialise() {
|
||||
final int maxBiomePerLine = (int) ((this.w() - 4.0f + 2.0f) / 18.0f);
|
||||
final float biomeListX = -6.0f + (this.w() - (maxBiomePerLine * 18 - 2)) / 2.0f;
|
||||
int dx = 0;
|
||||
int dy = 0;
|
||||
for (final IAlleleSpecies species : options) {
|
||||
final IIndividual ind = system.getSpeciesRoot().templateAsIndividual(system.getSpeciesRoot().getTemplate(species.getUID()));
|
||||
new ControlIndividualDisplay(this, biomeListX + dx, 2 + dy, ind) {
|
||||
@Override
|
||||
public void initialise() {
|
||||
this.addSelfEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Down event) {
|
||||
final WindowAnalyst window = (WindowAnalyst) AnalystPageDatabase.this.getSuperParent();
|
||||
window.setIndividual(ind);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
final WindowAnalyst window = (WindowAnalyst) AnalystPageDatabase.this.getSuperParent();
|
||||
if (window.getIndividual() != null && window.getIndividual().getGenome().getPrimary() == species) {
|
||||
CraftGUI.Render.colour(15658734);
|
||||
CraftGUI.Render.texture(CraftGUITexture.TabSolid, this.getArea().outset(1));
|
||||
CraftGUI.Render.colour(AnalystPageDatabase.this.getColour());
|
||||
CraftGUI.Render.texture(CraftGUITexture.TabOutline, this.getArea().outset(1));
|
||||
}
|
||||
else if (this.calculateIsMouseOver()) {
|
||||
CraftGUI.Render.colour(15658734);
|
||||
CraftGUI.Render.texture(CraftGUITexture.TabSolid, this.getArea().outset(1));
|
||||
}
|
||||
super.onRenderBackground();
|
||||
}
|
||||
};
|
||||
dx += 18;
|
||||
if (dx >= 18 * maxBiomePerLine) {
|
||||
dx = 0;
|
||||
dy += 18;
|
||||
}
|
||||
}
|
||||
this.setSize(new IPoint(this.w(), 4 + dy + 18));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Registry";
|
||||
}
|
||||
|
||||
private Collection<IAlleleSpecies> getSpecies(final BreedingSystem system) {
|
||||
final Collection<IAlleleSpecies> species = new ArrayList<IAlleleSpecies>();
|
||||
species.addAll(this.isMaster ? system.getAllSpecies() : system.getDiscoveredSpecies(this.getWindow().getWorld(), this.getWindow().getPlayer().getGameProfile()));
|
||||
return species;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.gui;
|
||||
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
import binnie.craftgui.core.geometry.TextJustification;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public class AnalystPageDescription extends ControlAnalystPage
|
||||
{
|
||||
public AnalystPageDescription(final IWidget parent, final IArea area, final IIndividual ind) {
|
||||
super(parent, area);
|
||||
this.setColour(3355443);
|
||||
int y = 4;
|
||||
final IAlleleSpecies species = ind.getGenome().getPrimary();
|
||||
final String branchBinomial = (species.getBranch() != null) ? species.getBranch().getScientific() : "<Unknown>";
|
||||
final String branchName = (species.getBranch() != null) ? species.getBranch().getName() : "Unknown";
|
||||
final String desc = species.getDescription();
|
||||
String descBody = "§o";
|
||||
String descSig = "";
|
||||
if (desc == null || desc == "" || desc.contains("for.description")) {
|
||||
descBody += "";
|
||||
}
|
||||
else {
|
||||
final String[] descStrings = desc.split("\\|");
|
||||
descBody += descStrings[0];
|
||||
for (int i = 1; i < descStrings.length - 1; ++i) {
|
||||
descBody = descBody + " " + descStrings[i];
|
||||
}
|
||||
if (descStrings.length > 1) {
|
||||
descSig += descStrings[descStrings.length - 1];
|
||||
}
|
||||
}
|
||||
String authority = species.getAuthority();
|
||||
if (authority.contains("Binnie")) {
|
||||
authority = "§1§l" + authority;
|
||||
}
|
||||
if (authority.contains("Sengir")) {
|
||||
authority = "§2§l" + authority;
|
||||
}
|
||||
if (authority.contains("MysteriousAges")) {
|
||||
authority = "§5§l" + authority;
|
||||
}
|
||||
new ControlTextCentered(this, y, "§nDescription").setColour(this.getColour());
|
||||
y += 16;
|
||||
new ControlTextCentered(this, y, species.getName() + "§r").setColour(this.getColour());
|
||||
y += 10;
|
||||
new ControlTextCentered(this, y, "§o" + branchBinomial + " " + species.getBinomial() + "§r").setColour(this.getColour());
|
||||
y += 20;
|
||||
new ControlTextCentered(this, y, "Discovered by §l" + authority + "§r").setColour(this.getColour());
|
||||
y += (int) (3.0f + CraftGUI.Render.textHeight("Discovered by §l" + authority + "§r", this.w()));
|
||||
new ControlTextCentered(this, y, "Genetic Complexity: " + species.getComplexity()).setColour(this.getColour());
|
||||
y += 26;
|
||||
final ControlText descText = new ControlText(this, new IArea(8.0f, y, this.w() - 16.0f, 0.0f), descBody + "§r", TextJustification.TopCenter);
|
||||
final IWidget signatureText = new ControlText(this, new IArea(8.0f, y, this.w() - 16.0f, 0.0f), descSig + "§r", TextJustification.BottomRight);
|
||||
descText.setColour(this.getColour());
|
||||
signatureText.setColour(this.getColour());
|
||||
final float descHeight = CraftGUI.Render.textHeight(descText.getValue(), descText.getSize().x());
|
||||
signatureText.setPosition(new IPoint(signatureText.pos().x(), descText.getPosition().y() + descHeight + 10.0f));
|
||||
this.setSize(new IPoint(this.w(), 20.0f + signatureText.y()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Description";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.gui;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import forestry.api.arboriculture.ITreeGenome;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import net.minecraft.init.Items;
|
||||
import forestry.api.arboriculture.IAlleleFruit;
|
||||
import forestry.api.genetics.IFruitFamily;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import java.util.Collection;
|
||||
import binnie.craftgui.minecraft.control.ControlItemDisplay;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import forestry.arboriculture.FruitProviderPod;
|
||||
import binnie.core.util.UniqueItemStackSet;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.arboriculture.EnumTreeChromosome;
|
||||
import binnie.Binnie;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public class AnalystPageFruit extends AnalystPageProduce
|
||||
{
|
||||
public AnalystPageFruit(final IWidget parent, final IArea area, final ITree ind) {
|
||||
super(parent, area);
|
||||
this.setColour(13382400);
|
||||
final ITreeGenome genome = ind.getGenome();
|
||||
int y = 4;
|
||||
new ControlTextCentered(this, y, "§nFruit").setColour(this.getColour());
|
||||
y += 12;
|
||||
new ControlTextCentered(this, y, "§oYield: " + Binnie.Genetics.treeBreedingSystem.getAlleleName(EnumTreeChromosome.YIELD, ind.getGenome().getActiveAllele(EnumTreeChromosome.YIELD))).setColour(this.getColour());
|
||||
y += 20;
|
||||
final Collection<ItemStack> products = new UniqueItemStackSet();
|
||||
final Collection<ItemStack> specialties = new UniqueItemStackSet();
|
||||
final Collection<ItemStack> wiid = new UniqueItemStackSet();
|
||||
for (final ItemStack stack : ind.getProduceList()) {
|
||||
products.add(stack);
|
||||
}
|
||||
for (final ItemStack stack : ind.getSpecialtyList()) {
|
||||
specialties.add(stack);
|
||||
}
|
||||
try {
|
||||
if (ind.getGenome().getFruitProvider() instanceof FruitProviderPod) {
|
||||
final FruitProviderPod pod = (FruitProviderPod) ind.getGenome().getFruitProvider();
|
||||
final Field f = FruitProviderPod.class.getDeclaredField("drop");
|
||||
f.setAccessible(true);
|
||||
for (final ItemStack stack2 : (ItemStack[]) f.get(pod)) {
|
||||
products.add(stack2);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (products.size() > 0) {
|
||||
new ControlTextCentered(this, y, "Natural Fruit").setColour(this.getColour());
|
||||
y += 10;
|
||||
final int w = products.size() * 18 - 2;
|
||||
final int i = 0;
|
||||
for (final ItemStack stack : products) {
|
||||
final ControlItemDisplay d = new ControlItemDisplay(this, (this.w() - w) / 2.0f + 18 * i, y);
|
||||
d.setTooltip();
|
||||
d.setItemStack(stack);
|
||||
}
|
||||
y += 26;
|
||||
}
|
||||
if (specialties.size() > 0) {
|
||||
new ControlTextCentered(this, y, "Specialty Fruit").setColour(this.getColour());
|
||||
y += 10;
|
||||
final int w = products.size() * 18 - 2;
|
||||
final int i = 0;
|
||||
for (final ItemStack stack : specialties) {
|
||||
final ControlItemDisplay d = new ControlItemDisplay(this, (this.w() - w) / 2.0f + 18 * i, y);
|
||||
d.setTooltip();
|
||||
d.setItemStack(stack);
|
||||
}
|
||||
y += 26;
|
||||
}
|
||||
final Collection<ItemStack> allProducts = new UniqueItemStackSet();
|
||||
for (final ItemStack stack3 : products) {
|
||||
allProducts.add(stack3);
|
||||
}
|
||||
for (final ItemStack stack3 : specialties) {
|
||||
allProducts.add(stack3);
|
||||
}
|
||||
final Collection<ItemStack> refinedProducts = new UniqueItemStackSet();
|
||||
refinedProducts.addAll(this.getAllProductsAndFluids(allProducts));
|
||||
if (refinedProducts.size() > 0) {
|
||||
y = this.getRefined("Refined Products", y, refinedProducts);
|
||||
y += 8;
|
||||
}
|
||||
if (products.size() == 0 && specialties.size() == 0) {
|
||||
new ControlTextCentered(this, y, "This tree has no \nfruits or nuts").setColour(this.getColour());
|
||||
y += 28;
|
||||
}
|
||||
new ControlTextCentered(this, y, "Possible Fruits").setColour(this.getColour());
|
||||
y += 12;
|
||||
final Collection<IAllele> fruitAlleles = Binnie.Genetics.getChromosomeMap(Binnie.Genetics.getTreeRoot()).get(EnumTreeChromosome.FRUITS);
|
||||
for (final IFruitFamily fam : ind.getGenome().getPrimary().getSuitableFruit()) {
|
||||
final Collection<ItemStack> stacks = new UniqueItemStackSet();
|
||||
for (final IAllele a : fruitAlleles) {
|
||||
if (((IAlleleFruit) a).getProvider().getFamily() == fam) {
|
||||
for (final ItemStack p : ((IAlleleFruit) a).getProvider().getProducts()) {
|
||||
stacks.add(p);
|
||||
}
|
||||
for (final ItemStack p : ((IAlleleFruit) a).getProvider().getSpecialty()) {
|
||||
stacks.add(p);
|
||||
}
|
||||
try {
|
||||
if (a.getUID().contains("fruitCocoa")) {
|
||||
stacks.add(new ItemStack(Items.dye, 1, 3));
|
||||
}
|
||||
else {
|
||||
if (!(((IAlleleFruit) a).getProvider() instanceof FruitProviderPod)) {
|
||||
continue;
|
||||
}
|
||||
final FruitProviderPod pod2 = (FruitProviderPod) ((IAlleleFruit) a).getProvider();
|
||||
final Field field = FruitProviderPod.class.getDeclaredField("drop");
|
||||
field.setAccessible(true);
|
||||
for (final ItemStack stack4 : (ItemStack[]) field.get(pod2)) {
|
||||
stacks.add(stack4);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
y = this.getRefined("§o" + fam.getName(), y, stacks);
|
||||
y += 2;
|
||||
}
|
||||
this.setSize(new IPoint(this.w(), y + 8));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Fruit";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.gui;
|
||||
|
||||
import forestry.api.genetics.IAllele;
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
import binnie.craftgui.core.geometry.TextJustification;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
import binnie.Binnie;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public class AnalystPageGenome extends ControlAnalystPage
|
||||
{
|
||||
boolean active;
|
||||
|
||||
public AnalystPageGenome(final IWidget parent, final IArea area, final boolean active, final IIndividual ind) {
|
||||
super(parent, area);
|
||||
this.active = active;
|
||||
this.setColour(26265);
|
||||
int y = 4;
|
||||
new ControlTextCentered(this, y, "§n" + this.getTitle()).setColour(this.getColour());
|
||||
y += 16;
|
||||
final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(ind.getClass());
|
||||
final BreedingSystem system = Binnie.Genetics.getSystem(root);
|
||||
final Control scaled = new Control(this, 0.0f, y, 0.0f, 0.0f) {
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(10.0f, -15.0f, 0.0f);
|
||||
GL11.glScalef(0.9f, 0.95f, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderForeground() {
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
};
|
||||
for (final IChromosomeType chromo : system.getActiveKaryotype()) {
|
||||
final IAllele allele = active ? ind.getGenome().getActiveAllele(chromo) : ind.getGenome().getInactiveAllele(chromo);
|
||||
final String alleleName = system.getAlleleName(chromo, allele);
|
||||
final float height = CraftGUI.Render.textHeight(alleleName, this.w() / 2.0f - 2.0f);
|
||||
new ControlText(scaled, new IArea(0.0f, y + (height - 9.0f) / 2.0f, this.w() / 2.0f - 2.0f, 0.0f), system.getChromosomeShortName(chromo) + " :", TextJustification.TopRight).setColour(this.getColour());
|
||||
new ControlText(scaled, new IArea(this.w() / 2.0f + 2.0f, y, this.w() / 2.0f - 2.0f, 0.0f), alleleName, TextJustification.TopLeft).setColour(this.getColour());
|
||||
y += (int) (3.0f + height);
|
||||
}
|
||||
this.setSize(new IPoint(this.w(), y + 8));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return (this.active ? "Active" : "Inactive") + " Genome";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.gui;
|
||||
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.arboriculture.EnumTreeChromosome;
|
||||
import binnie.Binnie;
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public class AnalystPageGrowth extends ControlAnalystPage
|
||||
{
|
||||
public AnalystPageGrowth(final IWidget parent, final IArea area, final IIndividual ind) {
|
||||
super(parent, area);
|
||||
this.setColour(3355443);
|
||||
int y = 4;
|
||||
final IAlleleSpecies species = ind.getGenome().getPrimary();
|
||||
new ControlTextCentered(this, y, "§nGrowth").setColour(this.getColour());
|
||||
y += 12;
|
||||
if (ind instanceof ITree) {
|
||||
final ITree tree = (ITree) ind;
|
||||
final int mat = tree.getGenome().getMaturationTime();
|
||||
new ControlTextCentered(this, y, "Saplings mature in").setColour(this.getColour());
|
||||
y += 12;
|
||||
new ControlTextCentered(this, y, "§l" + this.getTimeString(1373.3999f * mat)).setColour(this.getColour());
|
||||
y += 22;
|
||||
new ControlTextCentered(this, y, "§oHeight: " + Binnie.Genetics.treeBreedingSystem.getAlleleName(EnumTreeChromosome.HEIGHT, ind.getGenome().getActiveAllele(EnumTreeChromosome.HEIGHT))).setColour(this.getColour());
|
||||
y += 12;
|
||||
new ControlTextCentered(this, y, "§oGirth: " + Binnie.Genetics.treeBreedingSystem.getAlleleName(EnumTreeChromosome.GIRTH, ind.getGenome().getActiveAllele(EnumTreeChromosome.GIRTH))).setColour(this.getColour());
|
||||
y += 20;
|
||||
new ControlTextCentered(this, y, "Growth Conditions").setColour(this.getColour());
|
||||
y += 12;
|
||||
new ControlTextCentered(this, y, "§o" + tree.getGenome().getGrowthProvider().getDescription()).setColour(this.getColour());
|
||||
y += 12;
|
||||
for (final String s : tree.getGenome().getGrowthProvider().getInfo()) {
|
||||
new ControlTextCentered(this, y, "§o" + s).setColour(this.getColour());
|
||||
y += 12;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Growth";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.gui;
|
||||
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import binnie.Binnie;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public class AnalystPageKaryogram extends ControlAnalystPage
|
||||
{
|
||||
public AnalystPageKaryogram(final IWidget parent, final IArea area, final IIndividual ind) {
|
||||
super(parent, area);
|
||||
this.setColour(10040319);
|
||||
int y = 4;
|
||||
new ControlTextCentered(this, y, "§nKaryogram").setColour(this.getColour());
|
||||
y += 16;
|
||||
y += 8;
|
||||
final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(ind.getClass());
|
||||
final BreedingSystem system = Binnie.Genetics.getSystem(root);
|
||||
final int maxBiomePerLine = (int) ((this.w() + 4.0f - 16.0f) / 22.0f);
|
||||
float karygramX = (this.w() - (Math.min(maxBiomePerLine, system.getActiveKaryotype().size()) * 18 - 4)) / 2.0f;
|
||||
int dx = 0;
|
||||
int dy = 0;
|
||||
int rem = system.getActiveKaryotype().size();
|
||||
for (final IChromosomeType type : system.getActiveKaryotype()) {
|
||||
new ControlAnalystChromosome(this, karygramX + dx, y + dy, root, type, ind.getGenome().getActiveAllele(type), ind.getGenome().getInactiveAllele(type));
|
||||
dx += 22;
|
||||
if (dx >= 22 * maxBiomePerLine - 22) {
|
||||
rem -= maxBiomePerLine - 1;
|
||||
if (rem < maxBiomePerLine) {
|
||||
karygramX += (maxBiomePerLine - 1 - rem) * 22 / 2.0f;
|
||||
}
|
||||
dx = 0;
|
||||
dy += 28;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Karyogram";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,277 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.gui;
|
||||
|
||||
import binnie.craftgui.core.geometry.TextJustification;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import binnie.craftgui.minecraft.EnumColor;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import binnie.genetics.item.ModuleItem;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
import forestry.api.genetics.IMutation;
|
||||
import binnie.craftgui.minecraft.control.ControlItemDisplay;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import binnie.core.Mods;
|
||||
import binnie.core.genetics.ForestryAllele;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.extrabees.ExtraBees;
|
||||
import binnie.extrabees.genetics.ExtraBeesSpecies;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.Binnie;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public class AnalystPageMutations extends ControlAnalystPage
|
||||
{
|
||||
public AnalystPageMutations(final IWidget parent, final IArea area, final IIndividual ind, final boolean isMaster) {
|
||||
super(parent, area);
|
||||
this.setColour(3355392);
|
||||
int y = 4;
|
||||
new ControlTextCentered(this, y, "§nMutations").setColour(this.getColour());
|
||||
y += 18;
|
||||
final BreedingSystem system = Binnie.Genetics.getSystem(ind.getGenome().getSpeciesRoot());
|
||||
final List<IMutation> discovered = system.getDiscoveredMutations(Window.get(this).getWorld(), Window.get(this).getUsername());
|
||||
final IAlleleSpecies speciesCurrent = ind.getGenome().getPrimary();
|
||||
final Collection<IMutation> resultant = system.getResultantMutations(speciesCurrent);
|
||||
final Collection<IMutation> further = system.getFurtherMutations(speciesCurrent);
|
||||
if (ind instanceof IBee) {
|
||||
ItemStack hive = null;
|
||||
if (ind.getGenome().getPrimary() == ExtraBeesSpecies.WATER) {
|
||||
hive = new ItemStack(ExtraBees.hive, 1, 0);
|
||||
}
|
||||
if (ind.getGenome().getPrimary() == ExtraBeesSpecies.ROCK) {
|
||||
hive = new ItemStack(ExtraBees.hive, 1, 1);
|
||||
}
|
||||
if (ind.getGenome().getPrimary() == ExtraBeesSpecies.BASALT) {
|
||||
hive = new ItemStack(ExtraBees.hive, 1, 2);
|
||||
}
|
||||
if (ind.getGenome().getPrimary() == ForestryAllele.BeeSpecies.Forest.getAllele()) {
|
||||
hive = new ItemStack(Mods.Forestry.block("beehives"), 1, 1);
|
||||
}
|
||||
if (ind.getGenome().getPrimary() == ForestryAllele.BeeSpecies.Meadows.getAllele()) {
|
||||
hive = new ItemStack(Mods.Forestry.block("beehives"), 1, 2);
|
||||
}
|
||||
if (ind.getGenome().getPrimary() == ForestryAllele.BeeSpecies.Modest.getAllele()) {
|
||||
hive = new ItemStack(Mods.Forestry.block("beehives"), 1, 3);
|
||||
}
|
||||
if (ind.getGenome().getPrimary() == ForestryAllele.BeeSpecies.Tropical.getAllele()) {
|
||||
hive = new ItemStack(Mods.Forestry.block("beehives"), 1, 4);
|
||||
}
|
||||
if (ind.getGenome().getPrimary() == ForestryAllele.BeeSpecies.Ended.getAllele()) {
|
||||
hive = new ItemStack(Mods.Forestry.block("beehives"), 1, 5);
|
||||
}
|
||||
if (ind.getGenome().getPrimary() == ForestryAllele.BeeSpecies.Wintry.getAllele()) {
|
||||
hive = new ItemStack(Mods.Forestry.block("beehives"), 1, 6);
|
||||
}
|
||||
if (ind.getGenome().getPrimary() == ForestryAllele.BeeSpecies.Marshy.getAllele()) {
|
||||
hive = new ItemStack(Mods.Forestry.block("beehives"), 1, 7);
|
||||
}
|
||||
if (ind.getGenome().getPrimary() == ForestryAllele.BeeSpecies.Steadfast.getAllele()) {
|
||||
hive = new ItemStack(Blocks.chest);
|
||||
}
|
||||
if (ind.getGenome().getPrimary() == ForestryAllele.BeeSpecies.Valiant.getAllele()) {
|
||||
new ControlTextCentered(this, y, "Natural Habitat").setColour(this.getColour());
|
||||
y += 10;
|
||||
new ControlTextCentered(this, y, "§oFound in any Hive").setColour(this.getColour());
|
||||
y += 22;
|
||||
}
|
||||
else if (ind.getGenome().getPrimary() == ForestryAllele.BeeSpecies.Monastic.getAllele()) {
|
||||
new ControlTextCentered(this, y, "Natural Habitat").setColour(this.getColour());
|
||||
y += 10;
|
||||
new ControlTextCentered(this, y, "§oBought from Villagers").setColour(this.getColour());
|
||||
y += 22;
|
||||
}
|
||||
else if (hive != null) {
|
||||
new ControlTextCentered(this, y, "Natural Habitat").setColour(this.getColour());
|
||||
y += 10;
|
||||
final ControlItemDisplay display = new ControlItemDisplay(this, (this.w() - 16.0f) / 2.0f, y);
|
||||
if (ind.getGenome().getPrimary() == ForestryAllele.BeeSpecies.Steadfast.getAllele()) {
|
||||
display.addTooltip("Dungeon Chests");
|
||||
}
|
||||
else {
|
||||
display.setTooltip();
|
||||
}
|
||||
display.setItemStack(hive);
|
||||
y += 24;
|
||||
}
|
||||
}
|
||||
float ox = (this.w() - 88.0f - 8.0f) / 2.0f;
|
||||
float dx = 0.0f;
|
||||
if (!resultant.isEmpty()) {
|
||||
if (resultant.size() == 1) {
|
||||
ox = (this.w() - 44.0f) / 2.0f;
|
||||
}
|
||||
new ControlTextCentered(this, y, "Resultant Mutations").setColour(this.getColour());
|
||||
y += 10;
|
||||
for (final IMutation mutation : resultant) {
|
||||
final float specificChance = this.getSpecificChance(ind, mutation, system);
|
||||
if (!isMaster && !this.isKnown(system, mutation)) {
|
||||
new ControlUnknownMutation(this, ox + dx, y, 44.0f, 16.0f);
|
||||
}
|
||||
else {
|
||||
new Control(this, ox + dx, y, 44.0f, 16.0f) {
|
||||
@Override
|
||||
public void initialise() {
|
||||
final IAlleleSpecies species0 = mutation.getAllele0();
|
||||
final IAlleleSpecies species2 = mutation.getAllele1();
|
||||
final String comb = species0.getName() + " + " + species2.getName();
|
||||
this.addTooltip(comb);
|
||||
String chance = AnalystPageMutations.this.getMutationColour(mutation.getBaseChance()).getCode() + (int) mutation.getBaseChance() + "% Chance";
|
||||
if (specificChance != mutation.getBaseChance()) {
|
||||
chance = chance + AnalystPageMutations.this.getMutationColour(specificChance).getCode() + " (" + (int) specificChance + "% currently)";
|
||||
}
|
||||
this.addTooltip(chance);
|
||||
for (final String s : mutation.getSpecialConditions()) {
|
||||
this.addTooltip(s);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.Render.item(new IPoint(0.0f, 0.0f), system.getDefaultMember(mutation.getAllele0().getUID()));
|
||||
CraftGUI.Render.item(new IPoint(28.0f, 0.0f), system.getDefaultMember(mutation.getAllele1().getUID()));
|
||||
if (specificChance != mutation.getBaseChance()) {
|
||||
CraftGUI.Render.colour(AnalystPageMutations.this.getMutationColour(mutation.getBaseChance()).getColour());
|
||||
CraftGUI.Render.iconItem(new IPoint(14.0f, 0.0f), ModuleItem.iconAdd0.getIcon());
|
||||
CraftGUI.Render.colour(AnalystPageMutations.this.getMutationColour(specificChance).getColour());
|
||||
CraftGUI.Render.iconItem(new IPoint(14.0f, 0.0f), ModuleItem.iconAdd1.getIcon());
|
||||
}
|
||||
else {
|
||||
CraftGUI.Render.colour(AnalystPageMutations.this.getMutationColour(mutation.getBaseChance()).getColour());
|
||||
CraftGUI.Render.iconItem(new IPoint(14.0f, 0.0f), ModuleItem.iconAdd.getIcon());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
dx = 52.0f - dx;
|
||||
if (dx == 0.0f || resultant.size() == 1) {
|
||||
y += 18;
|
||||
}
|
||||
}
|
||||
if (dx != 0.0f && resultant.size() != 1) {
|
||||
y += 18;
|
||||
}
|
||||
y += 10;
|
||||
}
|
||||
ox = (this.w() - 88.0f - 8.0f) / 2.0f;
|
||||
dx = 0.0f;
|
||||
if (!further.isEmpty()) {
|
||||
if (further.size() == 1) {
|
||||
ox = (this.w() - 44.0f) / 2.0f;
|
||||
}
|
||||
new ControlTextCentered(this, y, "Further Mutations").setColour(this.getColour());
|
||||
y += 10;
|
||||
for (final IMutation mutation : further) {
|
||||
final IAllele speciesComb = mutation.getPartner(speciesCurrent);
|
||||
final float specificChance2 = this.getSpecificChance(ind, mutation, system);
|
||||
if (!isMaster && !this.isKnown(system, mutation)) {
|
||||
new ControlUnknownMutation(this, ox + dx, y, 44.0f, 16.0f);
|
||||
}
|
||||
else {
|
||||
new Control(this, ox + dx, y, 44.0f, 16.0f) {
|
||||
@Override
|
||||
public void initialise() {
|
||||
final IAlleleSpecies species0 = (IAlleleSpecies) speciesComb;
|
||||
final IAlleleSpecies species2 = (IAlleleSpecies) mutation.getTemplate()[0];
|
||||
this.addTooltip(species2.getName());
|
||||
final String comb = speciesCurrent.getName() + " + " + species0.getName();
|
||||
this.addTooltip(comb);
|
||||
String chance = AnalystPageMutations.this.getMutationColour(mutation.getBaseChance()).getCode() + (int) mutation.getBaseChance() + "% Chance";
|
||||
if (specificChance2 != mutation.getBaseChance()) {
|
||||
chance = chance + AnalystPageMutations.this.getMutationColour(specificChance2).getCode() + " (" + (int) specificChance2 + "% currently)";
|
||||
}
|
||||
this.addTooltip(chance);
|
||||
for (final String s : mutation.getSpecialConditions()) {
|
||||
this.addTooltip(s);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.Render.item(new IPoint(0.0f, 0.0f), system.getDefaultMember(speciesComb.getUID()));
|
||||
CraftGUI.Render.item(new IPoint(28.0f, 0.0f), system.getDefaultMember(mutation.getTemplate()[0].getUID()));
|
||||
CraftGUI.Render.colour(AnalystPageMutations.this.getMutationColour(mutation.getBaseChance()).getColour());
|
||||
if (specificChance2 != mutation.getBaseChance()) {
|
||||
CraftGUI.Render.colour(AnalystPageMutations.this.getMutationColour(mutation.getBaseChance()).getColour());
|
||||
CraftGUI.Render.iconItem(new IPoint(14.0f, 0.0f), ModuleItem.iconArrow0.getIcon());
|
||||
CraftGUI.Render.colour(AnalystPageMutations.this.getMutationColour(specificChance2).getColour());
|
||||
CraftGUI.Render.iconItem(new IPoint(14.0f, 0.0f), ModuleItem.iconArrow1.getIcon());
|
||||
}
|
||||
else {
|
||||
CraftGUI.Render.colour(AnalystPageMutations.this.getMutationColour(mutation.getBaseChance()).getColour());
|
||||
CraftGUI.Render.iconItem(new IPoint(14.0f, 0.0f), ModuleItem.iconArrow.getIcon());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
dx = 52.0f - dx;
|
||||
if (dx == 0.0f || further.size() == 1) {
|
||||
y += 18;
|
||||
}
|
||||
}
|
||||
if (dx != 0.0f && further.size() != 1) {
|
||||
y += 18;
|
||||
}
|
||||
}
|
||||
y += 8;
|
||||
this.setSize(new IPoint(this.w(), y));
|
||||
}
|
||||
|
||||
private boolean isKnown(final BreedingSystem system, final IMutation mutation) {
|
||||
return system.getDiscoveredMutations(this.getWindow().getWorld(), this.getWindow().getPlayer().getGameProfile()).contains(mutation);
|
||||
}
|
||||
|
||||
private float getSpecificChance(final IIndividual ind, final IMutation mutation, final BreedingSystem system) {
|
||||
return system.getChance(mutation, this.getWindow().getPlayer(), mutation.getAllele0(), mutation.getAllele1());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Mutations";
|
||||
}
|
||||
|
||||
protected EnumColor getMutationColour(final float percent) {
|
||||
if (percent >= 20.0f) {
|
||||
return EnumColor.DarkGreen;
|
||||
}
|
||||
if (percent >= 15.0f) {
|
||||
return EnumColor.Green;
|
||||
}
|
||||
if (percent >= 10.0f) {
|
||||
return EnumColor.Yellow;
|
||||
}
|
||||
if (percent >= 5.0f) {
|
||||
return EnumColor.Gold;
|
||||
}
|
||||
if (percent > 0.0f) {
|
||||
return EnumColor.Red;
|
||||
}
|
||||
return EnumColor.DarkRed;
|
||||
}
|
||||
|
||||
static class ControlUnknownMutation extends Control
|
||||
{
|
||||
public ControlUnknownMutation(final IWidget parent, final float x, final float y, final float w, final float h) {
|
||||
super(parent, x, y, w, h);
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
this.addTooltip("Unknown Mutation");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.Render.text(this.getArea(), TextJustification.MiddleCenter, "UNKNOWN", 11184810);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.gui;
|
||||
|
||||
import binnie.craftgui.minecraft.control.ControlItemDisplay;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import binnie.extratrees.machines.Distillery;
|
||||
import binnie.extratrees.machines.Brewery;
|
||||
import binnie.core.util.UniqueFluidStackSet;
|
||||
import binnie.extratrees.machines.Press;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
import net.minecraft.item.crafting.ShapedRecipes;
|
||||
import net.minecraft.item.crafting.ShapelessRecipes;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import binnie.core.util.UniqueItemStackSet;
|
||||
import java.util.Collection;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public abstract class AnalystPageProduce extends ControlAnalystPage
|
||||
{
|
||||
public AnalystPageProduce(final IWidget parent, final IArea area) {
|
||||
super(parent, area);
|
||||
}
|
||||
|
||||
protected Collection<? extends ItemStack> getAllProducts(final ItemStack key) {
|
||||
final Collection<ItemStack> products = new UniqueItemStackSet();
|
||||
products.addAll(this.getCentrifuge(key));
|
||||
products.addAll(this.getSqueezer(key));
|
||||
products.add(FurnaceRecipes.smelting().getSmeltingResult(key));
|
||||
products.addAll(this.getCrafting(key));
|
||||
return products;
|
||||
}
|
||||
|
||||
public Collection<ItemStack> getCentrifuge(final ItemStack stack) {
|
||||
final List<ItemStack> products = new ArrayList<ItemStack>();
|
||||
for (final Map.Entry<Object[], Object[]> recipe : RecipeManagers.centrifugeManager.getRecipes().entrySet()) {
|
||||
boolean isRecipe = false;
|
||||
for (final Object obj : recipe.getKey()) {
|
||||
if (obj instanceof ItemStack && stack.isItemEqual((ItemStack) obj)) {
|
||||
isRecipe = true;
|
||||
}
|
||||
}
|
||||
if (isRecipe) {
|
||||
for (final Object obj : recipe.getValue()) {
|
||||
if (obj instanceof ItemStack) {
|
||||
products.add((ItemStack) obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return products;
|
||||
}
|
||||
|
||||
public Collection<ItemStack> getSqueezer(final ItemStack stack) {
|
||||
final List<ItemStack> products = new ArrayList<ItemStack>();
|
||||
for (final Map.Entry<Object[], Object[]> recipe : RecipeManagers.squeezerManager.getRecipes().entrySet()) {
|
||||
boolean isRecipe = false;
|
||||
for (final Object obj : recipe.getKey()) {
|
||||
if (obj instanceof ItemStack && stack.isItemEqual((ItemStack) obj)) {
|
||||
isRecipe = true;
|
||||
}
|
||||
}
|
||||
if (isRecipe) {
|
||||
for (final Object obj : recipe.getValue()) {
|
||||
if (obj instanceof ItemStack) {
|
||||
products.add((ItemStack) obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return products;
|
||||
}
|
||||
|
||||
public Collection<ItemStack> getCrafting(final ItemStack stack) {
|
||||
final List<ItemStack> products = new ArrayList<ItemStack>();
|
||||
for (final Object recipeO : CraftingManager.getInstance().getRecipeList()) {
|
||||
if (recipeO instanceof ShapelessRecipes) {
|
||||
final ShapelessRecipes recipe = (ShapelessRecipes) recipeO;
|
||||
boolean match = true;
|
||||
for (final Object rec : recipe.recipeItems) {
|
||||
if (rec != null && (!(rec instanceof ItemStack) || !stack.isItemEqual((ItemStack) rec))) {
|
||||
match = false;
|
||||
}
|
||||
}
|
||||
if (match) {
|
||||
products.add(recipe.getRecipeOutput());
|
||||
}
|
||||
}
|
||||
if (recipeO instanceof ShapedRecipes) {
|
||||
final ShapedRecipes recipe2 = (ShapedRecipes) recipeO;
|
||||
boolean match = true;
|
||||
for (final Object rec2 : recipe2.recipeItems) {
|
||||
if (rec2 != null && (!(rec2 instanceof ItemStack) || !stack.isItemEqual((ItemStack) rec2))) {
|
||||
match = false;
|
||||
}
|
||||
}
|
||||
if (match) {
|
||||
products.add(recipe2.getRecipeOutput());
|
||||
}
|
||||
}
|
||||
if (recipeO instanceof ShapelessOreRecipe) {
|
||||
final ShapelessOreRecipe recipe3 = (ShapelessOreRecipe) recipeO;
|
||||
boolean match = true;
|
||||
for (final Object rec : recipe3.getInput()) {
|
||||
if (rec != null && (!(rec instanceof ItemStack) || !stack.isItemEqual((ItemStack) rec))) {
|
||||
match = false;
|
||||
}
|
||||
}
|
||||
if (!match) {
|
||||
continue;
|
||||
}
|
||||
products.add(recipe3.getRecipeOutput());
|
||||
}
|
||||
}
|
||||
return products;
|
||||
}
|
||||
|
||||
public Collection<FluidStack> getAllFluids(final ItemStack stack) {
|
||||
final List<FluidStack> products = new ArrayList<FluidStack>();
|
||||
products.addAll(this.getSqueezerFluid(stack));
|
||||
if (Press.getOutput(stack) != null) {
|
||||
products.add(Press.getOutput(stack));
|
||||
}
|
||||
return products;
|
||||
}
|
||||
|
||||
public Collection<FluidStack> getSqueezerFluid(final ItemStack stack) {
|
||||
final List<FluidStack> products = new ArrayList<FluidStack>();
|
||||
for (final Map.Entry<Object[], Object[]> recipe : RecipeManagers.squeezerManager.getRecipes().entrySet()) {
|
||||
boolean isRecipe = false;
|
||||
for (final Object obj : recipe.getKey()) {
|
||||
if (obj instanceof ItemStack && stack.isItemEqual((ItemStack) obj)) {
|
||||
isRecipe = true;
|
||||
}
|
||||
}
|
||||
if (isRecipe) {
|
||||
for (final Object obj : recipe.getValue()) {
|
||||
if (obj instanceof FluidStack) {
|
||||
products.add((FluidStack) obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return products;
|
||||
}
|
||||
|
||||
protected Collection<? extends FluidStack> getAllProducts(final FluidStack stack) {
|
||||
final Collection<FluidStack> fluids = new UniqueFluidStackSet();
|
||||
fluids.add(Brewery.getOutput(stack));
|
||||
fluids.add(Distillery.getOutput(stack, 0));
|
||||
fluids.add(Distillery.getOutput(stack, 1));
|
||||
fluids.add(Distillery.getOutput(stack, 2));
|
||||
return fluids;
|
||||
}
|
||||
|
||||
protected Collection<ItemStack> getAllProductsAndFluids(final Collection<ItemStack> collection) {
|
||||
final Collection<ItemStack> products = new UniqueItemStackSet();
|
||||
for (final ItemStack stack : collection) {
|
||||
products.addAll(this.getAllProducts(stack));
|
||||
}
|
||||
final Collection<ItemStack> products2 = new UniqueItemStackSet();
|
||||
for (final ItemStack stack2 : products) {
|
||||
products2.addAll(this.getAllProducts(stack2));
|
||||
}
|
||||
final Collection<ItemStack> products3 = new UniqueItemStackSet();
|
||||
for (final ItemStack stack3 : products2) {
|
||||
products3.addAll(this.getAllProducts(stack3));
|
||||
}
|
||||
products.addAll(products2);
|
||||
products.addAll(products3);
|
||||
final Collection<FluidStack> allFluids = new UniqueFluidStackSet();
|
||||
for (final ItemStack stack4 : collection) {
|
||||
allFluids.addAll(this.getAllFluids(stack4));
|
||||
}
|
||||
final Collection<FluidStack> fluids2 = new UniqueFluidStackSet();
|
||||
for (final FluidStack stack5 : allFluids) {
|
||||
fluids2.addAll(this.getAllProducts(stack5));
|
||||
}
|
||||
final Collection<FluidStack> fluids3 = new UniqueFluidStackSet();
|
||||
for (final FluidStack stack6 : fluids2) {
|
||||
fluids3.addAll(this.getAllProducts(stack6));
|
||||
}
|
||||
allFluids.addAll(fluids2);
|
||||
allFluids.addAll(fluids3);
|
||||
for (final FluidStack fluid : allFluids) {
|
||||
ItemStack container = null;
|
||||
for (final FluidContainerRegistry.FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) {
|
||||
if (data.emptyContainer.isItemEqual(new ItemStack(Items.glass_bottle)) && data.fluid.isFluidEqual(fluid)) {
|
||||
container = data.filledContainer;
|
||||
break;
|
||||
}
|
||||
if (data.emptyContainer.isItemEqual(new ItemStack(Items.bucket)) && data.fluid.isFluidEqual(fluid)) {
|
||||
container = data.filledContainer;
|
||||
break;
|
||||
}
|
||||
if (data.fluid.isFluidEqual(fluid)) {
|
||||
container = data.filledContainer;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (container != null) {
|
||||
products.add(container);
|
||||
}
|
||||
}
|
||||
return products;
|
||||
}
|
||||
|
||||
protected int getRefined(final String string, int y, final Collection<ItemStack> products) {
|
||||
new ControlTextCentered(this, y, string).setColour(this.getColour());
|
||||
y += 10;
|
||||
final int maxBiomePerLine = (int) ((this.w() + 2.0f - 16.0f) / 18.0f);
|
||||
final float biomeListX = (this.w() - (Math.min(maxBiomePerLine, products.size()) * 18 - 2)) / 2.0f;
|
||||
int dx = 0;
|
||||
int dy = 0;
|
||||
for (final ItemStack soilStack : products) {
|
||||
if (dx >= 18 * maxBiomePerLine) {
|
||||
dx = 0;
|
||||
dy += 18;
|
||||
}
|
||||
final FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(soilStack);
|
||||
soilStack.stackSize = 1;
|
||||
final ControlItemDisplay display = new ControlItemDisplay(this, biomeListX + dx, y + dy, soilStack, fluid == null);
|
||||
if (fluid != null) {
|
||||
display.addTooltip(fluid.getLocalizedName());
|
||||
}
|
||||
dx += 18;
|
||||
}
|
||||
if (dx != 0) {
|
||||
dy += 18;
|
||||
}
|
||||
y += dy;
|
||||
return y;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.gui;
|
||||
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
import binnie.craftgui.core.geometry.CraftGUIUtil;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import binnie.craftgui.core.Tooltip;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.extratrees.kitchen.ControlFluidDisplay;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import binnie.craftgui.minecraft.control.ControlItemDisplay;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import java.util.HashMap;
|
||||
import binnie.core.util.UniqueItemStackSet;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.Binnie;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public class AnalystPageProducts extends AnalystPageProduce
|
||||
{
|
||||
public AnalystPageProducts(final IWidget parent, final IArea area, final IBee ind) {
|
||||
super(parent, area);
|
||||
this.setColour(13382400);
|
||||
final IBeeGenome genome = ind.getGenome();
|
||||
final float speed = genome.getSpeed();
|
||||
final float modeSpeed = Binnie.Genetics.getBeeRoot().getBeekeepingMode(BinnieCore.proxy.getWorld()).getBeeModifier().getProductionModifier(genome, 1.0f);
|
||||
int y = 4;
|
||||
new ControlTextCentered(this, y, "§nProduce").setColour(this.getColour());
|
||||
y += 12;
|
||||
new ControlTextCentered(this, y, "§oRate: " + Binnie.Genetics.beeBreedingSystem.getAlleleName(EnumBeeChromosome.SPEED, ind.getGenome().getActiveAllele(EnumBeeChromosome.SPEED))).setColour(this.getColour());
|
||||
y += 20;
|
||||
final Collection<ItemStack> refinedProducts = new UniqueItemStackSet();
|
||||
final Collection<ItemStack> productList = new UniqueItemStackSet();
|
||||
final Collection<ItemStack> specialtyList = new UniqueItemStackSet();
|
||||
Map<ItemStack, Float> products = new HashMap<ItemStack, Float>();
|
||||
products.putAll(genome.getPrimary().getProductChances());
|
||||
products.putAll(genome.getSecondary().getProductChances());
|
||||
if (!products.isEmpty()) {
|
||||
new ControlTextCentered(this, y, "Natural Products").setColour(this.getColour());
|
||||
y += 12;
|
||||
for (final Map.Entry<ItemStack, Float> entry : products.entrySet()) {
|
||||
if (!productList.add(entry.getKey())) {
|
||||
continue;
|
||||
}
|
||||
refinedProducts.addAll(this.getAllProducts(entry.getKey()));
|
||||
this.createProductEntry(entry.getKey(), entry.getValue(), y, speed * modeSpeed);
|
||||
y += 18;
|
||||
}
|
||||
y += 12;
|
||||
}
|
||||
products = genome.getPrimary().getSpecialtyChances();
|
||||
if (!products.isEmpty()) {
|
||||
new ControlTextCentered(this, y, "Specialty Products").setColour(this.getColour());
|
||||
y += 12;
|
||||
for (final Map.Entry<ItemStack, Float> entry : products.entrySet()) {
|
||||
refinedProducts.addAll(this.getAllProducts(entry.getKey()));
|
||||
this.createProductEntry(entry.getKey(), entry.getValue(), y, speed * modeSpeed);
|
||||
y += 18;
|
||||
}
|
||||
y += 12;
|
||||
}
|
||||
new ControlTextCentered(this, y, "Refined Products").setColour(this.getColour());
|
||||
y += 12;
|
||||
Collection<ItemStack> level2Products = new UniqueItemStackSet();
|
||||
for (final ItemStack stack : refinedProducts) {
|
||||
level2Products.addAll(this.getAllProducts(stack));
|
||||
}
|
||||
refinedProducts.addAll(level2Products);
|
||||
level2Products = new UniqueItemStackSet();
|
||||
for (final ItemStack stack : refinedProducts) {
|
||||
level2Products.addAll(this.getAllProducts(stack));
|
||||
}
|
||||
refinedProducts.addAll(level2Products);
|
||||
final Collection<FluidStack> allFluids = new ArrayList<FluidStack>();
|
||||
for (final ItemStack stack2 : refinedProducts) {
|
||||
for (final FluidStack addition : this.getAllFluids(stack2)) {
|
||||
boolean alreadyIn = false;
|
||||
for (final FluidStack existing : allFluids) {
|
||||
if (existing.isFluidEqual(addition)) {
|
||||
alreadyIn = true;
|
||||
}
|
||||
}
|
||||
if (!alreadyIn) {
|
||||
allFluids.add(addition);
|
||||
}
|
||||
}
|
||||
}
|
||||
final int maxBiomePerLine = (int) ((this.w() + 2.0f - 16.0f) / 18.0f);
|
||||
final float biomeListX = (this.w() - (Math.min(maxBiomePerLine, allFluids.size() + refinedProducts.size()) * 18 - 2)) / 2.0f;
|
||||
int dx = 0;
|
||||
int dy = 0;
|
||||
for (final ItemStack soilStack : refinedProducts) {
|
||||
if (dx >= 18 * maxBiomePerLine) {
|
||||
dx = 0;
|
||||
dy += 18;
|
||||
}
|
||||
final ControlItemDisplay display = new ControlItemDisplay(this, biomeListX + dx, y + dy);
|
||||
display.setItemStack(soilStack);
|
||||
display.setTooltip();
|
||||
dx += 18;
|
||||
}
|
||||
for (final FluidStack soilStack2 : allFluids) {
|
||||
if (dx >= 18 * maxBiomePerLine) {
|
||||
dx = 0;
|
||||
dy += 18;
|
||||
}
|
||||
ItemStack container = null;
|
||||
for (final FluidContainerRegistry.FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) {
|
||||
if (data.emptyContainer.isItemEqual(new ItemStack(Items.glass_bottle)) && data.fluid.isFluidEqual(soilStack2)) {
|
||||
container = data.filledContainer;
|
||||
break;
|
||||
}
|
||||
if (data.emptyContainer.isItemEqual(new ItemStack(Items.bucket)) && data.fluid.isFluidEqual(soilStack2)) {
|
||||
container = data.filledContainer;
|
||||
break;
|
||||
}
|
||||
if (data.fluid.isFluidEqual(soilStack2)) {
|
||||
container = data.filledContainer;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (container == null) {
|
||||
final ControlFluidDisplay display2 = new ControlFluidDisplay(this, biomeListX + dx, y + dy);
|
||||
display2.setItemStack(soilStack2);
|
||||
display2.setTooltip();
|
||||
}
|
||||
else {
|
||||
final ControlItemDisplay display3 = new ControlItemDisplay(this, biomeListX + dx, y + dy);
|
||||
display3.setItemStack(container);
|
||||
display3.setTooltip();
|
||||
}
|
||||
dx += 18;
|
||||
}
|
||||
this.setSize(new IPoint(this.w(), y + dy + 18 + 8));
|
||||
}
|
||||
|
||||
private void createProductEntry(final ItemStack key, final Float value, final int y, final float speed) {
|
||||
final ControlItemDisplay item = new ControlItemDisplay(this, 16.0f, y) {
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
super.getTooltip(tooltip);
|
||||
final Collection<ItemStack> products = AnalystPageProducts.this.getCentrifuge(key);
|
||||
if (!products.isEmpty()) {
|
||||
tooltip.add("Centrifuges to give: ");
|
||||
for (final ItemStack prod : products) {
|
||||
final NBTTagCompound nbt = new NBTTagCompound();
|
||||
prod.writeToNBT(nbt);
|
||||
tooltip.add(prod, prod.getDisplayName());
|
||||
}
|
||||
}
|
||||
final Collection<ItemStack> liquids = AnalystPageProducts.this.getSqueezer(key);
|
||||
if (!liquids.isEmpty()) {
|
||||
tooltip.add("Squeezes to give: ");
|
||||
for (final ItemStack prod2 : liquids) {
|
||||
final NBTTagCompound nbt2 = new NBTTagCompound();
|
||||
prod2.writeToNBT(nbt2);
|
||||
tooltip.add(prod2, prod2.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
item.setTooltip();
|
||||
final ControlText textWidget = new ControlTextCentered(this, y + 4, "");
|
||||
textWidget.setColour(this.getColour());
|
||||
CraftGUIUtil.moveWidget(textWidget, new IPoint(12.0f, 0.0f));
|
||||
item.setItemStack(key);
|
||||
final float time = (int) (PluginApiculture.ticksPerBeeWorkCycle * 100.0 / (speed * value));
|
||||
textWidget.setValue("Every " + this.getTimeString(time));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Produce";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.gui;
|
||||
|
||||
import binnie.Binnie;
|
||||
import java.util.List;
|
||||
import forestry.api.genetics.EnumTolerance;
|
||||
import java.util.EnumSet;
|
||||
import java.util.ArrayList;
|
||||
import binnie.craftgui.minecraft.control.ControlItemDisplay;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.botany.gardening.BlockSoil;
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.api.EnumAcidity;
|
||||
import binnie.core.genetics.Tolerance;
|
||||
import binnie.botany.api.EnumMoisture;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
import binnie.craftgui.core.geometry.TextJustification;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import binnie.botany.api.IFlower;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public class AnalystPageSoil extends ControlAnalystPage
|
||||
{
|
||||
public AnalystPageSoil(final IWidget parent, final IArea area, final IFlower flower) {
|
||||
super(parent, area);
|
||||
this.setColour(6697728);
|
||||
final EnumMoisture moisture = flower.getGenome().getPrimary().getMoisture();
|
||||
final EnumTolerance moistureTol = flower.getGenome().getToleranceMoisture();
|
||||
final EnumAcidity pH = flower.getGenome().getPrimary().getPH();
|
||||
final EnumTolerance pHTol = flower.getGenome().getTolerancePH();
|
||||
int y = 4;
|
||||
new ControlTextCentered(this, y, "§nSoil").setColour(this.getColour());
|
||||
y += 16;
|
||||
new ControlText(this, new IArea(4.0f, y, this.w() - 8.0f, 14.0f), "Moisture Tolerance", TextJustification.MiddleCenter).setColour(this.getColour());
|
||||
y += 12;
|
||||
this.createMoisture(this, (this.w() - 100.0f) / 2.0f, y, 100.0f, 10.0f, moisture, moistureTol);
|
||||
y += 16;
|
||||
new ControlText(this, new IArea(4.0f, y, this.w() - 8.0f, 14.0f), "pH Tolerance", TextJustification.MiddleCenter).setColour(this.getColour());
|
||||
y += 12;
|
||||
this.createAcidity(this, (this.w() - 100.0f) / 2.0f, y, 100.0f, 10.0f, pH, pHTol);
|
||||
y += 16;
|
||||
new ControlText(this, new IArea(4.0f, y, this.w() - 8.0f, 14.0f), "Recommended Soil", TextJustification.MiddleCenter).setColour(this.getColour());
|
||||
y += 12;
|
||||
EnumMoisture recomMoisture = EnumMoisture.Normal;
|
||||
final boolean canTolNormal = Tolerance.canTolerate(moisture, EnumMoisture.Normal, moistureTol);
|
||||
final boolean canTolDamp = Tolerance.canTolerate(moisture, EnumMoisture.Damp, moistureTol);
|
||||
final boolean canTolDry = Tolerance.canTolerate(moisture, EnumMoisture.Dry, moistureTol);
|
||||
if (canTolNormal) {
|
||||
if (canTolDamp && !canTolDry) {
|
||||
recomMoisture = EnumMoisture.Damp;
|
||||
}
|
||||
else if (canTolDry && !canTolDamp) {
|
||||
recomMoisture = EnumMoisture.Dry;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (canTolDamp) {
|
||||
recomMoisture = EnumMoisture.Damp;
|
||||
}
|
||||
if (canTolDry) {
|
||||
recomMoisture = EnumMoisture.Dry;
|
||||
}
|
||||
}
|
||||
EnumAcidity recomPH = EnumAcidity.Neutral;
|
||||
final boolean canTolNeutral = Tolerance.canTolerate(pH, EnumAcidity.Neutral, pHTol);
|
||||
final boolean canTolAcid = Tolerance.canTolerate(pH, EnumAcidity.Acid, pHTol);
|
||||
final boolean canTolAlkaline = Tolerance.canTolerate(pH, EnumAcidity.Alkaline, pHTol);
|
||||
if (canTolNeutral) {
|
||||
if (canTolAcid && !canTolAlkaline) {
|
||||
recomPH = EnumAcidity.Acid;
|
||||
}
|
||||
else if (canTolAlkaline && !canTolAcid) {
|
||||
recomPH = EnumAcidity.Alkaline;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (canTolAcid) {
|
||||
recomPH = EnumAcidity.Acid;
|
||||
}
|
||||
if (canTolAlkaline) {
|
||||
recomPH = EnumAcidity.Alkaline;
|
||||
}
|
||||
}
|
||||
final ItemStack stack = new ItemStack(Botany.soil, 1, BlockSoil.getMeta(recomPH, recomMoisture));
|
||||
final ControlItemDisplay recomSoil = new ControlItemDisplay(this, (this.w() - 24.0f) / 2.0f, y, 24.0f);
|
||||
recomSoil.setItemStack(stack);
|
||||
recomSoil.setTooltip();
|
||||
y += 32;
|
||||
new ControlText(this, new IArea(4.0f, y, this.w() - 8.0f, 14.0f), "Other Soils", TextJustification.MiddleCenter).setColour(this.getColour());
|
||||
y += 12;
|
||||
final List<ItemStack> stacks = new ArrayList<ItemStack>();
|
||||
for (final EnumAcidity a : EnumSet.range(EnumAcidity.Acid, EnumAcidity.Alkaline)) {
|
||||
for (final EnumMoisture b : EnumSet.range(EnumMoisture.Dry, EnumMoisture.Damp)) {
|
||||
if (Tolerance.canTolerate(pH, a, pHTol) && Tolerance.canTolerate(moisture, b, moistureTol) && (a != recomPH || b != recomMoisture)) {
|
||||
stacks.add(new ItemStack(Botany.soil, 1, BlockSoil.getMeta(a, b)));
|
||||
}
|
||||
}
|
||||
}
|
||||
final float soilListWidth = 17 * stacks.size() - 1;
|
||||
final float soilListX = (this.w() - soilListWidth) / 2.0f;
|
||||
int t = 0;
|
||||
for (final ItemStack soilStack : stacks) {
|
||||
final ControlItemDisplay display = new ControlItemDisplay(this, soilListX + 17 * t++, y);
|
||||
display.setItemStack(soilStack);
|
||||
display.setTooltip();
|
||||
}
|
||||
}
|
||||
|
||||
protected void createMoisture(final IWidget parent, final float x, final float y, final float w, final float h, final EnumMoisture value, final EnumTolerance tol) {
|
||||
new ControlToleranceBar<EnumMoisture>(parent, x, y, w, h, EnumMoisture.class) {
|
||||
@Override
|
||||
protected String getName(final EnumMoisture value) {
|
||||
return Binnie.Language.localise(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getColour(final EnumMoisture value) {
|
||||
return (new int[] { 13434828, 6737151, 3368703 })[value.ordinal()];
|
||||
}
|
||||
}.setValues(value, tol);
|
||||
}
|
||||
|
||||
protected void createAcidity(final IWidget parent, final float x, final float y, final float w, final float h, final EnumAcidity value, final EnumTolerance tol) {
|
||||
new ControlToleranceBar<EnumAcidity>(parent, x, y, w, h, EnumAcidity.class) {
|
||||
@Override
|
||||
protected String getName(final EnumAcidity value) {
|
||||
return Binnie.Language.localise(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getColour(final EnumAcidity value) {
|
||||
return (new int[] { 16711782, 65280, 26367 })[value.ordinal()];
|
||||
}
|
||||
}.setValues(value, tol);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Soil";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.gui;
|
||||
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import forestry.api.lepidopterology.IButterfly;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public class AnalystPageSpecimen extends ControlAnalystPage
|
||||
{
|
||||
public AnalystPageSpecimen(final IWidget parent, final IArea area, final IButterfly ind) {
|
||||
super(parent, area);
|
||||
this.setColour(3355443);
|
||||
int y = 4;
|
||||
new ControlTextCentered(this, y, "§nSpecimen").setColour(this.getColour());
|
||||
y += 12;
|
||||
final float w = (this.w() - 16.0f) * ind.getSize();
|
||||
new ControlIndividualDisplay(this, (this.w() - w) / 2.0f, y + (this.w() - w) / 2.0f, w, ind);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Specimen";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.gui;
|
||||
|
||||
import forestry.api.arboriculture.ITreeGenome;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import binnie.craftgui.minecraft.control.ControlItemDisplay;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import binnie.core.util.UniqueItemStackSet;
|
||||
import binnie.craftgui.minecraft.control.ControlIconDisplay;
|
||||
import binnie.genetics.item.ModuleItem;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.arboriculture.EnumTreeChromosome;
|
||||
import forestry.api.genetics.IAlleleBoolean;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.extratrees.FakeWorld;
|
||||
|
||||
public class AnalystPageWood extends AnalystPageProduce
|
||||
{
|
||||
public AnalystPageWood(final IWidget parent, final IArea area, final ITree ind) {
|
||||
super(parent, area);
|
||||
this.setColour(6697728);
|
||||
final ITreeGenome genome = ind.getGenome();
|
||||
int y = 4;
|
||||
new ControlTextCentered(this, y, "§nWood").setColour(this.getColour());
|
||||
y += 12;
|
||||
if (((IAlleleBoolean) ind.getGenome().getActiveAllele(EnumTreeChromosome.FIREPROOF)).getValue()) {
|
||||
new ControlIconDisplay(this, (this.w() - 16.0f) / 2.0f, y, ModuleItem.iconNoFire.getIcon()).addTooltip("Fireproof");
|
||||
}
|
||||
else {
|
||||
new ControlIconDisplay(this, (this.w() - 16.0f) / 2.0f, y, ModuleItem.iconFire.getIcon()).addTooltip("Flammable");
|
||||
}
|
||||
y += 30;
|
||||
final Collection<ItemStack> products = new UniqueItemStackSet();
|
||||
|
||||
genome.getPrimary().getGenerator().setLogBlock(genome, FakeWorld.instance, 0, 0, 0, ForgeDirection.UP);
|
||||
ItemStack stackWood = FakeWorld.instance.getWooLog();
|
||||
if (stackWood != null) {
|
||||
products.add(stackWood);
|
||||
}
|
||||
// for (final ItemStack stack :
|
||||
// ind.getGenome().getFruitProvider().getProducts()) {
|
||||
// products.add(stack);
|
||||
// }
|
||||
if (products.size() > 0) {
|
||||
new ControlTextCentered(this, y, "Logs").setColour(this.getColour());
|
||||
y += 10;
|
||||
final int w = products.size() * 18 - 2;
|
||||
final int i = 0;
|
||||
for (final ItemStack stack : products) {
|
||||
final ControlItemDisplay d = new ControlItemDisplay(this, (this.w() - w) / 2.0f + 18 * i, y);
|
||||
d.setTooltip();
|
||||
d.setItemStack(stack);
|
||||
}
|
||||
y += 26;
|
||||
}
|
||||
final Collection<ItemStack> allProducts = new UniqueItemStackSet();
|
||||
for (final ItemStack stack2 : products) {
|
||||
allProducts.add(stack2);
|
||||
}
|
||||
final Collection<ItemStack> refinedProducts = new UniqueItemStackSet();
|
||||
refinedProducts.addAll(this.getAllProductsAndFluids(allProducts));
|
||||
if (refinedProducts.size() > 0) {
|
||||
y = this.getRefined("Refined Products", y, refinedProducts);
|
||||
y += 8;
|
||||
}
|
||||
if (products.size() == 0) {
|
||||
new ControlTextCentered(this, y, "This tree has no \nfruits or nuts").setColour(this.getColour());
|
||||
y += 28;
|
||||
}
|
||||
this.setSize(new IPoint(this.w(), y + 8));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Wood";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.gui;
|
||||
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import binnie.Binnie;
|
||||
import binnie.craftgui.core.Tooltip;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import binnie.craftgui.resource.minecraft.StandardTexture;
|
||||
import binnie.core.texture.BinnieCoreTexture;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.resource.Texture;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import binnie.craftgui.core.ITooltip;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlAnalystChromosome extends Control implements ITooltip
|
||||
{
|
||||
IAllele allele0;
|
||||
IAllele allele1;
|
||||
IChromosomeType chromosomeType;
|
||||
ISpeciesRoot root;
|
||||
Texture Homozygous;
|
||||
Texture Heterozygous;
|
||||
|
||||
public ControlAnalystChromosome(final IWidget parent, final float x, final float y, final ISpeciesRoot root, final IChromosomeType type, final IAllele allele0, final IAllele allele1) {
|
||||
super(parent, x, y, 16.0f, 22.0f);
|
||||
this.Homozygous = new StandardTexture(0, 0, 16, 22, BinnieCoreTexture.GUIAnalyst);
|
||||
this.Heterozygous = new StandardTexture(16, 0, 16, 22, BinnieCoreTexture.GUIAnalyst);
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
this.root = root;
|
||||
this.chromosomeType = type;
|
||||
this.allele0 = allele0;
|
||||
this.allele1 = allele1;
|
||||
}
|
||||
|
||||
public boolean isHomozygous() {
|
||||
return this.allele0.getUID().equals(this.allele1.getUID());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
super.onRenderBackground();
|
||||
CraftGUI.Render.texture(this.isHomozygous() ? this.Homozygous : this.Heterozygous, IPoint.ZERO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
final BreedingSystem system = Binnie.Genetics.getSystem(this.root);
|
||||
tooltip.add(system.getChromosomeName(this.chromosomeType));
|
||||
if (this.isHomozygous()) {
|
||||
tooltip.add(system.getAlleleName(this.chromosomeType, this.allele0));
|
||||
}
|
||||
else {
|
||||
tooltip.add("Active: " + system.getAlleleName(this.chromosomeType, this.allele0));
|
||||
tooltip.add("Inactive: " + system.getAlleleName(this.chromosomeType, this.allele1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.gui;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public abstract class ControlAnalystPage extends Control
|
||||
{
|
||||
public ControlAnalystPage(final IWidget parent, final IArea area) {
|
||||
super(parent, area);
|
||||
this.hide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
}
|
||||
|
||||
public abstract String getTitle();
|
||||
|
||||
protected String getTimeString(final float time) {
|
||||
final float seconds = time / 20.0f;
|
||||
final float minutes = seconds / 60.0f;
|
||||
final float hours = minutes / 60.0f;
|
||||
final DecimalFormat df = new DecimalFormat("#.0");
|
||||
if (hours > 1.0f) {
|
||||
return df.format(hours) + " hours";
|
||||
}
|
||||
if (minutes > 1.0f) {
|
||||
return df.format(minutes) + " min.";
|
||||
}
|
||||
return df.format(seconds) + " sec.";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.gui;
|
||||
|
||||
import binnie.craftgui.core.Tooltip;
|
||||
import net.minecraft.util.IIcon;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import forestry.core.render.TextureManager;
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import binnie.craftgui.core.ITooltip;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlBiome extends Control implements ITooltip
|
||||
{
|
||||
BiomeGenBase biome;
|
||||
String iconCategory;
|
||||
|
||||
public ControlBiome(final IWidget parent, final float x, final float y, final float w, final float h, final BiomeGenBase biome) {
|
||||
super(parent, x, y, w, h);
|
||||
this.biome = null;
|
||||
this.iconCategory = "plains";
|
||||
this.biome = biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
if (BiomeDictionary.isBiomeOfType(this.biome, BiomeDictionary.Type.MOUNTAIN)) {
|
||||
this.iconCategory = "hills";
|
||||
}
|
||||
if (BiomeDictionary.isBiomeOfType(this.biome, BiomeDictionary.Type.HILLS)) {
|
||||
this.iconCategory = "hills";
|
||||
}
|
||||
if (BiomeDictionary.isBiomeOfType(this.biome, BiomeDictionary.Type.SANDY)) {
|
||||
this.iconCategory = "desert";
|
||||
}
|
||||
if (BiomeDictionary.isBiomeOfType(this.biome, BiomeDictionary.Type.SNOWY)) {
|
||||
this.iconCategory = "snow";
|
||||
}
|
||||
if (BiomeDictionary.isBiomeOfType(this.biome, BiomeDictionary.Type.FOREST)) {
|
||||
this.iconCategory = "forest";
|
||||
}
|
||||
if (BiomeDictionary.isBiomeOfType(this.biome, BiomeDictionary.Type.SWAMP)) {
|
||||
this.iconCategory = "swamp";
|
||||
}
|
||||
if (BiomeDictionary.isBiomeOfType(this.biome, BiomeDictionary.Type.JUNGLE)) {
|
||||
this.iconCategory = "jungle";
|
||||
}
|
||||
if (BiomeDictionary.isBiomeOfType(this.biome, BiomeDictionary.Type.COLD) && BiomeDictionary.isBiomeOfType(this.biome, BiomeDictionary.Type.FOREST)) {
|
||||
this.iconCategory = "taiga";
|
||||
}
|
||||
if (BiomeDictionary.isBiomeOfType(this.biome, BiomeDictionary.Type.MUSHROOM)) {
|
||||
this.iconCategory = "mushroom";
|
||||
}
|
||||
if (BiomeDictionary.isBiomeOfType(this.biome, BiomeDictionary.Type.OCEAN)) {
|
||||
this.iconCategory = "ocean";
|
||||
}
|
||||
if (BiomeDictionary.isBiomeOfType(this.biome, BiomeDictionary.Type.NETHER)) {
|
||||
this.iconCategory = "nether";
|
||||
}
|
||||
if (BiomeDictionary.isBiomeOfType(this.biome, BiomeDictionary.Type.END)) {
|
||||
this.iconCategory = "end";
|
||||
}
|
||||
final IIcon icon = TextureManager.getInstance().getDefault("habitats/" + this.iconCategory);
|
||||
CraftGUI.Render.iconItem(IPoint.ZERO, icon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
tooltip.add(this.biome.biomeName.replaceAll("(\\p{Ll})(\\p{Lu})", "$1 $2"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.gui;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.craftgui.core.Tooltip;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.events.EventValueChanged;
|
||||
import binnie.craftgui.events.EventWidget;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import binnie.craftgui.resource.minecraft.StandardTexture;
|
||||
import binnie.extrabees.core.ExtraBeeTexture;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import binnie.craftgui.resource.Texture;
|
||||
import binnie.craftgui.core.ITooltip;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlChromoPicker extends Control implements ITooltip
|
||||
{
|
||||
Texture Selected;
|
||||
Texture Texture;
|
||||
IChromosomeType type;
|
||||
ControlChromosome parent;
|
||||
|
||||
public ControlChromoPicker(final ControlChromosome parent, final float x, final float y, final IChromosomeType chromo) {
|
||||
super(parent, x, y, 16.0f, 16.0f);
|
||||
this.Selected = new StandardTexture(160, 18, 16, 16, ExtraBeeTexture.GUIPunnett);
|
||||
this.Texture = new StandardTexture(160, 34, 16, 16, ExtraBeeTexture.GUIPunnett);
|
||||
this.type = chromo;
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
this.parent = parent;
|
||||
this.addSelfEventHandler(new EventWidget.StartMouseOver.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventWidget.StartMouseOver event) {
|
||||
ControlChromoPicker.this.callEvent(new EventValueChanged<Object>(ControlChromoPicker.this.getWidget(), ControlChromoPicker.this.type));
|
||||
}
|
||||
});
|
||||
this.addSelfEventHandler(new EventWidget.EndMouseOver.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventWidget.EndMouseOver event) {
|
||||
ControlChromoPicker.this.callEvent(new EventValueChanged<Object>(ControlChromoPicker.this.getWidget(), null));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
super.onRenderBackground();
|
||||
final boolean selected = this.isMouseOver();
|
||||
final Texture text = selected ? this.Selected : this.Texture;
|
||||
CraftGUI.Render.texture(text, IPoint.ZERO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
tooltip.add(Binnie.Genetics.getSystem(this.parent.getRoot()).getChromosomeName(this.type));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.gui;
|
||||
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import forestry.api.lepidopterology.EnumButterflyChromosome;
|
||||
import binnie.botany.api.EnumFlowerChromosome;
|
||||
import forestry.api.arboriculture.EnumTreeChromosome;
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import binnie.Binnie;
|
||||
import binnie.craftgui.resource.minecraft.StandardTexture;
|
||||
import binnie.core.texture.BinnieCoreTexture;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import binnie.craftgui.resource.Texture;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import binnie.craftgui.controls.core.IControlValue;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlChromosome extends Control implements IControlValue<IChromosomeType>
|
||||
{
|
||||
Texture BeeTexture;
|
||||
Texture TreeTexture;
|
||||
Texture MothTexture;
|
||||
Texture FlowerTexture;
|
||||
IChromosomeType chromo;
|
||||
ISpeciesRoot species;
|
||||
|
||||
public ControlChromosome(final IWidget parent, final float x, final float y) {
|
||||
super(parent, x, y, 96.0f, 96.0f);
|
||||
this.BeeTexture = new StandardTexture(0, 0, 96, 96, BinnieCoreTexture.GUIBreeding);
|
||||
this.TreeTexture = new StandardTexture(96, 0, 96, 96, BinnieCoreTexture.GUIBreeding);
|
||||
this.MothTexture = new StandardTexture(96, 96, 96, 96, BinnieCoreTexture.GUIBreeding);
|
||||
this.FlowerTexture = new StandardTexture(0, 96, 96, 96, BinnieCoreTexture.GUIBreeding);
|
||||
this.chromo = null;
|
||||
this.species = null;
|
||||
}
|
||||
|
||||
public ISpeciesRoot getRoot() {
|
||||
return this.species;
|
||||
}
|
||||
|
||||
public void setRoot(final ISpeciesRoot root) {
|
||||
if (root != this.species) {
|
||||
this.species = root;
|
||||
this.deleteAllChildren();
|
||||
if (root == Binnie.Genetics.getBeeRoot()) {
|
||||
new ControlChromoPicker(this, 28.0f, 47.0f, EnumBeeChromosome.SPECIES);
|
||||
new ControlChromoPicker(this, 28.0f, 72.0f, EnumBeeChromosome.SPEED);
|
||||
new ControlChromoPicker(this, 19.0f, 20.0f, EnumBeeChromosome.LIFESPAN);
|
||||
new ControlChromoPicker(this, 55.0f, 65.0f, EnumBeeChromosome.FERTILITY);
|
||||
new ControlChromoPicker(this, 28.0f, 1.0f, EnumBeeChromosome.TEMPERATURE_TOLERANCE);
|
||||
new ControlChromoPicker(this, 61.0f, 37.0f, EnumBeeChromosome.NOCTURNAL);
|
||||
new ControlChromoPicker(this, 81.0f, 76.0f, EnumBeeChromosome.HUMIDITY_TOLERANCE);
|
||||
new ControlChromoPicker(this, 44.0f, 21.0f, EnumBeeChromosome.TOLERANT_FLYER);
|
||||
new ControlChromoPicker(this, 3.0f, 37.0f, EnumBeeChromosome.CAVE_DWELLING);
|
||||
new ControlChromoPicker(this, 4.0f, 65.0f, EnumBeeChromosome.FLOWER_PROVIDER);
|
||||
new ControlChromoPicker(this, 83.0f, 27.0f, EnumBeeChromosome.FLOWERING);
|
||||
new ControlChromoPicker(this, 71.0f, 10.0f, EnumBeeChromosome.TERRITORY);
|
||||
new ControlChromoPicker(this, 84.0f, 54.0f, EnumBeeChromosome.EFFECT);
|
||||
}
|
||||
else if (root == Binnie.Genetics.getTreeRoot()) {
|
||||
new ControlChromoPicker(this, 48.0f, 48.0f, EnumTreeChromosome.SPECIES);
|
||||
new ControlChromoPicker(this, 43.0f, 12.0f, EnumTreeChromosome.GROWTH);
|
||||
new ControlChromoPicker(this, 43.0f, 84.0f, EnumTreeChromosome.HEIGHT);
|
||||
new ControlChromoPicker(this, 25.0f, 63.0f, EnumTreeChromosome.FERTILITY);
|
||||
new ControlChromoPicker(this, 72.0f, 57.0f, EnumTreeChromosome.FRUITS);
|
||||
new ControlChromoPicker(this, 21.0f, 43.0f, EnumTreeChromosome.YIELD);
|
||||
new ControlChromoPicker(this, 38.0f, 32.0f, EnumTreeChromosome.PLANT);
|
||||
new ControlChromoPicker(this, 15.0f, 17.0f, EnumTreeChromosome.SAPPINESS);
|
||||
new ControlChromoPicker(this, 75.0f, 78.0f, EnumTreeChromosome.TERRITORY);
|
||||
new ControlChromoPicker(this, 67.0f, 15.0f, EnumTreeChromosome.EFFECT);
|
||||
new ControlChromoPicker(this, 70.0f, 34.0f, EnumTreeChromosome.MATURATION);
|
||||
new ControlChromoPicker(this, 45.0f, 67.0f, EnumTreeChromosome.GIRTH);
|
||||
new ControlChromoPicker(this, 5.0f, 70.0f, EnumTreeChromosome.FIREPROOF);
|
||||
}
|
||||
else if (root == Binnie.Genetics.getFlowerRoot()) {
|
||||
new ControlChromoPicker(this, 35.0f, 81.0f, EnumFlowerChromosome.SPECIES);
|
||||
new ControlChromoPicker(this, 36.0f, 28.0f, EnumFlowerChromosome.PRIMARY);
|
||||
new ControlChromoPicker(this, 27.0f, 13.0f, EnumFlowerChromosome.SECONDARY);
|
||||
new ControlChromoPicker(this, 47.0f, 15.0f, EnumFlowerChromosome.FERTILITY);
|
||||
new ControlChromoPicker(this, 54.0f, 31.0f, EnumFlowerChromosome.TERRITORY);
|
||||
new ControlChromoPicker(this, 15.0f, 55.0f, EnumFlowerChromosome.EFFECT);
|
||||
new ControlChromoPicker(this, 23.0f, 38.0f, EnumFlowerChromosome.LIFESPAN);
|
||||
new ControlChromoPicker(this, 17.0f, 77.0f, EnumFlowerChromosome.TEMPERATURE_TOLERANCE);
|
||||
new ControlChromoPicker(this, 52.0f, 51.0f, EnumFlowerChromosome.HUMIDITY_TOLERANCE);
|
||||
new ControlChromoPicker(this, 54.0f, 80.0f, EnumFlowerChromosome.PH_TOLERANCE);
|
||||
new ControlChromoPicker(this, 41.0f, 42.0f, EnumFlowerChromosome.SAPPINESS);
|
||||
new ControlChromoPicker(this, 37.0f, 63.0f, EnumFlowerChromosome.STEM);
|
||||
}
|
||||
else if (root == Binnie.Genetics.getButterflyRoot()) {
|
||||
new ControlChromoPicker(this, 40.0f, 40.0f, EnumButterflyChromosome.SPECIES);
|
||||
new ControlChromoPicker(this, 63.0f, 32.0f, EnumButterflyChromosome.SIZE);
|
||||
new ControlChromoPicker(this, 32.0f, 63.0f, EnumButterflyChromosome.SPEED);
|
||||
new ControlChromoPicker(this, 11.0f, 27.0f, EnumButterflyChromosome.LIFESPAN);
|
||||
new ControlChromoPicker(this, 16.0f, 12.0f, EnumButterflyChromosome.METABOLISM);
|
||||
new ControlChromoPicker(this, 17.0f, 63.0f, EnumButterflyChromosome.FERTILITY);
|
||||
new ControlChromoPicker(this, 34.0f, 12.0f, EnumButterflyChromosome.TEMPERATURE_TOLERANCE);
|
||||
new ControlChromoPicker(this, 22.0f, 46.0f, EnumButterflyChromosome.HUMIDITY_TOLERANCE);
|
||||
new ControlChromoPicker(this, 53.0f, 26.0f, EnumButterflyChromosome.NOCTURNAL);
|
||||
new ControlChromoPicker(this, 71.0f, 53.0f, EnumButterflyChromosome.TOLERANT_FLYER);
|
||||
new ControlChromoPicker(this, 78.0f, 12.0f, EnumButterflyChromosome.FIRE_RESIST);
|
||||
new ControlChromoPicker(this, 55.0f, 55.0f, EnumButterflyChromosome.FLOWER_PROVIDER);
|
||||
new ControlChromoPicker(this, 27.0f, 31.0f, EnumButterflyChromosome.EFFECT);
|
||||
new ControlChromoPicker(this, 87.0f, 45.0f, EnumButterflyChromosome.TERRITORY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChromosomeType getValue() {
|
||||
return this.chromo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(final IChromosomeType value) {
|
||||
this.chromo = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
if (this.species == null) {
|
||||
return;
|
||||
}
|
||||
super.onRenderBackground();
|
||||
final Texture text = this.getTypeTexture();
|
||||
CraftGUI.Render.texture(text, IPoint.ZERO);
|
||||
}
|
||||
|
||||
private Texture getTypeTexture() {
|
||||
if (this.species == Binnie.Genetics.getBeeRoot()) {
|
||||
return this.BeeTexture;
|
||||
}
|
||||
if (this.species == Binnie.Genetics.getTreeRoot()) {
|
||||
return this.TreeTexture;
|
||||
}
|
||||
if (this.species == Binnie.Genetics.getButterflyRoot()) {
|
||||
return this.MothTexture;
|
||||
}
|
||||
if (this.species == Binnie.Genetics.getFlowerRoot()) {
|
||||
return this.FlowerTexture;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.gui;
|
||||
|
||||
import binnie.craftgui.core.geometry.TextJustification;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.controls.listbox.ControlList;
|
||||
import binnie.core.genetics.Gene;
|
||||
import binnie.craftgui.controls.listbox.ControlOption;
|
||||
|
||||
public class ControlGenesisOption extends ControlOption<Gene>
|
||||
{
|
||||
public ControlGenesisOption(final ControlList<Gene> parent, final Gene gene, final int y) {
|
||||
super(parent, gene, y);
|
||||
}
|
||||
|
||||
String getAlleleName() {
|
||||
return this.getValue().getAlleleName();
|
||||
}
|
||||
|
||||
String getChromosomeName() {
|
||||
return this.getValue().getShortChromosomeName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
super.onRenderBackground();
|
||||
CraftGUI.Render.text(new IArea(0.0f, 0.0f, 70.0f, 22.0f), TextJustification.MiddleCenter, this.getChromosomeName(), this.getColour());
|
||||
CraftGUI.Render.text(new IArea(75.0f, 0.0f, 80.0f, 22.0f), TextJustification.MiddleCenter, this.getAlleleName(), this.getColour());
|
||||
CraftGUI.Render.solid(new IArea(70.0f, 2.0f, 1.0f, 16.0f), -16777216 + this.getColour());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.gui;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import binnie.craftgui.core.Tooltip;
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import binnie.Binnie;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.core.ITooltip;
|
||||
import binnie.craftgui.minecraft.control.ControlItemDisplay;
|
||||
|
||||
public class ControlIndividualDisplay extends ControlItemDisplay implements ITooltip
|
||||
{
|
||||
public ControlIndividualDisplay(final IWidget parent, final float x, final float y, final IIndividual ind) {
|
||||
this(parent, x, y, 16.0f, ind);
|
||||
}
|
||||
|
||||
public ControlIndividualDisplay(final IWidget parent, final float x, final float y, final float size, final IIndividual ind) {
|
||||
super(parent, x, y, size);
|
||||
final BreedingSystem system = Binnie.Genetics.getSystem(ind.getGenome().getSpeciesRoot());
|
||||
this.setItemStack(system.getSpeciesRoot().getMemberStack(ind, system.getDefaultType()));
|
||||
this.setTooltip();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
final ItemStack stack = this.getItemStack();
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(stack);
|
||||
if (ind == null) {
|
||||
return;
|
||||
}
|
||||
tooltip.add(ind.getGenome().getPrimary().getName());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.gui;
|
||||
|
||||
import binnie.core.genetics.Tolerance;
|
||||
import forestry.api.genetics.EnumTolerance;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.geometry.IBorder;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.core.Tooltip;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import java.util.EnumSet;
|
||||
import binnie.craftgui.core.ITooltip;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public abstract class ControlToleranceBar<T extends Enum<T>> extends Control implements ITooltip
|
||||
{
|
||||
private Class<T> enumClass;
|
||||
EnumSet<T> tolerated;
|
||||
EnumSet<T> fullSet;
|
||||
|
||||
public ControlToleranceBar(final IWidget parent, final float x, final float y, final float width, final float height, final Class<T> clss) {
|
||||
super(parent, x, y, width, height);
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
this.enumClass = clss;
|
||||
this.tolerated = EnumSet.noneOf(this.enumClass);
|
||||
this.fullSet = EnumSet.allOf(this.enumClass);
|
||||
if (this.enumClass == EnumTemperature.class) {
|
||||
this.fullSet.remove(EnumTemperature.NONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(final Tooltip list) {
|
||||
final int types = this.fullSet.size();
|
||||
final int type = (int) ((int) this.getRelativeMousePosition().x() / (this.getSize().x() / types));
|
||||
for (final T tol : this.fullSet) {
|
||||
if (tol.ordinal() - ((this.enumClass == EnumTemperature.class) ? 1 : 0) == type) {
|
||||
list.add((this.tolerated.contains(tol) ? "" : "§8") + this.getName(tol));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract String getName(final T p0);
|
||||
|
||||
protected abstract int getColour(final T p0);
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.Render.gradientRect(this.getArea(), -1431655766, -1431655766);
|
||||
final float w = this.getArea().w() / this.fullSet.size();
|
||||
int t = 0;
|
||||
for (final T value : this.fullSet) {
|
||||
final int col = (this.tolerated.contains(value) ? -16777216 : 855638016) + this.getColour(value);
|
||||
final IBorder inset = new IBorder(this.tolerated.contains(value) ? 1.0f : 3.0f);
|
||||
CraftGUI.Render.gradientRect(new IArea(w * t, 0.0f, w, this.h()).inset(inset), col, col);
|
||||
++t;
|
||||
}
|
||||
}
|
||||
|
||||
public void setValues(final T value, final EnumTolerance enumTol) {
|
||||
this.tolerated.clear();
|
||||
final Tolerance tol = Tolerance.get(enumTol);
|
||||
for (final T full : this.fullSet) {
|
||||
if (full.ordinal() > value.ordinal() + tol.getBounds()[1]) {
|
||||
continue;
|
||||
}
|
||||
if (full.ordinal() < value.ordinal() + tol.getBounds()[0]) {
|
||||
continue;
|
||||
}
|
||||
this.tolerated.add(full);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.gui;
|
||||
|
||||
import binnie.craftgui.core.Tooltip;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.core.ITooltip;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlTooltip extends Control implements ITooltip
|
||||
{
|
||||
public ControlTooltip(final IWidget parent, final float x, final float y, final float w, final float h) {
|
||||
super(parent, x, y, w, h);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,485 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.gui;
|
||||
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.lepidopterology.IButterfly;
|
||||
import binnie.botany.api.IFlower;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import binnie.craftgui.events.EventKey;
|
||||
import binnie.craftgui.minecraft.control.ControlPlayerInventory;
|
||||
import binnie.craftgui.core.geometry.Position;
|
||||
import binnie.craftgui.controls.scroll.ControlScrollBar;
|
||||
import binnie.craftgui.minecraft.MinecraftGUI;
|
||||
import binnie.craftgui.minecraft.InventoryType;
|
||||
import binnie.craftgui.minecraft.control.ControlSlot;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.resource.minecraft.CraftGUITexture;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.core.Tooltip;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import binnie.craftgui.core.Widget;
|
||||
import forestry.api.genetics.IBreedingTracker;
|
||||
import binnie.Binnie;
|
||||
import binnie.genetics.machine.ModuleMachine;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import binnie.genetics.machine.Analyser;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.core.AbstractMod;
|
||||
import java.util.ArrayList;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import binnie.craftgui.minecraft.control.ControlSlide;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import java.util.List;
|
||||
import binnie.craftgui.window.Panel;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
import binnie.craftgui.controls.scroll.ControlScrollableContent;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
|
||||
public class WindowAnalyst extends Window
|
||||
{
|
||||
IWidget baseWidget;
|
||||
ControlScrollableContent leftPage;
|
||||
ControlScrollableContent rightPage;
|
||||
Control tabBar;
|
||||
Panel analystPanel;
|
||||
List<ControlAnalystPage> analystPages;
|
||||
IArea analystPageSize;
|
||||
boolean isDatabase;
|
||||
boolean isMaster;
|
||||
boolean lockedSearch;
|
||||
private Control analystNone;
|
||||
private ControlSlide slideUpInv;
|
||||
IIndividual current;
|
||||
BreedingSystem currentSystem;
|
||||
|
||||
public WindowAnalyst(final EntityPlayer player, final IInventory inventory, final Side side, final boolean database, final boolean master) {
|
||||
super(312.0f, 230.0f, player, inventory, side);
|
||||
this.baseWidget = null;
|
||||
this.tabBar = null;
|
||||
this.analystPages = new ArrayList<ControlAnalystPage>();
|
||||
this.analystPageSize = null;
|
||||
this.isDatabase = false;
|
||||
this.isMaster = false;
|
||||
this.lockedSearch = false;
|
||||
this.current = null;
|
||||
this.currentSystem = null;
|
||||
this.isDatabase = database;
|
||||
this.isMaster = master;
|
||||
this.lockedSearch = this.isDatabase;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractMod getMod() {
|
||||
return Genetics.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getName() {
|
||||
return "Analyst";
|
||||
}
|
||||
|
||||
private void setupValidators() {
|
||||
if (!this.isDatabase) {
|
||||
this.getWindowInventory().setValidator(0, new SlotValidator.Individual() {
|
||||
@Override
|
||||
public boolean isValid(final ItemStack itemStack) {
|
||||
return Analyser.isAnalysed(itemStack) || (Analyser.isAnalysable(itemStack) && WindowAnalyst.this.getWindowInventory().getStackInSlot(1) != null);
|
||||
}
|
||||
});
|
||||
this.getWindowInventory().setValidator(1, new SlotValidator.Item(GeneticsItems.DNADye.get(1), ModuleMachine.IconDye));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialiseServer() {
|
||||
for (final BreedingSystem system : Binnie.Genetics.getActiveSystems()) {
|
||||
final IBreedingTracker tracker = system.getSpeciesRoot().getBreedingTracker(this.getWorld(), this.getUsername());
|
||||
if (tracker != null) {
|
||||
tracker.synchToPlayer(this.getPlayer());
|
||||
}
|
||||
}
|
||||
this.setupValidators();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
this.setTitle(this.isDatabase ? (this.isMaster ? "Master Registry" : "Registry") : "Analyst");
|
||||
final BreedingSystem system = Binnie.Genetics.beeBreedingSystem;
|
||||
final IIndividual ind = system.getDefaultIndividual();
|
||||
final ItemStack stack = system.getSpeciesRoot().getMemberStack(ind, system.getDefaultType());
|
||||
this.getWindowInventory().createSlot(0);
|
||||
this.baseWidget = new Widget(this);
|
||||
int x = 16;
|
||||
final int y = 28;
|
||||
if (this.isDatabase) {
|
||||
for (final BreedingSystem syst : Binnie.Genetics.getActiveSystems()) {
|
||||
new Control(this, x, y, 20.0f, 20.0f) {
|
||||
@Override
|
||||
public void initialise() {
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
this.addSelfEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Down event) {
|
||||
WindowAnalyst.this.setSystem(syst);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
tooltip.add(syst.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.Render.colour(syst.getColour());
|
||||
final int outset = (WindowAnalyst.this.getSystem() == syst) ? 1 : 0;
|
||||
CraftGUI.Render.texture(CraftGUITexture.TabOutline, this.getArea().outset(outset));
|
||||
if (WindowAnalyst.this.getSystem() == syst) {
|
||||
CraftGUI.Render.colour(1140850688 + syst.getColour());
|
||||
CraftGUI.Render.texture(CraftGUITexture.TabSolid, this.getArea().outset(outset));
|
||||
}
|
||||
CraftGUI.Render.item(new IPoint(2.0f, 2.0f), syst.getItemStackRepresentitive());
|
||||
}
|
||||
};
|
||||
x += 22;
|
||||
}
|
||||
}
|
||||
else {
|
||||
new ControlSlot(this, x, y + 1).assign(InventoryType.Window, 0);
|
||||
x += 22;
|
||||
new ControlSlot(this, x, y + 1).assign(InventoryType.Window, 1);
|
||||
x += 26;
|
||||
this.setupValidators();
|
||||
}
|
||||
this.tabBar = new Control(this, x, 28.0f, this.w() - 16.0f - x, 20.0f);
|
||||
this.analystPanel = new Panel(this, 16.0f, 54.0f, 280.0f, 164.0f, MinecraftGUI.PanelType.Outline) {
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.Render.gradientRect(this.getArea(), 1157627903, 1728053247);
|
||||
super.onRenderBackground();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialise() {
|
||||
this.setColour(4473924);
|
||||
final float sectionWidth = (this.w() - 8.0f - 4.0f) / 2.0f;
|
||||
WindowAnalyst.this.leftPage = new ControlScrollableContent<IWidget>(this, 3.0f, 3.0f, sectionWidth + 2.0f, this.h() - 8.0f + 2.0f, 0.0f) {
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
if (this.getContent() == null) {
|
||||
return;
|
||||
}
|
||||
CraftGUI.Render.colour(this.getContent().getColour());
|
||||
CraftGUI.Render.texture(CraftGUITexture.TabOutline, this.getArea());
|
||||
}
|
||||
};
|
||||
new ControlScrollBar(this, sectionWidth + 2.0f - 3.0f, 6.0f, 3.0f, this.h() - 8.0f + 2.0f - 6.0f, WindowAnalyst.this.leftPage) {
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
if (!this.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
if (WindowAnalyst.this.leftPage.getContent() == null) {
|
||||
return;
|
||||
}
|
||||
CraftGUI.Render.gradientRect(this.getArea(), 1140850688 + WindowAnalyst.this.leftPage.getContent().getColour(), 1140850688 + WindowAnalyst.this.leftPage.getContent().getColour());
|
||||
CraftGUI.Render.solid(this.getRenderArea(), WindowAnalyst.this.leftPage.getContent().getColour());
|
||||
}
|
||||
};
|
||||
WindowAnalyst.this.rightPage = new ControlScrollableContent<IWidget>(this, 3.0f + sectionWidth + 4.0f, 3.0f, sectionWidth + 2.0f, this.h() - 8.0f + 2.0f, 0.0f) {
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
if (this.getContent() == null) {
|
||||
return;
|
||||
}
|
||||
CraftGUI.Render.colour(this.getContent().getColour());
|
||||
CraftGUI.Render.texture(CraftGUITexture.TabOutline, this.getArea());
|
||||
}
|
||||
};
|
||||
new ControlScrollBar(this, sectionWidth + 2.0f - 3.0f + sectionWidth + 4.0f, 6.0f, 3.0f, this.h() - 8.0f + 2.0f - 6.0f, WindowAnalyst.this.rightPage) {
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
if (!this.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
if (WindowAnalyst.this.rightPage.getContent() == null) {
|
||||
return;
|
||||
}
|
||||
CraftGUI.Render.gradientRect(this.getArea(), 1140850688 + WindowAnalyst.this.rightPage.getContent().getColour(), 1140850688 + WindowAnalyst.this.rightPage.getContent().getColour());
|
||||
CraftGUI.Render.solid(this.getRenderArea(), WindowAnalyst.this.rightPage.getContent().getColour());
|
||||
}
|
||||
};
|
||||
WindowAnalyst.this.analystPageSize = new IArea(1.0f, 1.0f, sectionWidth, this.h() - 8.0f);
|
||||
}
|
||||
};
|
||||
if (!this.isDatabase) {
|
||||
this.slideUpInv = new ControlSlide(this, (this.getSize().x() - 244.0f) / 2.0f, this.getSize().y() - 80.0f + 1.0f, 244.0f, 80.0f, Position.Bottom);
|
||||
new ControlPlayerInventory(this.slideUpInv, true);
|
||||
this.slideUpInv.setSlide(false);
|
||||
}
|
||||
this.addEventHandler(new EventKey.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventKey.Down event) {
|
||||
if (event.getKey() == 205) {
|
||||
WindowAnalyst.this.shiftPages(true);
|
||||
}
|
||||
if (event.getKey() == 203) {
|
||||
WindowAnalyst.this.shiftPages(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (!this.isDatabase) {
|
||||
this.analystNone = new Control(this.analystPanel, 0.0f, 0.0f, this.analystPanel.w(), this.analystPanel.h()) {
|
||||
@Override
|
||||
public void initialise() {
|
||||
new ControlTextCentered(this, 20.0f, "Add a bee, tree, flower or butterfly to the top left slot. DNA Dye is required if it has not been analysed yet. This dye can also convert vanilla items to breedable individuals.").setColour(4473924);
|
||||
new ControlPlayerInventory(this);
|
||||
}
|
||||
};
|
||||
}
|
||||
this.setIndividual(null);
|
||||
this.setSystem(Binnie.Genetics.beeBreedingSystem);
|
||||
}
|
||||
|
||||
public void setIndividual(final IIndividual ind) {
|
||||
if (!this.isDatabase) {
|
||||
if (ind == null) {
|
||||
this.analystNone.show();
|
||||
this.slideUpInv.hide();
|
||||
}
|
||||
else {
|
||||
this.analystNone.hide();
|
||||
this.slideUpInv.show();
|
||||
}
|
||||
}
|
||||
if (ind == this.current || (ind != null && this.current != null && ind.isGeneticEqual(this.current))) {
|
||||
return;
|
||||
}
|
||||
final boolean systemChange = (this.current = ind) != null && ind.getGenome().getSpeciesRoot() != this.getSystem().getSpeciesRoot();
|
||||
if (systemChange) {
|
||||
this.currentSystem = Binnie.Genetics.getSystem(ind.getGenome().getSpeciesRoot());
|
||||
}
|
||||
this.updatePages(systemChange);
|
||||
}
|
||||
|
||||
public void setSystem(final BreedingSystem system) {
|
||||
if (system == this.currentSystem) {
|
||||
return;
|
||||
}
|
||||
this.currentSystem = system;
|
||||
this.current = null;
|
||||
this.updatePages(true);
|
||||
}
|
||||
|
||||
public void updatePages(final boolean systemChange) {
|
||||
int oldLeft = -1;
|
||||
int oldRight = -1;
|
||||
if (!systemChange) {
|
||||
oldLeft = this.analystPages.indexOf(this.leftPage.getContent());
|
||||
oldRight = this.analystPages.indexOf(this.rightPage.getContent());
|
||||
}
|
||||
ControlAnalystPage databasePage = null;
|
||||
if (this.isDatabase && !systemChange) {
|
||||
databasePage = ((this.analystPages.size() > 0) ? this.analystPages.get(0) : null);
|
||||
}
|
||||
this.analystPages.clear();
|
||||
this.setPage(this.leftPage, null);
|
||||
this.setPage(this.rightPage, null);
|
||||
if (this.isDatabase) {
|
||||
this.analystPages.add((databasePage != null) ? databasePage : new AnalystPageDatabase(this.analystPanel, this.analystPageSize, this.currentSystem, this.isMaster));
|
||||
}
|
||||
if (this.current != null) {
|
||||
this.analystPages.add(new AnalystPageDescription(this.analystPanel, this.analystPageSize, this.current));
|
||||
this.analystPages.add(new AnalystPageGenome(this.analystPanel, this.analystPageSize, true, this.current));
|
||||
if (!this.isDatabase) {
|
||||
this.analystPages.add(new AnalystPageGenome(this.analystPanel, this.analystPageSize, false, this.current));
|
||||
this.analystPages.add(new AnalystPageKaryogram(this.analystPanel, this.analystPageSize, this.current));
|
||||
}
|
||||
if (!(this.current instanceof ITree)) {
|
||||
this.analystPages.add(new AnalystPageClimate(this.analystPanel, this.analystPageSize, this.current));
|
||||
}
|
||||
if (this.current instanceof IBee) {
|
||||
this.analystPages.add(new AnalystPageProducts(this.analystPanel, this.analystPageSize, (IBee) this.current));
|
||||
}
|
||||
else if (this.current instanceof ITree) {
|
||||
this.analystPages.add(new AnalystPageFruit(this.analystPanel, this.analystPageSize, (ITree) this.current));
|
||||
this.analystPages.add(new AnalystPageWood(this.analystPanel, this.analystPageSize, (ITree) this.current));
|
||||
}
|
||||
else if (this.current instanceof IFlower) {
|
||||
this.analystPages.add(new AnalystPageSoil(this.analystPanel, this.analystPageSize, (IFlower) this.current));
|
||||
}
|
||||
else if (this.current instanceof IButterfly) {
|
||||
this.analystPages.add(new AnalystPageSpecimen(this.analystPanel, this.analystPageSize, (IButterfly) this.current));
|
||||
}
|
||||
this.analystPages.add(new AnalystPageBiology(this.analystPanel, this.analystPageSize, this.current));
|
||||
if (this.current instanceof IBee || this.current instanceof IButterfly) {
|
||||
this.analystPages.add(new AnalystPageBehaviour(this.analystPanel, this.analystPageSize, this.current));
|
||||
}
|
||||
else if (this.current instanceof ITree) {
|
||||
this.analystPages.add(new AnalystPageGrowth(this.analystPanel, this.analystPageSize, this.current));
|
||||
}
|
||||
else if (this.current instanceof IFlower) {
|
||||
this.analystPages.add(new AnalystPageAppearance(this.analystPanel, this.analystPageSize, (IFlower) this.current));
|
||||
}
|
||||
this.analystPages.add(new AnalystPageMutations(this.analystPanel, this.analystPageSize, this.current, this.isMaster));
|
||||
}
|
||||
this.tabBar.deleteAllChildren();
|
||||
final float width = this.tabBar.w() / this.analystPages.size();
|
||||
float x = 0.0f;
|
||||
for (final ControlAnalystPage page : this.analystPages) {
|
||||
new ControlTooltip(this.tabBar, x, 0.0f, width, this.tabBar.h()) {
|
||||
ControlAnalystPage value;
|
||||
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
tooltip.add(this.value.getTitle());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialise() {
|
||||
super.initialise();
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
this.value = page;
|
||||
this.addSelfEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Down event) {
|
||||
final int currentIndex = WindowAnalyst.this.analystPages.indexOf(WindowAnalyst.this.rightPage.getContent());
|
||||
int clickedIndex = WindowAnalyst.this.analystPages.indexOf(value);
|
||||
if (WindowAnalyst.this.isDatabase) {
|
||||
if (clickedIndex != 0 && clickedIndex != currentIndex) {
|
||||
WindowAnalyst.this.setPage(WindowAnalyst.this.rightPage, value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (clickedIndex < 0) {
|
||||
clickedIndex = 0;
|
||||
}
|
||||
if (clickedIndex < currentIndex) {
|
||||
++clickedIndex;
|
||||
}
|
||||
WindowAnalyst.this.setPage(WindowAnalyst.this.rightPage, null);
|
||||
WindowAnalyst.this.setPage(WindowAnalyst.this.leftPage, null);
|
||||
WindowAnalyst.this.setPage(WindowAnalyst.this.rightPage, WindowAnalyst.this.analystPages.get(clickedIndex));
|
||||
WindowAnalyst.this.setPage(WindowAnalyst.this.leftPage, WindowAnalyst.this.analystPages.get(clickedIndex - 1));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
final boolean active = this.value == WindowAnalyst.this.leftPage.getContent() || this.value == WindowAnalyst.this.rightPage.getContent();
|
||||
CraftGUI.Render.colour((active ? -16777216 : 1140850688) + this.value.getColour());
|
||||
CraftGUI.Render.texture(CraftGUITexture.TabSolid, this.getArea().inset(1));
|
||||
CraftGUI.Render.colour(this.value.getColour());
|
||||
CraftGUI.Render.texture(CraftGUITexture.TabOutline, this.getArea().inset(1));
|
||||
super.onRenderBackground();
|
||||
}
|
||||
};
|
||||
x += width;
|
||||
}
|
||||
if (this.analystPages.size() > 0) {
|
||||
this.setPage(this.leftPage, this.analystPages.get((oldLeft >= 0) ? oldLeft : 0));
|
||||
}
|
||||
if (this.analystPages.size() > 1) {
|
||||
this.setPage(this.rightPage, this.analystPages.get((oldRight >= 0) ? oldRight : 1));
|
||||
}
|
||||
}
|
||||
|
||||
public void shiftPages(final boolean right) {
|
||||
if (this.analystPages.size() < 2) {
|
||||
return;
|
||||
}
|
||||
final int leftIndex = this.analystPages.indexOf(this.leftPage.getContent());
|
||||
final int rightIndex = this.analystPages.indexOf(this.rightPage.getContent());
|
||||
if (right && rightIndex + 1 >= this.analystPages.size()) {
|
||||
return;
|
||||
}
|
||||
if (!this.lockedSearch && !right && leftIndex <= 0) {
|
||||
return;
|
||||
}
|
||||
if (!this.lockedSearch && !right && rightIndex <= 1) {
|
||||
return;
|
||||
}
|
||||
final int newRightIndex = rightIndex + (right ? 1 : -1);
|
||||
final int newLeftIndex = this.lockedSearch ? 0 : (newRightIndex - 1);
|
||||
float oldRightPercent = 0.0f;
|
||||
float oldLeftPercent = 0.0f;
|
||||
if (newLeftIndex == rightIndex) {
|
||||
oldRightPercent = this.rightPage.getPercentageIndex();
|
||||
}
|
||||
if (newRightIndex == leftIndex) {
|
||||
oldLeftPercent = this.leftPage.getPercentageIndex();
|
||||
}
|
||||
this.setPage(this.leftPage, null);
|
||||
this.setPage(this.rightPage, null);
|
||||
this.setPage(this.leftPage, this.analystPages.get(newLeftIndex));
|
||||
this.setPage(this.rightPage, this.analystPages.get(newRightIndex));
|
||||
this.analystPages.get(newLeftIndex).show();
|
||||
if (oldRightPercent != 0.0f) {
|
||||
this.leftPage.setPercentageIndex(oldRightPercent);
|
||||
}
|
||||
if (oldLeftPercent != 0.0f) {
|
||||
this.rightPage.setPercentageIndex(oldLeftPercent);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPage(final ControlScrollableContent side, final ControlAnalystPage page) {
|
||||
final ControlAnalystPage existingPage = (ControlAnalystPage) side.getContent();
|
||||
if (existingPage != null) {
|
||||
existingPage.hide();
|
||||
side.setScrollableContent(null);
|
||||
}
|
||||
if (page != null) {
|
||||
page.show();
|
||||
side.setScrollableContent(page);
|
||||
side.setPercentageIndex(0.0f);
|
||||
page.setPosition(side.pos().add(1.0f, 1.0f));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowInventoryChanged() {
|
||||
super.onWindowInventoryChanged();
|
||||
if (this.getWindowInventory().getStackInSlot(0) != null && !Analyser.isAnalysed(this.getWindowInventory().getStackInSlot(0))) {
|
||||
this.getWindowInventory().setInventorySlotContents(0, Analyser.analyse(this.getWindowInventory().getStackInSlot(0)));
|
||||
this.getWindowInventory().decrStackSize(1, 1);
|
||||
}
|
||||
final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(this.getWindowInventory().getStackInSlot(0));
|
||||
if (ind != null) {
|
||||
ind.getGenome().getSpeciesRoot().getBreedingTracker(this.getWorld(), this.getUsername()).registerBirth(ind);
|
||||
}
|
||||
if (this.isClient()) {
|
||||
this.setStack(this.getWindowInventory().getStackInSlot(0));
|
||||
}
|
||||
else if (this.isServer()) {
|
||||
}
|
||||
}
|
||||
|
||||
public void setStack(final ItemStack stack) {
|
||||
final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(stack);
|
||||
this.setIndividual(ind);
|
||||
}
|
||||
|
||||
public IIndividual getIndividual() {
|
||||
return this.current;
|
||||
}
|
||||
|
||||
public BreedingSystem getSystem() {
|
||||
return this.currentSystem;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.item;
|
||||
|
||||
import binnie.core.liquid.FluidContainer;
|
||||
import binnie.Binnie;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import binnie.genetics.Genetics;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import binnie.core.liquid.IFluidType;
|
||||
|
||||
public enum GeneticLiquid implements IFluidType
|
||||
{
|
||||
GrowthMedium("Growth Medium", "growthMedium", 15460533),
|
||||
Bacteria("Bacteria", "bacteria", 14203521),
|
||||
BacteriaPoly("Polymerising Bacteria", "bacteriaPoly", 11443396),
|
||||
RawDNA("Raw DNA", "dna.raw", 15089129),
|
||||
BacteriaVector("Bacteria Vector", "bacteriaVector", 15960958);
|
||||
|
||||
String name;
|
||||
String ident;
|
||||
IIcon icon;
|
||||
int colour;
|
||||
float transparency;
|
||||
|
||||
private GeneticLiquid(final String name, final String ident, final int colour) {
|
||||
this.name = name;
|
||||
this.ident = ident;
|
||||
this.colour = colour;
|
||||
this.transparency = 1.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon() {
|
||||
return this.icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcon(final IIconRegister register) {
|
||||
this.icon = Genetics.proxy.getIcon(register, "liquids/" + this.ident);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "binnie." + this.ident;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColour() {
|
||||
return 16777215;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getContainerColour() {
|
||||
return this.colour;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack get(final int amount) {
|
||||
return Binnie.Liquid.getLiquidStack(this.getIdentifier(), amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTransparency() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceIn(final FluidContainer container) {
|
||||
return this == GeneticLiquid.GrowthMedium || container == FluidContainer.Cylinder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInCreative(final FluidContainer container) {
|
||||
return container == FluidContainer.Cylinder;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.item;
|
||||
|
||||
import java.util.List;
|
||||
import binnie.genetics.Genetics;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import binnie.core.item.IItemMisc;
|
||||
|
||||
public enum GeneticsItems implements IItemMisc
|
||||
{
|
||||
LaboratoryCasing("Reinforced Casing", "casingIron"),
|
||||
DNADye("DNA Dye", "dnaDye"),
|
||||
FluorescentDye("Fluorescent Dye", "dyeFluor"),
|
||||
Enzyme("Enzyme", "enzyme"),
|
||||
GrowthMedium("Growth Medium", "growthMedium"),
|
||||
EmptySequencer("Blank Sequence", "sequencerEmpty"),
|
||||
EmptySerum("Empty Serum Vial", "serumEmpty"),
|
||||
EmptyGenome("Empty Serum Array", "genomeEmpty"),
|
||||
Cylinder("Glass Cylinder", "cylinderEmpty"),
|
||||
IntegratedCircuit("Integrated Circuit Board", "integratedCircuit"),
|
||||
IntegratedCPU("Integrated CPU", "integratedCPU"),
|
||||
IntegratedCasing("Integrated Casing", "casingCircuit");
|
||||
|
||||
IIcon icon;
|
||||
String name;
|
||||
String iconPath;
|
||||
|
||||
private GeneticsItems(final String name, final String iconPath) {
|
||||
this.name = name;
|
||||
this.iconPath = iconPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(final ItemStack stack) {
|
||||
return this.icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(final IIconRegister register) {
|
||||
this.icon = Genetics.proxy.getIcon(register, this.iconPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(final List par3List) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(final ItemStack stack) {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack get(final int size) {
|
||||
return (Genetics.itemGenetics == null) ? null : new ItemStack(Genetics.itemGenetics, size, this.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.item;
|
||||
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.genetics.CreativeTabGenetics;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import binnie.genetics.Genetics;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class ItemAnalyst extends Item
|
||||
{
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(final IIconRegister register) {
|
||||
this.itemIcon = Genetics.proxy.getIcon(register, "analyst");
|
||||
}
|
||||
|
||||
public ItemAnalyst() {
|
||||
this.setCreativeTab(CreativeTabGenetics.instance);
|
||||
this.setUnlocalizedName("analyst");
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(final ItemStack itemstack, final World world, final EntityPlayer player) {
|
||||
Genetics.proxy.openGui(GeneticsGUI.Analyst, player, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack i) {
|
||||
return "Analyst";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.item;
|
||||
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import net.minecraft.world.World;
|
||||
import binnie.genetics.CreativeTabGenetics;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import java.util.List;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import binnie.genetics.Genetics;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class ItemDatabase extends Item
|
||||
{
|
||||
IIcon iconMaster;
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(final IIconRegister register) {
|
||||
this.itemIcon = Genetics.proxy.getIcon(register, "geneDatabase");
|
||||
this.iconMaster = Genetics.proxy.getIcon(register, "masterGeneDatabase");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(final int par1) {
|
||||
return (par1 == 0) ? this.itemIcon : this.iconMaster;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(final ItemStack par1ItemStack, final EntityPlayer par2EntityPlayer, final List par3List, final boolean par4) {
|
||||
super.addInformation(par1ItemStack, par2EntityPlayer, par3List, par4);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(final Item par1, final CreativeTabs par2CreativeTabs, final List par3List) {
|
||||
super.getSubItems(par1, par2CreativeTabs, par3List);
|
||||
par3List.add(new ItemStack(par1, 1, 1));
|
||||
}
|
||||
|
||||
public ItemDatabase() {
|
||||
this.setCreativeTab(CreativeTabGenetics.instance);
|
||||
this.setUnlocalizedName("database");
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(final ItemStack itemstack, final World world, final EntityPlayer player) {
|
||||
if (itemstack.getItemDamage() == 0) {
|
||||
Genetics.proxy.openGui(GeneticsGUI.Database, player, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
}
|
||||
else {
|
||||
Genetics.proxy.openGui(GeneticsGUI.DatabaseNEI, player, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
}
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack i) {
|
||||
return (i.getItemDamage() == 0) ? "Gene Database" : "Master Gene Database";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.item;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import java.util.List;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import binnie.genetics.genetics.IGeneItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.genetics.CreativeTabGenetics;
|
||||
import binnie.genetics.Genetics;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public abstract class ItemGene extends Item
|
||||
{
|
||||
IIcon[] icons;
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) {
|
||||
return this.icons[pass];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getShareTag() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRepairable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(final IIconRegister register) {
|
||||
this.icons[0] = Genetics.proxy.getIcon(register, "machines/serum.glass");
|
||||
this.icons[1] = Genetics.proxy.getIcon(register, "machines/serum.cap");
|
||||
this.icons[2] = Genetics.proxy.getIcon(register, "machines/serum.edges");
|
||||
this.icons[3] = Genetics.proxy.getIcon(register, "machines/serum.dna");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderPasses(final int metadata) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
public ItemGene(final String unlocName) {
|
||||
this.icons = new IIcon[4];
|
||||
this.setMaxStackSize(1);
|
||||
this.setMaxDamage(16);
|
||||
this.setUnlocalizedName(unlocName);
|
||||
this.setCreativeTab(CreativeTabGenetics.instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorFromItemStack(final ItemStack itemstack, final int j) {
|
||||
final IGeneItem gene = this.getGeneItem(itemstack);
|
||||
return gene.getColour(j);
|
||||
}
|
||||
|
||||
public int getCharges(final ItemStack stack) {
|
||||
return (stack == null) ? 0 : (stack.getItem().getMaxDamage() - stack.getItemDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(final ItemStack itemstack, final EntityPlayer entityPlayer, final List list, final boolean par4) {
|
||||
super.addInformation(itemstack, entityPlayer, list, par4);
|
||||
final int damage = this.getMaxDamage() - itemstack.getItemDamage();
|
||||
if (damage == 0) {
|
||||
list.add("Empty");
|
||||
}
|
||||
else if (damage == 1) {
|
||||
list.add("1 Charge");
|
||||
}
|
||||
else {
|
||||
list.add(damage + " Charges");
|
||||
}
|
||||
final IGeneItem gene = this.getGeneItem(itemstack);
|
||||
gene.getInfo(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract String getItemStackDisplayName(final ItemStack p0);
|
||||
|
||||
@Override
|
||||
public void getSubItems(final Item par1, final CreativeTabs par2CreativeTabs, final List itemList) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresMultipleRenderPasses() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public abstract IGeneItem getGeneItem(final ItemStack p0);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.item;
|
||||
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.genetics.CreativeTabGenetics;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import binnie.genetics.Genetics;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class ItemMasterRegistry extends Item
|
||||
{
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(final IIconRegister register) {
|
||||
this.itemIcon = Genetics.proxy.getIcon(register, "masterRegistry");
|
||||
}
|
||||
|
||||
public ItemMasterRegistry() {
|
||||
this.setCreativeTab(CreativeTabGenetics.instance);
|
||||
this.setUnlocalizedName("masterRegistry");
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(final ItemStack itemstack, final World world, final EntityPlayer player) {
|
||||
Genetics.proxy.openGui(GeneticsGUI.MasterRegistry, player, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack i) {
|
||||
return "Master Registry";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.item;
|
||||
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.genetics.CreativeTabGenetics;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import binnie.genetics.Genetics;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class ItemRegistry extends Item
|
||||
{
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(final IIconRegister register) {
|
||||
this.itemIcon = Genetics.proxy.getIcon(register, "registry");
|
||||
}
|
||||
|
||||
public ItemRegistry() {
|
||||
this.setCreativeTab(CreativeTabGenetics.instance);
|
||||
this.setUnlocalizedName("registry");
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(final ItemStack itemstack, final World world, final EntityPlayer player) {
|
||||
Genetics.proxy.openGui(GeneticsGUI.Registry, player, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack i) {
|
||||
return "Registry";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.item;
|
||||
|
||||
import binnie.genetics.api.IGene;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import binnie.core.genetics.Gene;
|
||||
import binnie.Binnie;
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import binnie.genetics.genetics.SequencerItem;
|
||||
import binnie.genetics.Genetics;
|
||||
import java.util.List;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import binnie.genetics.genetics.GeneItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.genetics.CreativeTabGenetics;
|
||||
import binnie.genetics.api.IItemChargable;
|
||||
import binnie.genetics.api.IItemAnalysable;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class ItemSequence extends Item implements IItemAnalysable, IItemChargable
|
||||
{
|
||||
public ItemSequence() {
|
||||
this.setMaxStackSize(1);
|
||||
this.setMaxDamage(5);
|
||||
this.setUnlocalizedName("sequence");
|
||||
this.setCreativeTab(CreativeTabGenetics.instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack itemstack) {
|
||||
final GeneItem gene = new GeneItem(itemstack);
|
||||
if (gene.isCorrupted()) {
|
||||
return "Corrupted Sequence";
|
||||
}
|
||||
return gene.getBreedingSystem().getDescriptor() + " DNA Sequence";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(final ItemStack itemstack, final EntityPlayer entityPlayer, final List list, final boolean par4) {
|
||||
super.addInformation(itemstack, entityPlayer, list, par4);
|
||||
list.add(Genetics.proxy.localise("item.sequence." + (5 - itemstack.getItemDamage() % 6)));
|
||||
final SequencerItem gene = new SequencerItem(itemstack);
|
||||
if (gene.isCorrupted()) {
|
||||
return;
|
||||
}
|
||||
if (gene.analysed) {
|
||||
gene.getInfo(list);
|
||||
}
|
||||
else {
|
||||
list.add("<Unknown>");
|
||||
}
|
||||
final int seq = gene.sequenced;
|
||||
if (seq == 0) {
|
||||
list.add("Unsequenced");
|
||||
}
|
||||
else if (seq < 100) {
|
||||
list.add("Partially Sequenced (" + seq + "%)");
|
||||
}
|
||||
else {
|
||||
list.add("Fully Sequenced");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(final IIconRegister register) {
|
||||
this.itemIcon = Genetics.proxy.getIcon(register, "sequencer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(final Item par1, final CreativeTabs par2CreativeTabs, final List itemList) {
|
||||
final IAlleleBeeSpecies species = (IAlleleBeeSpecies) AlleleManager.alleleRegistry.getAllele("forestry.speciesMeadows");
|
||||
itemList.add(create(new Gene(species, EnumBeeChromosome.SPECIES, Binnie.Genetics.getBeeRoot()), false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAnalysed(final ItemStack stack) {
|
||||
final SequencerItem seq = new SequencerItem(stack);
|
||||
return seq.isCorrupted() || seq.analysed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack analyse(final ItemStack stack) {
|
||||
final SequencerItem seq = new SequencerItem(stack);
|
||||
seq.analysed = true;
|
||||
seq.writeToItem(stack);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAnalyseTimeMult(final ItemStack stack) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
public static ItemStack create(final IGene gene) {
|
||||
return create(gene, false);
|
||||
}
|
||||
|
||||
public static ItemStack create(final IGene gene, final boolean sequenced) {
|
||||
final ItemStack item = new ItemStack(Genetics.itemSequencer);
|
||||
item.setItemDamage(sequenced ? 0 : item.getMaxDamage());
|
||||
final SequencerItem seq = new SequencerItem(gene);
|
||||
seq.writeToItem(item);
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCharges(final ItemStack stack) {
|
||||
return stack.getItem().getMaxDamage() - stack.getItemDamage();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.item;
|
||||
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.genetics.IGeneItem;
|
||||
import binnie.genetics.api.IGene;
|
||||
import binnie.genetics.genetics.GeneItem;
|
||||
import binnie.core.genetics.Gene;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import java.util.Map;
|
||||
import binnie.Binnie;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.genetics.api.IItemSerum;
|
||||
|
||||
public class ItemSerum extends ItemGene implements IItemSerum
|
||||
{
|
||||
public ItemSerum() {
|
||||
super("serum");
|
||||
this.setMaxDamage(16);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void addInformation(final ItemStack itemstack, final EntityPlayer entityPlayer, final List list, final boolean par4) {
|
||||
super.addInformation(itemstack, entityPlayer, list, par4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCharges(final ItemStack stack) {
|
||||
return stack.getItem().getMaxDamage() - stack.getItemDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(final Item par1, final CreativeTabs par2CreativeTabs, final List itemList) {
|
||||
for (final ISpeciesRoot root : AlleleManager.alleleRegistry.getSpeciesRoot().values()) {
|
||||
final Map<IChromosomeType, List<IAllele>> chromosomeMap = Binnie.Genetics.getChromosomeMap(root);
|
||||
for (final Map.Entry<IChromosomeType, List<IAllele>> entry : chromosomeMap.entrySet()) {
|
||||
final IChromosomeType chromosome = entry.getKey();
|
||||
for (final IAllele allele : entry.getValue()) {
|
||||
final Gene gene = Gene.create(allele, chromosome, root);
|
||||
if (gene == null) {
|
||||
continue;
|
||||
}
|
||||
final IGeneItem item = new GeneItem(gene);
|
||||
final ItemStack stack = new ItemStack(this);
|
||||
item.writeToItem(stack);
|
||||
itemList.add(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGene[] getGenes(final ItemStack stack) {
|
||||
return new IGene[] { this.getGeneItem(stack).getGene() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISpeciesRoot getSpeciesRoot(final ItemStack stack) {
|
||||
return this.getGeneItem(stack).getSpeciesRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGene getGene(final ItemStack stack, final int chromosome) {
|
||||
return this.getGeneItem(stack).getGene();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeneItem getGeneItem(final ItemStack stack) {
|
||||
return new GeneItem(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack itemstack) {
|
||||
final IGeneItem gene = this.getGeneItem(itemstack);
|
||||
return Binnie.Genetics.getSystem(gene.getSpeciesRoot()).getDescriptor() + " Serum";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack addGene(final ItemStack stack, final IGene gene) {
|
||||
final IGeneItem geneI = this.getGeneItem(stack);
|
||||
geneI.addGene(gene);
|
||||
geneI.writeToItem(stack);
|
||||
return stack;
|
||||
}
|
||||
|
||||
public static ItemStack create(final IGene gene) {
|
||||
final ItemStack item = new ItemStack(Genetics.itemSerum);
|
||||
item.setItemDamage(item.getMaxDamage());
|
||||
final GeneItem seq = new GeneItem(gene);
|
||||
seq.writeToItem(item);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.item;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.genetics.Genetics;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IChromosome;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import binnie.genetics.genetics.IGeneItem;
|
||||
import binnie.core.genetics.Gene;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import binnie.genetics.genetics.GeneArrayItem;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import binnie.genetics.api.IGene;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.genetics.api.IItemSerum;
|
||||
|
||||
public class ItemSerumArray extends ItemGene implements IItemSerum
|
||||
{
|
||||
public ItemSerumArray() {
|
||||
super("serumArray");
|
||||
this.setMaxDamage(16);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void addInformation(final ItemStack itemstack, final EntityPlayer entityPlayer, final List list, final boolean par4) {
|
||||
super.addInformation(itemstack, entityPlayer, list, par4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCharges(final ItemStack stack) {
|
||||
return stack.getItem().getMaxDamage() - stack.getItemDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGene[] getGenes(final ItemStack stack) {
|
||||
return this.getGeneItem(stack).getGenes().toArray(new IGene[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISpeciesRoot getSpeciesRoot(final ItemStack stack) {
|
||||
return this.getGeneItem(stack).getSpeciesRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGene getGene(final ItemStack stack, final int chromosome) {
|
||||
return this.getGeneItem(stack).getGene(chromosome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeneArrayItem getGeneItem(final ItemStack stack) {
|
||||
return new GeneArrayItem(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(final Item par1, final CreativeTabs par2CreativeTabs, final List itemList) {
|
||||
for (final ISpeciesRoot root : AlleleManager.alleleRegistry.getSpeciesRoot().values()) {
|
||||
for (final IIndividual template : root.getIndividualTemplates()) {
|
||||
if (template.getGenome().getPrimary().isSecret()) {
|
||||
continue;
|
||||
}
|
||||
final IGeneItem item = new GeneArrayItem();
|
||||
for (final IChromosomeType type : root.getKaryotype()) {
|
||||
final IChromosome c = template.getGenome().getChromosomes()[type.ordinal()];
|
||||
if (c != null) {
|
||||
final IAllele active = c.getActiveAllele();
|
||||
if (active != null) {
|
||||
item.addGene(new Gene(active, type, root));
|
||||
}
|
||||
}
|
||||
}
|
||||
final ItemStack array = new ItemStack(this);
|
||||
item.writeToItem(array);
|
||||
itemList.add(array);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerIcons(final IIconRegister register) {
|
||||
this.icons[0] = Genetics.proxy.getIcon(register, "machines/genome.glass");
|
||||
this.icons[1] = Genetics.proxy.getIcon(register, "machines/genome.cap");
|
||||
this.icons[2] = Genetics.proxy.getIcon(register, "machines/genome.edges");
|
||||
this.icons[3] = Genetics.proxy.getIcon(register, "machines/genome.dna");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack itemstack) {
|
||||
final IGeneItem gene = this.getGeneItem(itemstack);
|
||||
return Binnie.Genetics.getSystem(gene.getSpeciesRoot()).getDescriptor() + " Serum Array";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack addGene(final ItemStack stack, final IGene gene) {
|
||||
final IGeneItem geneI = this.getGeneItem(stack);
|
||||
geneI.addGene(gene);
|
||||
geneI.writeToItem(stack);
|
||||
return stack;
|
||||
}
|
||||
|
||||
public static ItemStack create(final IGene gene) {
|
||||
final ItemStack item = new ItemStack(Genetics.itemSerumArray);
|
||||
item.setItemDamage(item.getMaxDamage());
|
||||
final GeneArrayItem seq = new GeneArrayItem(gene);
|
||||
seq.writeToItem(item);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.item;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extrabees.ExtraBees;
|
||||
import net.minecraft.item.Item;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import binnie.core.Mods;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.init.Items;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.liquid.ItemFluidContainer;
|
||||
import binnie.genetics.CreativeTabGenetics;
|
||||
import binnie.Binnie;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.core.resource.BinnieIcon;
|
||||
import binnie.core.IInitializable;
|
||||
|
||||
public class ModuleItem implements IInitializable
|
||||
{
|
||||
public static BinnieIcon iconNight;
|
||||
public static BinnieIcon iconDaytime;
|
||||
public static BinnieIcon iconAllDay;
|
||||
public static BinnieIcon iconRain;
|
||||
public static BinnieIcon iconNoRain;
|
||||
public static BinnieIcon iconSky;
|
||||
public static BinnieIcon iconNoSky;
|
||||
public static BinnieIcon iconFire;
|
||||
public static BinnieIcon iconNoFire;
|
||||
public static BinnieIcon iconAdd;
|
||||
public static BinnieIcon iconArrow;
|
||||
public static BinnieIcon iconAdd0;
|
||||
public static BinnieIcon iconArrow0;
|
||||
public static BinnieIcon iconAdd1;
|
||||
public static BinnieIcon iconArrow1;
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
Genetics.itemSerum = new ItemSerum();
|
||||
Genetics.itemSerumArray = new ItemSerumArray();
|
||||
Genetics.itemSequencer = new ItemSequence();
|
||||
Genetics.itemGenetics = Binnie.Item.registerMiscItems(GeneticsItems.values(), CreativeTabGenetics.instance);
|
||||
Genetics.database = new ItemDatabase();
|
||||
Genetics.analyst = new ItemAnalyst();
|
||||
Genetics.registry = new ItemRegistry();
|
||||
Genetics.masterRegistry = new ItemMasterRegistry();
|
||||
Binnie.Liquid.createLiquids(GeneticLiquid.values(), ItemFluidContainer.LiquidGenetics);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
ModuleItem.iconNight = Binnie.Resource.getItemIcon(BinnieCore.instance, "gui/analyst.night");
|
||||
ModuleItem.iconDaytime = Binnie.Resource.getItemIcon(BinnieCore.instance, "gui/analyst.day");
|
||||
ModuleItem.iconAllDay = Binnie.Resource.getItemIcon(BinnieCore.instance, "gui/analyst.allday");
|
||||
ModuleItem.iconRain = Binnie.Resource.getItemIcon(BinnieCore.instance, "gui/analyst.rain");
|
||||
ModuleItem.iconNoRain = Binnie.Resource.getItemIcon(BinnieCore.instance, "gui/analyst.norain");
|
||||
ModuleItem.iconSky = Binnie.Resource.getItemIcon(BinnieCore.instance, "gui/analyst.sky");
|
||||
ModuleItem.iconNoSky = Binnie.Resource.getItemIcon(BinnieCore.instance, "gui/analyst.nosky");
|
||||
ModuleItem.iconFire = Binnie.Resource.getItemIcon(BinnieCore.instance, "gui/analyst.fire");
|
||||
ModuleItem.iconNoFire = Binnie.Resource.getItemIcon(BinnieCore.instance, "gui/analyst.nofire");
|
||||
ModuleItem.iconAdd = Binnie.Resource.getItemIcon(BinnieCore.instance, "gui/analyst.add");
|
||||
ModuleItem.iconArrow = Binnie.Resource.getItemIcon(BinnieCore.instance, "gui/analyst.arrow");
|
||||
ModuleItem.iconAdd0 = Binnie.Resource.getItemIcon(BinnieCore.instance, "gui/analyst.add.0");
|
||||
ModuleItem.iconArrow0 = Binnie.Resource.getItemIcon(BinnieCore.instance, "gui/analyst.arrow.0");
|
||||
ModuleItem.iconAdd1 = Binnie.Resource.getItemIcon(BinnieCore.instance, "gui/analyst.add.1");
|
||||
ModuleItem.iconArrow1 = Binnie.Resource.getItemIcon(BinnieCore.instance, "gui/analyst.arrow.1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
GameRegistry.addShapelessRecipe(GeneticsItems.DNADye.get(8), new Object[] { Items.glowstone_dust, new ItemStack(Items.dye, 1, 5) });
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(GeneticsItems.LaboratoryCasing.get(1), new Object[] { "iii", "iYi", "iii", 'i', "ingotIron", 'Y', Mods.Forestry.item("sturdyMachine") }));
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(GeneticsItems.DNADye.get(2), new Object[] { "dyePurple", "dyeMagenta", "dyePink" }));
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(GeneticsItems.FluorescentDye.get(2), new Object[] { "dyeOrange", "dyeYellow", "dustGlowstone" }));
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(GeneticsItems.GrowthMedium.get(2), new Object[] { new ItemStack(Items.dye, 1, 15), Items.sugar }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(GeneticsItems.EmptySequencer.get(1), new Object[] { " p ", "iGi", " p ", 'i', "ingotGold", 'G', Blocks.glass_pane, 'p', Items.paper }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(GeneticsItems.EmptySerum.get(1), new Object[] { " g ", " G ", "GGG", 'g', "ingotGold", 'G', Blocks.glass_pane }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(GeneticsItems.EmptyGenome.get(1), new Object[] { "sss", "sss", "sss", 's', GeneticsItems.EmptySerum.get(1) }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(GeneticsItems.Cylinder.get(8), new Object[] { " g ", "g g", " ", 'g', Blocks.glass_pane }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(GeneticsItems.IntegratedCircuit.get(1), new Object[] { "l g", " c ", "g l", 'c', Mods.Forestry.stack("chipsets", 1, 1), 'l', new ItemStack(Items.dye, 1, 4), 'g', "dustGlowstone" }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(GeneticsItems.IntegratedCircuit.get(1), new Object[] { "g l", " c ", "l g", 'c', Mods.Forestry.stack("chipsets", 1, 1), 'l', new ItemStack(Items.dye, 1, 4), 'g', "dustGlowstone" }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(GeneticsItems.IntegratedCasing.get(1), new Object[] { "ccc", "cdc", "ccc", 'c', GeneticsItems.IntegratedCircuit.get(1), 'd', GeneticsItems.LaboratoryCasing.get(1) }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(GeneticsItems.IntegratedCPU.get(1), new Object[] { "ccc", "cdc", "ccc", 'c', GeneticsItems.IntegratedCircuit.get(1), 'd', Items.diamond }));
|
||||
RecipeManagers.carpenterManager.addRecipe(100, Binnie.Liquid.getLiquidStack("water", 2000), (ItemStack) null, new ItemStack(Genetics.database), new Object[] { "X#X", "YEY", "RDR", '#', Blocks.glass_pane, 'X', Items.diamond, 'Y', Items.diamond, 'R', Items.redstone, 'D', Items.ender_eye, 'E', Blocks.obsidian });
|
||||
GameRegistry.addSmelting(Genetics.itemSequencer, GeneticsItems.EmptySequencer.get(1), 0.0f);
|
||||
GameRegistry.addSmelting(Genetics.itemSerum, GeneticsItems.EmptySerum.get(1), 0.0f);
|
||||
GameRegistry.addSmelting(Genetics.itemSerumArray, GeneticsItems.EmptyGenome.get(1), 0.0f);
|
||||
final Item[] arr$;
|
||||
final Item[] lyzers = arr$ = new Item[] { Mods.Forestry.item("beealyzer"), Mods.Forestry.item("treealyzer"), Mods.Forestry.item("flutterlyzer") };
|
||||
for (final Item a : arr$) {
|
||||
for (final Item b : lyzers) {
|
||||
for (final Item c : lyzers) {
|
||||
if (a != b && a != c && b != c) {
|
||||
GameRegistry.addShapedRecipe(new ItemStack(Genetics.analyst), new Object[] { " b ", "fct", " d ", 'c', GeneticsItems.IntegratedCircuit.get(1), 'b', a, 't', b, 'f', c, 'd', new ItemStack(Items.diamond) });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
final Item[] dbs = { ExtraBees.dictionary, ExtraTrees.itemDictionary, ExtraTrees.itemDictionaryLepi, Botany.database };
|
||||
if (BinnieCore.isBotanyActive() && BinnieCore.isExtraBeesActive() && BinnieCore.isExtraTreesActive()) {
|
||||
for (final Item a2 : dbs) {
|
||||
for (final Item b2 : dbs) {
|
||||
for (final Item c2 : dbs) {
|
||||
for (final Item d : dbs) {
|
||||
if (a2 != b2 && a2 != c2 && a2 != d && b2 != c2 && b2 != d && c2 != d) {
|
||||
GameRegistry.addShapedRecipe(new ItemStack(Genetics.registry), new Object[] { " b ", "fct", " l ", 'c', GeneticsItems.IntegratedCircuit.get(1), 'b', a2, 't', b2, 'f', c2, 'l', d });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,394 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import binnie.core.genetics.Gene;
|
||||
import java.util.Random;
|
||||
import forestry.api.genetics.IGenome;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IAlleleTolerance;
|
||||
import binnie.botany.gardening.Gardening;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.core.machines.power.ComponentProcessIndefinate;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.core.machines.inventory.ComponentInventoryTransfer;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.craftgui.minecraft.IMachineInformation;
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import forestry.api.genetics.EnumTolerance;
|
||||
import binnie.core.genetics.Tolerance;
|
||||
import binnie.core.Mods;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import binnie.botany.api.EnumFlowerChromosome;
|
||||
import forestry.api.lepidopterology.EnumButterflyChromosome;
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import binnie.Binnie;
|
||||
import binnie.core.BinnieCore;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
public class Acclimatiser
|
||||
{
|
||||
public static final int[] slotReserve;
|
||||
public static final int slotTarget = 4;
|
||||
public static final int[] slotAcclimatiser;
|
||||
public static final int[] slotDone;
|
||||
private static List<ToleranceSystem> toleranceSystems;
|
||||
static Map<ItemStack, Float> temperatureItems;
|
||||
static Map<ItemStack, Float> humidityItems;
|
||||
|
||||
private static ToleranceSystem getToleranceSystem(final ItemStack stack, final ItemStack acclim) {
|
||||
final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack);
|
||||
if (root == null) {
|
||||
return null;
|
||||
}
|
||||
for (final ToleranceSystem system : Acclimatiser.toleranceSystems) {
|
||||
if (root.getUID() == system.uid && system.type.hasEffect(acclim)) {
|
||||
return system;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void addTolerance(final String uid, final IChromosomeType chromosome, final ToleranceType type) {
|
||||
Acclimatiser.toleranceSystems.add(new ToleranceSystem(uid, chromosome, type));
|
||||
}
|
||||
|
||||
public static float getTemperatureEffect(final ItemStack item) {
|
||||
for (final ItemStack stack : Acclimatiser.temperatureItems.keySet()) {
|
||||
if (stack.isItemEqual(item)) {
|
||||
return Acclimatiser.temperatureItems.get(stack);
|
||||
}
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
public static float getHumidityEffect(final ItemStack item) {
|
||||
for (final ItemStack stack : Acclimatiser.humidityItems.keySet()) {
|
||||
if (stack.isItemEqual(item)) {
|
||||
return Acclimatiser.humidityItems.get(stack);
|
||||
}
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
public static void addTemperatureItem(final ItemStack itemstack, final float amount) {
|
||||
if (itemstack == null) {
|
||||
return;
|
||||
}
|
||||
Acclimatiser.temperatureItems.put(itemstack, amount);
|
||||
}
|
||||
|
||||
public static void addHumidityItem(final ItemStack itemstack, final 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(final ItemStack stack, final List<ItemStack> acclimatisers) {
|
||||
if (stack == null || acclimatisers.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
for (final ItemStack acclim : acclimatisers) {
|
||||
if (canAcclimatise(stack, acclim)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean canAcclimatise(final ItemStack stack, final ItemStack acclim) {
|
||||
final ToleranceSystem system = getToleranceSystem(stack, acclim);
|
||||
return system != null && system.canAlter(stack, acclim);
|
||||
}
|
||||
|
||||
public static ItemStack acclimatise(final ItemStack stack, final ItemStack acc) {
|
||||
final ToleranceSystem system = getToleranceSystem(stack, acc);
|
||||
return system.alter(stack, acc);
|
||||
}
|
||||
|
||||
public static Tolerance alterTolerance(final Tolerance tol, final float effect) {
|
||||
final int[] is = tol.getBounds();
|
||||
int[] range = new int[2];
|
||||
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;
|
||||
}
|
||||
final EnumTolerance[] up = { EnumTolerance.NONE, EnumTolerance.UP_1, EnumTolerance.UP_2, EnumTolerance.UP_3, EnumTolerance.UP_4, EnumTolerance.UP_5 };
|
||||
final EnumTolerance[] down = { EnumTolerance.NONE, EnumTolerance.DOWN_1, EnumTolerance.DOWN_2, EnumTolerance.DOWN_3, EnumTolerance.DOWN_4, EnumTolerance.DOWN_5 };
|
||||
final 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]]);
|
||||
}
|
||||
final int avg = (int) ((-range[0] + range[1]) / 2.0f + 0.6f);
|
||||
return Tolerance.get(both[avg]);
|
||||
}
|
||||
|
||||
static {
|
||||
slotReserve = new int[] { 0, 1, 2, 3 };
|
||||
slotAcclimatiser = new int[] { 5, 6, 7 };
|
||||
slotDone = new int[] { 8, 9, 10, 11 };
|
||||
Acclimatiser.toleranceSystems = new ArrayList<ToleranceSystem>();
|
||||
Acclimatiser.temperatureItems = new HashMap<ItemStack, Float>();
|
||||
Acclimatiser.humidityItems = new HashMap<ItemStack, Float>();
|
||||
}
|
||||
|
||||
public static class PackageAcclimatiser extends GeneticMachine.PackageGeneticBase implements IMachineInformation
|
||||
{
|
||||
public PackageAcclimatiser() {
|
||||
super("acclimatiser", GeneticsTexture.Acclimatiser, 9857609, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Acclimatiser);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(4, "process");
|
||||
inventory.getSlot(4).setValidator(new SlotValidator.Individual());
|
||||
inventory.getSlot(4).setReadOnly();
|
||||
inventory.getSlot(4).forbidExtraction();
|
||||
for (final InventorySlot slot : inventory.addSlotArray(Acclimatiser.slotReserve, "input")) {
|
||||
slot.forbidExtraction();
|
||||
slot.setValidator(new SlotValidator.Individual());
|
||||
}
|
||||
for (final InventorySlot slot : inventory.addSlotArray(Acclimatiser.slotDone, "output")) {
|
||||
slot.setReadOnly();
|
||||
slot.setValidator(new SlotValidator.Individual());
|
||||
}
|
||||
for (final InventorySlot slot : inventory.addSlotArray(Acclimatiser.slotAcclimatiser, "acclimatiser")) {
|
||||
slot.setValidator(new ValidatorAcclimatiserItem());
|
||||
}
|
||||
final ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Acclimatiser.slotReserve, 4, 1);
|
||||
transfer.addStorage(4, Acclimatiser.slotDone, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(final 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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentAcclimatiserLogic extends ComponentProcessIndefinate
|
||||
{
|
||||
public ComponentAcclimatiserLogic(final IMachine machine) {
|
||||
super(machine, 2.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().getStack(4) == null) {
|
||||
return new ErrorState.NoItem("No Individual to Acclimatise", 4);
|
||||
}
|
||||
if (this.getUtil().getNonNullStacks(Acclimatiser.slotAcclimatiser).isEmpty()) {
|
||||
return new ErrorState.NoItem("No Acclimatising Items", Acclimatiser.slotAcclimatiser);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (!Acclimatiser.canAcclimatise(this.getUtil().getStack(4), this.getUtil().getNonNullStacks(Acclimatiser.slotAcclimatiser))) {
|
||||
return new ErrorState.InvalidItem("Cannot Acclimatise this individual with these items", 4);
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean inProgress() {
|
||||
return this.canWork() == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
super.onTickTask();
|
||||
if (this.getUtil().getRandom().nextInt(100) == 0) {
|
||||
this.attemptAcclimatisation();
|
||||
}
|
||||
}
|
||||
|
||||
protected void attemptAcclimatisation() {
|
||||
final List<ItemStack> acclms = new ArrayList<ItemStack>();
|
||||
for (final ItemStack s : this.getUtil().getNonNullStacks(Acclimatiser.slotAcclimatiser)) {
|
||||
if (Acclimatiser.canAcclimatise(this.getUtil().getStack(4), s)) {
|
||||
acclms.add(s);
|
||||
}
|
||||
}
|
||||
final ItemStack acc = acclms.get(this.getUtil().getRandom().nextInt(acclms.size()));
|
||||
final ItemStack acclimed = Acclimatiser.acclimatise(this.getUtil().getStack(4), acc);
|
||||
if (acclimed != null) {
|
||||
this.getUtil().setStack(4, acclimed);
|
||||
boolean removed = false;
|
||||
for (final int i : Acclimatiser.slotAcclimatiser) {
|
||||
if (!removed && this.getUtil().getStack(i) != null && this.getUtil().getStack(i).isItemEqual(acc)) {
|
||||
this.getUtil().decreaseStack(i, 1);
|
||||
removed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ValidatorAcclimatiserItem extends SlotValidator
|
||||
{
|
||||
public ValidatorAcclimatiserItem() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final ItemStack stack) {
|
||||
for (final ToleranceType type : ToleranceType.values()) {
|
||||
if (type.hasEffect(stack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Acclimatising Items";
|
||||
}
|
||||
}
|
||||
|
||||
public enum ToleranceType
|
||||
{
|
||||
Temperature,
|
||||
Humidity,
|
||||
PH;
|
||||
|
||||
public float getEffect(final 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(final ItemStack stack) {
|
||||
return this.getEffect(stack) != 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ToleranceSystem
|
||||
{
|
||||
String uid;
|
||||
IChromosomeType chromosomeOrdinal;
|
||||
ToleranceType type;
|
||||
|
||||
private ToleranceSystem(final String uid, final IChromosomeType chromosomeOrdinal, final ToleranceType type) {
|
||||
this.uid = uid;
|
||||
this.chromosomeOrdinal = chromosomeOrdinal;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public boolean canAlter(final ItemStack stack, final ItemStack acclim) {
|
||||
final IIndividual member = AlleleManager.alleleRegistry.getIndividual(stack);
|
||||
final IGenome genome = member.getGenome();
|
||||
final IAlleleTolerance tolAllele = (IAlleleTolerance) genome.getActiveAllele(this.chromosomeOrdinal);
|
||||
final Tolerance tol = Tolerance.get(tolAllele.getValue());
|
||||
final float effect = this.type.getEffect(acclim);
|
||||
return (effect > 0.0f && tol.getBounds()[1] < 5) || (effect < 0.0f && tol.getBounds()[0] > -5);
|
||||
}
|
||||
|
||||
public ItemStack alter(final ItemStack stack, final ItemStack acc) {
|
||||
final Random rand = new Random();
|
||||
final float effect = this.type.getEffect(acc);
|
||||
if (rand.nextFloat() > Math.abs(effect)) {
|
||||
return stack;
|
||||
}
|
||||
final IIndividual member = AlleleManager.alleleRegistry.getIndividual(stack);
|
||||
final IGenome genome = member.getGenome();
|
||||
final IAlleleTolerance tolAllele = (IAlleleTolerance) genome.getActiveAllele(this.chromosomeOrdinal);
|
||||
final Tolerance tol = Tolerance.get(tolAllele.getValue());
|
||||
final Tolerance newTol = Acclimatiser.alterTolerance(tol, effect);
|
||||
if (rand.nextFloat() > 1.0f / (-newTol.getBounds()[0] + newTol.getBounds()[1])) {
|
||||
return stack;
|
||||
}
|
||||
final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack);
|
||||
Inoculator.setGene(new Gene(newTol.getAllele(), this.chromosomeOrdinal, root), stack, rand.nextInt(2));
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import binnie.core.resource.IBinnieTexture;
|
||||
import net.minecraft.block.Block;
|
||||
import binnie.genetics.Genetics;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.core.machines.MachinePackage;
|
||||
import binnie.core.machines.IMachineType;
|
||||
|
||||
public enum AdvGeneticMachine implements IMachineType
|
||||
{
|
||||
Splicer(Splicer.PackageSplicer.class);
|
||||
|
||||
Class<? extends MachinePackage> clss;
|
||||
|
||||
private AdvGeneticMachine(final Class<? extends MachinePackage> clss) {
|
||||
this.clss = clss;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends MachinePackage> getPackageClass() {
|
||||
return this.clss;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public ItemStack get(final int i) {
|
||||
return new ItemStack(Genetics.packageAdvGenetic.getBlock(), i, this.ordinal());
|
||||
}
|
||||
|
||||
public abstract static class PackageAdvGeneticBase extends GeneticMachine.PackageGeneticBase
|
||||
{
|
||||
protected PackageAdvGeneticBase(final String uid, final IBinnieTexture renderTexture, final int flashColour, final boolean powered) {
|
||||
super(uid, renderTexture, flashColour, powered);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,314 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import binnie.core.BinnieCore;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.Random;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import binnie.core.machines.network.INetwork;
|
||||
import binnie.core.machines.component.IRender;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.core.machines.power.IProcess;
|
||||
import binnie.core.machines.power.ComponentProcessSetCost;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.core.machines.inventory.ComponentChargedSlots;
|
||||
import binnie.core.machines.inventory.ComponentInventoryTransfer;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.craftgui.minecraft.IMachineInformation;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import binnie.Binnie;
|
||||
import binnie.genetics.api.IItemAnalysable;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class Analyser
|
||||
{
|
||||
public static final int[] slotReserve;
|
||||
public static final int slotTarget = 6;
|
||||
public static final int[] slotFinished;
|
||||
public static final int slotDye = 13;
|
||||
|
||||
public static boolean isAnalysable(final ItemStack stack) {
|
||||
final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(stack);
|
||||
return ind != null || stack.getItem() instanceof IItemAnalysable || Binnie.Genetics.getConversion(stack) != null;
|
||||
}
|
||||
|
||||
public static boolean isAnalysed(final ItemStack stack) {
|
||||
final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(stack);
|
||||
if (ind != null) {
|
||||
return ind.isAnalyzed();
|
||||
}
|
||||
return stack.getItem() instanceof IItemAnalysable && ((IItemAnalysable) stack.getItem()).isAnalysed(stack);
|
||||
}
|
||||
|
||||
public static ItemStack analyse(ItemStack stack) {
|
||||
final ItemStack conv = Binnie.Genetics.getConversionStack(stack);
|
||||
if (conv != null) {
|
||||
stack = conv;
|
||||
}
|
||||
final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack);
|
||||
if (root != null) {
|
||||
final IIndividual ind = root.getMember(stack);
|
||||
ind.analyze();
|
||||
final NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
ind.writeToNBT(nbttagcompound);
|
||||
stack.setTagCompound(nbttagcompound);
|
||||
return stack;
|
||||
}
|
||||
if (stack.getItem() instanceof IItemAnalysable) {
|
||||
return ((IItemAnalysable) stack.getItem()).analyse(stack);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
static {
|
||||
slotReserve = new int[] { 0, 1, 2, 3, 4, 5 };
|
||||
slotFinished = new int[] { 7, 8, 9, 10, 11, 12 };
|
||||
}
|
||||
|
||||
public static class PackageAnalyser extends GeneticMachine.PackageGeneticBase implements IMachineInformation
|
||||
{
|
||||
public PackageAnalyser() {
|
||||
super("analyser", GeneticsTexture.Analyser, 9961727, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Analyser);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlotArray(Analyser.slotReserve, "input");
|
||||
for (final InventorySlot slot : inventory.getSlots(Analyser.slotReserve)) {
|
||||
slot.setValidator(new SlotValidatorUnanalysed());
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
inventory.addSlot(6, "analyse");
|
||||
inventory.getSlot(6).setValidator(new SlotValidatorUnanalysed());
|
||||
inventory.getSlot(6).setReadOnly();
|
||||
inventory.getSlot(6).forbidInteraction();
|
||||
inventory.addSlot(13, "dye");
|
||||
inventory.getSlot(13).forbidExtraction();
|
||||
inventory.getSlot(13).setValidator(new SlotValidator(ModuleMachine.IconDye) {
|
||||
@Override
|
||||
public boolean isValid(final ItemStack itemStack) {
|
||||
return itemStack.isItemEqual(GeneticsItems.DNADye.get(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "DNA Dye";
|
||||
}
|
||||
});
|
||||
inventory.addSlotArray(Analyser.slotFinished, "output");
|
||||
for (final InventorySlot slot : inventory.getSlots(Analyser.slotFinished)) {
|
||||
slot.forbidInsertion();
|
||||
slot.setReadOnly();
|
||||
}
|
||||
final ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Analyser.slotReserve, 6, 1);
|
||||
transfer.addStorage(6, Analyser.slotFinished, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(final ItemStack stack) {
|
||||
return Analyser.isAnalysed(stack);
|
||||
}
|
||||
});
|
||||
new ComponentChargedSlots(machine).addCharge(13);
|
||||
new ComponentPowerReceptor(machine, 500);
|
||||
new ComponentAnalyserLogic(machine);
|
||||
new ComponentAnalyserFX(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentAnalyserLogic extends ComponentProcessSetCost implements IProcess
|
||||
{
|
||||
private static final float DYE_PER_TICK = 0.002f;
|
||||
|
||||
public ComponentAnalyserLogic(final Machine machine) {
|
||||
super(machine, 9000, 300);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isSlotEmpty(6)) {
|
||||
return new ErrorState.NoItem("No item to analyse", 6);
|
||||
}
|
||||
final boolean analysed = Analyser.isAnalysed(this.getUtil().getStack(6));
|
||||
if (analysed) {
|
||||
return new ErrorState.InvalidItem("Already Analysed", "Item has already been analysed", 6);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (this.getUtil().getSlotCharge(13) == 0.0f) {
|
||||
return new ErrorState.Item("Insufficient Dye", "Not enough DNA dye to analyse", new int[] { 13 });
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
ItemStack itemStack = this.getUtil().getStack(6);
|
||||
itemStack = Analyser.analyse(itemStack);
|
||||
this.getInventory().setInventorySlotContents(6, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
this.getUtil().useCharge(13, 0.002f);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SlotValidatorUnanalysed extends SlotValidator
|
||||
{
|
||||
public SlotValidatorUnanalysed() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final ItemStack itemStack) {
|
||||
return Analyser.isAnalysable(itemStack) && !Analyser.isAnalysed(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Unanalysed Item";
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentAnalyserFX extends MachineComponent implements IRender.RandomDisplayTick, IRender.DisplayTick, IRender.Render, INetwork.TilePacketSync
|
||||
{
|
||||
private final EntityItem dummyEntityItem;
|
||||
|
||||
public ComponentAnalyserFX(final IMachine machine) {
|
||||
super(machine);
|
||||
this.dummyEntityItem = new EntityItem((World) null);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onRandomDisplayTick(final World world, final int x, final int y, final int z, final Random rand) {
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(final World world, final int x, final int y, final int z, final Random rand) {
|
||||
if (rand.nextFloat() < 1.0f && this.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 = this.posX;
|
||||
double axisZ = this.posZ;
|
||||
double angle = this.rand.nextDouble() * 2.0 * 3.1415;
|
||||
|
||||
{
|
||||
this.axisX = 0.0;
|
||||
this.axisZ = 0.0;
|
||||
this.angle = 0.0;
|
||||
this.motionX = 0.05 * (this.rand.nextDouble() - 0.5);
|
||||
this.motionZ = 0.05 * (this.rand.nextDouble() - 0.5);
|
||||
this.motionY = 0.0;
|
||||
this.particleMaxAge = 25;
|
||||
this.particleGravity = 0.05f;
|
||||
this.noClip = true;
|
||||
this.setRBGColorF(0.6f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
this.setAlphaF((float) Math.cos(1.57 * this.particleAge / this.particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void renderInWorld(final RenderItem customRenderItem, final double x, final double y, final double z) {
|
||||
if (!this.getUtil().getProcess().isInProgress()) {
|
||||
return;
|
||||
}
|
||||
final ItemStack stack = this.getUtil().getStack(6);
|
||||
this.dummyEntityItem.worldObj = this.getMachine().getWorld();
|
||||
this.dummyEntityItem.setEntityItemStack(stack);
|
||||
final EntityItem dummyEntityItem = this.dummyEntityItem;
|
||||
++dummyEntityItem.age;
|
||||
this.dummyEntityItem.hoverStart = 0.0f;
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
final EntityPlayer player = BinnieCore.proxy.getPlayer();
|
||||
final double dx = x + 0.5 - player.lastTickPosX;
|
||||
final double dz = z + 0.5 - player.lastTickPosZ;
|
||||
final double t = Math.atan2(dz, dx) * 180.0 / 3.1415;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(180.0f, 0.0f, 0.0f, 1.0f);
|
||||
GL11.glTranslatef(0.0f, -0.2f, 0.0f);
|
||||
customRenderItem.doRender(this.dummyEntityItem, 0.0, 0.0, 0.0, 0.0f, 0.0f);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncToNBT(final NBTTagCompound nbt) {
|
||||
final NBTTagCompound item = new NBTTagCompound();
|
||||
final ItemStack stack = this.getUtil().getStack(6);
|
||||
if (stack != null) {
|
||||
stack.writeToNBT(item);
|
||||
nbt.setTag("item", item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncFromNBT(final NBTTagCompound nbt) {
|
||||
if (nbt.hasKey("item")) {
|
||||
this.getUtil().setStack(6, ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("item")));
|
||||
}
|
||||
else {
|
||||
this.getUtil().setStack(6, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryUpdate() {
|
||||
if (this.getUtil().isServer()) {
|
||||
this.getMachine().getWorld().markBlockForUpdate(this.getMachine().getTileEntity().xCoord, this.getMachine().getTileEntity().yCoord, this.getMachine().getTileEntity().zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import binnie.genetics.Genetics;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.core.machines.component.IInteraction;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
|
||||
public class ComponentGeneticGUI extends MachineComponent implements IInteraction.RightClick
|
||||
{
|
||||
GeneticsGUI id;
|
||||
|
||||
public ComponentGeneticGUI(final Machine machine, final GeneticsGUI id) {
|
||||
super(machine);
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRightClick(final World world, final EntityPlayer player, final int x, final int y, final int z) {
|
||||
Genetics.proxy.openGui(this.id, player, x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,272 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import java.util.Map;
|
||||
import binnie.Binnie;
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import binnie.core.machines.inventory.SetList;
|
||||
import binnie.core.machines.Machine;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import java.util.List;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import binnie.core.machines.inventory.ComponentInventory;
|
||||
|
||||
public abstract class ComponentIndexerInventory<T> extends ComponentInventory implements IInventory
|
||||
{
|
||||
int indexerSize;
|
||||
public int guiRefreshCounter;
|
||||
List<ItemStack> indexerInventory;
|
||||
public List<Integer> sortedInventory;
|
||||
T sortingMode;
|
||||
boolean needsSorting;
|
||||
|
||||
public ComponentIndexerInventory(final Machine machine) {
|
||||
super(machine);
|
||||
this.indexerSize = -1;
|
||||
this.guiRefreshCounter = 0;
|
||||
this.indexerInventory = new SetList<ItemStack>();
|
||||
this.sortedInventory = new SetList<Integer>();
|
||||
this.needsSorting = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
if (this.indexerSize > 0) {
|
||||
return this.indexerSize + 1;
|
||||
}
|
||||
return this.indexerInventory.size() + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(final int index) {
|
||||
if (index >= 0 && index < this.indexerInventory.size()) {
|
||||
return this.indexerInventory.get(index);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(final int index, final int amount) {
|
||||
if (index >= 0) {
|
||||
final ItemStack returnStack = this.getStackInSlot(index).copy();
|
||||
this.setInventorySlotContents(index, null);
|
||||
return returnStack;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(final int var1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
super.markDirty();
|
||||
++this.guiRefreshCounter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(final int index, final ItemStack itemStack) {
|
||||
if (index >= 0 && index < this.indexerInventory.size()) {
|
||||
this.indexerInventory.set(index, itemStack);
|
||||
}
|
||||
else if (itemStack != null) {
|
||||
this.indexerInventory.add(itemStack);
|
||||
}
|
||||
this.needsSorting = true;
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(final EntityPlayer var1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
|
||||
public void setMode(final T mode) {
|
||||
this.sortingMode = mode;
|
||||
this.needsSorting = true;
|
||||
}
|
||||
|
||||
public T getMode() {
|
||||
return this.sortingMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
final NBTTagList indexerNBT = new NBTTagList();
|
||||
for (final ItemStack item : this.indexerInventory) {
|
||||
final NBTTagCompound itemNBT = new NBTTagCompound();
|
||||
item.writeToNBT(itemNBT);
|
||||
indexerNBT.appendTag(itemNBT);
|
||||
}
|
||||
nbttagcompound.setTag("indexer", indexerNBT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
final NBTTagList indexerNBT = nbttagcompound.getTagList("indexer", 10);
|
||||
this.indexerInventory.clear();
|
||||
for (int i = 0; i < indexerNBT.tagCount(); ++i) {
|
||||
final NBTTagCompound itemNBT = indexerNBT.getCompoundTagAt(i);
|
||||
this.setInventorySlotContents(i, ItemStack.loadItemStackFromNBT(itemNBT));
|
||||
}
|
||||
this.needsSorting = true;
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
public abstract void Sort();
|
||||
|
||||
public static class ComponentApiaristIndexerInventory extends ComponentIndexerInventory<ComponentApiaristIndexerInventory.Mode> implements IInventory
|
||||
{
|
||||
public ComponentApiaristIndexerInventory(final Machine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Sort() {
|
||||
int i = 0;
|
||||
while (i < this.indexerInventory.size()) {
|
||||
if (this.indexerInventory.get(i) == null) {
|
||||
this.indexerInventory.remove(i);
|
||||
}
|
||||
else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
if (!this.needsSorting) {
|
||||
return;
|
||||
}
|
||||
this.needsSorting = false;
|
||||
++this.guiRefreshCounter;
|
||||
switch (this.sortingMode) {
|
||||
case Species:
|
||||
case Type: {
|
||||
class SpeciesList
|
||||
{
|
||||
public List<Integer> drones;
|
||||
public List<Integer> queens;
|
||||
public List<Integer> princesses;
|
||||
public List<ItemStack> bees;
|
||||
|
||||
SpeciesList() {
|
||||
this.drones = new ArrayList<Integer>();
|
||||
this.queens = new ArrayList<Integer>();
|
||||
this.princesses = new ArrayList<Integer>();
|
||||
this.bees = new ArrayList<ItemStack>();
|
||||
}
|
||||
|
||||
public void add(final ItemStack stack) {
|
||||
this.bees.add(stack);
|
||||
}
|
||||
}
|
||||
final Map<Integer, SpeciesList> speciesList = new HashMap<Integer, SpeciesList>();
|
||||
for (final ItemStack itemStack : this.indexerInventory) {
|
||||
final int species = itemStack.getItemDamage();
|
||||
if (!speciesList.containsKey(species)) {
|
||||
speciesList.put(species, new SpeciesList());
|
||||
}
|
||||
speciesList.get(species).add(itemStack);
|
||||
}
|
||||
for (final SpeciesList sortableList : speciesList.values()) {
|
||||
for (final ItemStack beeStack : sortableList.bees) {
|
||||
if (Binnie.Genetics.getBeeRoot().isDrone(beeStack)) {
|
||||
sortableList.drones.add(this.indexerInventory.indexOf(beeStack));
|
||||
}
|
||||
else if (Binnie.Genetics.getBeeRoot().isMated(beeStack)) {
|
||||
sortableList.queens.add(this.indexerInventory.indexOf(beeStack));
|
||||
}
|
||||
else {
|
||||
sortableList.princesses.add(this.indexerInventory.indexOf(beeStack));
|
||||
}
|
||||
}
|
||||
}
|
||||
this.sortedInventory = new SetList<Integer>();
|
||||
switch (this.sortingMode) {
|
||||
case Species: {
|
||||
for (int j = 0; j < 1024; ++j) {
|
||||
if (speciesList.containsKey(j)) {
|
||||
this.sortedInventory.addAll(speciesList.get(j).queens);
|
||||
this.sortedInventory.addAll(speciesList.get(j).princesses);
|
||||
this.sortedInventory.addAll(speciesList.get(j).drones);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Type: {
|
||||
for (int j = 0; j < 1024; ++j) {
|
||||
if (speciesList.containsKey(j)) {
|
||||
this.sortedInventory.addAll(speciesList.get(j).queens);
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < 1024; ++j) {
|
||||
if (speciesList.containsKey(j)) {
|
||||
this.sortedInventory.addAll(speciesList.get(j).princesses);
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < 1024; ++j) {
|
||||
if (speciesList.containsKey(j)) {
|
||||
this.sortedInventory.addAll(speciesList.get(j).drones);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
this.sortedInventory.clear();
|
||||
for (i = 0; i < this.indexerInventory.size(); ++i) {
|
||||
this.sortedInventory.add(i);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(final int i, final ItemStack itemstack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static enum Mode
|
||||
{
|
||||
None,
|
||||
Species,
|
||||
Type;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,229 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import binnie.core.BinnieCore;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.Random;
|
||||
import net.minecraft.world.World;
|
||||
import binnie.core.machines.component.IRender;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import binnie.core.machines.inventory.IChargedSlots;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import binnie.Binnie;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.genetics.item.GeneticLiquid;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.core.machines.power.IProcess;
|
||||
import binnie.core.machines.power.ComponentProcessSetCost;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.core.machines.inventory.ComponentChargedSlots;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.core.machines.inventory.ComponentInventoryTransfer;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import binnie.core.machines.inventory.TankValidator;
|
||||
import binnie.core.machines.inventory.ComponentTankContainer;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.craftgui.minecraft.IMachineInformation;
|
||||
|
||||
public class Genepool
|
||||
{
|
||||
public static final int slotBee = 0;
|
||||
public static final int[] slotReserve;
|
||||
public static final int tankDNA = 0;
|
||||
public static final int tankEthanol = 1;
|
||||
public static final 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, 12661942, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Genepool);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(7, "enzyme");
|
||||
inventory.getSlot(7).setValidator(new SlotValidator.Item(GeneticsItems.Enzyme.get(1), ModuleMachine.IconEnzyme));
|
||||
inventory.getSlot(7).forbidExtraction();
|
||||
inventory.addSlot(0, "process");
|
||||
inventory.getSlot(0).setValidator(new SlotValidator.Individual());
|
||||
inventory.getSlot(0).setReadOnly();
|
||||
inventory.getSlot(0).forbidExtraction();
|
||||
inventory.addSlotArray(Genepool.slotReserve, "input");
|
||||
for (final InventorySlot slot : inventory.getSlots(Genepool.slotReserve)) {
|
||||
slot.setValidator(new SlotValidator.Individual());
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
final ComponentTankContainer tanks = new ComponentTankContainer(machine);
|
||||
tanks.addTank(0, "output", 2000);
|
||||
tanks.getTankSlot(0).setReadOnly();
|
||||
tanks.addTank(1, "input", 1000);
|
||||
tanks.getTankSlot(1).forbidExtraction();
|
||||
tanks.getTankSlot(1).setValidator(new TankValidator() {
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Ethanol";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final FluidStack stack) {
|
||||
return stack.getFluid().getName() == "bioethanol";
|
||||
}
|
||||
});
|
||||
final ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Genepool.slotReserve, 0, 1);
|
||||
new ComponentPowerReceptor(machine, 1600);
|
||||
new ComponentGenepoolLogic(machine);
|
||||
final ComponentChargedSlots chargedSlots = new ComponentChargedSlots(machine);
|
||||
chargedSlots.addCharge(7);
|
||||
new ComponentGenepoolFX(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentGenepoolLogic extends ComponentProcessSetCost implements IProcess
|
||||
{
|
||||
float enzymePerProcess;
|
||||
float ethanolPerProcess;
|
||||
private float ethanolDrain;
|
||||
|
||||
public ComponentGenepoolLogic(final Machine machine) {
|
||||
super(machine, 8000, 400);
|
||||
this.enzymePerProcess = 0.25f;
|
||||
this.ethanolPerProcess = 50.0f;
|
||||
this.ethanolDrain = 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isSlotEmpty(0)) {
|
||||
return new ErrorState.NoItem("No Individual", 0);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (!this.getUtil().spaceInTank(0, this.getDNAAmount(this.getUtil().getStack(0)))) {
|
||||
return new ErrorState.NoSpace("Not enough room in Tank", new int[] { 0 });
|
||||
}
|
||||
if (!this.getUtil().liquidInTank(1, 1)) {
|
||||
return new ErrorState.InsufficientLiquid("Not enough Ethanol", 1);
|
||||
}
|
||||
if (this.getUtil().getSlotCharge(7) == 0.0f) {
|
||||
return new ErrorState.NoItem("Insufficient Enzyme", 7);
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
final int amount = this.getDNAAmount(this.getUtil().getStack(0));
|
||||
this.getUtil().fillTank(0, GeneticLiquid.RawDNA.get(amount));
|
||||
this.getUtil().deleteStack(0);
|
||||
}
|
||||
|
||||
private int getDNAAmount(final ItemStack stack) {
|
||||
final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack);
|
||||
if (root == null) {
|
||||
return 10;
|
||||
}
|
||||
if (root != Binnie.Genetics.getBeeRoot()) {
|
||||
return 10;
|
||||
}
|
||||
if (Binnie.Genetics.getBeeRoot().isDrone(stack)) {
|
||||
return 10;
|
||||
}
|
||||
if (Binnie.Genetics.getBeeRoot().isMated(stack)) {
|
||||
return 50;
|
||||
}
|
||||
return 30;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
this.ethanolDrain += this.getDNAAmount(this.getUtil().getStack(0)) * 1.2f * this.getProgressPerTick() / 100.0f;
|
||||
if (this.ethanolDrain >= 1.0f) {
|
||||
this.getUtil().drainTank(1, 1);
|
||||
--this.ethanolDrain;
|
||||
}
|
||||
this.getMachine().getInterface(IChargedSlots.class).alterCharge(7, -this.enzymePerProcess * this.getProgressPerTick() / 100.0f);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentGenepoolFX extends MachineComponent implements IRender.RandomDisplayTick, IRender.DisplayTick
|
||||
{
|
||||
public ComponentGenepoolFX(final IMachine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onRandomDisplayTick(final World world, final int x, final int y, final int z, final Random rand) {
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(final World world, final int x, final int y, final int z, final Random rand) {
|
||||
if (rand.nextFloat() < 1.0f && this.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 = this.posX;
|
||||
double axisZ = this.posZ;
|
||||
double angle = this.rand.nextDouble() * 2.0 * 3.1415;
|
||||
|
||||
{
|
||||
this.axisX = 0.0;
|
||||
this.axisZ = 0.0;
|
||||
this.angle = 0.0;
|
||||
this.motionX = 0.0;
|
||||
this.motionZ = 0.0;
|
||||
this.motionY = this.rand.nextFloat() * 0.01;
|
||||
this.particleMaxAge = 25;
|
||||
this.particleGravity = 0.0f;
|
||||
this.noClip = true;
|
||||
this.setRBGColorF(0.4f + 0.6f * this.rand.nextFloat(), 0.6f * this.rand.nextFloat(), 0.6f + 0.4f * this.rand.nextFloat());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
this.setAlphaF((float) Math.cos(1.57 * this.particleAge / this.particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import binnie.core.resource.IBinnieTexture;
|
||||
import binnie.core.resource.BinnieResource;
|
||||
import net.minecraft.block.Block;
|
||||
import binnie.genetics.Genetics;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.core.machines.MachinePackage;
|
||||
import binnie.core.machines.IMachineType;
|
||||
|
||||
public enum GeneticMachine implements IMachineType
|
||||
{
|
||||
Isolator(Isolator.PackageIsolator.class),
|
||||
Sequencer(Sequencer.PackageSequencer.class),
|
||||
Polymeriser(Polymeriser.PackagePolymeriser.class),
|
||||
Inoculator(Inoculator.PackageInoculator.class);
|
||||
|
||||
Class<? extends MachinePackage> clss;
|
||||
|
||||
private GeneticMachine(final Class<? extends MachinePackage> clss) {
|
||||
this.clss = clss;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends MachinePackage> getPackageClass() {
|
||||
return this.clss;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public ItemStack get(final int i) {
|
||||
return new ItemStack(Genetics.packageGenetic.getBlock(), i, this.ordinal());
|
||||
}
|
||||
|
||||
public abstract static class PackageGeneticBase extends MachinePackage
|
||||
{
|
||||
BinnieResource renderTexture;
|
||||
int colour;
|
||||
|
||||
protected PackageGeneticBase(final String uid, final IBinnieTexture renderTexture, final int flashColour, final boolean powered) {
|
||||
super(uid, powered);
|
||||
this.renderTexture = renderTexture.getTexture();
|
||||
this.colour = flashColour;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderMachine(final Machine machine, final double x, final double y, final double z, final float var8, final RenderBlocks renderer) {
|
||||
MachineRendererGenetics.instance.renderMachine(machine, this.colour, this.renderTexture, x, y, z, var8);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,360 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import binnie.core.machines.transfer.TransferRequest;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import java.util.Random;
|
||||
import binnie.core.machines.power.IProcess;
|
||||
import binnie.core.machines.power.ComponentProcessIndefinate;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.core.machines.inventory.ComponentTankContainer;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.craftgui.minecraft.IMachineInformation;
|
||||
import java.util.ArrayList;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import binnie.core.machines.MachineUtil;
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import binnie.core.BinnieCore;
|
||||
import net.minecraft.init.Items;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import binnie.genetics.item.GeneticLiquid;
|
||||
import binnie.Binnie;
|
||||
import binnie.genetics.api.IIncubatorRecipe;
|
||||
import java.util.List;
|
||||
|
||||
public class Incubator
|
||||
{
|
||||
public static final int[] slotQueue;
|
||||
public static final int slotIncubator = 3;
|
||||
public static final int[] slotOutput;
|
||||
public static final int tankInput = 0;
|
||||
public static final int tankOutput = 1;
|
||||
private static List<IIncubatorRecipe> RECIPES;
|
||||
|
||||
public static void addRecipes() {
|
||||
Incubator.RECIPES.add(new IncubatorRecipe(Binnie.Liquid.getLiquidStack("water", 25), GeneticLiquid.GrowthMedium.get(25), 0.2f) {
|
||||
@Override
|
||||
public boolean isItemStack(final 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(final 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(final 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(final 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(final 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(final 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(final 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(final 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(final ItemStack stack) {
|
||||
return Binnie.Genetics.getBeeRoot().isMember(stack) && Binnie.Genetics.getBeeRoot().getType(stack) == EnumBeeType.LARVAE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getOutputStack(final MachineUtil machine) {
|
||||
final ItemStack larvae = machine.getStack(3);
|
||||
final IBee bee = Binnie.Genetics.getBeeRoot().getMember(larvae);
|
||||
return Binnie.Genetics.getBeeRoot().getMemberStack(bee, EnumBeeType.DRONE.ordinal());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
slotQueue = new int[] { 0, 1, 2 };
|
||||
slotOutput = new int[] { 4, 5, 6 };
|
||||
Incubator.RECIPES = new ArrayList<IIncubatorRecipe>();
|
||||
}
|
||||
|
||||
public static class PackageIncubator extends GeneticMachine.PackageGeneticBase implements IMachineInformation
|
||||
{
|
||||
public PackageIncubator() {
|
||||
super("incubator", GeneticsTexture.Incubator, 16767313, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Incubator);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlotArray(Incubator.slotQueue, "input");
|
||||
for (final 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 (final InventorySlot slot : inventory.getSlots(Incubator.slotOutput)) {
|
||||
slot.forbidInsertion();
|
||||
slot.setReadOnly();
|
||||
}
|
||||
new ComponentPowerReceptor(machine, 2000);
|
||||
final 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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentIncubatorLogic extends ComponentProcessIndefinate implements IProcess
|
||||
{
|
||||
IIncubatorRecipe recipe;
|
||||
private Random rand;
|
||||
private boolean roomForOutput;
|
||||
|
||||
public ComponentIncubatorLogic(final Machine machine) {
|
||||
super(machine, 2.0f);
|
||||
this.recipe = null;
|
||||
this.rand = new Random();
|
||||
this.roomForOutput = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.recipe == null) {
|
||||
return new ErrorState("No Recipe", "There is no valid recipe");
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (this.recipe != null) {
|
||||
if (!this.recipe.isInputLiquidSufficient(this.getUtil().getFluid(0))) {
|
||||
return new ErrorState.InsufficientLiquid("Not enough incubation liquid", 0);
|
||||
}
|
||||
if (!this.roomForOutput) {
|
||||
return new ErrorState.TankSpace("No room for output", 1);
|
||||
}
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
if (this.rand.nextInt(20) == 0 && this.recipe != null && this.rand.nextFloat() < this.recipe.getChance()) {
|
||||
this.recipe.doTask(this.getUtil());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inProgress() {
|
||||
return this.recipe != null;
|
||||
}
|
||||
|
||||
private IIncubatorRecipe getRecipe(final ItemStack stack, final FluidStack liquid) {
|
||||
for (final IIncubatorRecipe recipe : Incubator.RECIPES) {
|
||||
final boolean rightLiquid = recipe.isInputLiquid(liquid);
|
||||
final boolean rightItem = recipe.isItemStack(stack);
|
||||
if (rightLiquid && rightItem) {
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryUpdate() {
|
||||
super.onInventoryUpdate();
|
||||
if (!this.getUtil().isServer()) {
|
||||
return;
|
||||
}
|
||||
final FluidStack liquid = this.getUtil().getFluid(0);
|
||||
final ItemStack incubator = this.getUtil().getStack(3);
|
||||
if (this.recipe != null && (incubator == null || liquid == null || !this.recipe.isInputLiquid(liquid) || !this.recipe.isItemStack(incubator))) {
|
||||
this.recipe = null;
|
||||
final ItemStack leftover = new TransferRequest(incubator, this.getInventory()).setTargetSlots(Incubator.slotOutput).ignoreValidation().transfer(true);
|
||||
this.getUtil().setStack(3, leftover);
|
||||
}
|
||||
if (this.recipe == null) {
|
||||
if (liquid == null) {
|
||||
return;
|
||||
}
|
||||
if (incubator != null) {
|
||||
final IIncubatorRecipe recipe = this.getRecipe(incubator, liquid);
|
||||
if (recipe != null) {
|
||||
this.recipe = recipe;
|
||||
return;
|
||||
}
|
||||
}
|
||||
IIncubatorRecipe potential = null;
|
||||
int potentialSlot = 0;
|
||||
for (final int slot : Incubator.slotQueue) {
|
||||
final ItemStack stack = this.getUtil().getStack(slot);
|
||||
if (stack != null) {
|
||||
if (potential == null) {
|
||||
for (final IIncubatorRecipe recipe2 : Incubator.RECIPES) {
|
||||
final boolean rightLiquid = recipe2.isInputLiquid(liquid);
|
||||
final boolean rightItem = recipe2.isItemStack(stack);
|
||||
if (rightLiquid && rightItem) {
|
||||
potential = recipe2;
|
||||
potentialSlot = slot;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (potential != null) {
|
||||
final TransferRequest removal = new TransferRequest(incubator, this.getInventory()).setTargetSlots(Incubator.slotOutput).ignoreValidation();
|
||||
if (removal.transfer(false) == null) {
|
||||
this.recipe = potential;
|
||||
}
|
||||
removal.transfer(true);
|
||||
final ItemStack stack2 = this.getUtil().getStack(potentialSlot);
|
||||
this.getUtil().setStack(potentialSlot, null);
|
||||
this.getUtil().setStack(3, stack2);
|
||||
}
|
||||
}
|
||||
if (this.recipe != null) {
|
||||
this.roomForOutput = this.recipe.roomForOutput(this.getUtil());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class IncubatorCrafting
|
||||
{
|
||||
ItemStack input;
|
||||
FluidStack fluid;
|
||||
}
|
||||
|
||||
private abstract static class IncubatorRecipe implements IIncubatorRecipe
|
||||
{
|
||||
FluidStack input;
|
||||
FluidStack output;
|
||||
float lossChance;
|
||||
ItemStack outputStack;
|
||||
float tickChance;
|
||||
|
||||
@Override
|
||||
public float getChance() {
|
||||
return this.tickChance;
|
||||
}
|
||||
|
||||
public IncubatorRecipe(final FluidStack input, final FluidStack output, final float lossChance) {
|
||||
this(input, output, lossChance, 1.0f);
|
||||
}
|
||||
|
||||
public IncubatorRecipe(final FluidStack input, final FluidStack output, final float lossChance, final float chance) {
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
this.lossChance = lossChance;
|
||||
this.tickChance = chance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInputLiquid(final FluidStack fluid) {
|
||||
return fluid != null && this.input.isFluidEqual(fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInputLiquidSufficient(final FluidStack fluid) {
|
||||
return fluid != null && fluid.amount >= 500;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doTask(final MachineUtil machine) {
|
||||
machine.drainTank(0, this.input.amount);
|
||||
if (this.output != null) {
|
||||
machine.fillTank(1, this.output);
|
||||
}
|
||||
this.outputStack = this.getOutputStack(machine);
|
||||
if (this.outputStack != null) {
|
||||
final ItemStack output = this.outputStack.copy();
|
||||
final TransferRequest product = new TransferRequest(output, machine.getInventory()).setTargetSlots(Incubator.slotOutput).ignoreValidation();
|
||||
product.transfer(true);
|
||||
}
|
||||
final Random rand = machine.getRandom();
|
||||
if (rand.nextFloat() < this.lossChance) {
|
||||
machine.decreaseStack(3, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public IncubatorRecipe setOutputStack(final ItemStack stack) {
|
||||
this.outputStack = stack;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected ItemStack getOutputStack(final MachineUtil util) {
|
||||
return this.outputStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean roomForOutput(final MachineUtil machine) {
|
||||
if (this.output != null && !machine.isTankEmpty(1)) {
|
||||
if (!machine.getFluid(1).isFluidEqual(this.output)) {
|
||||
return false;
|
||||
}
|
||||
if (!machine.spaceInTank(1, this.output.amount)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
final ItemStack outputStack = this.getOutputStack(machine);
|
||||
if (outputStack != null) {
|
||||
final ItemStack output = outputStack.copy();
|
||||
final TransferRequest product = new TransferRequest(output, machine.getInventory()).setTargetSlots(Incubator.slotOutput).ignoreValidation();
|
||||
final ItemStack leftover = product.transfer(false);
|
||||
return leftover == null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,425 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import binnie.Binnie;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import binnie.core.BinnieCore;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.Random;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import binnie.core.machines.network.INetwork;
|
||||
import binnie.core.machines.component.IRender;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.core.machines.power.IProcess;
|
||||
import binnie.core.machines.power.ComponentProcessSetCost;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.genetics.item.GeneticLiquid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import binnie.core.machines.inventory.ComponentTankContainer;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.genetics.genetics.Engineering;
|
||||
import binnie.core.machines.inventory.ComponentInventoryTransfer;
|
||||
import binnie.core.machines.inventory.Validator;
|
||||
import binnie.genetics.api.IItemSerum;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.craftgui.minecraft.IMachineInformation;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.apiculture.IBeeRoot;
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.genetics.api.IGene;
|
||||
|
||||
public class Inoculator
|
||||
{
|
||||
public static final int slotSerumVial = 0;
|
||||
public static final int[] slotSerumReserve;
|
||||
public static final int[] slotSerumExpended;
|
||||
public static final int[] slotReserve;
|
||||
public static final int slotTarget = 9;
|
||||
public static final int[] slotFinished;
|
||||
public static final int tankVector = 0;
|
||||
|
||||
public static void setGene(final IGene gene, final ItemStack target, final int chromoN) {
|
||||
int chromosomeID;
|
||||
final int chromosome = chromosomeID = gene.getChromosome().ordinal();
|
||||
if (chromosomeID >= EnumBeeChromosome.HUMIDITY.ordinal() && gene.getSpeciesRoot() instanceof IBeeRoot) {
|
||||
--chromosomeID;
|
||||
}
|
||||
final Class<? extends IAllele> cls = gene.getChromosome().getAlleleClass();
|
||||
if (!cls.isInstance(gene.getAllele())) {
|
||||
return;
|
||||
}
|
||||
final NBTTagCompound beeNBT = target.getTagCompound();
|
||||
final NBTTagCompound genomeNBT = beeNBT.getCompoundTag("Genome");
|
||||
final NBTTagList chromosomes = genomeNBT.getTagList("Chromosomes", 10);
|
||||
final NBTTagCompound chromosomeNBT = chromosomes.getCompoundTagAt(chromosomeID);
|
||||
chromosomeNBT.setString("UID" + chromoN, gene.getAllele().getUID());
|
||||
target.setTagCompound(beeNBT);
|
||||
}
|
||||
|
||||
static {
|
||||
slotSerumReserve = new int[] { 1, 2 };
|
||||
slotSerumExpended = new int[] { 3, 4 };
|
||||
slotReserve = new int[] { 5, 6, 7, 8 };
|
||||
slotFinished = new int[] { 10, 11, 12, 13 };
|
||||
}
|
||||
|
||||
public static class PackageInoculator extends GeneticMachine.PackageGeneticBase implements IMachineInformation
|
||||
{
|
||||
public PackageInoculator() {
|
||||
super("inoculator", GeneticsTexture.Inoculator, 14819893, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Inoculator);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(0, "serum.active");
|
||||
inventory.getSlot(0).forbidInteraction();
|
||||
inventory.getSlot(0).setReadOnly();
|
||||
final SlotValidator serumValid = new SlotValidator(ModuleMachine.IconSerum) {
|
||||
@Override
|
||||
public boolean isValid(final ItemStack itemStack) {
|
||||
return itemStack.getItem() instanceof IItemSerum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Serum Vials & Arrays";
|
||||
}
|
||||
};
|
||||
inventory.getSlot(0).setValidator(serumValid);
|
||||
inventory.addSlotArray(Inoculator.slotSerumReserve, "serum.input");
|
||||
for (final InventorySlot slot : inventory.getSlots(Inoculator.slotSerumReserve)) {
|
||||
slot.setValidator(serumValid);
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
inventory.addSlotArray(Inoculator.slotSerumExpended, "serum.output");
|
||||
for (final InventorySlot slot : inventory.getSlots(Inoculator.slotSerumExpended)) {
|
||||
slot.setValidator(serumValid);
|
||||
slot.setReadOnly();
|
||||
}
|
||||
inventory.addSlotArray(Inoculator.slotReserve, "input");
|
||||
for (final InventorySlot slot : inventory.getSlots(Inoculator.slotReserve)) {
|
||||
slot.forbidExtraction();
|
||||
slot.setValidator(new ValidatorIndividualInoculate());
|
||||
}
|
||||
inventory.addSlot(9, "process");
|
||||
inventory.getSlot(9).setValidator(new ValidatorIndividualInoculate());
|
||||
inventory.getSlot(9).setReadOnly();
|
||||
inventory.getSlot(9).forbidInteraction();
|
||||
inventory.addSlotArray(Inoculator.slotFinished, "output");
|
||||
for (final InventorySlot slot : inventory.getSlots(Inoculator.slotFinished)) {
|
||||
slot.setReadOnly();
|
||||
slot.forbidInsertion();
|
||||
slot.setValidator(new ValidatorIndividualInoculate());
|
||||
}
|
||||
final ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Inoculator.slotReserve, 9, 1);
|
||||
transfer.addRestock(Inoculator.slotSerumReserve, 0);
|
||||
transfer.addStorage(0, Inoculator.slotSerumExpended, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(final ItemStack stack) {
|
||||
return Engineering.getCharges(stack) == 0;
|
||||
}
|
||||
});
|
||||
transfer.addStorage(9, Inoculator.slotFinished, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(final ItemStack stack) {
|
||||
return stack != null && this.transfer.getMachine().getMachineUtil().getStack(0) != null && this.transfer.getMachine().getInterface(ComponentInoculatorLogic.class).isValidSerum() != null;
|
||||
}
|
||||
});
|
||||
new ComponentPowerReceptor(machine, 15000);
|
||||
new ComponentInoculatorLogic(machine);
|
||||
new ComponentInoculatorFX(machine);
|
||||
new ComponentTankContainer(machine).addTank(0, "input", 1000).setValidator(new Validator<FluidStack>() {
|
||||
@Override
|
||||
public boolean isValid(final FluidStack object) {
|
||||
return GeneticLiquid.BacteriaVector.get(1).isFluidEqual(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return GeneticLiquid.BacteriaVector.getName();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentInoculatorLogic extends ComponentProcessSetCost implements IProcess
|
||||
{
|
||||
private float bacteriaDrain;
|
||||
|
||||
@Override
|
||||
public int getProcessLength() {
|
||||
return super.getProcessLength() * this.getNumberOfGenes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessEnergy() {
|
||||
return super.getProcessEnergy() * this.getNumberOfGenes();
|
||||
}
|
||||
|
||||
private int getNumberOfGenes() {
|
||||
final ItemStack serum = this.getUtil().getStack(0);
|
||||
if (serum == null) {
|
||||
return 1;
|
||||
}
|
||||
return Engineering.getGenes(serum).length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
final int n = this.getNumberOfGenes();
|
||||
return "Inoculating with " + n + " gene" + ((n > 1) ? "s" : "");
|
||||
}
|
||||
|
||||
public ComponentInoculatorLogic(final Machine machine) {
|
||||
super(machine, 600000, 12000);
|
||||
this.bacteriaDrain = 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isSlotEmpty(9)) {
|
||||
return new ErrorState.NoItem("No Individual to Inoculate", 9);
|
||||
}
|
||||
if (this.getUtil().isSlotEmpty(0)) {
|
||||
return new ErrorState.NoItem("No Serum", 0);
|
||||
}
|
||||
final ErrorState state = this.isValidSerum();
|
||||
if (state != null) {
|
||||
return state;
|
||||
}
|
||||
if (this.getUtil().getStack(0) != null && Engineering.getCharges(this.getUtil().getStack(0)) == 0) {
|
||||
return new ErrorState("Empty Serum", "Serum is empty");
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
public ErrorState isValidSerum() {
|
||||
final ItemStack serum = this.getUtil().getStack(0);
|
||||
final ItemStack target = this.getUtil().getStack(9);
|
||||
final IGene[] genes = Engineering.getGenes(serum);
|
||||
if (genes.length == 0) {
|
||||
return new ErrorState("Invalid Serum", "Serum does not hold any genes");
|
||||
}
|
||||
if (!genes[0].getSpeciesRoot().isMember(target)) {
|
||||
return new ErrorState("Invalid Serum", "Mismatch of Serum Type and Target");
|
||||
}
|
||||
final IIndividual individual = genes[0].getSpeciesRoot().getMember(target);
|
||||
boolean hasAll = true;
|
||||
for (final IGene gene : genes) {
|
||||
if (hasAll) {
|
||||
final IAllele a = individual.getGenome().getActiveAllele(gene.getChromosome());
|
||||
final IAllele b = individual.getGenome().getInactiveAllele(gene.getChromosome());
|
||||
hasAll = (hasAll && a.getUID().equals(gene.getAllele().getUID()) && b.getUID().equals(gene.getAllele().getUID()));
|
||||
}
|
||||
}
|
||||
if (hasAll) {
|
||||
return new ErrorState("Defunct Serum", "Individual already possesses this allele");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
final ItemStack serum = this.getUtil().getStack(0);
|
||||
final ItemStack target = this.getUtil().getStack(9);
|
||||
final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(target);
|
||||
if (!ind.isAnalyzed()) {
|
||||
ind.analyze();
|
||||
final NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
ind.writeToNBT(nbttagcompound);
|
||||
target.setTagCompound(nbttagcompound);
|
||||
}
|
||||
final IGene[] arr$;
|
||||
final IGene[] genes = arr$ = ((IItemSerum) serum.getItem()).getGenes(serum);
|
||||
for (final IGene gene : arr$) {
|
||||
Inoculator.setGene(gene, target, 0);
|
||||
Inoculator.setGene(gene, target, 1);
|
||||
}
|
||||
this.getUtil().damageItem(0, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
this.bacteriaDrain += 15.0f * this.getProgressPerTick() / 100.0f;
|
||||
if (this.bacteriaDrain >= 1.0f) {
|
||||
this.getUtil().drainTank(0, 1);
|
||||
--this.bacteriaDrain;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentInoculatorFX extends MachineComponent implements IRender.RandomDisplayTick, IRender.DisplayTick, IRender.Render, INetwork.TilePacketSync
|
||||
{
|
||||
private final EntityItem dummyEntityItem;
|
||||
|
||||
public ComponentInoculatorFX(final IMachine machine) {
|
||||
super(machine);
|
||||
this.dummyEntityItem = new EntityItem((World) null);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onRandomDisplayTick(final World world, final int x, final int y, final int z, final Random rand) {
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(final World world, final int x, final int y, final int z, final Random rand) {
|
||||
final int tick = (int) (world.getTotalWorldTime() % 3L);
|
||||
if (tick == 0 && this.getUtil().getProcess().isInProgress()) {
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new EntityFX(world, x + 0.5, y + 0.92, z + 0.5, 0.0, 0.0, 0.0) {
|
||||
double axisX = this.posX;
|
||||
double axisZ = this.posZ;
|
||||
double angle = (int) (this.worldObj.getTotalWorldTime() % 4L) * 0.5 * 3.1415;
|
||||
|
||||
{
|
||||
this.axisX = 0.0;
|
||||
this.axisZ = 0.0;
|
||||
this.angle = 0.0;
|
||||
this.motionX = 0.0;
|
||||
this.motionZ = 0.0;
|
||||
this.motionY = 0.007 + this.rand.nextDouble() * 0.002;
|
||||
this.particleMaxAge = 240;
|
||||
this.particleGravity = 0.0f;
|
||||
this.noClip = true;
|
||||
this.setRBGColorF(0.8f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
double speed = 5.0E-4;
|
||||
if (this.particleAge > 60) {
|
||||
speed += (this.particleAge - 60) / 4000.0f;
|
||||
}
|
||||
this.angle += speed;
|
||||
final double dist = 0.27;
|
||||
this.setPosition(this.axisX + dist * Math.sin(this.angle), this.posY, this.axisZ + dist * Math.cos(this.angle));
|
||||
this.setAlphaF((float) Math.cos(1.57 * this.particleAge / this.particleMaxAge));
|
||||
if (this.particleAge > 40) {
|
||||
this.setRBGColorF(this.particleRed + (1.0f - this.particleRed) / 10.0f, this.particleGreen + (0.0f - this.particleGreen) / 10.0f, this.particleBlue + (0.0f - this.particleBlue) / 10.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void renderInWorld(final RenderItem customRenderItem, final double x, final double y, final double z) {
|
||||
if (!this.getUtil().getProcess().isInProgress()) {
|
||||
return;
|
||||
}
|
||||
final ItemStack stack = this.getUtil().getStack(9);
|
||||
this.dummyEntityItem.worldObj = this.getMachine().getWorld();
|
||||
this.dummyEntityItem.setEntityItemStack(stack);
|
||||
final EntityItem dummyEntityItem = this.dummyEntityItem;
|
||||
++dummyEntityItem.age;
|
||||
this.dummyEntityItem.hoverStart = 0.0f;
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
final EntityPlayer player = BinnieCore.proxy.getPlayer();
|
||||
final double dx = x + 0.5 - player.lastTickPosX;
|
||||
final double dz = z + 0.5 - player.lastTickPosZ;
|
||||
final double t = Math.atan2(dz, dx) * 180.0 / 3.1415;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(180.0f, 0.0f, 0.0f, 1.0f);
|
||||
GL11.glTranslatef(0.0f, -0.25f, 0.0f);
|
||||
customRenderItem.doRender(this.dummyEntityItem, 0.0, 0.0, 0.0, 0.0f, 0.0f);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncToNBT(final NBTTagCompound nbt) {
|
||||
final NBTTagCompound item = new NBTTagCompound();
|
||||
final ItemStack stack = this.getUtil().getStack(9);
|
||||
if (stack != null) {
|
||||
stack.writeToNBT(item);
|
||||
nbt.setTag("item", item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncFromNBT(final NBTTagCompound nbt) {
|
||||
if (nbt.hasKey("item")) {
|
||||
this.getUtil().setStack(9, ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("item")));
|
||||
}
|
||||
else {
|
||||
this.getUtil().setStack(9, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryUpdate() {
|
||||
if (!this.getUtil().isServer()) {
|
||||
return;
|
||||
}
|
||||
this.getUtil().refreshBlock();
|
||||
}
|
||||
}
|
||||
|
||||
public static class ValidatorIndividualInoculate extends SlotValidator
|
||||
{
|
||||
public ValidatorIndividualInoculate() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final ItemStack object) {
|
||||
final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(object);
|
||||
return root != null && Binnie.Genetics.getSystem(root).isDNAManipulable(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Inoculable Individual";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,282 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import binnie.core.BinnieCore;
|
||||
import net.minecraft.world.World;
|
||||
import binnie.core.machines.component.IRender;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import binnie.core.machines.inventory.IChargedSlots;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import java.util.Random;
|
||||
import binnie.genetics.item.ItemSequence;
|
||||
import binnie.core.genetics.Gene;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.core.machines.power.IProcess;
|
||||
import binnie.core.machines.power.ComponentProcessSetCost;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.core.machines.inventory.ComponentInventoryTransfer;
|
||||
import binnie.core.machines.inventory.ComponentChargedSlots;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import binnie.core.machines.inventory.TankValidator;
|
||||
import binnie.core.machines.inventory.ComponentTankContainer;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.craftgui.minecraft.IMachineInformation;
|
||||
|
||||
public class Isolator
|
||||
{
|
||||
public static final int slotEnzyme = 0;
|
||||
public static final int slotSequencerVial = 1;
|
||||
public static final int[] slotReserve;
|
||||
public static final int slotTarget = 5;
|
||||
public static final int slotResult = 6;
|
||||
public static final int[] slotFinished;
|
||||
public static final int tankEthanol = 0;
|
||||
|
||||
static {
|
||||
slotReserve = new int[] { 2, 3, 4 };
|
||||
slotFinished = new int[] { 7, 8, 9, 10, 11, 12 };
|
||||
}
|
||||
|
||||
public static class PackageIsolator extends GeneticMachine.PackageGeneticBase implements IMachineInformation
|
||||
{
|
||||
public PackageIsolator() {
|
||||
super("isolator", GeneticsTexture.Isolator, 16740111, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Isolator);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(0, "enzyme");
|
||||
inventory.getSlot(0).setValidator(new SlotValidator.Item(GeneticsItems.Enzyme.get(1), ModuleMachine.IconEnzyme));
|
||||
inventory.getSlot(0).forbidExtraction();
|
||||
inventory.addSlot(1, "sequencervial");
|
||||
inventory.getSlot(1).setValidator(new SlotValidator.Item(GeneticsItems.EmptySequencer.get(1), ModuleMachine.IconSequencer));
|
||||
inventory.getSlot(1).forbidExtraction();
|
||||
inventory.addSlotArray(Isolator.slotReserve, "input");
|
||||
for (final InventorySlot slot : inventory.getSlots(Isolator.slotReserve)) {
|
||||
slot.setValidator(new SlotValidator.Individual());
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
inventory.addSlot(5, "process");
|
||||
inventory.getSlot(5).setValidator(new SlotValidator.Individual());
|
||||
inventory.getSlot(5).setReadOnly();
|
||||
inventory.getSlot(5).forbidInteraction();
|
||||
inventory.addSlot(6, "output");
|
||||
inventory.getSlot(6).setReadOnly();
|
||||
inventory.getSlot(6).forbidInteraction();
|
||||
inventory.addSlotArray(Isolator.slotFinished, "output");
|
||||
for (final InventorySlot slot : inventory.getSlots(Isolator.slotFinished)) {
|
||||
slot.setReadOnly();
|
||||
slot.forbidInsertion();
|
||||
}
|
||||
final ComponentTankContainer tanks = new ComponentTankContainer(machine);
|
||||
tanks.addTank(0, "input", 1000);
|
||||
tanks.getTankSlot(0).setValidator(new TankValidator() {
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Ethanol";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final FluidStack stack) {
|
||||
return stack.getFluid().getName() == "bioethanol";
|
||||
}
|
||||
});
|
||||
final ComponentChargedSlots chargedSlots = new ComponentChargedSlots(machine);
|
||||
chargedSlots.addCharge(0);
|
||||
final ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Isolator.slotReserve, 5, 1);
|
||||
transfer.addStorage(6, Isolator.slotFinished);
|
||||
new ComponentPowerReceptor(machine, 20000);
|
||||
new ComponentIsolatorLogic(machine);
|
||||
new ComponentIsolaterFX(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentIsolatorLogic extends ComponentProcessSetCost implements IProcess
|
||||
{
|
||||
float enzymePerProcess;
|
||||
float ethanolPerProcess;
|
||||
|
||||
public ComponentIsolatorLogic(final Machine machine) {
|
||||
super(machine, 192000, 4800);
|
||||
this.enzymePerProcess = 0.5f;
|
||||
this.ethanolPerProcess = 10.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isSlotEmpty(5)) {
|
||||
return new ErrorState.NoItem("No individual to isolate", 5);
|
||||
}
|
||||
if (!this.getUtil().isSlotEmpty(6)) {
|
||||
return new ErrorState.NoSpace("No room for DNA sequences", Isolator.slotFinished);
|
||||
}
|
||||
if (this.getUtil().isSlotEmpty(1)) {
|
||||
return new ErrorState.NoItem("No empty sequencer vials", 1);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (!this.getUtil().liquidInTank(0, (int) this.ethanolPerProcess)) {
|
||||
return new ErrorState.InsufficientLiquid("Insufficient ethanol", 0);
|
||||
}
|
||||
if (this.getUtil().getSlotCharge(0) == 0.0f) {
|
||||
return new ErrorState.NoItem("No enzyme", 0);
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
final Random rand = this.getMachine().getWorld().rand;
|
||||
final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(this.getUtil().getStack(5));
|
||||
if (root == null) {
|
||||
return;
|
||||
}
|
||||
final IIndividual individual = root.getMember(this.getUtil().getStack(5));
|
||||
if (individual == null) {
|
||||
return;
|
||||
}
|
||||
IAllele allele = null;
|
||||
IChromosomeType chromosome = null;
|
||||
Gene gene = null;
|
||||
if (this.getMachine().getWorld().rand.nextFloat() < 2.0f) {
|
||||
while (gene == null) {
|
||||
try {
|
||||
chromosome = root.getKaryotype()[rand.nextInt(root.getKaryotype().length)];
|
||||
allele = (rand.nextBoolean() ? individual.getGenome().getActiveAllele(chromosome) : individual.getGenome().getInactiveAllele(chromosome));
|
||||
gene = Gene.create(allele, chromosome, root);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
final ItemStack serum = ItemSequence.create(gene);
|
||||
this.getUtil().setStack(6, serum);
|
||||
this.getUtil().decreaseStack(1, 1);
|
||||
if (rand.nextFloat() < 0.05f) {
|
||||
this.getUtil().decreaseStack(5, 1);
|
||||
}
|
||||
this.getUtil().drainTank(0, (int) this.ethanolPerProcess);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
this.getMachine().getInterface(IChargedSlots.class).alterCharge(0, -this.enzymePerProcess * this.getProgressPerTick() / 100.0f);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentIsolaterFX extends MachineComponent implements IRender.RandomDisplayTick, IRender.DisplayTick
|
||||
{
|
||||
public ComponentIsolaterFX(final IMachine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onRandomDisplayTick(final World world, final int x, final int y, final int z, final Random rand) {
|
||||
if (!this.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;
|
||||
|
||||
{
|
||||
this.motionX = 0.0;
|
||||
this.motionZ = 0.0;
|
||||
this.motionY = -0.012;
|
||||
this.particleMaxAge = 100;
|
||||
this.particleGravity = 0.0f;
|
||||
this.noClip = true;
|
||||
this.setRBGColorF(0.8f, 0.4f, 0.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
this.angle += 0.06;
|
||||
this.setAlphaF((float) Math.sin(3.14 * this.particleAge / this.particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(final World world, final int x, final int y, final int z, final Random rand) {
|
||||
final int tick = (int) (world.getTotalWorldTime() % 6L);
|
||||
if ((tick == 0 || tick == 5) && this.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 = this.posX;
|
||||
double axisZ = this.posZ;
|
||||
double angle = 0.7 + (int) (this.worldObj.getTotalWorldTime() % 2L) * 3.1415;
|
||||
|
||||
{
|
||||
this.axisX = 0.0;
|
||||
this.axisZ = 0.0;
|
||||
this.angle = 0.0;
|
||||
this.motionX = 0.0;
|
||||
this.motionZ = 0.0;
|
||||
this.motionY = 0.012;
|
||||
this.particleMaxAge = 100;
|
||||
this.particleGravity = 0.0f;
|
||||
this.noClip = true;
|
||||
this.setRBGColorF(0.8f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
this.angle += 0.06;
|
||||
this.setPosition(this.axisX + 0.26 * Math.sin(this.angle), this.posY, this.axisZ + 0.26 * Math.cos(this.angle));
|
||||
this.setAlphaF((float) Math.cos(1.57 * this.particleAge / this.particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import java.util.List;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extrabees.ExtraBees;
|
||||
import binnie.botany.Botany;
|
||||
import net.minecraft.item.Item;
|
||||
import java.util.ArrayList;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import binnie.core.BinnieCore;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import binnie.core.machines.component.IInteraction;
|
||||
import binnie.core.machines.network.INetwork;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import net.minecraft.block.Block;
|
||||
import binnie.genetics.Genetics;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.core.machines.MachinePackage;
|
||||
import binnie.core.machines.IMachineType;
|
||||
|
||||
public enum LaboratoryMachine implements IMachineType
|
||||
{
|
||||
LabMachine(PackageLabMachine.class),
|
||||
Analyser(Analyser.PackageAnalyser.class),
|
||||
Incubator(Incubator.PackageIncubator.class),
|
||||
Genepool(Genepool.PackageGenepool.class),
|
||||
Acclimatiser(Acclimatiser.PackageAcclimatiser.class);
|
||||
|
||||
Class<? extends MachinePackage> clss;
|
||||
|
||||
private LaboratoryMachine(final Class<? extends MachinePackage> clss) {
|
||||
this.clss = clss;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends MachinePackage> getPackageClass() {
|
||||
return this.clss;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public ItemStack get(final int i) {
|
||||
return new ItemStack(Genetics.packageLabMachine.getBlock(), i, this.ordinal());
|
||||
}
|
||||
|
||||
public static class PackageLabMachine extends GeneticMachine.PackageGeneticBase
|
||||
{
|
||||
public PackageLabMachine() {
|
||||
super("labMachine", GeneticsTexture.LabMachine, 16777215, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentGUIHolder(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderMachine(final Machine machine, final double x, final double y, final double z, final float var8, final RenderBlocks renderer) {
|
||||
MachineRendererLab.instance.renderMachine(machine, this.colour, this.renderTexture, x, y, z, var8);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentGUIHolder extends MachineComponent implements INetwork.TilePacketSync, IInteraction.RightClick
|
||||
{
|
||||
private ItemStack stack;
|
||||
|
||||
public ComponentGUIHolder(final IMachine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
public ItemStack getStack() {
|
||||
return this.stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
if (nbttagcompound == null) {
|
||||
return;
|
||||
}
|
||||
this.stack = ItemStack.loadItemStackFromNBT(nbttagcompound.getCompoundTag("Item"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
final NBTTagCompound nbt = new NBTTagCompound();
|
||||
if (this.stack != null) {
|
||||
this.stack.writeToNBT(nbt);
|
||||
}
|
||||
nbttagcompound.setTag("Item", nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncToNBT(final NBTTagCompound nbt) {
|
||||
this.writeToNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncFromNBT(final NBTTagCompound nbt) {
|
||||
this.readFromNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestruction() {
|
||||
super.onDestruction();
|
||||
if (this.stack != null) {
|
||||
final float f = this.getMachine().getWorld().rand.nextFloat() * 0.8f + 0.1f;
|
||||
final float f2 = this.getMachine().getWorld().rand.nextFloat() * 0.8f + 0.1f;
|
||||
final float f3 = this.getMachine().getWorld().rand.nextFloat() * 0.8f + 0.1f;
|
||||
if (this.stack.stackSize == 0) {
|
||||
this.stack.stackSize = 1;
|
||||
}
|
||||
final EntityItem entityitem = new EntityItem(this.getMachine().getWorld(), this.getMachine().getTileEntity().xCoord + f, this.getMachine().getTileEntity().yCoord + f2, this.getMachine().getTileEntity().zCoord + f3, this.stack.copy());
|
||||
final float accel = 0.05f;
|
||||
entityitem.motionX = (float) this.getMachine().getWorld().rand.nextGaussian() * accel;
|
||||
entityitem.motionY = (float) this.getMachine().getWorld().rand.nextGaussian() * accel + 0.2f;
|
||||
entityitem.motionZ = (float) this.getMachine().getWorld().rand.nextGaussian() * accel;
|
||||
this.getMachine().getWorld().spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRightClick(final World world, final EntityPlayer player, final int x, final int y, final int z) {
|
||||
if (BinnieCore.proxy.isSimulating(world) && player.getHeldItem() != null) {
|
||||
if (this.stack != null && player.getHeldItem().getItem() instanceof IToolWrench) {
|
||||
final float f = 0.7f;
|
||||
final double d0 = world.rand.nextFloat() * f + (1.0f - f) * 0.5;
|
||||
final double d2 = world.rand.nextFloat() * f + (1.0f - f) * 0.5;
|
||||
final double d3 = world.rand.nextFloat() * f + (1.0f - f) * 0.5;
|
||||
final EntityItem entityitem = new EntityItem(world, x + d0, y + d2, z + d3, this.stack);
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
this.stack = null;
|
||||
((IToolWrench) player.getHeldItem().getItem()).wrenchUsed(player, x, y, z);
|
||||
this.getUtil().refreshBlock();
|
||||
return;
|
||||
}
|
||||
final List<Item> validSelections = new ArrayList<Item>();
|
||||
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 (this.stack == null && validSelections.contains(player.getHeldItem().getItem())) {
|
||||
this.stack = player.getHeldItem().copy();
|
||||
final ItemStack heldItem = player.getHeldItem();
|
||||
--heldItem.stackSize;
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (this.stack != null && player.getHeldItem().getItem() instanceof IToolWrench) {
|
||||
this.stack.getItem().onItemRightClick(this.stack, world, player);
|
||||
}
|
||||
}
|
||||
if (this.stack != null) {
|
||||
this.stack.getItem().onItemRightClick(this.stack, world, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import binnie.core.machines.component.IRender;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import binnie.core.BinnieCore;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import binnie.core.resource.BinnieResource;
|
||||
import binnie.core.machines.Machine;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class MachineRendererGenetics
|
||||
{
|
||||
public static MachineRendererGenetics instance;
|
||||
public final RenderItem customRenderItem;
|
||||
private ModelMachine model;
|
||||
|
||||
public MachineRendererGenetics() {
|
||||
this.model = new ModelMachine();
|
||||
(this.customRenderItem = new RenderItem() {
|
||||
@Override
|
||||
public boolean shouldBob() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSpreadItems() {
|
||||
return false;
|
||||
}
|
||||
}).setRenderManager(RenderManager.instance);
|
||||
}
|
||||
|
||||
public void renderMachine(final Machine machine, final int colour, final BinnieResource texture, final double x, final double y, final double z, final float var8) {
|
||||
GL11.glPushMatrix();
|
||||
int i1 = 0;
|
||||
final int ix = machine.getTileEntity().xCoord;
|
||||
final int iy = machine.getTileEntity().yCoord;
|
||||
final int iz = machine.getTileEntity().zCoord;
|
||||
if (machine.getTileEntity() != null) {
|
||||
i1 = ix * iy * iz + ix * iy - ix * iz + iy * iz - ix + iy - iz;
|
||||
}
|
||||
final 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);
|
||||
GL11.glPushMatrix();
|
||||
this.model.render((float) x, (float) y, (float) z, 0.0625f, 0.0625f, 0.0625f);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPushMatrix();
|
||||
BinnieCore.proxy.getMinecraftInstance();
|
||||
if (Minecraft.isFancyGraphicsEnabled()) {
|
||||
for (final IRender.Render render : machine.getInterfaces(IRender.Render.class)) {
|
||||
render.renderInWorld(this.customRenderItem, x, y, z);
|
||||
}
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
static {
|
||||
MachineRendererGenetics.instance = new MachineRendererGenetics();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import binnie.core.BinnieCore;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import binnie.core.resource.BinnieResource;
|
||||
import binnie.core.machines.Machine;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class MachineRendererLab
|
||||
{
|
||||
public static MachineRendererLab instance;
|
||||
private final EntityItem dummyEntityItem;
|
||||
private final EntityItem[] itemSides;
|
||||
private final RenderItem customRenderItem;
|
||||
private long lastTick;
|
||||
private ModelMachine model;
|
||||
|
||||
public MachineRendererLab() {
|
||||
this.dummyEntityItem = new EntityItem((World) null);
|
||||
this.itemSides = new EntityItem[] { new EntityItem((World) null), new EntityItem((World) null), new EntityItem((World) null), new EntityItem((World) null) };
|
||||
this.model = new ModelMachine();
|
||||
(this.customRenderItem = new RenderItem() {
|
||||
@Override
|
||||
public boolean shouldBob() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSpreadItems() {
|
||||
return false;
|
||||
}
|
||||
}).setRenderManager(RenderManager.instance);
|
||||
}
|
||||
|
||||
public void renderMachine(final Machine machine, final int colour, final BinnieResource texture, final double x, final double y, final double z, final float var8) {
|
||||
GL11.glPushMatrix();
|
||||
int i1 = 0;
|
||||
final int ix = machine.getTileEntity().xCoord;
|
||||
final int iy = machine.getTileEntity().yCoord;
|
||||
final int iz = machine.getTileEntity().zCoord;
|
||||
if (machine.getTileEntity() != null) {
|
||||
i1 = ix * iy * iz + ix * iy - ix * iz + iy * iz - ix + iy - iz;
|
||||
}
|
||||
final 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);
|
||||
GL11.glPushMatrix();
|
||||
this.model.render((float) x, (float) y, (float) z, 0.0625f, 0.0625f, 0.0625f);
|
||||
GL11.glPopMatrix();
|
||||
final World world = machine.getWorld();
|
||||
final LaboratoryMachine.ComponentGUIHolder holder = Machine.getInterface(LaboratoryMachine.ComponentGUIHolder.class, machine);
|
||||
Label_0591: {
|
||||
if (world != null && holder != null && holder.getStack() != null) {
|
||||
BinnieCore.proxy.getMinecraftInstance();
|
||||
if (Minecraft.isFancyGraphicsEnabled()) {
|
||||
final ItemStack stack = holder.getStack();
|
||||
this.dummyEntityItem.worldObj = world;
|
||||
this.dummyEntityItem.setEntityItemStack(stack);
|
||||
if (world.getTotalWorldTime() != this.lastTick) {
|
||||
this.lastTick = world.getTotalWorldTime();
|
||||
this.dummyEntityItem.onUpdate();
|
||||
}
|
||||
this.dummyEntityItem.age = 0;
|
||||
this.dummyEntityItem.hoverStart = 0.0f;
|
||||
GL11.glPushMatrix();
|
||||
final EntityPlayer player = BinnieCore.proxy.getPlayer();
|
||||
final double dx = ix + 0.5 - player.lastTickPosX;
|
||||
final double dz = iz + 0.5 - player.lastTickPosZ;
|
||||
final double t = Math.atan2(dz, dx) * 180.0 / 3.1415;
|
||||
GL11.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
|
||||
GL11.glTranslatef(0.0f, 0.0f, -0.55f);
|
||||
GL11.glRotatef(90.0f + (float) (-t), 0.0f, 0.0f, 1.0f);
|
||||
GL11.glTranslatef(0.0f, -0.125f, 0.0f);
|
||||
GL11.glScalef(1.2f, 1.2f, 1.2f);
|
||||
GL11.glRotatef(45.0f, 1.0f, 0.0f, 0.0f);
|
||||
GL11.glTranslatef(0.0f, 0.1f, 0.1f);
|
||||
this.customRenderItem.doRender(this.dummyEntityItem, 0.0, 0.0, 0.0, 0.0f, 0.0f);
|
||||
GL11.glPopMatrix();
|
||||
int rot = 0;
|
||||
for (final EntityItem item : this.itemSides) {
|
||||
GL11.glPushMatrix();
|
||||
item.worldObj = world;
|
||||
item.setEntityItemStack(stack);
|
||||
item.age = 0;
|
||||
item.hoverStart = 0.0f;
|
||||
GL11.glRotatef(rot, 0.0f, 1.0f, 0.0f);
|
||||
GL11.glRotatef(180.0f, 1.0f, 0.0f, 0.0f);
|
||||
GL11.glTranslated(0.0, -1.13, 0.4);
|
||||
GL11.glScalef(0.8f, 0.8f, 0.8f);
|
||||
this.customRenderItem.doRender(item, 0.0, 0.0, 0.0, 0.0f, 0.0f);
|
||||
rot += 90;
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
break Label_0591;
|
||||
}
|
||||
}
|
||||
this.dummyEntityItem.setEntityItemStack((ItemStack) null);
|
||||
for (final EntityItem item2 : this.itemSides) {
|
||||
item2.setEntityItemStack((ItemStack) null);
|
||||
}
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
static {
|
||||
MachineRendererLab.instance = new MachineRendererLab();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
|
||||
public class ModelMachine extends ModelBase
|
||||
{
|
||||
ModelRenderer Base;
|
||||
ModelRenderer Body;
|
||||
ModelRenderer Arm1;
|
||||
ModelRenderer Arm2;
|
||||
ModelRenderer Arm3;
|
||||
ModelRenderer Arm4;
|
||||
ModelRenderer Top;
|
||||
|
||||
public ModelMachine() {
|
||||
this.textureWidth = 64;
|
||||
this.textureHeight = 64;
|
||||
(this.Base = new ModelRenderer(this, 0, 18)).addBox(0.0f, 0.0f, 0.0f, 16, 4, 16);
|
||||
this.Base.setRotationPoint(-8.0f, 20.0f, -8.0f);
|
||||
this.Base.setTextureSize(64, 64);
|
||||
this.Base.mirror = true;
|
||||
this.setRotation(this.Base, 0.0f, 0.0f, 0.0f);
|
||||
(this.Body = new ModelRenderer(this, 0, 26)).addBox(0.0f, 0.0f, 0.0f, 12, 7, 12);
|
||||
this.Body.setRotationPoint(-6.0f, 13.0f, -6.0f);
|
||||
this.Body.setTextureSize(64, 64);
|
||||
this.Body.mirror = true;
|
||||
this.setRotation(this.Body, 0.0f, 0.0f, 0.0f);
|
||||
(this.Arm1 = new ModelRenderer(this, 0, 0)).addBox(0.0f, 0.0f, 0.0f, 3, 6, 3);
|
||||
this.Arm1.setRotationPoint(5.0f, 8.0f, 5.0f);
|
||||
this.Arm1.setTextureSize(64, 64);
|
||||
this.Arm1.mirror = true;
|
||||
this.setRotation(this.Arm1, 0.0f, 0.0f, 0.0f);
|
||||
(this.Arm2 = new ModelRenderer(this, 0, 0)).addBox(0.0f, 0.0f, 0.0f, 3, 6, 3);
|
||||
this.Arm2.setRotationPoint(-5.0f, 8.0f, 5.0f);
|
||||
this.Arm2.setTextureSize(64, 64);
|
||||
this.Arm2.mirror = true;
|
||||
this.setRotation(this.Arm2, 0.0f, -1.57075f, 0.0f);
|
||||
(this.Arm3 = new ModelRenderer(this, 0, 0)).addBox(0.0f, 0.0f, 0.0f, 3, 6, 3);
|
||||
this.Arm3.setRotationPoint(-5.0f, 8.0f, -5.0f);
|
||||
this.Arm3.setTextureSize(64, 64);
|
||||
this.Arm3.mirror = true;
|
||||
this.setRotation(this.Arm3, 0.0f, -3.1415f, 0.0f);
|
||||
(this.Arm4 = new ModelRenderer(this, 0, 0)).addBox(0.0f, 0.0f, 0.0f, 3, 6, 3);
|
||||
this.Arm4.setRotationPoint(5.0f, 8.0f, -5.0f);
|
||||
this.Arm4.setTextureSize(64, 64);
|
||||
this.Arm4.mirror = true;
|
||||
this.setRotation(this.Arm4, 0.0f, -4.7122498f, 0.0f);
|
||||
(this.Top = new ModelRenderer(this, 0, 0)).addBox(0.0f, 0.0f, 0.0f, 14, 4, 14);
|
||||
this.Top.setRotationPoint(-7.0f, 9.0f, -7.0f);
|
||||
this.Top.setTextureSize(64, 64);
|
||||
this.Top.mirror = true;
|
||||
this.setRotation(this.Top, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
public void render(final float f, final float f1, final float f2, final float f3, final float f4, final float f5) {
|
||||
super.render((Entity) null, f, f1, f2, f3, f4, f5);
|
||||
this.setRotationAngles(f, f1, f2, f3, f4, f5);
|
||||
this.Base.render(f5);
|
||||
this.Body.render(f5);
|
||||
this.Arm1.render(f5);
|
||||
this.Arm2.render(f5);
|
||||
this.Arm3.render(f5);
|
||||
this.Arm4.render(f5);
|
||||
this.Top.render(f5);
|
||||
}
|
||||
|
||||
private void setRotation(final ModelRenderer model, final float x, final float y, final float z) {
|
||||
model.rotateAngleX = x;
|
||||
model.rotateAngleY = y;
|
||||
model.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
public void setRotationAngles(final float f, final float f1, final float f2, final float f3, final float f4, final float f5) {
|
||||
super.setRotationAngles(f, f1, f2, f3, f4, f5, (Entity) null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.init.Items;
|
||||
import binnie.core.BinnieCore;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import binnie.core.Mods;
|
||||
import binnie.genetics.CreativeTabGenetics;
|
||||
import binnie.core.machines.MachineGroup;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.core.machines.inventory.ValidatorIcon;
|
||||
import binnie.core.IInitializable;
|
||||
|
||||
public class ModuleMachine implements IInitializable
|
||||
{
|
||||
static ValidatorIcon IconSequencer;
|
||||
static ValidatorIcon IconSerum;
|
||||
static ValidatorIcon IconEnzyme;
|
||||
public static ValidatorIcon IconDye;
|
||||
static ValidatorIcon IconBacteria;
|
||||
static ValidatorIcon IconNugget;
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
(Genetics.packageGenetic = new MachineGroup(Genetics.instance, "machine", "machine", GeneticMachine.values())).setCreativeTab(CreativeTabGenetics.instance);
|
||||
(Genetics.packageLabMachine = new MachineGroup(Genetics.instance, "labMachine", "labMachine", LaboratoryMachine.values())).setCreativeTab(CreativeTabGenetics.instance);
|
||||
(Genetics.packageAdvGenetic = new MachineGroup(Genetics.instance, "advMachine", "advMachine", AdvGeneticMachine.values())).setCreativeTab(CreativeTabGenetics.instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
ModuleMachine.IconSequencer = new ValidatorIcon(Genetics.instance, "validator/sequencer.0", "validator/sequencer.1");
|
||||
ModuleMachine.IconSerum = new ValidatorIcon(Genetics.instance, "validator/serum.0", "validator/serum.1");
|
||||
ModuleMachine.IconEnzyme = new ValidatorIcon(Genetics.instance, "validator/enzyme.0", "validator/enzyme.1");
|
||||
ModuleMachine.IconDye = new ValidatorIcon(Genetics.instance, "validator/dye.0", "validator/dye.1");
|
||||
ModuleMachine.IconNugget = new ValidatorIcon(Genetics.instance, "validator/nugget.0", "validator/nugget.1");
|
||||
ModuleMachine.IconBacteria = new ValidatorIcon(Genetics.instance, "validator/bacteria.0", "validator/bacteria.1");
|
||||
Incubator.addRecipes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
Acclimatiser.setupRecipes();
|
||||
final Object[] standardCircuit = { Mods.Forestry.stack("chipsets", 1, 1) };
|
||||
final Object[] advCircuit = { GeneticsItems.IntegratedCircuit.get(1) };
|
||||
final String ironGear = OreDictionary.getOres("gearIron").isEmpty() ? "gearIron" : "ingotIron";
|
||||
final String goldGear = OreDictionary.getOres("gearGold").isEmpty() ? "gearIron" : "ingotIron";
|
||||
final String diamondGear = OreDictionary.getOres("gearDiamond").isEmpty() ? "gearIron" : "ingotIron";
|
||||
for (final Object circuit : standardCircuit) {
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(LaboratoryMachine.Incubator.get(1), new Object[] { "gFg", "cCc", "aPa", 'C', GeneticsItems.LaboratoryCasing.get(1), 'F', Blocks.furnace, 'c', circuit, 'g', Blocks.glass_pane, 'P', "gearBronze", 'a', ironGear }));
|
||||
Item alyzer = null;
|
||||
if (BinnieCore.isApicultureActive()) {
|
||||
alyzer = Mods.Forestry.item("beealyzer");
|
||||
}
|
||||
else if (BinnieCore.isArboricultureActive()) {
|
||||
alyzer = Mods.Forestry.item("treealyzer");
|
||||
}
|
||||
else if (BinnieCore.isArboricultureActive()) {
|
||||
alyzer = Mods.Forestry.item("flutterlyzer");
|
||||
}
|
||||
if (alyzer != null) {
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(LaboratoryMachine.Analyser.get(1), new Object[] { "gBg", "cCc", "aPa", 'C', GeneticsItems.LaboratoryCasing.get(1), 'B', alyzer, 'c', circuit, 'g', Blocks.glass_pane, 'P', "gearBronze", 'a', GeneticsItems.DNADye.get(1) }));
|
||||
}
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(LaboratoryMachine.Genepool.get(1), new Object[] { "gBg", "cCc", "aPa", 'C', GeneticsItems.LaboratoryCasing.get(1), 'B', "gearBronze", 'c', circuit, 'g', Blocks.glass_pane, 'P', "gearBronze", 'a', Blocks.glass }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(LaboratoryMachine.Acclimatiser.get(1), new Object[] { "gBg", "cCc", "aPa", 'C', GeneticsItems.LaboratoryCasing.get(1), 'B', Items.lava_bucket, 'c', circuit, 'g', Blocks.glass_pane, 'P', "gearBronze", 'a', Items.water_bucket }));
|
||||
}
|
||||
for (final Object circuit : advCircuit) {
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(GeneticMachine.Isolator.get(1), new Object[] { "gBg", "cCc", "aPa", 'C', GeneticsItems.LaboratoryCasing.get(1), 'B', goldGear, 'c', circuit, 'g', Items.gold_nugget, 'P', "gearBronze", 'a', GeneticsItems.Enzyme.get(1) }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(GeneticMachine.Polymeriser.get(1), new Object[] { "gBg", "cCc", "gPg", 'C', GeneticsItems.LaboratoryCasing.get(1), 'B', ironGear, 'c', circuit, 'g', Items.gold_nugget, 'P', "gearBronze" }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(GeneticMachine.Sequencer.get(1), new Object[] { "gBg", "cCc", "aPa", 'C', GeneticsItems.LaboratoryCasing.get(1), 'B', "gearBronze", 'c', circuit, 'g', Items.gold_nugget, 'P', "gearBronze", 'a', GeneticsItems.FluorescentDye.get(1) }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(GeneticMachine.Inoculator.get(1), new Object[] { "gBg", "cCc", "aPa", 'C', GeneticsItems.LaboratoryCasing.get(1), 'B', diamondGear, 'c', circuit, 'g', Items.gold_nugget, 'P', "gearBronze", 'a', Items.emerald }));
|
||||
}
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(AdvGeneticMachine.Splicer.get(1), new Object[] { "gBg", "cCc", "aPa", 'C', GeneticsItems.IntegratedCasing.get(1), 'B', diamondGear, 'c', GeneticsItems.IntegratedCPU.get(1), 'g', Items.gold_nugget, 'P', "gearBronze", 'a', Items.blaze_rod }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(LaboratoryMachine.LabMachine.get(1), new Object[] { "igi", "gCg", "igi", 'C', GeneticsItems.LaboratoryCasing.get(1), 'i', "ingotIron", 'g', Blocks.glass_pane }));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,302 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import binnie.core.BinnieCore;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.Random;
|
||||
import net.minecraft.world.World;
|
||||
import binnie.core.machines.component.IRender;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import binnie.genetics.api.IItemChargable;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.genetics.genetics.Engineering;
|
||||
import binnie.core.machines.power.IProcess;
|
||||
import binnie.core.machines.power.ComponentProcessSetCost;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.core.machines.inventory.ComponentChargedSlots;
|
||||
import binnie.genetics.item.GeneticLiquid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import binnie.core.machines.inventory.ComponentTankContainer;
|
||||
import binnie.core.machines.inventory.ComponentInventoryTransfer;
|
||||
import binnie.core.machines.inventory.Validator;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.init.Items;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.craftgui.minecraft.IMachineInformation;
|
||||
|
||||
public class Polymeriser
|
||||
{
|
||||
public static final int tankBacteria = 0;
|
||||
public static final int tankDNA = 1;
|
||||
public static final int slotSerum = 0;
|
||||
public static final int slotGold = 1;
|
||||
public static final int[] slotSerumReserve;
|
||||
public static final int[] slotSerumFinished;
|
||||
|
||||
static {
|
||||
slotSerumReserve = new int[] { 2, 3, 4, 5 };
|
||||
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(final Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Replicator);
|
||||
final 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 (final InventorySlot slot : inventory.addSlotArray(Polymeriser.slotSerumReserve, "input")) {
|
||||
slot.setValidator(new SlotValidatorUnfilledSerum());
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
for (final InventorySlot slot : inventory.addSlotArray(Polymeriser.slotSerumFinished, "output")) {
|
||||
slot.setReadOnly();
|
||||
}
|
||||
final ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Polymeriser.slotSerumReserve, 0, 1);
|
||||
transfer.addStorage(0, Polymeriser.slotSerumFinished, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(final ItemStack stack) {
|
||||
return !stack.isItemDamaged();
|
||||
}
|
||||
});
|
||||
final ComponentTankContainer tank = new ComponentTankContainer(machine);
|
||||
tank.addTank(0, "input", 1000);
|
||||
tank.getTankSlot(0).setValidator(new Validator<FluidStack>() {
|
||||
@Override
|
||||
public boolean isValid(final 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(final 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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentPolymeriserLogic extends ComponentProcessSetCost implements IProcess
|
||||
{
|
||||
private static float chargePerProcess;
|
||||
private float dnaDrain;
|
||||
private float bacteriaDrain;
|
||||
|
||||
public ComponentPolymeriserLogic(final Machine machine) {
|
||||
super(machine, 96000, 2400);
|
||||
this.dnaDrain = 0.0f;
|
||||
this.bacteriaDrain = 0.0f;
|
||||
}
|
||||
|
||||
private float getCatalyst() {
|
||||
return (this.getUtil().getSlotCharge(1) > 0.0f) ? 0.2f : 1.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessLength() {
|
||||
return (int) (super.getProcessLength() * this.getNumberOfGenes() * this.getCatalyst());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessEnergy() {
|
||||
return (int) (super.getProcessEnergy() * this.getNumberOfGenes() * this.getCatalyst());
|
||||
}
|
||||
|
||||
private float getDNAPerProcess() {
|
||||
return this.getNumberOfGenes() * 50;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTickTask() {
|
||||
super.onTickTask();
|
||||
this.getUtil().useCharge(1, ComponentPolymeriserLogic.chargePerProcess * this.getProgressPerTick() / 100.0f);
|
||||
this.dnaDrain += this.getDNAPerProcess() * this.getProgressPerTick() / 100.0f;
|
||||
this.bacteriaDrain += 0.2f * this.getDNAPerProcess() * this.getProgressPerTick() / 100.0f;
|
||||
if (this.dnaDrain >= 1.0f) {
|
||||
this.getUtil().drainTank(1, 1);
|
||||
--this.dnaDrain;
|
||||
}
|
||||
if (this.bacteriaDrain >= 1.0f) {
|
||||
this.getUtil().drainTank(0, 1);
|
||||
--this.bacteriaDrain;
|
||||
}
|
||||
}
|
||||
|
||||
private int getNumberOfGenes() {
|
||||
final ItemStack serum = this.getUtil().getStack(0);
|
||||
if (serum == null) {
|
||||
return 1;
|
||||
}
|
||||
return Engineering.getGenes(serum).length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
final int n = this.getNumberOfGenes();
|
||||
return "Replicating " + n + " genes" + ((n > 1) ? "s" : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isSlotEmpty(0)) {
|
||||
return new ErrorState.NoItem("No item to replicate", 0);
|
||||
}
|
||||
if (!this.getUtil().getStack(0).isItemDamaged()) {
|
||||
return new ErrorState.InvalidItem("Item filled", 0);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (this.getUtil().getFluid(0) == null) {
|
||||
return new ErrorState.InsufficientLiquid("Insufficient Bacteria", 0);
|
||||
}
|
||||
if (this.getUtil().getFluid(1) == null) {
|
||||
return new ErrorState.InsufficientLiquid("Insufficient DNA", 1);
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
this.getUtil().damageItem(0, -1);
|
||||
}
|
||||
|
||||
static {
|
||||
ComponentPolymeriserLogic.chargePerProcess = 0.4f;
|
||||
}
|
||||
}
|
||||
|
||||
public static class SlotValidatorUnfilledSerum extends SlotValidator
|
||||
{
|
||||
public SlotValidatorUnfilledSerum() {
|
||||
super(ModuleMachine.IconSerum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final 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(final IMachine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onRandomDisplayTick(final World world, final int x, final int y, final int z, final Random rand) {
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(final World world, final int x, final int y, final int z, final Random rand) {
|
||||
final int tick = (int) (world.getTotalWorldTime() % 8L);
|
||||
if ((tick == 0 || tick == 3) && this.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 = this.posX;
|
||||
double axisZ = this.posZ;
|
||||
double angle = 0.7 + (int) (this.worldObj.getTotalWorldTime() % 2L) * 3.1415;
|
||||
|
||||
{
|
||||
this.axisX = 0.0;
|
||||
this.axisZ = 0.0;
|
||||
this.angle = 0.0;
|
||||
this.motionX = 0.0;
|
||||
this.motionZ = 0.0;
|
||||
this.motionY = -0.006;
|
||||
this.particleMaxAge = 140;
|
||||
this.particleGravity = 0.0f;
|
||||
this.noClip = true;
|
||||
this.setRBGColorF(0.8f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
this.angle += 0.1;
|
||||
this.motionY = -0.006;
|
||||
double dist = 0.2;
|
||||
if (this.particleAge > 60) {
|
||||
if (this.particleAge > 120) {
|
||||
dist = 0.1;
|
||||
}
|
||||
else {
|
||||
dist = 0.2 - 0.1 * ((this.particleAge - 60.0f) / 60.0f);
|
||||
}
|
||||
}
|
||||
this.setPosition(this.axisX + dist * Math.sin(this.angle), this.posY, this.axisZ + dist * Math.cos(this.angle));
|
||||
if (this.particleAge <= 40) {
|
||||
this.setAlphaF(this.particleAge / 40.0f);
|
||||
}
|
||||
if (this.particleAge > 80) {
|
||||
this.setRBGColorF(this.particleRed + (0.0f - this.particleRed) / 10.0f, this.particleGreen + (1.0f - this.particleGreen) / 10.0f, this.particleBlue + (1.0f - this.particleBlue) / 10.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,296 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import binnie.core.BinnieCore;
|
||||
import java.util.Random;
|
||||
import net.minecraft.world.World;
|
||||
import binnie.core.machines.component.IRender;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import binnie.genetics.genetics.GeneTracker;
|
||||
import binnie.genetics.genetics.SequencerItem;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.core.machines.power.IProcess;
|
||||
import binnie.core.machines.power.ComponentProcess;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.core.machines.inventory.ComponentChargedSlots;
|
||||
import binnie.core.machines.inventory.ComponentInventoryTransfer;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.Binnie;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.core.resource.BinnieIcon;
|
||||
|
||||
public class Sequencer
|
||||
{
|
||||
public static final int slotDye = 0;
|
||||
public static final int[] slotReserve;
|
||||
public static final int slotTarget = 5;
|
||||
public static final int slotDone = 6;
|
||||
public static BinnieIcon fxSeqA;
|
||||
public static BinnieIcon fxSeqG;
|
||||
public static BinnieIcon fxSeqT;
|
||||
public static BinnieIcon fxSeqC;
|
||||
|
||||
static {
|
||||
slotReserve = new int[] { 1, 2, 3, 4 };
|
||||
}
|
||||
|
||||
public static class PackageSequencer extends GeneticMachine.PackageGeneticBase implements IMachineInformation
|
||||
{
|
||||
public PackageSequencer() {
|
||||
super("sequencer", GeneticsTexture.Sequencer, 12058418, true);
|
||||
Sequencer.fxSeqA = Binnie.Resource.getBlockIcon(Genetics.instance, "fx/sequencer.a");
|
||||
Sequencer.fxSeqG = Binnie.Resource.getBlockIcon(Genetics.instance, "fx/sequencer.g");
|
||||
Sequencer.fxSeqT = Binnie.Resource.getBlockIcon(Genetics.instance, "fx/sequencer.t");
|
||||
Sequencer.fxSeqC = Binnie.Resource.getBlockIcon(Genetics.instance, "fx/sequencer.c");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Sequencer);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(0, "dye");
|
||||
inventory.getSlot(0).setValidator(new SlotValidator.Item(GeneticsItems.FluorescentDye.get(1), ModuleMachine.IconDye));
|
||||
inventory.getSlot(0).forbidExtraction();
|
||||
inventory.addSlotArray(Sequencer.slotReserve, "input");
|
||||
for (final InventorySlot slot : inventory.getSlots(Sequencer.slotReserve)) {
|
||||
slot.setValidator(new SlotValidatorUnsequenced());
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
inventory.addSlot(5, "process");
|
||||
inventory.getSlot(5).setValidator(new SlotValidatorUnsequenced());
|
||||
inventory.getSlot(5).setReadOnly();
|
||||
inventory.getSlot(5).forbidInteraction();
|
||||
inventory.addSlot(6, "output");
|
||||
inventory.getSlot(6).setReadOnly();
|
||||
final ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Sequencer.slotReserve, 5, 1);
|
||||
new ComponentChargedSlots(machine).addCharge(0);
|
||||
new ComponentPowerReceptor(machine, 10000);
|
||||
new ComponentSequencerLogic(machine);
|
||||
new ComponentSequencerFX(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentSequencerLogic extends ComponentProcess implements IProcess
|
||||
{
|
||||
public ComponentSequencerLogic(final Machine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
public float getSequenceStrength() {
|
||||
final ItemStack stack = this.getUtil().getStack(5);
|
||||
if (stack == null) {
|
||||
return 1.0f;
|
||||
}
|
||||
final float mult = 1.0f - stack.getItemDamage() % 6 / 5.0f;
|
||||
return 1.0f - mult * mult * 0.75f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessLength() {
|
||||
return (int) (19200.0f * this.getSequenceStrength());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessEnergy() {
|
||||
return this.getProcessLength() * 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isSlotEmpty(5)) {
|
||||
return new ErrorState.NoItem("No DNA sequence", 5);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (this.getMachine().getOwner() == null) {
|
||||
return new ErrorState("No Owner", "Replace this block to claim this machine");
|
||||
}
|
||||
if (this.getUtil().getSlotCharge(0) == 0.0f) {
|
||||
return new ErrorState.NoItem("Insufficient Dye", 0);
|
||||
}
|
||||
if (this.getUtil().getStack(6) != null && this.getUtil().getStack(6).stackSize >= 64) {
|
||||
return new ErrorState.NoSpace("No space for empty sequences", new int[] { 6 });
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStartTask() {
|
||||
super.onStartTask();
|
||||
final ItemStack item = this.getUtil().getStack(5);
|
||||
final SequencerItem seqItem = new SequencerItem(item);
|
||||
final int seq = seqItem.sequenced;
|
||||
if (seq != 0) {
|
||||
this.setProgress(seq);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
this.updateSequence();
|
||||
final SequencerItem seqItem = new SequencerItem(this.getUtil().getStack(5));
|
||||
GeneTracker.getTracker(this.getMachine().getWorld(), this.getMachine().getOwner()).registerGene(seqItem.getGene());
|
||||
this.getUtil().decreaseStack(5, 1);
|
||||
if (this.getUtil().getStack(6) == null) {
|
||||
this.getUtil().setStack(6, GeneticsItems.EmptySequencer.get(1));
|
||||
}
|
||||
else {
|
||||
this.getUtil().decreaseStack(6, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
this.updateSequence();
|
||||
this.getUtil().useCharge(0, 0.4f * this.getProgressPerTick() / 100.0f);
|
||||
}
|
||||
|
||||
private void updateSequence() {
|
||||
final int prog = (int) this.getProgress();
|
||||
final ItemStack item = this.getUtil().getStack(5);
|
||||
final SequencerItem seqItem = new SequencerItem(item);
|
||||
final int seq = seqItem.sequenced;
|
||||
if (prog != seq) {
|
||||
seqItem.sequenced = prog;
|
||||
seqItem.writeToItem(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentSequencerFX extends MachineComponent implements IRender.RandomDisplayTick, IRender.DisplayTick
|
||||
{
|
||||
public ComponentSequencerFX(final IMachine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onRandomDisplayTick(final World world, final int x, final int y, final int z, final Random rand) {
|
||||
if (!this.getUtil().getProcess().isInProgress()) {
|
||||
return;
|
||||
}
|
||||
BinnieCore.proxy.getMinecraftInstance().effectRenderer.addEffect(new EntityFX(world, x + 0.5, y + 1.2 + rand.nextDouble() * 0.2, z + 0.5, 0.0, 0.0, 0.0) {
|
||||
double axisX = this.posX;
|
||||
double axisZ = this.posZ;
|
||||
double angle = this.rand.nextDouble() * 2.0 * 3.1415;
|
||||
|
||||
{
|
||||
this.axisX = 0.0;
|
||||
this.axisZ = 0.0;
|
||||
this.angle = 0.0;
|
||||
this.motionX = 0.0;
|
||||
this.motionZ = 0.0;
|
||||
this.motionY = 0.0;
|
||||
this.particleMaxAge = 200;
|
||||
this.particleGravity = 0.0f;
|
||||
this.noClip = true;
|
||||
this.setRBGColorF(0.6f + this.rand.nextFloat() * 0.2f, 1.0f, 0.8f * this.rand.nextFloat() * 0.2f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
this.angle += 0.03;
|
||||
this.setPosition(this.axisX + 0.4 * Math.sin(this.angle), this.posY, this.axisZ + 0.4 * Math.cos(this.angle));
|
||||
this.motionY = 0.0;
|
||||
this.setAlphaF((float) Math.sin(3.14 * this.particleAge / this.particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(final World world, final int x, final int y, final int z, final Random rand) {
|
||||
final int ticks = (int) (world.getTotalWorldTime() % 16L);
|
||||
if (ticks == 0 && this.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 = 0.0;
|
||||
double axisZ = 0.0;
|
||||
double angle = 0.0;
|
||||
|
||||
{
|
||||
this.motionX = 0.0;
|
||||
this.motionZ = 0.0;
|
||||
this.motionY = 0.012;
|
||||
this.particleMaxAge = 50;
|
||||
this.particleGravity = 0.0f;
|
||||
this.noClip = true;
|
||||
this.particleScale = 2.0f;
|
||||
this.setParticleIcon((new BinnieIcon[] { Sequencer.fxSeqA, Sequencer.fxSeqG, Sequencer.fxSeqC, Sequencer.fxSeqT })[this.rand.nextInt(4)].getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
this.motionY = 0.012;
|
||||
if (this.particleAge > 40) {
|
||||
this.setAlphaF((50 - this.particleAge) / 10.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class SlotValidatorUnsequenced extends SlotValidator
|
||||
{
|
||||
public SlotValidatorUnsequenced() {
|
||||
super(ModuleMachine.IconSequencer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final ItemStack itemStack) {
|
||||
if (itemStack.getItem() == Genetics.itemSequencer) {
|
||||
final SequencerItem seq = new SequencerItem(itemStack);
|
||||
return seq.sequenced < 100;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Unsequenced DNA";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.core.machines.inventory.Validator;
|
||||
|
||||
public class SlotValidatorInoculatorCatalyst extends Validator<ItemStack>
|
||||
{
|
||||
@Override
|
||||
public boolean isValid(final ItemStack itemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Inoculation Catalyst";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,439 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.machine;
|
||||
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import binnie.Binnie;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import binnie.core.BinnieCore;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.Random;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import binnie.core.machines.network.INetwork;
|
||||
import binnie.core.machines.component.IRender;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import binnie.core.machines.power.IProcess;
|
||||
import binnie.core.machines.power.ComponentProcessSetCost;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.genetics.genetics.Engineering;
|
||||
import binnie.core.machines.inventory.ComponentInventoryTransfer;
|
||||
import binnie.genetics.api.IItemSerum;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.machines.IMachine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.genetics.core.GeneticsGUI;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.craftgui.minecraft.IMachineInformation;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.apiculture.IBeeRoot;
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.genetics.api.IGene;
|
||||
|
||||
public class Splicer
|
||||
{
|
||||
public static final int slotSerumVial = 0;
|
||||
public static final int[] slotSerumReserve;
|
||||
public static final int[] slotSerumExpended;
|
||||
public static final int[] slotReserve;
|
||||
public static final int slotTarget = 9;
|
||||
public static final int[] slotFinished;
|
||||
|
||||
public static void setGene(final IGene gene, final ItemStack target, final int chromoN) {
|
||||
int chromosomeID;
|
||||
final int chromosome = chromosomeID = gene.getChromosome().ordinal();
|
||||
if (chromosomeID >= EnumBeeChromosome.HUMIDITY.ordinal() && gene.getSpeciesRoot() instanceof IBeeRoot) {
|
||||
--chromosomeID;
|
||||
}
|
||||
final Class<? extends IAllele> cls = gene.getChromosome().getAlleleClass();
|
||||
if (!cls.isInstance(gene.getAllele())) {
|
||||
return;
|
||||
}
|
||||
final NBTTagCompound beeNBT = target.getTagCompound();
|
||||
final NBTTagCompound genomeNBT = beeNBT.getCompoundTag("Genome");
|
||||
final NBTTagList chromosomes = genomeNBT.getTagList("Chromosomes", 10);
|
||||
final NBTTagCompound chromosomeNBT = chromosomes.getCompoundTagAt(chromosomeID);
|
||||
chromosomeNBT.setString("UID" + chromoN, gene.getAllele().getUID());
|
||||
target.setTagCompound(beeNBT);
|
||||
}
|
||||
|
||||
static {
|
||||
slotSerumReserve = new int[] { 1, 2 };
|
||||
slotSerumExpended = new int[] { 3, 4 };
|
||||
slotReserve = new int[] { 5, 6, 7, 8, 9 };
|
||||
slotFinished = new int[] { 10, 11, 12, 13 };
|
||||
}
|
||||
|
||||
public static class PackageSplicer extends AdvGeneticMachine.PackageAdvGeneticBase implements IMachineInformation
|
||||
{
|
||||
public PackageSplicer() {
|
||||
super("splicer", GeneticsTexture.Splicer, 14819893, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ComponentGeneticGUI(machine, GeneticsGUI.Splicer);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(0, "serum.active");
|
||||
inventory.getSlot(0).forbidInteraction();
|
||||
inventory.getSlot(0).setReadOnly();
|
||||
final SlotValidator serumValid = new SlotValidator(ModuleMachine.IconSerum) {
|
||||
@Override
|
||||
public boolean isValid(final ItemStack itemStack) {
|
||||
return itemStack.getItem() instanceof IItemSerum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Serum Vials & Arrays";
|
||||
}
|
||||
};
|
||||
inventory.getSlot(0).setValidator(serumValid);
|
||||
inventory.addSlotArray(Splicer.slotSerumReserve, "serum.input");
|
||||
for (final InventorySlot slot : inventory.getSlots(Splicer.slotSerumReserve)) {
|
||||
slot.setValidator(serumValid);
|
||||
slot.forbidExtraction();
|
||||
}
|
||||
inventory.addSlotArray(Splicer.slotSerumExpended, "serum.output");
|
||||
for (final InventorySlot slot : inventory.getSlots(Splicer.slotSerumExpended)) {
|
||||
slot.setValidator(serumValid);
|
||||
slot.setReadOnly();
|
||||
}
|
||||
inventory.addSlotArray(Splicer.slotReserve, "input");
|
||||
for (final InventorySlot slot : inventory.getSlots(Splicer.slotReserve)) {
|
||||
slot.forbidExtraction();
|
||||
slot.setValidator(new ValidatorIndividualInoculate());
|
||||
}
|
||||
inventory.addSlot(9, "process");
|
||||
inventory.getSlot(9).setValidator(new ValidatorIndividualInoculate());
|
||||
inventory.getSlot(9).setReadOnly();
|
||||
inventory.getSlot(9).forbidInteraction();
|
||||
inventory.addSlotArray(Splicer.slotFinished, "output");
|
||||
for (final InventorySlot slot : inventory.getSlots(Splicer.slotFinished)) {
|
||||
slot.setReadOnly();
|
||||
slot.forbidInsertion();
|
||||
slot.setValidator(new ValidatorIndividualInoculate());
|
||||
}
|
||||
final ComponentInventoryTransfer transfer = new ComponentInventoryTransfer(machine);
|
||||
transfer.addRestock(Splicer.slotReserve, 9, 1);
|
||||
transfer.addRestock(Splicer.slotSerumReserve, 0);
|
||||
transfer.addStorage(0, Splicer.slotSerumExpended, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(final ItemStack stack) {
|
||||
return Engineering.getCharges(stack) == 0;
|
||||
}
|
||||
});
|
||||
transfer.addStorage(9, Splicer.slotFinished, new ComponentInventoryTransfer.Condition() {
|
||||
@Override
|
||||
public boolean fufilled(final ItemStack stack) {
|
||||
return stack != null && this.transfer.getMachine().getMachineUtil().getStack(0) != null && this.transfer.getMachine().getInterface(ComponentSplicerLogic.class).isValidSerum() != null;
|
||||
}
|
||||
});
|
||||
new ComponentPowerReceptor(machine, 20000);
|
||||
new ComponentSplicerLogic(machine);
|
||||
new ComponentSplicerFX(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentSplicerLogic extends ComponentProcessSetCost implements IProcess
|
||||
{
|
||||
int nOfGenes;
|
||||
|
||||
@Override
|
||||
public int getProcessLength() {
|
||||
float n = this.getNumberOfGenes();
|
||||
if (n > 1.0f) {
|
||||
n = 1.0f + (n - 1.0f) * 0.5f;
|
||||
}
|
||||
// Fix for / by 0
|
||||
int temp = (int) (super.getProcessLength() * n);
|
||||
return temp != 0 ? temp : 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProcessEnergy() {
|
||||
float n = this.getNumberOfGenes();
|
||||
if (n > 1.0f) {
|
||||
n = 1.0f + (n - 1.0f) * 0.5f;
|
||||
}
|
||||
return (int) (super.getProcessEnergy() * n);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryUpdate() {
|
||||
super.onInventoryUpdate();
|
||||
this.nOfGenes = this.getGenesToUse();
|
||||
}
|
||||
|
||||
protected int getGenesToUse() {
|
||||
final ItemStack serum = this.getUtil().getStack(0);
|
||||
final ItemStack target = this.getUtil().getStack(9);
|
||||
if (serum == null || target == null) {
|
||||
return 1;
|
||||
}
|
||||
final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(target);
|
||||
final IGene[] genes = ((IItemSerum) serum.getItem()).getGenes(serum);
|
||||
if (ind.getGenome().getSpeciesRoot() != ((IItemSerum) serum.getItem()).getSpeciesRoot(serum)) {
|
||||
return 1;
|
||||
}
|
||||
int i = 0;
|
||||
for (final IGene gene : genes) {
|
||||
if (ind.getGenome().getActiveAllele(gene.getChromosome()) != gene.getAllele() || ind.getGenome().getInactiveAllele(gene.getChromosome()) != gene.getAllele()) {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
return (i < 1) ? 1 : i;
|
||||
}
|
||||
|
||||
private int getFullNumberOfGenes() {
|
||||
final ItemStack serum = this.getUtil().getStack(0);
|
||||
if (serum == null) {
|
||||
return 1;
|
||||
}
|
||||
return Engineering.getGenes(serum).length;
|
||||
}
|
||||
|
||||
private int getNumberOfGenes() {
|
||||
return this.nOfGenes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
final int n = this.getNumberOfGenes();
|
||||
final int f = this.getFullNumberOfGenes();
|
||||
return "Splicing in " + n + ((f > 1) ? ("/" + f) : "") + " gene" + ((n > 1) ? "s" : "");
|
||||
}
|
||||
|
||||
public ComponentSplicerLogic(final Machine machine) {
|
||||
super(machine, 12000000, 1200);
|
||||
this.nOfGenes = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isSlotEmpty(9)) {
|
||||
return new ErrorState.NoItem("No Individual to Splice", 9);
|
||||
}
|
||||
if (this.getUtil().isSlotEmpty(0)) {
|
||||
return new ErrorState.NoItem("No Serum", 0);
|
||||
}
|
||||
final ErrorState state = this.isValidSerum();
|
||||
if (state != null) {
|
||||
return state;
|
||||
}
|
||||
if (this.getUtil().getStack(0) != null && Engineering.getCharges(this.getUtil().getStack(0)) == 0) {
|
||||
return new ErrorState("Empty Serum", "Serum is empty");
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
public ErrorState isValidSerum() {
|
||||
final ItemStack serum = this.getUtil().getStack(0);
|
||||
final ItemStack target = this.getUtil().getStack(9);
|
||||
final IGene[] genes = Engineering.getGenes(serum);
|
||||
if (genes.length == 0) {
|
||||
return new ErrorState("Invalid Serum", "Serum does not hold any genes");
|
||||
}
|
||||
if (!genes[0].getSpeciesRoot().isMember(target)) {
|
||||
return new ErrorState("Invalid Serum", "Mismatch of Serum Type and Target");
|
||||
}
|
||||
final IIndividual individual = genes[0].getSpeciesRoot().getMember(target);
|
||||
boolean hasAll = true;
|
||||
for (final IGene gene : genes) {
|
||||
if (hasAll) {
|
||||
final IAllele a = individual.getGenome().getActiveAllele(gene.getChromosome());
|
||||
final IAllele b = individual.getGenome().getInactiveAllele(gene.getChromosome());
|
||||
hasAll = (hasAll && a.getUID().equals(gene.getAllele().getUID()) && b.getUID().equals(gene.getAllele().getUID()));
|
||||
}
|
||||
}
|
||||
if (hasAll) {
|
||||
return new ErrorState("Defunct Serum", "Individual already possesses this allele");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
super.onFinishTask();
|
||||
final ItemStack serum = this.getUtil().getStack(0);
|
||||
final ItemStack target = this.getUtil().getStack(9);
|
||||
final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(target);
|
||||
if (!ind.isAnalyzed()) {
|
||||
ind.analyze();
|
||||
final NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
ind.writeToNBT(nbttagcompound);
|
||||
target.setTagCompound(nbttagcompound);
|
||||
}
|
||||
final IGene[] arr$;
|
||||
final IGene[] genes = arr$ = ((IItemSerum) serum.getItem()).getGenes(serum);
|
||||
for (final IGene gene : arr$) {
|
||||
Splicer.setGene(gene, target, 0);
|
||||
Splicer.setGene(gene, target, 1);
|
||||
}
|
||||
this.getUtil().damageItem(0, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentSplicerFX extends MachineComponent implements IRender.RandomDisplayTick, IRender.DisplayTick, IRender.Render, INetwork.TilePacketSync
|
||||
{
|
||||
private final EntityItem dummyEntityItem;
|
||||
|
||||
public ComponentSplicerFX(final IMachine machine) {
|
||||
super(machine);
|
||||
this.dummyEntityItem = new EntityItem((World) null);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onRandomDisplayTick(final World world, final int x, final int y, final int z, final Random rand) {
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onDisplayTick(final World world, final int x, final int y, final int z, final Random rand) {
|
||||
final int tick = (int) (world.getTotalWorldTime() % 3L);
|
||||
if (tick == 0 && this.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 = this.posX;
|
||||
double axisZ = this.posZ;
|
||||
double angle = (int) (this.worldObj.getTotalWorldTime() % 4L) * 0.5 * 3.1415;
|
||||
|
||||
{
|
||||
this.axisX = 0.0;
|
||||
this.axisZ = 0.0;
|
||||
this.angle = 0.0;
|
||||
this.motionX = 0.0;
|
||||
this.motionZ = 0.0;
|
||||
this.motionY = (this.rand.nextDouble() - 0.5) * 0.02;
|
||||
this.particleMaxAge = 240;
|
||||
this.particleGravity = 0.0f;
|
||||
this.noClip = true;
|
||||
this.setRBGColorF(0.3f + this.rand.nextFloat() * 0.5f, 0.3f + this.rand.nextFloat() * 0.5f, 0.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
final double speed = 0.04;
|
||||
this.angle -= speed;
|
||||
final double dist = 0.25 + 0.2 * Math.sin(this.particleAge / 50.0f);
|
||||
this.setPosition(this.axisX + dist * Math.sin(this.angle), this.posY, this.axisZ + dist * Math.cos(this.angle));
|
||||
this.setAlphaF((float) Math.cos(1.57 * this.particleAge / this.particleMaxAge));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer() {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void renderInWorld(final RenderItem customRenderItem, final double x, final double y, final double z) {
|
||||
if (!this.getUtil().getProcess().isInProgress()) {
|
||||
return;
|
||||
}
|
||||
final ItemStack stack = this.getUtil().getStack(9);
|
||||
this.dummyEntityItem.worldObj = this.getMachine().getWorld();
|
||||
this.dummyEntityItem.setEntityItemStack(stack);
|
||||
final EntityItem dummyEntityItem = this.dummyEntityItem;
|
||||
++dummyEntityItem.age;
|
||||
this.dummyEntityItem.hoverStart = 0.0f;
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
final EntityPlayer player = BinnieCore.proxy.getPlayer();
|
||||
final double dx = x + 0.5 - player.lastTickPosX;
|
||||
final double dz = z + 0.5 - player.lastTickPosZ;
|
||||
final double t = Math.atan2(dz, dx) * 180.0 / 3.1415;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(180.0f, 0.0f, 0.0f, 1.0f);
|
||||
GL11.glTranslatef(0.0f, -0.25f, 0.0f);
|
||||
customRenderItem.doRender(this.dummyEntityItem, 0.0, 0.0, 0.0, 0.0f, 0.0f);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncToNBT(final NBTTagCompound nbt) {
|
||||
final NBTTagCompound item = new NBTTagCompound();
|
||||
final ItemStack stack = this.getUtil().getStack(9);
|
||||
if (stack != null) {
|
||||
stack.writeToNBT(item);
|
||||
nbt.setTag("item", item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncFromNBT(final NBTTagCompound nbt) {
|
||||
if (nbt.hasKey("item")) {
|
||||
this.getUtil().setStack(9, ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("item")));
|
||||
}
|
||||
else {
|
||||
this.getUtil().setStack(9, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryUpdate() {
|
||||
if (!this.getUtil().isServer()) {
|
||||
return;
|
||||
}
|
||||
this.getUtil().refreshBlock();
|
||||
}
|
||||
}
|
||||
|
||||
public static class ValidatorIndividualInoculate extends SlotValidator
|
||||
{
|
||||
public ValidatorIndividualInoculate() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final ItemStack object) {
|
||||
final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(object);
|
||||
return root != null && Binnie.Genetics.getSystem(root).isDNAManipulable(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Splicable Individual";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.network;
|
||||
|
||||
public enum PacketID
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.proxy;
|
||||
|
||||
import binnie.core.proxy.IProxyCore;
|
||||
|
||||
public interface IGeneticsProxy extends IProxyCore
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.proxy;
|
||||
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.core.proxy.BinnieModProxy;
|
||||
|
||||
public class Proxy extends BinnieModProxy implements IGeneticsProxy
|
||||
{
|
||||
public Proxy() {
|
||||
super(Genetics.instance);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.proxy;
|
||||
|
||||
public class ProxyClient extends Proxy implements IGeneticsProxy
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.genetics.proxy;
|
||||
|
||||
public class ProxyServer extends Proxy implements IGeneticsProxy
|
||||
{
|
||||
}
|
||||
Reference in new issue
Block a user