mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-20 20:22:35 +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,143 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import binnie.core.network.packet.MessageBinnie;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import binnie.core.mod.parser.FieldParser;
|
||||
import binnie.Binnie;
|
||||
import binnie.core.network.BinniePacketHandler;
|
||||
import binnie.core.proxy.IProxyCore;
|
||||
import binnie.core.gui.IBinnieGUID;
|
||||
import binnie.core.network.IPacketID;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.LinkedHashSet;
|
||||
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import binnie.core.network.IPacketProvider;
|
||||
|
||||
public abstract class AbstractMod implements IPacketProvider, IInitializable
|
||||
{
|
||||
private SimpleNetworkWrapper wrapper;
|
||||
private LinkedHashSet<Field> fields;
|
||||
protected List<IInitializable> modules;
|
||||
|
||||
public AbstractMod() {
|
||||
this.fields = new LinkedHashSet<Field>();
|
||||
this.modules = new ArrayList<IInitializable>();
|
||||
BinnieCore.registerMod(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
public abstract boolean isActive();
|
||||
|
||||
@Override
|
||||
public abstract String getChannel();
|
||||
|
||||
@Override
|
||||
public IPacketID[] getPacketIDs() {
|
||||
return new IPacketID[0];
|
||||
}
|
||||
|
||||
public IBinnieGUID[] getGUIDs() {
|
||||
return new IBinnieGUID[0];
|
||||
}
|
||||
|
||||
public Class[] getConfigs() {
|
||||
return new Class[0];
|
||||
}
|
||||
|
||||
public abstract IProxyCore getProxy();
|
||||
|
||||
public abstract String getModID();
|
||||
|
||||
public SimpleNetworkWrapper getNetworkWrapper() {
|
||||
return this.wrapper;
|
||||
}
|
||||
|
||||
protected abstract Class<? extends BinniePacketHandler> getPacketHandler();
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
if (!this.isActive()) {
|
||||
return;
|
||||
}
|
||||
if (this.getConfigs() != null) {
|
||||
for (final Class cls : this.getConfigs()) {
|
||||
Binnie.Configuration.registerConfiguration(cls, this);
|
||||
}
|
||||
}
|
||||
this.getProxy().preInit();
|
||||
for (final IInitializable module : this.modules) {
|
||||
module.preInit();
|
||||
}
|
||||
for (final Field field : this.getClass().getFields()) {
|
||||
this.fields.add(field);
|
||||
}
|
||||
for (final Class cls : this.getClass().getClasses()) {
|
||||
for (final Field field2 : this.getClass().getFields()) {
|
||||
this.fields.add(field2);
|
||||
}
|
||||
}
|
||||
for (final IInitializable module : this.modules) {
|
||||
for (final Field field3 : module.getClass().getFields()) {
|
||||
this.fields.add(field3);
|
||||
}
|
||||
}
|
||||
for (final Field field4 : this.fields) {
|
||||
try {
|
||||
FieldParser.preInitParse(field4, this);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
if (!this.isActive()) {
|
||||
return;
|
||||
}
|
||||
this.getProxy().init();
|
||||
(this.wrapper = NetworkRegistry.INSTANCE.newSimpleChannel(this.getChannel())).registerMessage((Class) this.getPacketHandler(), (Class) MessageBinnie.class, 1, Side.CLIENT);
|
||||
this.wrapper.registerMessage((Class) this.getPacketHandler(), (Class) MessageBinnie.class, 1, Side.SERVER);
|
||||
for (final IInitializable module : this.modules) {
|
||||
module.init();
|
||||
}
|
||||
for (final Field field : this.fields) {
|
||||
try {
|
||||
FieldParser.initParse(field, this);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
if (!this.isActive()) {
|
||||
return;
|
||||
}
|
||||
this.getProxy().postInit();
|
||||
for (final IInitializable module : this.modules) {
|
||||
module.postInit();
|
||||
}
|
||||
for (final Field field : this.fields) {
|
||||
try {
|
||||
FieldParser.postInitParse(field, this);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected final void addModule(final IInitializable init) {
|
||||
this.modules.add(init);
|
||||
MinecraftForge.EVENT_BUS.register(init);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,238 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core;
|
||||
|
||||
import binnie.core.network.BinniePacketHandler;
|
||||
import binnie.core.mod.config.ConfigurationMain;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import binnie.core.network.BinnieCorePacketID;
|
||||
import binnie.core.network.IPacketID;
|
||||
import binnie.core.proxy.IBinnieProxy;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import forestry.api.core.ForestryEvent;
|
||||
import java.util.ArrayList;
|
||||
import forestry.plugins.PluginManager;
|
||||
import binnie.core.block.TileEntityMetadata;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import binnie.core.block.MultipassBlockRenderer;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import binnie.core.gui.BinnieGUIHandler;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import net.minecraft.item.Item;
|
||||
import binnie.core.mod.parser.ItemParser;
|
||||
import binnie.core.mod.parser.FieldParser;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import binnie.core.liquid.ItemFluidContainer;
|
||||
import binnie.core.liquid.FluidContainer;
|
||||
import binnie.core.gui.BinnieCoreGUI;
|
||||
import binnie.core.gui.IBinnieGUID;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import binnie.core.triggers.ModuleTrigger;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import binnie.core.item.ModuleItems;
|
||||
import binnie.core.machines.storage.ModuleStorage;
|
||||
import binnie.craftgui.minecraft.ModuleCraftGUI;
|
||||
import binnie.core.mod.config.ConfigurationMods;
|
||||
import binnie.Binnie;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import binnie.core.item.ItemFieldKit;
|
||||
import binnie.core.item.ItemGenesis;
|
||||
import binnie.core.machines.MachineGroup;
|
||||
import java.util.List;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import binnie.core.proxy.BinnieProxy;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
|
||||
@Mod(modid = "BinnieCore", name = "Binnie Core", useMetadata = true)
|
||||
public final class BinnieCore extends AbstractMod
|
||||
{
|
||||
@Mod.Instance("BinnieCore")
|
||||
public static BinnieCore instance;
|
||||
@SidedProxy(clientSide = "binnie.core.proxy.BinnieProxyClient", serverSide = "binnie.core.proxy.BinnieProxyServer")
|
||||
public static BinnieProxy proxy;
|
||||
public static int multipassRenderID;
|
||||
private static List<AbstractMod> modList;
|
||||
public static MachineGroup packageCompartment;
|
||||
public static ItemGenesis genesis;
|
||||
public static ItemFieldKit fieldKit;
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(final FMLPreInitializationEvent evt) {
|
||||
Binnie.Configuration.registerConfiguration(ConfigurationMods.class, this);
|
||||
for (final ManagerBase baseManager : Binnie.Managers) {
|
||||
this.addModule(baseManager);
|
||||
}
|
||||
this.addModule(new ModuleCraftGUI());
|
||||
this.addModule(new ModuleStorage());
|
||||
this.addModule(new ModuleItems());
|
||||
if (Loader.isModLoaded("BuildCraft|Silicon")) {
|
||||
this.addModule(new ModuleTrigger());
|
||||
}
|
||||
this.preInit();
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(final FMLInitializationEvent evt) {
|
||||
this.init();
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void postInit(final FMLPostInitializationEvent evt) {
|
||||
this.postInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinnieGUID[] getGUIDs() {
|
||||
return BinnieCoreGUI.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
BinnieCore.instance = this;
|
||||
for (final FluidContainer container : FluidContainer.values()) {
|
||||
final Item item = new ItemFluidContainer(container);
|
||||
GameRegistry.registerItem(item, item.getUnlocalizedName().substring(5));
|
||||
}
|
||||
FieldParser.parsers.add(new ItemParser());
|
||||
super.preInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
for (final AbstractMod mod : getActiveMods()) {
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(mod, new BinnieGUIHandler(mod));
|
||||
}
|
||||
BinnieCore.multipassRenderID = RenderingRegistry.getNextAvailableRenderId();
|
||||
RenderingRegistry.registerBlockHandler(new MultipassBlockRenderer());
|
||||
GameRegistry.registerTileEntity(TileEntityMetadata.class, "binnie.tile.metadata");
|
||||
}
|
||||
|
||||
public static boolean isLepidopteryActive() {
|
||||
return PluginManager.Module.LEPIDOPTEROLOGY.isEnabled();
|
||||
}
|
||||
|
||||
public static boolean isApicultureActive() {
|
||||
return PluginManager.Module.APICULTURE.isEnabled();
|
||||
}
|
||||
|
||||
public static boolean isArboricultureActive() {
|
||||
return PluginManager.Module.ARBORICULTURE.isEnabled();
|
||||
}
|
||||
|
||||
public static boolean isBotanyActive() {
|
||||
return ConfigurationMods.botany;
|
||||
}
|
||||
|
||||
public static boolean isGeneticsActive() {
|
||||
return ConfigurationMods.genetics;
|
||||
}
|
||||
|
||||
public static boolean isExtraBeesActive() {
|
||||
return ConfigurationMods.extraBees && isApicultureActive();
|
||||
}
|
||||
|
||||
public static boolean isExtraTreesActive() {
|
||||
return ConfigurationMods.extraTrees && isArboricultureActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
super.postInit();
|
||||
}
|
||||
|
||||
static void registerMod(final AbstractMod mod) {
|
||||
BinnieCore.modList.add(mod);
|
||||
}
|
||||
|
||||
private static List<AbstractMod> getActiveMods() {
|
||||
final List<AbstractMod> list = new ArrayList<AbstractMod>();
|
||||
for (final AbstractMod mod : BinnieCore.modList) {
|
||||
if (mod.isActive()) {
|
||||
list.add(mod);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void handleSpeciesDiscovered(final ForestryEvent.SpeciesDiscovered event) {
|
||||
try {
|
||||
final EntityPlayerMP player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(event.username.getName());
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
event.tracker.synchToPlayer(player);
|
||||
final NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setString("species", event.species.getUID());
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChannel() {
|
||||
return "BIN";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinnieProxy getProxy() {
|
||||
return BinnieCore.proxy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModID() {
|
||||
return "binniecore";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacketID[] getPacketIDs() {
|
||||
return BinnieCorePacketID.values();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void handleTextureRemap(final TextureStitchEvent.Pre event) {
|
||||
if (event.map.getTextureType() == 0) {
|
||||
Binnie.Liquid.reloadIcons(event.map);
|
||||
}
|
||||
Binnie.Resource.registerIcons(event.map, event.map.getTextureType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?>[] getConfigs() {
|
||||
return new Class[] { ConfigurationMain.class };
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BinniePacketHandler> getPacketHandler() {
|
||||
return PacketHandler.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static {
|
||||
BinnieCore.modList = new ArrayList<AbstractMod>();
|
||||
}
|
||||
|
||||
public static class PacketHandler extends BinniePacketHandler
|
||||
{
|
||||
public PacketHandler() {
|
||||
super(BinnieCore.instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core;
|
||||
|
||||
public interface IInitializable
|
||||
{
|
||||
void preInit();
|
||||
|
||||
void init();
|
||||
|
||||
void postInit();
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core;
|
||||
|
||||
import binnie.Binnie;
|
||||
|
||||
public abstract class ManagerBase implements IInitializable
|
||||
{
|
||||
public ManagerBase() {
|
||||
Binnie.Managers.add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core;
|
||||
|
||||
import cpw.mods.fml.common.versioning.ArtifactVersion;
|
||||
import cpw.mods.fml.common.versioning.Restriction;
|
||||
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class Mods
|
||||
{
|
||||
public static Mod Forestry;
|
||||
public static Mod IC2;
|
||||
public static Mod Botania;
|
||||
private static boolean WARN;
|
||||
|
||||
private static Item findItem(final String modId, final String name) {
|
||||
final Item stack = GameRegistry.findItem(modId, name);
|
||||
if (stack == null && Mods.WARN && modId == "Forestry") {
|
||||
throw new RuntimeException("Item not found: " + modId + ":" + name);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
private static ItemStack findItemStack(final String modId, final String name, final int stackSize) {
|
||||
final ItemStack stack = GameRegistry.findItemStack(modId, name, stackSize);
|
||||
if (stack == null && Mods.WARN && modId == "Forestry") {
|
||||
throw new RuntimeException("Stack not found: " + modId + ":" + name);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
private static Block findBlock(final String modId, final String name) {
|
||||
final Block stack = GameRegistry.findBlock(modId, name);
|
||||
if (stack == null && Mods.WARN && modId == "Forestry") {
|
||||
throw new RuntimeException("Block not found: " + modId + ":" + name);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
static {
|
||||
Mods.Forestry = new Mod("Forestry") {
|
||||
@Override
|
||||
public boolean dev() {
|
||||
final String forVersion = Loader.instance().getIndexedModList().get("Forestry").getVersion();
|
||||
final Restriction rest = new Restriction(new DefaultArtifactVersion("3.6"), true, (ArtifactVersion) null, false);
|
||||
return rest.containsVersion(new DefaultArtifactVersion(forVersion));
|
||||
}
|
||||
};
|
||||
Mods.IC2 = new Mod("IC2");
|
||||
Mods.Botania = new Mod("Botania");
|
||||
Mods.WARN = true;
|
||||
}
|
||||
|
||||
public static class Mod
|
||||
{
|
||||
private String id;
|
||||
|
||||
private Mod(final String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Item item(final String name) {
|
||||
return findItem(this.id, name);
|
||||
}
|
||||
|
||||
public Block block(final String name) {
|
||||
return findBlock(this.id, name);
|
||||
}
|
||||
|
||||
public ItemStack stack(final String name, final int stackSize) {
|
||||
return findItemStack(this.id, name, stackSize);
|
||||
}
|
||||
|
||||
public ItemStack stack(final String name) {
|
||||
return this.stack(name, 1);
|
||||
}
|
||||
|
||||
public ItemStack stack(final String string, final int i, final int j) {
|
||||
return new ItemStack(this.item(string), i, j);
|
||||
}
|
||||
|
||||
public boolean active() {
|
||||
return Loader.isModLoaded(this.id);
|
||||
}
|
||||
|
||||
public boolean dev() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.block;
|
||||
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import binnie.core.BinnieCore;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import java.util.List;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
|
||||
public class BlockMetadata extends BlockContainer implements IBlockMetadata
|
||||
{
|
||||
static int temporyMeta;
|
||||
|
||||
public BlockMetadata(final Material material) {
|
||||
super(material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(final World world, final int x, final int y, final int z, final int blockMeta, final int fortune) {
|
||||
return getBlockDropped(this, world, x, y, z, blockMeta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(final World world, final EntityPlayer player, final int x, final int y, final int z) {
|
||||
return breakBlock(this, player, world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(final World var1, final int i) {
|
||||
return new TileEntityMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(final int meta) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockEventReceived(final World par1World, final int par2, final int par3, final int par4, final int par5, final int par6) {
|
||||
super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6);
|
||||
final TileEntity tileentity = par1World.getTileEntity(par2, par3, par4);
|
||||
return tileentity != null && tileentity.receiveClientEvent(par5, par6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4, final int par5) {
|
||||
final int metadata = TileEntityMetadata.getTileMetadata(par1IBlockAccess, par2, par3, par4);
|
||||
return this.getIcon(par5, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlockName(final ItemStack par1ItemStack) {
|
||||
return this.getLocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBlockTooltip(final ItemStack par1ItemStack, final List par3List) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlacedMeta(final ItemStack item, final World world, final int x, final int y, final int z, final ForgeDirection clickedBlock) {
|
||||
final int damage = TileEntityMetadata.getItemDamage(item);
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDroppedMeta(final int tileMeta, final int blockMeta) {
|
||||
return tileMeta;
|
||||
}
|
||||
|
||||
public static ArrayList<ItemStack> getBlockDropped(final IBlockMetadata block, final World world, final int x, final int y, final int z, final int blockMeta) {
|
||||
final ArrayList<ItemStack> array = new ArrayList<ItemStack>();
|
||||
final TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z);
|
||||
if (tile != null && !tile.hasDroppedBlock()) {
|
||||
final int meta = block.getDroppedMeta(world.getBlockMetadata(x, y, z), tile.getTileMetadata());
|
||||
array.add(TileEntityMetadata.getItemStack((Block) block, meta));
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public static boolean breakBlock(final IBlockMetadata block, final EntityPlayer player, final World world, final int i, final int j, final int k) {
|
||||
List<ItemStack> drops = new ArrayList<ItemStack>();
|
||||
final Block block2 = (Block) block;
|
||||
final TileEntityMetadata tile = TileEntityMetadata.getTile(world, i, j, k);
|
||||
if (tile != null && !tile.hasDroppedBlock()) {
|
||||
final int tileMeta = TileEntityMetadata.getTileMetadata(world, i, j, k);
|
||||
drops = block2.getDrops(world, i, j, k, world.getBlockMetadata(i, j, k), 0);
|
||||
}
|
||||
final boolean hasBeenBroken = world.setBlockToAir(i, j, k);
|
||||
if (hasBeenBroken && BinnieCore.proxy.isSimulating(world) && drops.size() > 0 && (player == null || !player.capabilities.isCreativeMode)) {
|
||||
for (final ItemStack drop : drops) {
|
||||
block.dropAsStack(world, i, j, k, drop);
|
||||
}
|
||||
tile.dropBlock();
|
||||
}
|
||||
return hasBeenBroken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropAsStack(final World world, final int x, final int y, final int z, final ItemStack drop) {
|
||||
this.dropBlockAsItem(world, x, y, z, drop);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(final World par1World, final int par2, final int par3, final int par4, final Block par5, final int par6) {
|
||||
super.breakBlock(par1World, par2, par3, par4, par5, par6);
|
||||
par1World.removeTileEntity(par2, par3, par4);
|
||||
}
|
||||
|
||||
public static ItemStack getPickBlock(final World world, final int x, final int y, final int z) {
|
||||
final List<ItemStack> list = getBlockDropped((IBlockMetadata) world.getBlock(x, y, z), world, x, y, z, world.getBlockMetadata(x, y, z));
|
||||
return list.isEmpty() ? null : list.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(final MovingObjectPosition target, final World world, final int x, final int y, final int z) {
|
||||
return getPickBlock(world, x, y, z);
|
||||
}
|
||||
|
||||
static {
|
||||
BlockMetadata.temporyMeta = -1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.block;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
|
||||
public interface IBlockMetadata extends ITileEntityProvider
|
||||
{
|
||||
int getPlacedMeta(final ItemStack p0, final World p1, final int p2, final int p3, final int p4, final ForgeDirection p5);
|
||||
|
||||
int getDroppedMeta(final int p0, final int p1);
|
||||
|
||||
String getBlockName(final ItemStack p0);
|
||||
|
||||
void getBlockTooltip(final ItemStack p0, final List p1);
|
||||
|
||||
void dropAsStack(final World p0, final int p1, final int p2, final int p3, final ItemStack p4);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.block;
|
||||
|
||||
public interface IMultipassBlock
|
||||
{
|
||||
int getNumberOfPasses();
|
||||
|
||||
int colorMultiplier(final int p0);
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.block;
|
||||
|
||||
import net.minecraft.util.IIcon;
|
||||
import java.util.List;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
|
||||
public class ItemMetadata extends ItemBlock
|
||||
{
|
||||
public ItemMetadata(final Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(final int par1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean placeBlockAt(final ItemStack stack, final EntityPlayer player, final World world, final int x, final int y, final int z, final int side, final float hitX, final float hitY, final float hitZ, final int metadata) {
|
||||
final Block block = this.field_150939_a;
|
||||
if (!(block instanceof IBlockMetadata)) {
|
||||
return false;
|
||||
}
|
||||
final int placedMeta = ((IBlockMetadata) block).getPlacedMeta(stack, world, x, y, z, ForgeDirection.values()[side]);
|
||||
if (placedMeta < 0) {
|
||||
return false;
|
||||
}
|
||||
if (!world.setBlock(x, y, z, block, metadata, 3)) {
|
||||
return false;
|
||||
}
|
||||
if (world.getBlock(x, y, z) == block) {
|
||||
final TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z);
|
||||
if (tile != null) {
|
||||
tile.setTileMetadata(placedMeta, false);
|
||||
}
|
||||
block.onBlockPlacedBy(world, x, y, z, player, stack);
|
||||
block.onPostBlockPlaced(world, x, y, z, metadata);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getItemStackDisplayName(final ItemStack par1ItemStack) {
|
||||
return ((IBlockMetadata) this.field_150939_a).getBlockName(par1ItemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(final ItemStack par1ItemStack, final EntityPlayer par2EntityPlayer, final List par3List, final boolean par4) {
|
||||
((IBlockMetadata) this.field_150939_a).getBlockTooltip(par1ItemStack, par3List);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIconFromDamage(final int par1) {
|
||||
return this.field_150939_a.getIcon(1, par1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.block;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
public class ItemMetadataRenderer implements IItemRenderer
|
||||
{
|
||||
@Override
|
||||
public boolean handleRenderType(final ItemStack item, final IItemRenderer.ItemRenderType type) {
|
||||
return type == IItemRenderer.ItemRenderType.INVENTORY || type == IItemRenderer.ItemRenderType.ENTITY || type == IItemRenderer.ItemRenderType.EQUIPPED || type == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(final IItemRenderer.ItemRenderType type, final ItemStack item, final IItemRenderer.ItemRendererHelper helper) {
|
||||
if (type == IItemRenderer.ItemRenderType.INVENTORY) {
|
||||
return helper == IItemRenderer.ItemRendererHelper.INVENTORY_BLOCK;
|
||||
}
|
||||
if (type == IItemRenderer.ItemRenderType.ENTITY) {
|
||||
return helper == IItemRenderer.ItemRendererHelper.ENTITY_BOBBING || helper == IItemRenderer.ItemRendererHelper.ENTITY_ROTATION;
|
||||
}
|
||||
return (type == IItemRenderer.ItemRenderType.EQUIPPED || type == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON) && helper == IItemRenderer.ItemRendererHelper.EQUIPPED_BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(final IItemRenderer.ItemRenderType type, final ItemStack item, final Object... data) {
|
||||
GL11.glPushMatrix();
|
||||
final Block block = Block.getBlockFromItem(item.getItem());
|
||||
if (type == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON) {
|
||||
GL11.glTranslated(0.5, 0.5, 0.5);
|
||||
}
|
||||
if (type == IItemRenderer.ItemRenderType.INVENTORY && block.getRenderBlockPass() != 0) {
|
||||
GL11.glAlphaFunc(516, 0.1f);
|
||||
GL11.glEnable(3042);
|
||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||
}
|
||||
GL11.glPushMatrix();
|
||||
((RenderBlocks) data[0]).renderBlockAsItem(block, TileEntityMetadata.getItemDamage(item), 1.0f);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.block;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.block.Block;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
|
||||
public class MultipassBlockRenderer implements ISimpleBlockRenderingHandler
|
||||
{
|
||||
public static MultipassBlockRenderer instance;
|
||||
private static int layer;
|
||||
|
||||
public MultipassBlockRenderer() {
|
||||
MultipassBlockRenderer.instance = this;
|
||||
}
|
||||
|
||||
private void setColour(final Tessellator tess, final int colour) {
|
||||
final float var6 = (colour >> 16 & 0xFF) / 255.0f;
|
||||
final float var7 = (colour >> 8 & 0xFF) / 255.0f;
|
||||
final float var8 = (colour & 0xFF) / 255.0f;
|
||||
GL11.glColor3f(var6, var7, var8);
|
||||
}
|
||||
|
||||
public static int getLayer() {
|
||||
return MultipassBlockRenderer.layer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(final Block block, final int meta, final int modelID, final RenderBlocks renderer) {
|
||||
block.setBlockBoundsForItemRender();
|
||||
renderer.setRenderBoundsFromBlock(block);
|
||||
GL11.glTranslatef(-0.5f, -0.5f, -0.5f);
|
||||
MultipassBlockRenderer.layer = 0;
|
||||
while (MultipassBlockRenderer.layer < ((IMultipassBlock) block).getNumberOfPasses()) {
|
||||
this.renderItem(block, renderer, meta);
|
||||
++MultipassBlockRenderer.layer;
|
||||
}
|
||||
MultipassBlockRenderer.layer = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(final IBlockAccess world, final int x, final int y, final int z, final Block block, final int modelId, final RenderBlocks renderer) {
|
||||
boolean r = true;
|
||||
MultipassBlockRenderer.layer = 0;
|
||||
while (MultipassBlockRenderer.layer < ((IMultipassBlock) block).getNumberOfPasses()) {
|
||||
r = renderer.renderStandardBlock(block, x, y, z);
|
||||
++MultipassBlockRenderer.layer;
|
||||
}
|
||||
MultipassBlockRenderer.layer = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(final int i) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return BinnieCore.multipassRenderID;
|
||||
}
|
||||
|
||||
public void renderItem(final Block block, final RenderBlocks renderer, final int meta) {
|
||||
this.setColor(((IMultipassBlock) block).colorMultiplier(meta));
|
||||
final Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0f, -1.0f, 0.0f);
|
||||
renderer.renderFaceYNeg(block, 0.0, 0.0, 0.0, renderer.getBlockIconFromSideAndMetadata(block, 0, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0f, 1.0f, 0.0f);
|
||||
renderer.renderFaceYPos(block, 0.0, 0.0, 0.0, renderer.getBlockIconFromSideAndMetadata(block, 1, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0f, 0.0f, -1.0f);
|
||||
renderer.renderFaceZNeg(block, 0.0, 0.0, 0.0, renderer.getBlockIconFromSideAndMetadata(block, 2, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0f, 0.0f, 1.0f);
|
||||
renderer.renderFaceZPos(block, 0.0, 0.0, 0.0, renderer.getBlockIconFromSideAndMetadata(block, 3, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1.0f, 0.0f, 0.0f);
|
||||
renderer.renderFaceXNeg(block, 0.0, 0.0, 0.0, renderer.getBlockIconFromSideAndMetadata(block, 4, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0f, 0.0f, 0.0f);
|
||||
renderer.renderFaceXPos(block, 0.0, 0.0, 0.0, renderer.getBlockIconFromSideAndMetadata(block, 5, meta));
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
public void setColor(final int l) {
|
||||
final float f = (l >> 16 & 0xFF) / 255.0f;
|
||||
final float f2 = (l >> 8 & 0xFF) / 255.0f;
|
||||
final float f3 = (l & 0xFF) / 255.0f;
|
||||
GL11.glColor3f(f, f2, f3);
|
||||
}
|
||||
|
||||
static {
|
||||
MultipassBlockRenderer.layer = 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
public class MultipassItemRenderer implements IItemRenderer
|
||||
{
|
||||
private void render(final RenderBlocks renderer, final ItemStack item, final float f, final float g, final float h) {
|
||||
GL11.glTranslatef(f, g, h);
|
||||
final Block block = ((ItemBlock) item.getItem()).field_150939_a;
|
||||
GL11.glEnable(3008);
|
||||
if (block.getRenderBlockPass() != 0) {
|
||||
GL11.glAlphaFunc(516, 0.1f);
|
||||
GL11.glEnable(3042);
|
||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||
}
|
||||
else {
|
||||
GL11.glAlphaFunc(516, 0.5f);
|
||||
GL11.glDisable(3042);
|
||||
}
|
||||
MultipassBlockRenderer.instance.renderInventoryBlock(block, TileEntityMetadata.getItemDamage(item), 0, renderer);
|
||||
if (block.getRenderBlockPass() == 0) {
|
||||
GL11.glAlphaFunc(516, 0.1f);
|
||||
}
|
||||
GL11.glTranslatef(-f, -g, -h);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(final ItemStack item, final IItemRenderer.ItemRenderType type) {
|
||||
switch (type) {
|
||||
case ENTITY: {
|
||||
return true;
|
||||
}
|
||||
case EQUIPPED: {
|
||||
return true;
|
||||
}
|
||||
case INVENTORY: {
|
||||
return true;
|
||||
}
|
||||
case EQUIPPED_FIRST_PERSON: {
|
||||
return true;
|
||||
}
|
||||
default: {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(final IItemRenderer.ItemRenderType type, final ItemStack item, final IItemRenderer.ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(final IItemRenderer.ItemRenderType type, final ItemStack item, final Object... data) {
|
||||
switch (type) {
|
||||
case ENTITY: {
|
||||
this.render((RenderBlocks) data[0], item, 0.0f, 0.0f, 0.0f);
|
||||
break;
|
||||
}
|
||||
case EQUIPPED:
|
||||
case EQUIPPED_FIRST_PERSON: {
|
||||
this.render((RenderBlocks) data[0], item, 0.5f, 0.5f, 0.5f);
|
||||
break;
|
||||
}
|
||||
case INVENTORY: {
|
||||
this.render((RenderBlocks) data[0], item, 0.0f, 0.0f, 0.0f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.block;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import binnie.core.network.packet.MessageMetadata;
|
||||
import binnie.core.BinnieCore;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TileEntityMetadata extends TileEntity
|
||||
{
|
||||
private int meta;
|
||||
private boolean droppedBlock;
|
||||
|
||||
public TileEntityMetadata() {
|
||||
this.droppedBlock = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean receiveClientEvent(final int par1, final int par2) {
|
||||
if (par1 == 42) {
|
||||
this.meta = par2;
|
||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
this.meta = nbt.getInteger("meta");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("meta", this.meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getTileMetadata() {
|
||||
return this.meta;
|
||||
}
|
||||
|
||||
public void setTileMetadata(final int meta, final boolean notify) {
|
||||
if (this.meta != meta) {
|
||||
this.meta = meta;
|
||||
if (notify) {
|
||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
return BinnieCore.instance.getNetworkWrapper().getPacketFrom(new MessageMetadata(this.xCoord, this.yCoord, this.zCoord, this.meta).GetMessage());
|
||||
}
|
||||
|
||||
public static TileEntityMetadata getTile(final IBlockAccess world, final int x, final int y, final int z) {
|
||||
final TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (!(tile instanceof TileEntityMetadata)) {
|
||||
return null;
|
||||
}
|
||||
return (TileEntityMetadata) tile;
|
||||
}
|
||||
|
||||
public static ItemStack getItemStack(final Block block, final int damage) {
|
||||
final ItemStack item = new ItemStack(block, 1, 0);
|
||||
setItemDamage(item, damage);
|
||||
return item;
|
||||
}
|
||||
|
||||
public static void setItemDamage(final ItemStack item, final int i) {
|
||||
item.setItemDamage((i < 16387) ? i : 16387);
|
||||
final NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setInteger("meta", i);
|
||||
item.setTagCompound(tag);
|
||||
}
|
||||
|
||||
public static int getItemDamage(final ItemStack item) {
|
||||
if (item.hasTagCompound() && item.getTagCompound().hasKey("meta")) {
|
||||
return item.getTagCompound().getInteger("meta");
|
||||
}
|
||||
return item.getItemDamage();
|
||||
}
|
||||
|
||||
public static int getTileMetadata(final IBlockAccess world, final int x, final int y, final int z) {
|
||||
final TileEntityMetadata tile = getTile(world, x, y, z);
|
||||
return (tile == null) ? 0 : tile.getTileMetadata();
|
||||
}
|
||||
|
||||
public boolean hasDroppedBlock() {
|
||||
return this.droppedBlock;
|
||||
}
|
||||
|
||||
public void dropBlock() {
|
||||
this.droppedBlock = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.circuits;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
import forestry.api.circuits.ChipsetManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.circuits.ICircuitLayout;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.circuits.ICircuit;
|
||||
|
||||
public class BinnieCircuit implements ICircuit
|
||||
{
|
||||
private String uid;
|
||||
private int limit;
|
||||
private List<String> tooltips;
|
||||
|
||||
public BinnieCircuit(final String uid, final int limit, final ICircuitLayout layout, final ItemStack itemStack) {
|
||||
this.tooltips = new ArrayList<String>();
|
||||
this.uid = "binnie.circuit." + uid;
|
||||
this.limit = limit;
|
||||
ChipsetManager.circuitRegistry.registerCircuit(this);
|
||||
if (itemStack != null) {
|
||||
ChipsetManager.solderManager.addRecipe(layout, itemStack, this);
|
||||
}
|
||||
}
|
||||
|
||||
public BinnieCircuit(final String uid, final int limit, final ICircuitLayout layout, final Item item, final int itemMeta) {
|
||||
this(uid, limit, layout, new ItemStack(item, 1, itemMeta));
|
||||
}
|
||||
|
||||
public void addTooltipString(final String string) {
|
||||
this.tooltips.add(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUID() {
|
||||
return this.uid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresDiscovery() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLimit() {
|
||||
return this.limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.uid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTooltip(final List<String> list) {
|
||||
for (final String string : this.tooltips) {
|
||||
list.add(" - " + string);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCircuitable(Object arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInsertion(int arg0, Object arg1) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad(int arg0, Object arg1) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoval(int arg0, Object arg1) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick(int arg0, Object arg1) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.circuits;
|
||||
|
||||
import binnie.Binnie;
|
||||
import forestry.api.circuits.ChipsetManager;
|
||||
import forestry.api.circuits.CircuitSocketType;
|
||||
import forestry.api.circuits.ICircuitSocketType;
|
||||
import binnie.core.AbstractMod;
|
||||
import forestry.api.circuits.ICircuitLayout;
|
||||
|
||||
public class BinnieCircuitLayout implements ICircuitLayout
|
||||
{
|
||||
private String uid;
|
||||
private AbstractMod mod;
|
||||
|
||||
public BinnieCircuitLayout(final AbstractMod mod, final String uid) {
|
||||
this.uid = uid;
|
||||
this.mod = mod;
|
||||
ChipsetManager.circuitRegistry.registerLayout(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUID() {
|
||||
return "binnie.circuitLayout" + this.uid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return Binnie.Language.localise(this.mod, "circuit.layout." + this.uid.toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsage() {
|
||||
return Binnie.Language.localise(this.mod, "circuit.layout." + this.uid.toLowerCase() + ".usage");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICircuitSocketType getSocketType() {
|
||||
return CircuitSocketType.NONE;// TODO hmm? CircuitSocketType
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.genetics;
|
||||
|
||||
import java.util.TreeSet;
|
||||
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeRoot;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.apiculture.IApiaristTracker;
|
||||
import forestry.api.genetics.IBreedingTracker;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.api.apiculture.IBeeMutation;
|
||||
import forestry.api.genetics.IAllele;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import forestry.api.genetics.IMutation;
|
||||
import binnie.extrabees.ExtraBees;
|
||||
import binnie.Binnie;
|
||||
|
||||
class BeeBreedingSystem extends BreedingSystem
|
||||
{
|
||||
public BeeBreedingSystem() {
|
||||
this.iconUndiscovered = Binnie.Resource.getItemIcon(ExtraBees.instance, "icon/undiscoveredBee");
|
||||
this.iconDiscovered = Binnie.Resource.getItemIcon(ExtraBees.instance, "icon/discoveredBee");
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getChance(final IMutation mutation, final EntityPlayer player, final IAllele species1, final IAllele species2) {
|
||||
return ((IBeeMutation) mutation).
|
||||
getChance(new VirtualBeeHousing(player),
|
||||
(IAlleleBeeSpecies) species1,
|
||||
(IAlleleBeeSpecies) species2,
|
||||
(IBeeGenome) this.getSpeciesRoot().
|
||||
templateAsGenome(this.getSpeciesRoot().getTemplate(species1.getUID())),
|
||||
(IBeeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(species2.getUID())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISpeciesRoot getSpeciesRoot() {
|
||||
return Binnie.Genetics.getBeeRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColour() {
|
||||
return 16767232;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends IBreedingTracker> getTrackerClass() {
|
||||
return IApiaristTracker.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAlleleName(final IChromosomeType chromosome, final IAllele allele) {
|
||||
if (chromosome == EnumBeeChromosome.FERTILITY) {
|
||||
if (allele.getUID().contains("Low")) {
|
||||
return Binnie.Language.localise(BinnieCore.instance, "allele.fertility.low");
|
||||
}
|
||||
if (allele.getUID().contains("Normal")) {
|
||||
return Binnie.Language.localise(BinnieCore.instance, "allele.fertility.normal");
|
||||
}
|
||||
if (allele.getUID().contains("High")) {
|
||||
return Binnie.Language.localise(BinnieCore.instance, "allele.fertility.high");
|
||||
}
|
||||
if (allele.getUID().contains("Maximum")) {
|
||||
return Binnie.Language.localise(BinnieCore.instance, "allele.fertility.maximum");
|
||||
}
|
||||
}
|
||||
return super.getAlleleName(chromosome, allele);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDNAManipulable(final ItemStack member) {
|
||||
return ((IBeeRoot) this.getSpeciesRoot()).getType(member) == EnumBeeType.LARVAE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getActiveTypes() {
|
||||
return new int[] { EnumBeeType.DRONE.ordinal(), EnumBeeType.PRINCESS.ordinal(), EnumBeeType.QUEEN.ordinal(), EnumBeeType.LARVAE.ordinal() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addExtraAlleles(final IChromosomeType chromosome, final TreeSet<IAllele> alleles) {
|
||||
switch ((EnumBeeChromosome) chromosome) {
|
||||
case FERTILITY: {
|
||||
for (final ForestryAllele.Fertility a : ForestryAllele.Fertility.values()) {
|
||||
alleles.add(a.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FLOWERING: {
|
||||
for (final ForestryAllele.Flowering a2 : ForestryAllele.Flowering.values()) {
|
||||
alleles.add(a2.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case HUMIDITY_TOLERANCE:
|
||||
case TEMPERATURE_TOLERANCE: {
|
||||
for (final Tolerance a3 : Tolerance.values()) {
|
||||
alleles.add(a3.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LIFESPAN: {
|
||||
for (final ForestryAllele.Lifespan a4 : ForestryAllele.Lifespan.values()) {
|
||||
alleles.add(a4.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SPEED: {
|
||||
for (final ForestryAllele.Speed a5 : ForestryAllele.Speed.values()) {
|
||||
alleles.add(a5.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TERRITORY: {
|
||||
for (final ForestryAllele.Territory a6 : ForestryAllele.Territory.values()) {
|
||||
alleles.add(a6.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NOCTURNAL:
|
||||
case CAVE_DWELLING:
|
||||
case TOLERANT_FLYER: {
|
||||
for (final ForestryAllele.Bool a7 : ForestryAllele.Bool.values()) {
|
||||
alleles.add(a7.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.genetics;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class BeeModifierLogic
|
||||
{
|
||||
private Map<EnumBeeModifier, Float[]> modifiers;
|
||||
private List<EnumBeeBooleanModifier> booleanModifiers;
|
||||
|
||||
public BeeModifierLogic() {
|
||||
this.modifiers = new HashMap<EnumBeeModifier, Float[]>();
|
||||
this.booleanModifiers = new ArrayList<EnumBeeBooleanModifier>();
|
||||
}
|
||||
|
||||
public float getModifier(final EnumBeeModifier modifier, final float currentModifier) {
|
||||
if (!this.modifiers.containsKey(modifier)) {
|
||||
return 1.0f;
|
||||
}
|
||||
final float mult = this.modifiers.get(modifier)[0];
|
||||
final float max = this.modifiers.get(modifier)[1];
|
||||
if (max >= 1.0f) {
|
||||
if (max <= currentModifier) {
|
||||
return 1.0f;
|
||||
}
|
||||
return Math.min(max / currentModifier, mult);
|
||||
}
|
||||
else {
|
||||
if (max >= currentModifier) {
|
||||
return 1.0f;
|
||||
}
|
||||
return Math.max(max / currentModifier, mult);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getModifier(final EnumBeeBooleanModifier modifier) {
|
||||
return this.booleanModifiers.contains(modifier);
|
||||
}
|
||||
|
||||
public void setModifier(final EnumBeeBooleanModifier modifier) {
|
||||
this.booleanModifiers.add(modifier);
|
||||
}
|
||||
|
||||
public void setModifier(final EnumBeeModifier modifier, final float mult, final float max) {
|
||||
this.modifiers.put(modifier, new Float[] { mult, max });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,494 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.genetics;
|
||||
|
||||
import forestry.api.genetics.IGenome;
|
||||
import java.util.TreeSet;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import forestry.api.genetics.IAlleleBoolean;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import forestry.api.core.ForestryEvent;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.IIcon;
|
||||
import forestry.api.genetics.IBreedingTracker;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.world.World;
|
||||
import java.util.Set;
|
||||
import binnie.extrabees.genetics.ExtraBeeMutation;
|
||||
import java.util.LinkedHashSet;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import java.util.Collection;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import binnie.core.BinnieCore;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import binnie.Binnie;
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import forestry.api.genetics.IMutation;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IClassification;
|
||||
import java.util.List;
|
||||
import binnie.core.resource.BinnieIcon;
|
||||
|
||||
public abstract class BreedingSystem implements IItemStackRepresentitive
|
||||
{
|
||||
protected BinnieIcon iconUndiscovered;
|
||||
protected BinnieIcon iconDiscovered;
|
||||
private List<IClassification> allBranches;
|
||||
List<IAlleleSpecies> allActiveSpecies;
|
||||
private List<IAlleleSpecies> allSpecies;
|
||||
private List<IMutation> allMutations;
|
||||
private Map<IAlleleSpecies, List<IMutation>> resultantMutations;
|
||||
private Map<IAlleleSpecies, List<IMutation>> furtherMutations;
|
||||
private Map<IAlleleSpecies, List<IMutation>> allResultantMutations;
|
||||
private Map<IAlleleSpecies, List<IMutation>> allFurtherMutations;
|
||||
public float discoveredSpeciesPercentage;
|
||||
public int totalSpeciesCount;
|
||||
public int discoveredSpeciesCount;
|
||||
public int totalSecretCount;
|
||||
public int discoveredSecretCount;
|
||||
public float discoveredBranchPercentage;
|
||||
public int totalBranchCount;
|
||||
public int discoveredBranchCount;
|
||||
private int totalSecretBranchCount;
|
||||
private int discoveredSecretBranchCount;
|
||||
String currentEpithet;
|
||||
|
||||
public BreedingSystem() {
|
||||
this.allBranches = new ArrayList<IClassification>();
|
||||
this.allActiveSpecies = new ArrayList<IAlleleSpecies>();
|
||||
this.allSpecies = new ArrayList<IAlleleSpecies>();
|
||||
this.allMutations = new ArrayList<IMutation>();
|
||||
this.resultantMutations = new HashMap<IAlleleSpecies, List<IMutation>>();
|
||||
this.furtherMutations = new HashMap<IAlleleSpecies, List<IMutation>>();
|
||||
this.allResultantMutations = new HashMap<IAlleleSpecies, List<IMutation>>();
|
||||
this.allFurtherMutations = new HashMap<IAlleleSpecies, List<IMutation>>();
|
||||
Binnie.Genetics.registerBreedingSystem(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
public String getChromosomeName(final IChromosomeType chromo) {
|
||||
return BinnieCore.proxy.localise(this.getSpeciesRoot().getUID() + ".chromosome." + chromo.getName());
|
||||
}
|
||||
|
||||
public String getChromosomeShortName(final IChromosomeType chromo) {
|
||||
return BinnieCore.proxy.localise(this.getSpeciesRoot().getUID() + ".chromosome." + chromo.getName() + ".short");
|
||||
}
|
||||
|
||||
public final String getEpitome(final float discoveredPercentage) {
|
||||
int i = 0;
|
||||
if (discoveredPercentage == 1.0f) {
|
||||
i = 6;
|
||||
}
|
||||
else if (discoveredPercentage < 0.1f) {
|
||||
i = 0;
|
||||
}
|
||||
else if (discoveredPercentage < 0.3f) {
|
||||
i = 1;
|
||||
}
|
||||
else if (discoveredPercentage < 0.5f) {
|
||||
i = 2;
|
||||
}
|
||||
else if (discoveredPercentage < 0.7f) {
|
||||
i = 3;
|
||||
}
|
||||
else if (discoveredPercentage < 0.9f) {
|
||||
i = 4;
|
||||
}
|
||||
else if (discoveredPercentage < 1.0f) {
|
||||
i = 5;
|
||||
}
|
||||
return BinnieCore.proxy.localise(this.getSpeciesRoot().getUID() + ".epitome." + i);
|
||||
}
|
||||
|
||||
public abstract ISpeciesRoot getSpeciesRoot();
|
||||
|
||||
public final List<IClassification> getAllBranches() {
|
||||
return this.allBranches;
|
||||
}
|
||||
|
||||
public final Collection<IAlleleSpecies> getAllSpecies() {
|
||||
return this.allActiveSpecies;
|
||||
}
|
||||
|
||||
public final Collection<IMutation> getAllMutations() {
|
||||
return this.allMutations;
|
||||
}
|
||||
|
||||
public void calculateArrays() {
|
||||
final Collection<IAllele> allAlleles = AlleleManager.alleleRegistry.getRegisteredAlleles().values();
|
||||
this.resultantMutations = new HashMap<IAlleleSpecies, List<IMutation>>();
|
||||
this.furtherMutations = new HashMap<IAlleleSpecies, List<IMutation>>();
|
||||
this.allResultantMutations = new HashMap<IAlleleSpecies, List<IMutation>>();
|
||||
this.allFurtherMutations = new HashMap<IAlleleSpecies, List<IMutation>>();
|
||||
this.allActiveSpecies = new ArrayList<IAlleleSpecies>();
|
||||
this.allSpecies = new ArrayList<IAlleleSpecies>();
|
||||
for (final IAllele species : allAlleles) {
|
||||
if (this.getSpeciesRoot().getTemplate(species.getUID()) != null) {
|
||||
this.resultantMutations.put((IAlleleSpecies) species, new ArrayList<IMutation>());
|
||||
this.furtherMutations.put((IAlleleSpecies) species, new ArrayList<IMutation>());
|
||||
this.allResultantMutations.put((IAlleleSpecies) species, new ArrayList<IMutation>());
|
||||
this.allFurtherMutations.put((IAlleleSpecies) species, new ArrayList<IMutation>());
|
||||
this.allSpecies.add((IAlleleSpecies) species);
|
||||
if (this.isBlacklisted(species) || species.getUID().contains("speciesBotAlfheim")) {
|
||||
continue;
|
||||
}
|
||||
this.allActiveSpecies.add((IAlleleSpecies) species);
|
||||
}
|
||||
}
|
||||
this.allMutations = new ArrayList<IMutation>();
|
||||
final Collection<IClassification> allRegBranches = AlleleManager.alleleRegistry.getRegisteredClassifications().values();
|
||||
this.allBranches = new ArrayList<IClassification>();
|
||||
for (final IClassification branch : allRegBranches) {
|
||||
if (branch.getMemberSpecies().length > 0 && this.getSpeciesRoot().getTemplate(branch.getMemberSpecies()[0].getUID()) != null) {
|
||||
boolean possible = false;
|
||||
for (final IAlleleSpecies species2 : branch.getMemberSpecies()) {
|
||||
if (this.allActiveSpecies.contains(species2)) {
|
||||
possible = true;
|
||||
}
|
||||
}
|
||||
if (!possible) {
|
||||
continue;
|
||||
}
|
||||
this.allBranches.add(branch);
|
||||
}
|
||||
}
|
||||
if (this.getSpeciesRoot().getMutations(false) != null) {
|
||||
final Set<IMutation> mutations = new LinkedHashSet<IMutation>();
|
||||
mutations.addAll(this.getSpeciesRoot().getMutations(false));
|
||||
if (this == Binnie.Genetics.beeBreedingSystem) {
|
||||
mutations.addAll(ExtraBeeMutation.mutations);
|
||||
}
|
||||
for (final IMutation mutation : mutations) {
|
||||
this.allMutations.add(mutation);
|
||||
final Set<IAlleleSpecies> participatingSpecies = new LinkedHashSet<IAlleleSpecies>();
|
||||
if (mutation.getAllele0() instanceof IAlleleSpecies) {
|
||||
participatingSpecies.add(mutation.getAllele0());
|
||||
}
|
||||
if (mutation.getAllele1() instanceof IAlleleSpecies) {
|
||||
participatingSpecies.add(mutation.getAllele1());
|
||||
}
|
||||
for (final IAlleleSpecies species3 : participatingSpecies) {
|
||||
this.allFurtherMutations.get(species3).add(mutation);
|
||||
if (this.allActiveSpecies.contains(species3)) {
|
||||
this.furtherMutations.get(species3).add(mutation);
|
||||
}
|
||||
}
|
||||
if (this.resultantMutations.containsKey(mutation.getTemplate()[0])) {
|
||||
this.allResultantMutations.get(mutation.getTemplate()[0]).add(mutation);
|
||||
this.resultantMutations.get(mutation.getTemplate()[0]).add(mutation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean isBlacklisted(final IAllele allele) {
|
||||
return AlleleManager.alleleRegistry.isBlacklisted(allele.getUID());
|
||||
}
|
||||
|
||||
public final List<IMutation> getResultantMutations(final IAlleleSpecies species, final boolean includeInactive) {
|
||||
if (this.resultantMutations.isEmpty()) {
|
||||
this.calculateArrays();
|
||||
}
|
||||
return includeInactive ? this.allResultantMutations.get(species) : this.resultantMutations.get(species);
|
||||
}
|
||||
|
||||
public final List<IMutation> getResultantMutations(final IAlleleSpecies species) {
|
||||
if (this.resultantMutations.isEmpty()) {
|
||||
this.calculateArrays();
|
||||
}
|
||||
return this.resultantMutations.get(species);
|
||||
}
|
||||
|
||||
public final List<IMutation> getFurtherMutations(final IAlleleSpecies species, final boolean includeInactive) {
|
||||
if (this.furtherMutations.isEmpty()) {
|
||||
this.calculateArrays();
|
||||
}
|
||||
return includeInactive ? this.allFurtherMutations.get(species) : this.furtherMutations.get(species);
|
||||
}
|
||||
|
||||
public final List<IMutation> getFurtherMutations(final IAlleleSpecies species) {
|
||||
if (this.furtherMutations.isEmpty()) {
|
||||
this.calculateArrays();
|
||||
}
|
||||
return this.furtherMutations.get(species);
|
||||
}
|
||||
|
||||
public final boolean isMutationDiscovered(final IMutation mutation, final World world, final GameProfile name) {
|
||||
return this.isMutationDiscovered(mutation, this.getSpeciesRoot().getBreedingTracker(world, name));
|
||||
}
|
||||
|
||||
public final boolean isMutationDiscovered(final IMutation mutation, final IBreedingTracker tracker) {
|
||||
return tracker == null || tracker.isDiscovered(mutation);
|
||||
}
|
||||
|
||||
public final boolean isSpeciesDiscovered(final IAlleleSpecies species, final World world, final GameProfile name) {
|
||||
return this.isSpeciesDiscovered(species, this.getSpeciesRoot().getBreedingTracker(world, name));
|
||||
}
|
||||
|
||||
public final boolean isSpeciesDiscovered(final IAlleleSpecies species, final IBreedingTracker tracker) {
|
||||
return tracker == null || tracker.isDiscovered(species);
|
||||
}
|
||||
|
||||
public final boolean isSecret(final IAlleleSpecies species) {
|
||||
return !species.isCounted();
|
||||
}
|
||||
|
||||
public final boolean isSecret(final IClassification branch) {
|
||||
for (final IAlleleSpecies species : branch.getMemberSpecies()) {
|
||||
if (!this.isSecret(species)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public final Collection<IClassification> getDiscoveredBranches(final World world, final GameProfile player) {
|
||||
final List<IClassification> branches = new ArrayList<IClassification>();
|
||||
for (final IClassification branch : this.getAllBranches()) {
|
||||
boolean discovered = false;
|
||||
for (final IAlleleSpecies species : branch.getMemberSpecies()) {
|
||||
if (this.isSpeciesDiscovered(species, world, player)) {
|
||||
discovered = true;
|
||||
}
|
||||
}
|
||||
if (discovered) {
|
||||
branches.add(branch);
|
||||
}
|
||||
}
|
||||
return branches;
|
||||
}
|
||||
|
||||
public final Collection<IClassification> getDiscoveredBranches(final IBreedingTracker tracker) {
|
||||
final List<IClassification> branches = new ArrayList<IClassification>();
|
||||
for (final IClassification branch : this.getAllBranches()) {
|
||||
boolean discovered = false;
|
||||
for (final IAlleleSpecies species : branch.getMemberSpecies()) {
|
||||
if (this.isSpeciesDiscovered(species, tracker)) {
|
||||
discovered = true;
|
||||
}
|
||||
}
|
||||
if (discovered) {
|
||||
branches.add(branch);
|
||||
}
|
||||
}
|
||||
return branches;
|
||||
}
|
||||
|
||||
public final Collection<IAlleleSpecies> getDiscoveredSpecies(final World world, final GameProfile player) {
|
||||
final List<IAlleleSpecies> speciesList = new ArrayList<IAlleleSpecies>();
|
||||
for (final IAlleleSpecies species : this.getAllSpecies()) {
|
||||
if (this.isSpeciesDiscovered(species, world, player)) {
|
||||
speciesList.add(species);
|
||||
}
|
||||
}
|
||||
return speciesList;
|
||||
}
|
||||
|
||||
public final Collection<IAlleleSpecies> getDiscoveredSpecies(final IBreedingTracker tracker) {
|
||||
final List<IAlleleSpecies> speciesList = new ArrayList<IAlleleSpecies>();
|
||||
for (final IAlleleSpecies species : this.getAllSpecies()) {
|
||||
if (this.isSpeciesDiscovered(species, tracker)) {
|
||||
speciesList.add(species);
|
||||
}
|
||||
}
|
||||
return speciesList;
|
||||
}
|
||||
|
||||
public final List<IMutation> getDiscoveredMutations(final World world, final GameProfile player) {
|
||||
final List<IMutation> speciesList = new ArrayList<IMutation>();
|
||||
for (final IMutation species : this.getAllMutations()) {
|
||||
if (this.isMutationDiscovered(species, world, player)) {
|
||||
speciesList.add(species);
|
||||
}
|
||||
}
|
||||
return speciesList;
|
||||
}
|
||||
|
||||
public final List<IMutation> getDiscoveredMutations(final IBreedingTracker tracker) {
|
||||
final List<IMutation> speciesList = new ArrayList<IMutation>();
|
||||
for (final IMutation species : this.getAllMutations()) {
|
||||
if (this.isMutationDiscovered(species, tracker)) {
|
||||
speciesList.add(species);
|
||||
}
|
||||
}
|
||||
return speciesList;
|
||||
}
|
||||
|
||||
public final int getDiscoveredBranchMembers(final IClassification branch, final IBreedingTracker tracker) {
|
||||
int discoveredSpecies = 0;
|
||||
for (final IAlleleSpecies species : branch.getMemberSpecies()) {
|
||||
if (this.isSpeciesDiscovered(species, tracker)) {
|
||||
++discoveredSpecies;
|
||||
}
|
||||
}
|
||||
return discoveredSpecies;
|
||||
}
|
||||
|
||||
public IIcon getUndiscoveredIcon() {
|
||||
return this.iconUndiscovered.getIcon();
|
||||
}
|
||||
|
||||
public IIcon getDiscoveredIcon() {
|
||||
return this.iconDiscovered.getIcon();
|
||||
}
|
||||
|
||||
public abstract float getChance(final IMutation p0, final EntityPlayer p1, final IAllele p2, final IAllele p3);
|
||||
|
||||
public abstract Class<? extends IBreedingTracker> getTrackerClass();
|
||||
|
||||
@SubscribeEvent
|
||||
public final void onSyncBreedingTracker(final ForestryEvent.SyncedBreedingTracker event) {
|
||||
final IBreedingTracker tracker = event.tracker;
|
||||
if (!this.getTrackerClass().isInstance(tracker)) {
|
||||
return;
|
||||
}
|
||||
this.syncTracker(tracker);
|
||||
}
|
||||
|
||||
public final void syncTracker(final IBreedingTracker tracker) {
|
||||
this.discoveredSpeciesPercentage = 0.0f;
|
||||
this.totalSpeciesCount = 0;
|
||||
this.discoveredSpeciesCount = 0;
|
||||
this.totalSecretCount = 0;
|
||||
this.discoveredSecretCount = 0;
|
||||
final Collection<IAlleleSpecies> discoveredSpecies = this.getDiscoveredSpecies(tracker);
|
||||
final Collection<IAlleleSpecies> allSpecies = this.getAllSpecies();
|
||||
for (final IAlleleSpecies species : allSpecies) {
|
||||
if (!this.isSecret(species)) {
|
||||
++this.totalSpeciesCount;
|
||||
if (!this.isSpeciesDiscovered(species, tracker)) {
|
||||
continue;
|
||||
}
|
||||
++this.discoveredSpeciesCount;
|
||||
}
|
||||
else {
|
||||
++this.totalSecretCount;
|
||||
if (!this.isSpeciesDiscovered(species, tracker)) {
|
||||
continue;
|
||||
}
|
||||
++this.discoveredSecretCount;
|
||||
}
|
||||
}
|
||||
this.discoveredBranchPercentage = 0.0f;
|
||||
this.totalBranchCount = 0;
|
||||
this.discoveredBranchCount = 0;
|
||||
final Collection<IClassification> discoveredBranches = this.getDiscoveredBranches(tracker);
|
||||
final Collection<IClassification> allBranches = this.getAllBranches();
|
||||
for (final IClassification branch : allBranches) {
|
||||
if (!this.isSecret(branch)) {
|
||||
++this.totalBranchCount;
|
||||
if (!discoveredBranches.contains(branch)) {
|
||||
continue;
|
||||
}
|
||||
++this.discoveredBranchCount;
|
||||
}
|
||||
else {
|
||||
++this.totalSecretBranchCount;
|
||||
if (!discoveredBranches.contains(branch)) {
|
||||
continue;
|
||||
}
|
||||
++this.discoveredSecretBranchCount;
|
||||
}
|
||||
}
|
||||
this.discoveredSpeciesPercentage = this.discoveredSpeciesCount / this.totalSpeciesCount;
|
||||
this.discoveredBranchPercentage = this.discoveredBranchCount / this.totalBranchCount;
|
||||
final String epithet = this.getEpitome();
|
||||
this.onSyncBreedingTracker(tracker);
|
||||
}
|
||||
|
||||
public void onSyncBreedingTracker(final IBreedingTracker tracker) {
|
||||
}
|
||||
|
||||
public String getEpitome() {
|
||||
return this.getEpitome(this.discoveredSpeciesPercentage);
|
||||
}
|
||||
|
||||
public final String getDescriptor() {
|
||||
return BinnieCore.proxy.localise(this.getSpeciesRoot().getUID() + ".descriptor");
|
||||
}
|
||||
|
||||
public final String getIdent() {
|
||||
return this.getSpeciesRoot().getUID();
|
||||
}
|
||||
|
||||
public final IChromosomeType getChromosome(final int i) {
|
||||
for (final IChromosomeType chromosome : this.getSpeciesRoot().getKaryotype()) {
|
||||
if (i == chromosome.ordinal()) {
|
||||
return chromosome;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract int getColour();
|
||||
|
||||
public String getAlleleName(final IChromosomeType chromosome, final IAllele allele) {
|
||||
if (allele instanceof IAlleleBoolean) {
|
||||
return ((IAlleleBoolean) allele).getValue() ? Binnie.Language.localise(BinnieCore.instance, "allele.true") : Binnie.Language.localise(BinnieCore.instance, "allele.false");
|
||||
}
|
||||
if (allele.getName() == "for.gui.maximum") {
|
||||
return Binnie.Language.localise(BinnieCore.instance, "allele.fertility.maximum");
|
||||
}
|
||||
return allele.getName();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return BinnieCore.proxy.localise(this.getSpeciesRoot().getUID() + ".shortName");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStackRepresentitive() {
|
||||
final IIndividual first = this.getSpeciesRoot().getIndividualTemplates().get(0);
|
||||
return this.getSpeciesRoot().getMemberStack(first, this.getDefaultType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getName();
|
||||
}
|
||||
|
||||
public abstract boolean isDNAManipulable(final ItemStack p0);
|
||||
|
||||
public IIndividual getConversion(final ItemStack stack) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final IIndividual getDefaultIndividual() {
|
||||
return this.getSpeciesRoot().templateAsIndividual(this.getSpeciesRoot().getDefaultTemplate());
|
||||
}
|
||||
|
||||
public final int getDefaultType() {
|
||||
return this.getActiveTypes()[0];
|
||||
}
|
||||
|
||||
public abstract int[] getActiveTypes();
|
||||
|
||||
public abstract void addExtraAlleles(final IChromosomeType p0, final TreeSet<IAllele> p1);
|
||||
|
||||
public ItemStack getConversionStack(final ItemStack stack) {
|
||||
return this.getSpeciesRoot().getMemberStack(this.getConversion(stack), this.getDefaultType());
|
||||
}
|
||||
|
||||
public final Collection<IChromosomeType> getActiveKaryotype() {
|
||||
return Binnie.Genetics.getActiveChromosomes(this.getSpeciesRoot());
|
||||
}
|
||||
|
||||
public ItemStack getDefaultMember(final String uid) {
|
||||
return this.getSpeciesRoot().getMemberStack(this.getIndividual(uid), this.getDefaultType());
|
||||
}
|
||||
|
||||
public IIndividual getIndividual(final String uid) {
|
||||
return this.getSpeciesRoot().templateAsIndividual(this.getSpeciesRoot().getTemplate(uid));
|
||||
}
|
||||
|
||||
public IGenome getGenome(final String uid) {
|
||||
return this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(uid));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.genetics;
|
||||
|
||||
public enum EnumBeeBooleanModifier
|
||||
{
|
||||
Sealed,
|
||||
SelfLighted,
|
||||
SunlightStimulated,
|
||||
Hellish;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.genetics;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.Binnie;
|
||||
|
||||
public enum EnumBeeModifier
|
||||
{
|
||||
Territory,
|
||||
Mutation,
|
||||
Lifespan,
|
||||
Production,
|
||||
Flowering,
|
||||
GeneticDecay;
|
||||
|
||||
public String getName() {
|
||||
return Binnie.Language.localise(BinnieCore.instance, "beemodifier." + this.name().toLowerCase());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.genetics;
|
||||
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import java.util.TreeSet;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import binnie.botany.api.EnumFlowerStage;
|
||||
import binnie.botany.api.IFlowerRoot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.botany.api.EnumFlowerChromosome;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import binnie.botany.api.IBotanistTracker;
|
||||
import forestry.api.genetics.IBreedingTracker;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import binnie.botany.api.IFlowerMutation;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import forestry.api.genetics.IMutation;
|
||||
import binnie.extrabees.ExtraBees;
|
||||
import binnie.Binnie;
|
||||
|
||||
class FlowerBreedingSystem extends BreedingSystem
|
||||
{
|
||||
public FlowerBreedingSystem() {
|
||||
this.iconUndiscovered = Binnie.Resource.getItemIcon(ExtraBees.instance, "icon/undiscoveredBee");
|
||||
this.iconDiscovered = Binnie.Resource.getItemIcon(ExtraBees.instance, "icon/discoveredBee");
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getChance(final IMutation mutation, final EntityPlayer player, final IAllele species1, final IAllele species2) {
|
||||
return ((IFlowerMutation) mutation).getBaseChance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISpeciesRoot getSpeciesRoot() {
|
||||
return Binnie.Genetics.getFlowerRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColour() {
|
||||
return 14563127;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends IBreedingTracker> getTrackerClass() {
|
||||
return IBotanistTracker.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAlleleName(final IChromosomeType chromosome, final IAllele allele) {
|
||||
if (chromosome == EnumFlowerChromosome.FERTILITY) {
|
||||
if (allele.getUID().contains("Low")) {
|
||||
return Binnie.Language.localise(BinnieCore.instance, "allele.fertility.low");
|
||||
}
|
||||
if (allele.getUID().contains("Normal")) {
|
||||
return Binnie.Language.localise(BinnieCore.instance, "allele.fertility.normal");
|
||||
}
|
||||
if (allele.getUID().contains("High")) {
|
||||
return Binnie.Language.localise(BinnieCore.instance, "allele.fertility.high");
|
||||
}
|
||||
if (allele.getUID().contains("Maximum")) {
|
||||
return Binnie.Language.localise(BinnieCore.instance, "allele.fertility.maximum");
|
||||
}
|
||||
}
|
||||
return super.getAlleleName(chromosome, allele);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDNAManipulable(final ItemStack member) {
|
||||
return ((IFlowerRoot) this.getSpeciesRoot()).getStageType(member) == EnumFlowerStage.POLLEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndividual getConversion(final ItemStack stack) {
|
||||
return BotanyCore.getFlowerRoot().getConversion(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getActiveTypes() {
|
||||
return new int[] { EnumFlowerStage.FLOWER.ordinal(), EnumFlowerStage.POLLEN.ordinal(), EnumFlowerStage.SEED.ordinal() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addExtraAlleles(final IChromosomeType chromosome, final TreeSet<IAllele> alleles) {
|
||||
switch ((EnumFlowerChromosome) chromosome) {
|
||||
case FERTILITY: {
|
||||
for (final ForestryAllele.Fertility a : ForestryAllele.Fertility.values()) {
|
||||
alleles.add(a.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LIFESPAN: {
|
||||
for (final ForestryAllele.Lifespan a2 : ForestryAllele.Lifespan.values()) {
|
||||
alleles.add(a2.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case HUMIDITY_TOLERANCE:
|
||||
case PH_TOLERANCE:
|
||||
case TEMPERATURE_TOLERANCE: {
|
||||
for (final Tolerance a3 : Tolerance.values()) {
|
||||
alleles.add(a3.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PRIMARY:
|
||||
case SECONDARY:
|
||||
case STEM: {
|
||||
for (final EnumFlowerColor a4 : EnumFlowerColor.values()) {
|
||||
alleles.add(a4.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SAPPINESS: {
|
||||
for (final ForestryAllele.Sappiness a5 : ForestryAllele.Sappiness.values()) {
|
||||
alleles.add(a5.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TERRITORY: {
|
||||
for (final ForestryAllele.Territory a6 : ForestryAllele.Territory.values()) {
|
||||
alleles.add(a6.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.genetics;
|
||||
|
||||
import binnie.Binnie;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
|
||||
public class ForestryAllele
|
||||
{
|
||||
public enum Lifespan
|
||||
{
|
||||
Shortest,
|
||||
Shorter,
|
||||
Short,
|
||||
Shortened,
|
||||
Normal,
|
||||
Elongated,
|
||||
Long,
|
||||
Longer,
|
||||
Longest;
|
||||
|
||||
public IAllele getAllele() {
|
||||
return AlleleManager.alleleRegistry.getAllele("forestry.lifespan" + this.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public enum Speed
|
||||
{
|
||||
Slowest,
|
||||
Slower,
|
||||
Slow,
|
||||
Norm,
|
||||
Fast,
|
||||
Faster,
|
||||
Fastest;
|
||||
|
||||
public IAllele getAllele() {
|
||||
return AlleleManager.alleleRegistry.getAllele("forestry.speed" + this.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public enum Fertility
|
||||
{
|
||||
Low,
|
||||
Normal,
|
||||
High,
|
||||
Maximum;
|
||||
|
||||
public IAllele getAllele() {
|
||||
return AlleleManager.alleleRegistry.getAllele("forestry.fertility" + this.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public enum Flowering
|
||||
{
|
||||
Slowest,
|
||||
Slower,
|
||||
Slow,
|
||||
Average,
|
||||
Fast,
|
||||
Faster,
|
||||
Fastest,
|
||||
Maximum;
|
||||
|
||||
public IAllele getAllele() {
|
||||
return AlleleManager.alleleRegistry.getAllele("forestry.flowering" + this.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public enum Territory
|
||||
{
|
||||
Default,
|
||||
Large,
|
||||
Larger,
|
||||
Largest;
|
||||
|
||||
public IAllele getAllele() {
|
||||
return AlleleManager.alleleRegistry.getAllele("forestry.territory" + this.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public enum Sappiness
|
||||
{
|
||||
Lowest,
|
||||
Lower,
|
||||
Low,
|
||||
Average,
|
||||
High,
|
||||
Higher,
|
||||
Highest;
|
||||
|
||||
public IAllele getAllele() {
|
||||
return AlleleManager.alleleRegistry.getAllele("forestry.sappiness" + this.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public enum TreeHeight
|
||||
{
|
||||
Smallest,
|
||||
Smaller,
|
||||
Small,
|
||||
Average,
|
||||
Large,
|
||||
Larger,
|
||||
Largest,
|
||||
Gigantic;
|
||||
|
||||
public IAllele getAllele() {
|
||||
return AlleleManager.alleleRegistry.getAllele("forestry.height" + ((this == TreeHeight.Average) ? "Max10" : this.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public enum Size
|
||||
{
|
||||
Smallest,
|
||||
Smaller,
|
||||
Small,
|
||||
Average,
|
||||
Large,
|
||||
Larger,
|
||||
Largest;
|
||||
|
||||
public IAllele getAllele() {
|
||||
return AlleleManager.alleleRegistry.getAllele("forestry.size" + this.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public enum Saplings
|
||||
{
|
||||
Lowest,
|
||||
Lower,
|
||||
Low,
|
||||
Average,
|
||||
High,
|
||||
Higher,
|
||||
Highest;
|
||||
|
||||
public IAllele getAllele() {
|
||||
String s = this.toString();
|
||||
if (this == Saplings.Average) {
|
||||
s = "Default";
|
||||
}
|
||||
if (this == Saplings.High) {
|
||||
s = "Double";
|
||||
}
|
||||
if (this == Saplings.Higher) {
|
||||
s = "Triple";
|
||||
}
|
||||
return AlleleManager.alleleRegistry.getAllele("forestry.saplings" + s);
|
||||
}
|
||||
}
|
||||
|
||||
public enum Yield
|
||||
{
|
||||
Lowest,
|
||||
Lower,
|
||||
Low,
|
||||
Average,
|
||||
High,
|
||||
Higher,
|
||||
Highest;
|
||||
|
||||
public IAllele getAllele() {
|
||||
return AlleleManager.alleleRegistry.getAllele("forestry.yield" + ((this == Yield.Average) ? "Default" : this.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public enum Maturation
|
||||
{
|
||||
Slowest,
|
||||
Slower,
|
||||
Slow,
|
||||
Average,
|
||||
Fast,
|
||||
Faster,
|
||||
Fastest;
|
||||
|
||||
public IAllele getAllele() {
|
||||
return AlleleManager.alleleRegistry.getAllele("forestry.maturation" + this.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public enum Bool
|
||||
{
|
||||
True,
|
||||
False;
|
||||
|
||||
public IAllele getAllele() {
|
||||
return AlleleManager.alleleRegistry.getAllele("forestry.bool" + this.toString());
|
||||
}
|
||||
|
||||
public static IAllele get(final boolean bool) {
|
||||
return (bool ? Bool.True : Bool.False).getAllele();
|
||||
}
|
||||
}
|
||||
|
||||
public enum Growth
|
||||
{
|
||||
Tropical;
|
||||
|
||||
public IAllele getAllele() {
|
||||
return AlleleManager.alleleRegistry.getAllele("forestry.growth" + this.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public enum Int
|
||||
{
|
||||
Int1,
|
||||
Int2,
|
||||
Int3,
|
||||
Int4,
|
||||
Int5,
|
||||
Int6,
|
||||
Int7,
|
||||
Int8,
|
||||
Int9,
|
||||
Int10;
|
||||
|
||||
public IAllele getAllele() {
|
||||
return AlleleManager.alleleRegistry.getAllele("forestry.i" + (this.ordinal() + 1) + "d");
|
||||
}
|
||||
}
|
||||
|
||||
public enum BeeSpecies
|
||||
{
|
||||
Modest,
|
||||
Noble,
|
||||
Forest,
|
||||
Rural,
|
||||
Marshy,
|
||||
Sinister,
|
||||
Tropical,
|
||||
Wintry,
|
||||
Merry,
|
||||
Austere,
|
||||
Imperial,
|
||||
Ended,
|
||||
Meadows,
|
||||
Common,
|
||||
Frugal,
|
||||
Unweary,
|
||||
Diligent,
|
||||
Majestic,
|
||||
Cultivated,
|
||||
Industrious,
|
||||
Valiant,
|
||||
Secluded,
|
||||
Hermitic,
|
||||
Spectral,
|
||||
Exotic,
|
||||
Fiendish,
|
||||
Monastic,
|
||||
Steadfast,
|
||||
Miry,
|
||||
Farmerly,
|
||||
Boggy,
|
||||
Demonic;
|
||||
|
||||
public IAlleleBeeSpecies getAllele() {
|
||||
return (IAlleleBeeSpecies) AlleleManager.alleleRegistry.getAllele("forestry.species" + this.toString());
|
||||
}
|
||||
|
||||
public IAllele[] getTemplate() {
|
||||
return Binnie.Genetics.getBeeRoot().getTemplate(this.getAllele().getUID());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.genetics;
|
||||
|
||||
import binnie.Binnie;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import binnie.genetics.api.IGene;
|
||||
import forestry.api.core.INBTTagable;
|
||||
|
||||
public class Gene implements INBTTagable, IGene
|
||||
{
|
||||
private IAllele allele;
|
||||
private IChromosomeType chromosome;
|
||||
private ISpeciesRoot root;
|
||||
|
||||
@Override
|
||||
public ISpeciesRoot getSpeciesRoot() {
|
||||
return this.root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getAlleleName();
|
||||
}
|
||||
|
||||
public Gene(final IAllele allele, final IChromosomeType chromosome, final ISpeciesRoot root) {
|
||||
this.allele = allele;
|
||||
this.chromosome = chromosome;
|
||||
this.root = root;
|
||||
}
|
||||
|
||||
public Gene(final NBTTagCompound nbt) {
|
||||
this.readFromNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound nbt) {
|
||||
this.allele = AlleleManager.alleleRegistry.getAllele(nbt.getString("allele"));
|
||||
this.root = AlleleManager.alleleRegistry.getSpeciesRoot(nbt.getString("root"));
|
||||
final int chromoID = nbt.getByte("chromo");
|
||||
if (this.root != null && chromoID >= 0 && chromoID < this.root.getKaryotype().length) {
|
||||
this.chromosome = this.root.getKaryotype()[chromoID];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound nbt) {
|
||||
nbt.setString("allele", this.allele.getUID());
|
||||
nbt.setString("root", this.root.getUID());
|
||||
nbt.setByte("chromo", (byte) this.chromosome.ordinal());
|
||||
}
|
||||
|
||||
public boolean isCorrupted() {
|
||||
return this.allele == null || this.chromosome == null || this.root == null;
|
||||
}
|
||||
|
||||
public static Gene create(final NBTTagCompound nbt) {
|
||||
final Gene gene = new Gene(nbt);
|
||||
return gene.isCorrupted() ? null : gene;
|
||||
}
|
||||
|
||||
public static Gene create(final IAllele allele, final IChromosomeType chromosome, final ISpeciesRoot root) {
|
||||
final Gene gene = new Gene(allele, chromosome, root);
|
||||
return gene.isCorrupted() ? null : gene;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTTagCompound() {
|
||||
final NBTTagCompound nbt = new NBTTagCompound();
|
||||
this.writeToNBT(nbt);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return Binnie.Genetics.getSystem(this.root).getAlleleName(this.chromosome, this.allele);
|
||||
}
|
||||
|
||||
public BreedingSystem getSystem() {
|
||||
return Binnie.Genetics.getSystem(this.root);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChromosomeType getChromosome() {
|
||||
return this.chromosome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAllele getAllele() {
|
||||
return this.allele;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (!(obj instanceof Gene)) {
|
||||
return false;
|
||||
}
|
||||
final Gene g = (Gene) obj;
|
||||
return this.allele == g.allele && this.chromosome.ordinal() == g.chromosome.ordinal() && this.root == g.root;
|
||||
}
|
||||
|
||||
public String getAlleleName() {
|
||||
return this.getSystem().getAlleleName(this.chromosome, this.allele);
|
||||
}
|
||||
|
||||
public String getChromosomeName() {
|
||||
return this.getSystem().getChromosomeName(this.chromosome);
|
||||
}
|
||||
|
||||
public String getShortChromosomeName() {
|
||||
return this.getSystem().getChromosomeShortName(this.chromosome);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.genetics;
|
||||
|
||||
import forestry.api.genetics.IAllele;
|
||||
|
||||
public interface IAlleleProvider
|
||||
{
|
||||
IAllele getAllele();
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.genetics;
|
||||
|
||||
import forestry.api.genetics.IClassification;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.Binnie;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
interface IBreedingMessage
|
||||
{
|
||||
String getTitle();
|
||||
|
||||
String getBody();
|
||||
|
||||
ItemStack getIcon();
|
||||
|
||||
public static class MessageSpeciesDiscovered implements IBreedingMessage
|
||||
{
|
||||
IAlleleSpecies species;
|
||||
ItemStack stack;
|
||||
|
||||
public MessageSpeciesDiscovered(final IAlleleSpecies species) {
|
||||
this.species = species;
|
||||
ISpeciesRoot root = null;
|
||||
for (final ISpeciesRoot sRoot : AlleleManager.alleleRegistry.getSpeciesRoot().values()) {
|
||||
if (sRoot.getKaryotype()[0].getAlleleClass().isInstance(species)) {
|
||||
root = sRoot;
|
||||
}
|
||||
}
|
||||
if (root != null) {
|
||||
this.stack = root.getMemberStack(root.templateAsIndividual(root.getTemplate(species.getUID())), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return Binnie.Language.localise(BinnieCore.instance, "gui.breedingmessage.species");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBody() {
|
||||
return this.species.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getIcon() {
|
||||
return this.stack;
|
||||
}
|
||||
}
|
||||
|
||||
public static class BranchDiscovered implements IBreedingMessage
|
||||
{
|
||||
IAlleleSpecies species;
|
||||
IClassification classification;
|
||||
ItemStack stack;
|
||||
|
||||
public BranchDiscovered(final IAlleleSpecies species, final IClassification classification) {
|
||||
this.species = species;
|
||||
this.classification = classification;
|
||||
ISpeciesRoot root = null;
|
||||
for (final ISpeciesRoot sRoot : AlleleManager.alleleRegistry.getSpeciesRoot().values()) {
|
||||
if (sRoot.getKaryotype()[0].getAlleleClass().isInstance(species)) {
|
||||
root = sRoot;
|
||||
}
|
||||
}
|
||||
if (root != null) {
|
||||
this.stack = root.getMemberStack(root.templateAsIndividual(root.getTemplate(species.getUID())), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return Binnie.Language.localise(BinnieCore.instance, "gui.breedingmessage.branch");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBody() {
|
||||
return this.classification.getScientific();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getIcon() {
|
||||
return this.stack;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EpithetGained implements IBreedingMessage
|
||||
{
|
||||
String epithet;
|
||||
ItemStack stack;
|
||||
|
||||
public EpithetGained(final String epithet, final ISpeciesRoot root) {
|
||||
this.epithet = epithet;
|
||||
this.stack = root.getMemberStack(root.templateAsIndividual(root.getDefaultTemplate()), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return Binnie.Language.localise(BinnieCore.instance, "gui.breedingmessage.epithet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBody() {
|
||||
return this.epithet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getIcon() {
|
||||
return this.stack;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.genetics;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IItemStackRepresentitive
|
||||
{
|
||||
ItemStack getItemStackRepresentitive();
|
||||
}
|
||||
@@ -0,0 +1,230 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.genetics;
|
||||
|
||||
import binnie.botany.genetics.AlleleColor;
|
||||
import forestry.api.genetics.IAlleleInteger;
|
||||
import forestry.api.genetics.IAlleleFloat;
|
||||
import forestry.api.genetics.IGenome;
|
||||
import java.util.Comparator;
|
||||
import java.util.TreeSet;
|
||||
import binnie.Binnie;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import java.util.Collection;
|
||||
import forestry.api.genetics.EnumTolerance;
|
||||
import binnie.botany.api.IFlowerRoot;
|
||||
import forestry.api.lepidopterology.IButterflyRoot;
|
||||
import forestry.api.apiculture.IBeeRoot;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.arboriculture.ITreeRoot;
|
||||
import net.minecraft.world.World;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import binnie.core.BinnieCore;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import java.util.List;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import java.util.Map;
|
||||
import binnie.core.ManagerBase;
|
||||
|
||||
public class ManagerGenetics extends ManagerBase
|
||||
{
|
||||
public BreedingSystem beeBreedingSystem;
|
||||
public BreedingSystem treeBreedingSystem;
|
||||
public BreedingSystem mothBreedingSystem;
|
||||
public BreedingSystem flowerBreedingSystem;
|
||||
private final Map<ISpeciesRoot, BreedingSystem> BREEDING_SYSTEMS;
|
||||
private List<IChromosomeType> invalidChromosomeTypes;
|
||||
private Map<ISpeciesRoot, Map<IChromosomeType, List<IAllele>>> chromosomeArray;
|
||||
|
||||
public ManagerGenetics() {
|
||||
this.BREEDING_SYSTEMS = new LinkedHashMap<ISpeciesRoot, BreedingSystem>();
|
||||
this.invalidChromosomeTypes = new ArrayList<IChromosomeType>();
|
||||
this.chromosomeArray = new LinkedHashMap<ISpeciesRoot, Map<IChromosomeType, List<IAllele>>>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
if (BinnieCore.isApicultureActive()) {
|
||||
this.beeBreedingSystem = new BeeBreedingSystem();
|
||||
}
|
||||
if (BinnieCore.isArboricultureActive()) {
|
||||
this.treeBreedingSystem = new TreeBreedingSystem();
|
||||
}
|
||||
if (BinnieCore.isLepidopteryActive()) {
|
||||
this.mothBreedingSystem = new MothBreedingSystem();
|
||||
}
|
||||
if (BinnieCore.isBotanyActive()) {
|
||||
this.flowerBreedingSystem = new FlowerBreedingSystem();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
this.refreshData();
|
||||
}
|
||||
|
||||
public boolean isSpeciesDiscovered(final IAlleleSpecies species, final World world, final boolean nei) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public ITreeRoot getTreeRoot() {
|
||||
return (ITreeRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees");
|
||||
}
|
||||
|
||||
public IBeeRoot getBeeRoot() {
|
||||
return (IBeeRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootBees");
|
||||
}
|
||||
|
||||
public IButterflyRoot getButterflyRoot() {
|
||||
return (IButterflyRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootButterflies");
|
||||
}
|
||||
|
||||
public IFlowerRoot getFlowerRoot() {
|
||||
return (IFlowerRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootFlowers");
|
||||
}
|
||||
|
||||
public BreedingSystem getSystem(final String string) {
|
||||
for (final BreedingSystem system : this.BREEDING_SYSTEMS.values()) {
|
||||
if (system.getIdent().equals(string)) {
|
||||
return system;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public BreedingSystem getSystem(final ISpeciesRoot root) {
|
||||
return this.getSystem(root.getUID());
|
||||
}
|
||||
|
||||
public ISpeciesRoot getSpeciesRoot(final IAlleleSpecies species) {
|
||||
for (final ISpeciesRoot root : AlleleManager.alleleRegistry.getSpeciesRoot().values()) {
|
||||
if (root.getKaryotype()[0].getAlleleClass().isInstance(species)) {
|
||||
return root;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public IAllele getToleranceAllele(final EnumTolerance tol) {
|
||||
return AlleleManager.alleleRegistry.getAllele(Tolerance.values()[tol.ordinal()].getUID());
|
||||
}
|
||||
|
||||
public int[] getTolerance(final EnumTolerance tol) {
|
||||
return Tolerance.values()[tol.ordinal()].getBounds();
|
||||
}
|
||||
|
||||
public Collection<BreedingSystem> getActiveSystems() {
|
||||
return this.BREEDING_SYSTEMS.values();
|
||||
}
|
||||
|
||||
public void registerBreedingSystem(final BreedingSystem system) {
|
||||
this.BREEDING_SYSTEMS.put(system.getSpeciesRoot(), system);
|
||||
}
|
||||
|
||||
public BreedingSystem getConversionSystem(final ItemStack stack) {
|
||||
for (final BreedingSystem system : this.getActiveSystems()) {
|
||||
if (system.getConversion(stack) != null) {
|
||||
return system;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack getConversionStack(final ItemStack stack) {
|
||||
final BreedingSystem system = this.getConversionSystem(stack);
|
||||
return (system == null) ? null : system.getConversionStack(stack);
|
||||
}
|
||||
|
||||
public IIndividual getConversion(final ItemStack stack) {
|
||||
final BreedingSystem system = this.getConversionSystem(stack);
|
||||
return (system == null) ? null : system.getConversion(stack);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onWorldLoad(final WorldEvent.Load event) {
|
||||
this.refreshData();
|
||||
}
|
||||
|
||||
private void refreshData() {
|
||||
this.loadAlleles();
|
||||
for (final BreedingSystem system : Binnie.Genetics.getActiveSystems()) {
|
||||
system.calculateArrays();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadAlleles() {
|
||||
this.invalidChromosomeTypes.clear();
|
||||
for (final ISpeciesRoot root : AlleleManager.alleleRegistry.getSpeciesRoot().values()) {
|
||||
final BreedingSystem system = this.getSystem(root);
|
||||
final Map<IChromosomeType, List<IAllele>> chromosomeMap = new LinkedHashMap<IChromosomeType, List<IAllele>>();
|
||||
for (final IChromosomeType chromosome : root.getKaryotype()) {
|
||||
final TreeSet<IAllele> alleles = new TreeSet<IAllele>(new ComparatorAllele());
|
||||
for (final IIndividual individual : root.getIndividualTemplates()) {
|
||||
final IGenome genome = individual.getGenome();
|
||||
try {
|
||||
final IAllele a1 = genome.getActiveAllele(chromosome);
|
||||
final IAllele a2 = genome.getInactiveAllele(chromosome);
|
||||
if (chromosome.getAlleleClass().isInstance(a1)) {
|
||||
alleles.add(a1);
|
||||
}
|
||||
if (!chromosome.getAlleleClass().isInstance(a2)) {
|
||||
continue;
|
||||
}
|
||||
alleles.add(a2);
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
system.addExtraAlleles(chromosome, alleles);
|
||||
if (alleles.size() == 0) {
|
||||
this.invalidChromosomeTypes.add(chromosome);
|
||||
}
|
||||
else {
|
||||
final List<IAllele> alleleList = new ArrayList<IAllele>();
|
||||
alleleList.addAll(alleles);
|
||||
chromosomeMap.put(chromosome, alleleList);
|
||||
}
|
||||
}
|
||||
this.chromosomeArray.put(root, chromosomeMap);
|
||||
}
|
||||
}
|
||||
|
||||
public Map<IChromosomeType, List<IAllele>> getChromosomeMap(final ISpeciesRoot root) {
|
||||
return this.chromosomeArray.get(root);
|
||||
}
|
||||
|
||||
public Collection<IChromosomeType> getActiveChromosomes(final ISpeciesRoot root) {
|
||||
return this.getChromosomeMap(root).keySet();
|
||||
}
|
||||
|
||||
public boolean isInvalidChromosome(final IChromosomeType type) {
|
||||
return this.invalidChromosomeTypes.contains(type);
|
||||
}
|
||||
|
||||
static class ComparatorAllele implements Comparator<IAllele>
|
||||
{
|
||||
@Override
|
||||
public int compare(final IAllele o1, final IAllele o2) {
|
||||
if (o1 == null || o2 == null) {
|
||||
throw new NullPointerException("Allele is null!");
|
||||
}
|
||||
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 && !(o1 instanceof AlleleColor)) {
|
||||
return Integer.valueOf(((IAlleleInteger) o1).getValue()).compareTo(Integer.valueOf(((IAlleleInteger) o2).getValue()));
|
||||
}
|
||||
if (o1.getName() != null && o2.getName() != null) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
return o1.getUID().compareTo(o2.getUID());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.genetics;
|
||||
|
||||
import java.util.TreeSet;
|
||||
import forestry.api.lepidopterology.EnumFlutterType;
|
||||
import forestry.api.lepidopterology.IButterflyRoot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.core.BinnieCore;
|
||||
import forestry.api.genetics.IAlleleInteger;
|
||||
import forestry.api.lepidopterology.EnumButterflyChromosome;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.lepidopterology.ILepidopteristTracker;
|
||||
import forestry.api.genetics.IBreedingTracker;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import forestry.api.genetics.IMutation;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.Binnie;
|
||||
|
||||
class MothBreedingSystem extends BreedingSystem
|
||||
{
|
||||
public MothBreedingSystem() {
|
||||
this.iconUndiscovered = Binnie.Resource.getItemIcon(ExtraTrees.instance, "icon/undiscoveredMoth");
|
||||
this.iconDiscovered = Binnie.Resource.getItemIcon(ExtraTrees.instance, "icon/discoveredMoth");
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getChance(final IMutation mutation, final EntityPlayer player, final IAllele species1, final IAllele species2) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISpeciesRoot getSpeciesRoot() {
|
||||
return Binnie.Genetics.getButterflyRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColour() {
|
||||
return 62194;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends IBreedingTracker> getTrackerClass() {
|
||||
return ILepidopteristTracker.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAlleleName(final IChromosomeType chromosome, final IAllele allele) {
|
||||
if (chromosome == EnumButterflyChromosome.METABOLISM) {
|
||||
final int metabolism = ((IAlleleInteger) allele).getValue();
|
||||
if (metabolism >= 19) {
|
||||
return Binnie.Language.localise(BinnieCore.instance, "allele.metabolism.highest");
|
||||
}
|
||||
if (metabolism >= 16) {
|
||||
return Binnie.Language.localise(BinnieCore.instance, "allele.metabolism.higher");
|
||||
}
|
||||
if (metabolism >= 13) {
|
||||
return Binnie.Language.localise(BinnieCore.instance, "allele.metabolism.high");
|
||||
}
|
||||
if (metabolism >= 10) {
|
||||
return Binnie.Language.localise(BinnieCore.instance, "allele.metabolism.normal");
|
||||
}
|
||||
if (metabolism >= 7) {
|
||||
return Binnie.Language.localise(BinnieCore.instance, "allele.metabolism.slow");
|
||||
}
|
||||
if (metabolism >= 4) {
|
||||
return Binnie.Language.localise(BinnieCore.instance, "allele.metabolism.slower");
|
||||
}
|
||||
return Binnie.Language.localise(BinnieCore.instance, "allele.metabolism.slowest");
|
||||
}
|
||||
else {
|
||||
if (chromosome == EnumButterflyChromosome.FERTILITY) {
|
||||
final int metabolism = ((IAlleleInteger) allele).getValue();
|
||||
return metabolism + "x";
|
||||
}
|
||||
return super.getAlleleName(chromosome, allele);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDNAManipulable(final ItemStack member) {
|
||||
return ((IButterflyRoot) this.getSpeciesRoot()).getType(member) == EnumFlutterType.SERUM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getActiveTypes() {
|
||||
return new int[] { EnumFlutterType.BUTTERFLY.ordinal(), EnumFlutterType.CATERPILLAR.ordinal(), EnumFlutterType.SERUM.ordinal() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addExtraAlleles(final IChromosomeType chromosome, final TreeSet<IAllele> alleles) {
|
||||
switch ((EnumButterflyChromosome) chromosome) {
|
||||
case FERTILITY: {
|
||||
for (final ForestryAllele.Int a : ForestryAllele.Int.values()) {
|
||||
alleles.add(a.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LIFESPAN: {
|
||||
for (final ForestryAllele.Lifespan a2 : ForestryAllele.Lifespan.values()) {
|
||||
alleles.add(a2.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case METABOLISM: {
|
||||
for (final ForestryAllele.Int a : ForestryAllele.Int.values()) {
|
||||
alleles.add(a.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TOLERANT_FLYER:
|
||||
case FIRE_RESIST:
|
||||
case NOCTURNAL: {
|
||||
for (final ForestryAllele.Bool a3 : ForestryAllele.Bool.values()) {
|
||||
alleles.add(a3.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SIZE: {
|
||||
for (final ForestryAllele.Size a4 : ForestryAllele.Size.values()) {
|
||||
alleles.add(a4.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SPEED: {
|
||||
for (final ForestryAllele.Speed a5 : ForestryAllele.Speed.values()) {
|
||||
alleles.add(a5.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case HUMIDITY_TOLERANCE:
|
||||
case TEMPERATURE_TOLERANCE: {
|
||||
for (final Tolerance a6 : Tolerance.values()) {
|
||||
alleles.add(a6.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.genetics;
|
||||
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.EnumTolerance;
|
||||
|
||||
public enum Tolerance
|
||||
{
|
||||
None(0, 0),
|
||||
Both1(-1, 1),
|
||||
Both2(-2, 2),
|
||||
Both3(-3, 3),
|
||||
Both4(-4, 4),
|
||||
Both5(-5, 5),
|
||||
Up1(0, 1),
|
||||
Up2(0, 2),
|
||||
Up3(0, 3),
|
||||
Up4(0, 4),
|
||||
Up5(0, 5),
|
||||
Down1(-1, 0),
|
||||
Down2(-2, 0),
|
||||
Down3(-3, 0),
|
||||
Down4(-4, 0),
|
||||
Down5(-5, 0);
|
||||
|
||||
private int[] bounds;
|
||||
|
||||
private Tolerance(final int a, final int b) {
|
||||
this.bounds = new int[] { a, b };
|
||||
}
|
||||
|
||||
public String getUID() {
|
||||
return "forestry.tolerance" + this.toString();
|
||||
}
|
||||
|
||||
public int[] getBounds() {
|
||||
return this.bounds;
|
||||
}
|
||||
|
||||
public static Tolerance get(final EnumTolerance tol) {
|
||||
return values()[tol.ordinal()];
|
||||
}
|
||||
|
||||
public IAllele getAllele() {
|
||||
return AlleleManager.alleleRegistry.getAllele(this.getUID());
|
||||
}
|
||||
|
||||
public <T extends Enum<T>> boolean canTolerate(final T base, final T test) {
|
||||
return test.ordinal() <= base.ordinal() + this.bounds[1] && test.ordinal() >= base.ordinal() + this.bounds[0];
|
||||
}
|
||||
|
||||
public static <T extends Enum<T>> boolean canTolerate(final T base, final T test, final EnumTolerance tol) {
|
||||
return get(tol).canTolerate(base, test);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,335 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.genetics;
|
||||
|
||||
import java.util.TreeSet;
|
||||
import java.util.Map;
|
||||
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.arboriculture.EnumGermlingType;
|
||||
import forestry.api.arboriculture.ITreeRoot;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import binnie.extratrees.machines.Lumbermill;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.genetics.IFruitFamily;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.arboriculture.ITreeGenome;
|
||||
import forestry.api.arboriculture.IAlleleTreeSpecies;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.arboriculture.IFruitProvider;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import forestry.api.arboriculture.IAlleleFruit;
|
||||
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import forestry.api.genetics.IAllelePlantType;
|
||||
import forestry.api.genetics.IAlleleInteger;
|
||||
import forestry.api.arboriculture.EnumTreeChromosome;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.arboriculture.IArboristTracker;
|
||||
import forestry.api.genetics.IBreedingTracker;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.api.arboriculture.ITreeMutation;
|
||||
import forestry.api.genetics.IAllele;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import forestry.api.genetics.IMutation;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.FakeWorld;
|
||||
import binnie.Binnie;
|
||||
import binnie.core.util.UniqueItemStackSet;
|
||||
|
||||
public class TreeBreedingSystem extends BreedingSystem
|
||||
{
|
||||
public UniqueItemStackSet allFruits;
|
||||
public UniqueItemStackSet allWoods;
|
||||
private UniqueItemStackSet discoveredFruits;
|
||||
private UniqueItemStackSet discoveredWoods;
|
||||
public UniqueItemStackSet discoveredPlanks;
|
||||
|
||||
public TreeBreedingSystem() {
|
||||
this.allFruits = new UniqueItemStackSet();
|
||||
this.allWoods = new UniqueItemStackSet();
|
||||
this.discoveredFruits = new UniqueItemStackSet();
|
||||
this.discoveredWoods = new UniqueItemStackSet();
|
||||
this.discoveredPlanks = new UniqueItemStackSet();
|
||||
this.iconUndiscovered = Binnie.Resource.getItemIcon(ExtraTrees.instance, "icon/undiscoveredTree");
|
||||
this.iconDiscovered = Binnie.Resource.getItemIcon(ExtraTrees.instance, "icon/discoveredTree");
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getChance(final IMutation mutation, final EntityPlayer player, final IAllele species1, final IAllele species2) {
|
||||
final ITreeGenome genome0 = (ITreeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(species1.getUID()));
|
||||
final ITreeGenome genome2 = (ITreeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(species2.getUID()));
|
||||
return ((ITreeMutation) mutation).getChance(player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ, (IAlleleTreeSpecies) species1, (IAlleleTreeSpecies) species2, genome0, genome2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISpeciesRoot getSpeciesRoot() {
|
||||
return Binnie.Genetics.getTreeRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColour() {
|
||||
return 53006;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends IBreedingTracker> getTrackerClass() {
|
||||
return IArboristTracker.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAlleleName(final IChromosomeType chromosome, final IAllele allele) {
|
||||
if (chromosome == EnumTreeChromosome.GIRTH) {
|
||||
return ((IAlleleInteger) allele).getValue() + "x" + ((IAlleleInteger) allele).getValue();
|
||||
}
|
||||
if (chromosome == EnumTreeChromosome.PLANT) {
|
||||
final EnumSet<EnumPlantType> types = ((IAllelePlantType) allele).getPlantTypes();
|
||||
return types.isEmpty() ? Binnie.Language.localise(BinnieCore.instance, "allele.none") : types.iterator().next().toString();
|
||||
}
|
||||
if (chromosome == EnumTreeChromosome.FRUITS && allele.getUID().contains(".")) {
|
||||
final IFruitProvider provider = ((IAlleleFruit) allele).getProvider();
|
||||
return (provider.getProducts().length == 0) ? Binnie.Language.localise(BinnieCore.instance, "allele.none") : provider.getProducts()[0].getDisplayName();
|
||||
}
|
||||
if (chromosome == EnumTreeChromosome.GROWTH) {
|
||||
if (allele.getUID().contains("Tropical")) {
|
||||
return Binnie.Language.localise(BinnieCore.instance, "allele.growth.tropical");
|
||||
}
|
||||
if (allele.getUID().contains("Lightlevel")) {
|
||||
return Binnie.Language.localise(BinnieCore.instance, "allele.growth.lightlevel");
|
||||
}
|
||||
}
|
||||
return super.getAlleleName(chromosome, allele);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSyncBreedingTracker(final IBreedingTracker tracker) {
|
||||
this.discoveredFruits.clear();
|
||||
this.discoveredWoods.clear();
|
||||
for (final IAlleleSpecies species : this.getDiscoveredSpecies(tracker)) {
|
||||
final IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
|
||||
final ITreeGenome genome = (ITreeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(tSpecies.getUID()));
|
||||
|
||||
FakeWorld world = FakeWorld.instance;
|
||||
genome.getPrimary().getGenerator().setLogBlock(genome, world, 0, 0, 0, ForgeDirection.UP);
|
||||
final ItemStack wood = world.getWooLog();
|
||||
if (wood != null) {
|
||||
this.discoveredWoods.add(wood);
|
||||
}
|
||||
|
||||
// for (final ItemStack wood :
|
||||
// tSpecies.getRoot().templateAsIndividual(getSpeciesRoot().getTemplate(tSpecies.getUID())).getProduceList())
|
||||
// {
|
||||
// this.discoveredWoods.add(wood);
|
||||
// }
|
||||
for (final ItemStack fruit : genome.getFruitProvider().getProducts()) {
|
||||
this.discoveredFruits.add(fruit);
|
||||
}
|
||||
for (ItemStack wood2 : this.discoveredWoods) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void calculateArrays() {
|
||||
super.calculateArrays();
|
||||
for (final IAlleleSpecies species : this.allActiveSpecies) {
|
||||
final IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
|
||||
final ITreeGenome genome = (ITreeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(tSpecies.getUID()));
|
||||
|
||||
FakeWorld world = FakeWorld.instance;
|
||||
genome.getPrimary().getGenerator().setLogBlock(genome, world, 0, 0, 0, ForgeDirection.UP);
|
||||
final ItemStack wood = world.getWooLog();
|
||||
if (wood != null) {
|
||||
this.allWoods.add(wood);
|
||||
}
|
||||
|
||||
// for (final ItemStack wood :
|
||||
// tSpecies.getRoot().templateAsIndividual(getSpeciesRoot().getTemplate(tSpecies.getUID())).getProduceList())
|
||||
// {
|
||||
// this.allWoods.add(wood);
|
||||
// }
|
||||
for (final ItemStack fruit : genome.getFruitProvider().getProducts()) {
|
||||
this.allFruits.add(fruit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<IAlleleSpecies> getTreesThatBearFruit(final ItemStack fruit, final boolean nei, final World world, final GameProfile player) {
|
||||
final Collection<IAlleleSpecies> set = nei ? this.getAllSpecies() : this.getDiscoveredSpecies(world, player);
|
||||
final List<IAlleleSpecies> found = new ArrayList<IAlleleSpecies>();
|
||||
for (final IAlleleSpecies species : set) {
|
||||
final IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
|
||||
final ITreeGenome genome = (ITreeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(tSpecies.getUID()));
|
||||
for (final ItemStack fruit2 : genome.getFruitProvider().getProducts()) {
|
||||
if (fruit2.isItemEqual(fruit)) {
|
||||
found.add(species);
|
||||
}
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
public Collection<IAlleleSpecies> getTreesThatCanBearFruit(final ItemStack fruit, final boolean nei, final World world, final GameProfile player) {
|
||||
final Collection<IAlleleSpecies> set = nei ? this.getAllSpecies() : this.getDiscoveredSpecies(world, player);
|
||||
final List<IAlleleSpecies> found = new ArrayList<IAlleleSpecies>();
|
||||
final Set<IFruitFamily> providers = new HashSet<IFruitFamily>();
|
||||
for (final IAlleleSpecies species : set) {
|
||||
final IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
|
||||
final ITreeGenome genome = (ITreeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(tSpecies.getUID()));
|
||||
for (final ItemStack fruit2 : genome.getFruitProvider().getProducts()) {
|
||||
if (fruit2.isItemEqual(fruit)) {
|
||||
providers.add(genome.getFruitProvider().getFamily());
|
||||
}
|
||||
}
|
||||
}
|
||||
for (final IAlleleSpecies species : set) {
|
||||
final IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
|
||||
for (final IFruitFamily family : providers) {
|
||||
if (tSpecies.getSuitableFruit().contains(family)) {
|
||||
found.add(species);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
public Collection<IAlleleSpecies> getTreesThatHaveWood(final ItemStack fruit, final boolean nei, final World world, final GameProfile player) {
|
||||
final Collection<IAlleleSpecies> set = nei ? this.getAllSpecies() : this.getDiscoveredSpecies(world, player);
|
||||
final List<IAlleleSpecies> found = new ArrayList<IAlleleSpecies>();
|
||||
for (final IAlleleSpecies species : set) {
|
||||
IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
|
||||
ITreeGenome genome = TreeManager.treeRoot.templateAsGenome(TreeManager.treeRoot.getTemplate(tSpecies.getUID()));
|
||||
// for (final ItemStack fruit2 :
|
||||
// tSpecies.getRoot().getMember(fruit).getProduceList()){
|
||||
tSpecies.getGenerator().setLogBlock(genome, FakeWorld.instance, 0, 0, 0, ForgeDirection.UP);
|
||||
ItemStack fruit2 = FakeWorld.instance.getWooLog();
|
||||
if (fruit2.isItemEqual(fruit)) {
|
||||
found.add(species);
|
||||
// }
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
public Collection<IAlleleSpecies> getTreesThatMakePlanks(final ItemStack fruit, final boolean nei, final World world, final GameProfile player) {
|
||||
if (fruit == null) {
|
||||
return new ArrayList<IAlleleSpecies>();
|
||||
}
|
||||
final Collection<IAlleleSpecies> set = nei ? this.getAllSpecies() : this.getDiscoveredSpecies(world, player);
|
||||
final List<IAlleleSpecies> found = new ArrayList<IAlleleSpecies>();
|
||||
for (final IAlleleSpecies species : set) {
|
||||
final IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
|
||||
ITreeGenome genome = TreeManager.treeRoot.templateAsGenome(TreeManager.treeRoot.getTemplate(tSpecies.getUID()));
|
||||
tSpecies.getGenerator().setLogBlock(genome, FakeWorld.instance, 0, 0, 0, ForgeDirection.UP);
|
||||
ItemStack fruit2 = FakeWorld.instance.getWooLog();
|
||||
// for (final ItemStack fruit2 :
|
||||
// tSpecies.getRoot().getMember(fruit).getProduceList()) {
|
||||
if (Lumbermill.getPlankProduct(fruit2) != null && fruit.isItemEqual(Lumbermill.getPlankProduct(fruit2))) {
|
||||
found.add(species);
|
||||
}
|
||||
// }
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDNAManipulable(final ItemStack member) {
|
||||
return ((ITreeRoot) this.getSpeciesRoot()).getType(member) == EnumGermlingType.POLLEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndividual getConversion(final ItemStack stack) {
|
||||
if (stack == null) {
|
||||
return null;
|
||||
}
|
||||
for (final Map.Entry<ItemStack, IIndividual> entry : AlleleManager.ersatzSaplings.entrySet()) {
|
||||
if (ItemStack.areItemStacksEqual(stack, entry.getKey())) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getActiveTypes() {
|
||||
return new int[] { EnumGermlingType.SAPLING.ordinal(), EnumGermlingType.POLLEN.ordinal() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addExtraAlleles(final IChromosomeType chromosome, final TreeSet<IAllele> alleles) {
|
||||
switch ((EnumTreeChromosome) chromosome) {
|
||||
case FERTILITY: {
|
||||
for (final ForestryAllele.Saplings a : ForestryAllele.Saplings.values()) {
|
||||
alleles.add(a.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GIRTH: {
|
||||
for (final ForestryAllele.Int a2 : ForestryAllele.Int.values()) {
|
||||
alleles.add(a2.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case HEIGHT: {
|
||||
for (final ForestryAllele.TreeHeight a3 : ForestryAllele.TreeHeight.values()) {
|
||||
alleles.add(a3.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MATURATION: {
|
||||
for (final ForestryAllele.Maturation a4 : ForestryAllele.Maturation.values()) {
|
||||
alleles.add(a4.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SAPPINESS: {
|
||||
for (final ForestryAllele.Sappiness a5 : ForestryAllele.Sappiness.values()) {
|
||||
alleles.add(a5.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TERRITORY: {
|
||||
for (final ForestryAllele.Territory a6 : ForestryAllele.Territory.values()) {
|
||||
alleles.add(a6.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case YIELD: {
|
||||
for (final ForestryAllele.Yield a7 : ForestryAllele.Yield.values()) {
|
||||
alleles.add(a7.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FIREPROOF: {
|
||||
for (final ForestryAllele.Bool a8 : ForestryAllele.Bool.values()) {
|
||||
alleles.add(a8.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.genetics;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeHousingInventory;
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.apiculture.IBeekeepingLogic;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.apiculture.InventoryBeeHousing;
|
||||
import forestry.core.access.FakeAccessHandler;
|
||||
|
||||
public class VirtualBeeHousing extends VirtualHousing implements IBeeHousing, IBeeModifier
|
||||
{
|
||||
ArrayList<IBeeModifier> beeModifier = new ArrayList<IBeeModifier>();
|
||||
private InventoryBeeHousing beeInventory;
|
||||
|
||||
public VirtualBeeHousing(final EntityPlayer player) {
|
||||
super(player);
|
||||
beeModifier.add(this);
|
||||
beeInventory = new InventoryBeeHousing(12, FakeAccessHandler.getInstance());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTerritoryModifier(final IBeeGenome genome, final float currentModifier) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMutationModifier(final IBeeGenome genome, final IBeeGenome mate, final float currentModifier) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLifespanModifier(final IBeeGenome genome, final IBeeGenome mate, final float currentModifier) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProductionModifier(final IBeeGenome genome, final float currentModifier) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
public ItemStack getQueen() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack getDrone() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setQueen(final ItemStack itemstack) {
|
||||
}
|
||||
|
||||
public void setDrone(final ItemStack itemstack) {
|
||||
}
|
||||
|
||||
public boolean canBreed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addProduct(final ItemStack product, final boolean all) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void wearOutEquipment(final int amount) {
|
||||
}
|
||||
|
||||
public void onQueenChange(final ItemStack queen) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSealed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelfLighted() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSunlightSimulated() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHellish() {
|
||||
return this.getBiomeId() == BiomeGenBase.hell.biomeID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloweringModifier(final IBeeGenome genome, final float currentModifier) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
public void onQueenDeath(final IBee queen) {
|
||||
}
|
||||
|
||||
public void onPostQueenDeath(final IBee queen) {
|
||||
}
|
||||
|
||||
public boolean onPollenRetrieved(final IBee queen, final IIndividual pollen, final boolean isHandled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onEggLaid(final IBee queen) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGeneticDecay(final IBeeGenome genome, final float currentModifier) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IErrorLogic getErrorLogic() {
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO ??
|
||||
@Override
|
||||
public boolean canBlockSeeTheSky() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO ??
|
||||
@Override
|
||||
public Vec3 getBeeFXCoordinates() {
|
||||
return Vec3.createVectorHelper(0, -100000, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBeeHousingInventory getBeeInventory() {
|
||||
return beeInventory;
|
||||
}
|
||||
|
||||
// TODO ??
|
||||
@Override
|
||||
public Iterable<IBeeListener> getBeeListeners() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<IBeeModifier> getBeeModifiers() {
|
||||
return beeModifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBeekeepingLogic getBeekeepingLogic() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockLightValue() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfile getOwner() {
|
||||
return getOwnerName();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.genetics;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.core.IErrorState;
|
||||
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import forestry.api.genetics.IHousing;
|
||||
|
||||
class VirtualHousing implements IHousing
|
||||
{
|
||||
private EntityPlayer player;
|
||||
|
||||
public VirtualHousing(final EntityPlayer player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public int getXCoord() {
|
||||
return (int) this.player.posX;
|
||||
}
|
||||
|
||||
public int getYCoord() {
|
||||
return (int) this.player.posY;
|
||||
}
|
||||
|
||||
public int getZCoord() {
|
||||
return (int) this.player.posZ;
|
||||
}
|
||||
|
||||
public int getBiomeId() {
|
||||
return this.player.worldObj.getBiomeGenForCoords(this.getXCoord(), this.getYCoord()).biomeID;
|
||||
}
|
||||
|
||||
public EnumTemperature getTemperature() {
|
||||
return EnumTemperature.getFromValue(this.getBiome().temperature);
|
||||
}
|
||||
|
||||
public EnumHumidity getHumidity() {
|
||||
return EnumHumidity.getFromValue(this.getBiome().rainfall);
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return this.player.worldObj;
|
||||
}
|
||||
|
||||
public void setErrorState(final int state) {
|
||||
}
|
||||
|
||||
public int getErrorOrdinal() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean addProduct(final ItemStack product, final boolean all) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public GameProfile getOwnerName() {
|
||||
return this.player.getGameProfile();
|
||||
}
|
||||
|
||||
public BiomeGenBase getBiome() {
|
||||
return this.player.worldObj.getBiomeGenForCoords(this.getXCoord(), this.getZCoord());
|
||||
}
|
||||
|
||||
// public EnumErrorCode getErrorState() {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
public void setErrorState(final IErrorState state) {
|
||||
}
|
||||
|
||||
public boolean setErrorCondition(final boolean condition, final IErrorState errorState) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Set<IErrorState> getErrorStates() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkCoordinates getCoordinates() {
|
||||
return new ChunkCoordinates(getXCoord(), getYCoord(), getZCoord());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.genetics;
|
||||
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.lepidopterology.IButterfly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import forestry.api.lepidopterology.IButterflyNursery;
|
||||
|
||||
public class VirtualMothHousing extends VirtualHousing implements IButterflyNursery
|
||||
{
|
||||
public VirtualMothHousing(final EntityPlayer player) {
|
||||
super(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IButterfly getCaterpillar() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndividual getNanny() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCaterpillar(final IButterfly butterfly) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canNurse(final IButterfly butterfly) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.gui;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import binnie.craftgui.binniecore.WindowGenesis;
|
||||
import binnie.craftgui.binniecore.WindowFieldKit;
|
||||
import binnie.core.machines.storage.WindowCompartment;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public enum BinnieCoreGUI implements IBinnieGUID
|
||||
{
|
||||
Compartment,
|
||||
FieldKit,
|
||||
Genesis;
|
||||
|
||||
public Window getWindow(final EntityPlayer player, final IInventory object, final Side side) throws Exception {
|
||||
switch (this) {
|
||||
case Compartment: {
|
||||
return new WindowCompartment(player, object, side);
|
||||
}
|
||||
case FieldKit: {
|
||||
return new WindowFieldKit(player, null, side);
|
||||
}
|
||||
case Genesis: {
|
||||
return new WindowGenesis(player, null, side);
|
||||
}
|
||||
default: {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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 {
|
||||
window = this.getWindow(player, object, side);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return window;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.gui;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import binnie.core.AbstractMod;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
|
||||
public final class BinnieGUIHandler implements IGuiHandler
|
||||
{
|
||||
private AbstractMod mod;
|
||||
|
||||
public BinnieGUIHandler(final AbstractMod mod) {
|
||||
this.mod = mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Object getServerGuiElement(final int id, final EntityPlayer player, final World world, final int x, final int y, final int z) {
|
||||
final Window window = this.getWindow(id, player, world, x, y, z, Side.SERVER);
|
||||
if (window == null) {
|
||||
return null;
|
||||
}
|
||||
window.initialiseServer();
|
||||
return window.getContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Object getClientGuiElement(final int id, final EntityPlayer player, final World world, final int x, final int y, final int z) {
|
||||
if (BinnieCore.proxy.isSimulating(world)) {
|
||||
return this.getServerGuiElement(id, player, world, x, y, z);
|
||||
}
|
||||
final Window window = this.getWindow(id, player, world, x, y, z, Side.CLIENT);
|
||||
if (window == null) {
|
||||
return null;
|
||||
}
|
||||
return window.getGui();
|
||||
}
|
||||
|
||||
public Window getWindow(final int id, final EntityPlayer player, final World world, final int x, final int y, final int z, final Side side) {
|
||||
for (final IBinnieGUID guid : this.mod.getGUIDs()) {
|
||||
if (guid.ordinal() == id) {
|
||||
return guid.getWindow(player, world, x, y, z, side);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.gui;
|
||||
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import binnie.core.network.IOrdinaled;
|
||||
|
||||
public interface IBinnieGUID extends IOrdinaled
|
||||
{
|
||||
Window getWindow(final EntityPlayer p0, final World p1, final int p2, final int p3, final int p4, final Side p5);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.item;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IItemEnum
|
||||
{
|
||||
boolean isActive();
|
||||
|
||||
String getName(final ItemStack p0);
|
||||
|
||||
int ordinal();
|
||||
|
||||
ItemStack get(final int p0);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.item;
|
||||
|
||||
import java.util.List;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IItemMisc extends IItemEnum
|
||||
{
|
||||
IIcon getIcon(final ItemStack p0);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
void registerIcons(final IIconRegister p0);
|
||||
|
||||
void addInformation(final List p0);
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.item;
|
||||
|
||||
import java.util.List;
|
||||
import binnie.core.gui.BinnieCoreGUI;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import binnie.core.BinnieCore;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class ItemFieldKit extends Item
|
||||
{
|
||||
private IIcon fieldKit0;
|
||||
private IIcon fieldKit1;
|
||||
private IIcon fieldKit2;
|
||||
private IIcon fieldKit3;
|
||||
|
||||
public ItemFieldKit() {
|
||||
this.setUnlocalizedName("fieldKit");
|
||||
this.setCreativeTab(CreativeTabs.tabTools);
|
||||
this.setMaxStackSize(1);
|
||||
this.setMaxDamage(64);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(final IIconRegister register) {
|
||||
this.fieldKit0 = BinnieCore.proxy.getIcon(register, "fieldKit");
|
||||
this.fieldKit1 = BinnieCore.proxy.getIcon(register, "fieldKit1");
|
||||
this.fieldKit2 = BinnieCore.proxy.getIcon(register, "fieldKit2");
|
||||
this.fieldKit3 = BinnieCore.proxy.getIcon(register, "fieldKit3");
|
||||
this.itemIcon = this.fieldKit0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(final ItemStack stack, final int pass) {
|
||||
final int damage = stack.getItemDamage();
|
||||
if (damage < 24) {
|
||||
return this.fieldKit3;
|
||||
}
|
||||
if (damage < 48) {
|
||||
return this.fieldKit2;
|
||||
}
|
||||
if (damage < 64) {
|
||||
return this.fieldKit1;
|
||||
}
|
||||
return this.fieldKit0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(final ItemStack itemstack, final World world, final EntityPlayer player) {
|
||||
if (!player.isSneaking()) {
|
||||
BinnieCore.proxy.openGui(BinnieCoreGUI.FieldKit, player, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
}
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(final ItemStack p_77624_1_, final EntityPlayer p_77624_2_, final List p_77624_3_, final boolean p_77624_4_) {
|
||||
final int i = this.getMaxDamage() - p_77624_1_.getItemDamage();
|
||||
if (i == 0) {
|
||||
p_77624_3_.add("No paper");
|
||||
}
|
||||
else {
|
||||
p_77624_3_.add("" + i + " sheet" + ((i > 1) ? "s" : "") + " of paper");
|
||||
}
|
||||
super.addInformation(p_77624_1_, p_77624_2_, p_77624_3_, p_77624_4_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack p_77653_1_) {
|
||||
return "Field Kit";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.item;
|
||||
|
||||
import binnie.core.gui.BinnieCoreGUI;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import forestry.api.core.Tabs;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import binnie.core.BinnieCore;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class ItemGenesis extends Item
|
||||
{
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(final IIconRegister register) {
|
||||
this.itemIcon = BinnieCore.proxy.getIcon(register, "genesis");
|
||||
}
|
||||
|
||||
public ItemGenesis() {
|
||||
this.setCreativeTab(Tabs.tabApiculture);
|
||||
this.setUnlocalizedName("genesis");
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(final ItemStack itemstack, final World world, final EntityPlayer player) {
|
||||
BinnieCore.proxy.openGui(BinnieCoreGUI.Genesis, player, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack i) {
|
||||
return "Genesis";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.item;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class ItemMisc extends Item
|
||||
{
|
||||
private IItemMisc[] items;
|
||||
|
||||
protected ItemMisc(final CreativeTabs tab, final IItemMisc[] items2) {
|
||||
this.setCreativeTab(tab);
|
||||
this.setHasSubtypes(true);
|
||||
this.setUnlocalizedName("misc");
|
||||
this.items = items2;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(final Item par1, final CreativeTabs par2CreativeTabs, final List par3List) {
|
||||
for (final IItemMisc item : this.items) {
|
||||
if (item.isActive()) {
|
||||
par3List.add(this.getStack(item, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IItemMisc getItem(final int damage) {
|
||||
return (damage >= this.items.length) ? this.items[0] : this.items[damage];
|
||||
}
|
||||
|
||||
public ItemStack getStack(final IItemMisc type, final int size) {
|
||||
return new ItemStack(this, size, type.ordinal());
|
||||
}
|
||||
|
||||
@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);
|
||||
final IItemMisc item = this.getItem(par1ItemStack.getItemDamage());
|
||||
if (item != null) {
|
||||
item.addInformation(par3List);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack stack) {
|
||||
final IItemMisc item = this.getItem(stack.getItemDamage());
|
||||
return (item != null) ? item.getName(stack) : "null";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(final ItemStack stack, final int pass) {
|
||||
final IItemMisc item = this.getItem(stack.getItemDamage());
|
||||
return (item != null) ? item.getIcon(stack) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIconFromDamage(final int damage) {
|
||||
final IItemMisc item = this.getItem(damage);
|
||||
return (item != null) ? item.getIcon(null) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(final IIconRegister register) {
|
||||
for (final IItemMisc item : this.items) {
|
||||
item.registerIcons(register);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.item;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
|
||||
public class ManagerItem
|
||||
{
|
||||
public ItemMisc registerMiscItems(final IItemMisc[] items, final CreativeTabs tab) {
|
||||
return new ItemMisc(tab, items);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.item;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import binnie.botany.api.IFlower;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import binnie.core.network.packet.MessageNBT;
|
||||
import binnie.botany.network.PacketID;
|
||||
import binnie.botany.Botany;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import binnie.botany.flower.TileEntityFlower;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.IInitializable;
|
||||
|
||||
public class ModuleItems implements IInitializable
|
||||
{
|
||||
@Override
|
||||
public void preInit() {
|
||||
BinnieCore.fieldKit = new ItemFieldKit();
|
||||
BinnieCore.genesis = new ItemGenesis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
GameRegistry.addRecipe(new ItemStack(BinnieCore.fieldKit, 1, 63), new Object[] { "g ", " is", " pi", 'g', Blocks.glass_pane, 'i', Items.iron_ingot, 'p', Items.paper, 's', new ItemStack(Items.dye, 1) });
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onUseFieldKit(final PlayerInteractEvent event) {
|
||||
if (!BinnieCore.isBotanyActive()) {
|
||||
return;
|
||||
}
|
||||
if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
|
||||
return;
|
||||
}
|
||||
if (event.entityPlayer != null && event.entityPlayer.getHeldItem() != null && event.entityPlayer.getHeldItem().getItem() == BinnieCore.fieldKit && event.entityPlayer.isSneaking()) {
|
||||
final TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
|
||||
if (tile instanceof TileEntityFlower) {
|
||||
final TileEntityFlower tileFlower = (TileEntityFlower) tile;
|
||||
final IFlower flower = tileFlower.getFlower();
|
||||
if (flower != null) {
|
||||
final NBTTagCompound info = new NBTTagCompound();
|
||||
info.setString("Species", flower.getGenome().getPrimary().getUID());
|
||||
info.setString("Species2", flower.getGenome().getSecondary().getUID());
|
||||
info.setFloat("Age", flower.getAge() / flower.getGenome().getLifespan());
|
||||
info.setShort("Colour", (short) flower.getGenome().getPrimaryColor().getID());
|
||||
info.setShort("Colour2", (short) flower.getGenome().getSecondaryColor().getID());
|
||||
info.setBoolean("Wilting", flower.isWilted());
|
||||
info.setBoolean("Flowered", flower.hasFlowered());
|
||||
Botany.proxy.sendToPlayer(new MessageNBT(PacketID.Encylopedia.ordinal(), info), event.entityPlayer);
|
||||
event.entityPlayer.getHeldItem().damageItem(1, event.entityPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.language;
|
||||
|
||||
import net.minecraft.util.StatCollector;
|
||||
import binnie.core.AbstractMod;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import binnie.core.ManagerBase;
|
||||
|
||||
public class ManagerLanguage extends ManagerBase
|
||||
{
|
||||
private Map<Object, String> objNames;
|
||||
|
||||
public ManagerLanguage() {
|
||||
this.objNames = new HashMap<Object, String>();
|
||||
}
|
||||
|
||||
public void addObjectName(final Object obj, final String name) {
|
||||
this.objNames.put(obj, name);
|
||||
}
|
||||
|
||||
public String unlocalised(final AbstractMod mod, final String id) {
|
||||
return mod.getModID() + "." + id;
|
||||
}
|
||||
|
||||
public String localise(final Object key) {
|
||||
final String loc = StatCollector.translateToLocal(key.toString());
|
||||
if (loc.equals(key.toString())) {
|
||||
return this.objNames.containsKey(key) ? this.localise(this.objNames.get(key)) : key.toString();
|
||||
}
|
||||
return loc;
|
||||
}
|
||||
|
||||
public String localise(final AbstractMod mod, final String id) {
|
||||
return this.localise(this.unlocalised(mod, id));
|
||||
}
|
||||
|
||||
public String localiseOrBlank(final AbstractMod mod, final String id) {
|
||||
return this.localiseOrBlank(this.unlocalised(mod, id));
|
||||
}
|
||||
|
||||
public String localise(final AbstractMod mod, final String id, final Object... objs) {
|
||||
return String.format(this.localise(mod, id), objs);
|
||||
}
|
||||
|
||||
public String localiseOrBlank(final Object key) {
|
||||
final String trans = this.localise(key);
|
||||
return trans.equals(key) ? "" : trans;
|
||||
}
|
||||
|
||||
public boolean canLocalise(final Object key) {
|
||||
final String trans = this.localise(key);
|
||||
return !trans.equals(key);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.liquid;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
class BinnieFluid extends Fluid
|
||||
{
|
||||
private final String name;
|
||||
final IFluidType fluidType;
|
||||
|
||||
@Override
|
||||
public String getLocalizedName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public BinnieFluid(final IFluidType fluid) {
|
||||
super(fluid.getIdentifier());
|
||||
this.fluidType = fluid;
|
||||
this.name = fluid.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return this.fluidType.getColour();
|
||||
}
|
||||
|
||||
public IFluidType getType() {
|
||||
return this.fluidType;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.liquid;
|
||||
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import binnie.core.Mods;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import binnie.core.BinnieCore;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public enum FluidContainer
|
||||
{
|
||||
Bucket,
|
||||
Capsule,
|
||||
Refractory,
|
||||
Can,
|
||||
Glass,
|
||||
Cylinder;
|
||||
|
||||
IIcon bottle;
|
||||
IIcon contents;
|
||||
ItemFluidContainer item;
|
||||
|
||||
public int getMaxStackSize() {
|
||||
return (this == FluidContainer.Bucket) ? 1 : 16;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void updateIcons(final IIconRegister register) {
|
||||
this.bottle = BinnieCore.proxy.getIcon(register, (this == FluidContainer.Cylinder) ? "binniecore" : "forestry", "liquids/" + this.toString().toLowerCase() + ".bottle");
|
||||
this.contents = BinnieCore.proxy.getIcon(register, (this == FluidContainer.Cylinder) ? "binniecore" : "forestry", "liquids/" + this.toString().toLowerCase() + ".contents");
|
||||
}
|
||||
|
||||
public IIcon getBottleIcon() {
|
||||
return this.bottle;
|
||||
}
|
||||
|
||||
public IIcon getContentsIcon() {
|
||||
return this.contents;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return BinnieCore.proxy.localise("item.container." + this.name().toLowerCase());
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return this.getEmpty() != null;
|
||||
}
|
||||
|
||||
public ItemStack getEmpty() {
|
||||
switch (this) {
|
||||
case Bucket: {
|
||||
return new ItemStack(Items.bucket, 1, 0);
|
||||
}
|
||||
case Can: {
|
||||
return Mods.Forestry.stack("canEmpty");
|
||||
}
|
||||
case Capsule: {
|
||||
return Mods.Forestry.stack("waxCapsule");
|
||||
}
|
||||
case Glass: {
|
||||
return new ItemStack(Items.glass_bottle, 1, 0);
|
||||
}
|
||||
case Refractory: {
|
||||
return Mods.Forestry.stack("refractoryEmpty");
|
||||
}
|
||||
case Cylinder: {
|
||||
return GeneticsItems.Cylinder.get(1);
|
||||
}
|
||||
default: {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void registerContainerData(final IFluidType fluid) {
|
||||
if (!this.isActive()) {
|
||||
return;
|
||||
}
|
||||
final ItemStack filled = this.item.getContainer(fluid);
|
||||
final ItemStack empty = this.getEmpty();
|
||||
if (filled == null || empty == null || fluid.get(1000) == null) {
|
||||
return;
|
||||
}
|
||||
final FluidContainerRegistry.FluidContainerData data = new FluidContainerRegistry.FluidContainerData(fluid.get(1000), filled, empty);
|
||||
FluidContainerRegistry.registerFluidContainer(data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.liquid;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public interface IFluidType
|
||||
{
|
||||
IIcon getIcon();
|
||||
|
||||
void registerIcon(final IIconRegister p0);
|
||||
|
||||
String getName();
|
||||
|
||||
String getIdentifier();
|
||||
|
||||
FluidStack get(final int p0);
|
||||
|
||||
int getColour();
|
||||
|
||||
int getContainerColour();
|
||||
|
||||
int getTransparency();
|
||||
|
||||
boolean canPlaceIn(final FluidContainer p0);
|
||||
|
||||
boolean showInCreative(final FluidContainer p0);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.liquid;
|
||||
|
||||
public interface ILiquidType extends IFluidType
|
||||
{
|
||||
int ordinal();
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.liquid;
|
||||
|
||||
import java.util.HashMap;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import binnie.extratrees.alcohol.drink.IDrinkLiquid;
|
||||
import binnie.extratrees.alcohol.AlcoholEffect;
|
||||
import binnie.extratrees.alcohol.drink.DrinkManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.IIcon;
|
||||
import java.util.List;
|
||||
import net.minecraft.item.Item;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import binnie.Binnie;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import java.util.Map;
|
||||
import net.minecraft.item.ItemFood;
|
||||
|
||||
public class ItemFluidContainer extends ItemFood
|
||||
{
|
||||
private FluidContainer container;
|
||||
public static int LiquidExtraBee;
|
||||
public static int LiquidExtraTree;
|
||||
public static int LiquidJuice;
|
||||
public static int LiquidAlcohol;
|
||||
public static int LiquidSpirit;
|
||||
public static int LiquidLiqueuer;
|
||||
public static int LiquidGenetics;
|
||||
private static Map<Integer, String> idToFluid;
|
||||
private static Map<String, Integer> fluidToID;
|
||||
|
||||
public static void registerFluid(final IFluidType fluid, final int id) {
|
||||
ItemFluidContainer.idToFluid.put(id, fluid.getIdentifier().toLowerCase());
|
||||
ItemFluidContainer.fluidToID.put(fluid.getIdentifier().toLowerCase(), id);
|
||||
}
|
||||
|
||||
public ItemFluidContainer(final FluidContainer container) {
|
||||
super(0, false);
|
||||
this.container = container;
|
||||
container.item = this;
|
||||
this.maxStackSize = container.getMaxStackSize();
|
||||
this.setHasSubtypes(true);
|
||||
this.setUnlocalizedName("container" + container.name());
|
||||
this.setCreativeTab(CreativeTabs.tabMaterials);
|
||||
}
|
||||
|
||||
private FluidStack getLiquid(final ItemStack stack) {
|
||||
final String liquid = ItemFluidContainer.idToFluid.get(stack.getItemDamage());
|
||||
return (liquid == null) ? null : Binnie.Liquid.getLiquidStack(liquid, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(final IIconRegister register) {
|
||||
this.container.updateIcons(register);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack itemstack) {
|
||||
if (itemstack == null) {
|
||||
return "???";
|
||||
}
|
||||
final FluidStack fluid = this.getLiquid(itemstack);
|
||||
if (fluid == null) {
|
||||
return "Missing Fluid";
|
||||
}
|
||||
return fluid.getFluid().getLocalizedName(fluid) + " " + this.container.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(final Item par1, final CreativeTabs par2CreativeTabs, final List itemList) {
|
||||
for (final IFluidType liquid : Binnie.Liquid.fluids.values()) {
|
||||
if (!liquid.canPlaceIn(this.container)) {
|
||||
continue;
|
||||
}
|
||||
if (!liquid.showInCreative(this.container)) {
|
||||
continue;
|
||||
}
|
||||
itemList.add(this.getContainer(liquid));
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getContainer(final IFluidType liquid) {
|
||||
final int id = ItemFluidContainer.fluidToID.get(liquid.getIdentifier().toLowerCase());
|
||||
final ItemStack itemstack = new ItemStack(this, 1, id);
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(final ItemStack itemstack, final int j) {
|
||||
if (j > 0) {
|
||||
return this.container.getBottleIcon();
|
||||
}
|
||||
return this.container.getContentsIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getColorFromItemStack(final ItemStack item, final int pass) {
|
||||
final FluidStack fluid = this.getLiquid(item);
|
||||
if (fluid == null) {
|
||||
return 16777215;
|
||||
}
|
||||
if (pass == 0 && fluid.getFluid() instanceof BinnieFluid) {
|
||||
return ((BinnieFluid) fluid.getFluid()).fluidType.getContainerColour();
|
||||
}
|
||||
return super.getColorFromItemStack(item, pass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresMultipleRenderPasses() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onEaten(final ItemStack stack, final World world, final EntityPlayer player) {
|
||||
player.getFoodStats().func_151686_a(this, stack);
|
||||
world.playSoundAtEntity(player, "random.burp", 0.5f, world.rand.nextFloat() * 0.1f + 0.9f);
|
||||
this.onFoodEaten(stack, world, player);
|
||||
return this.container.getEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFoodEaten(final ItemStack stack, final World world, final EntityPlayer player) {
|
||||
if (!world.isRemote) {
|
||||
final FluidStack fluid = this.getLiquid(stack);
|
||||
final IDrinkLiquid liquid = DrinkManager.getLiquid(fluid);
|
||||
if (liquid != null) {
|
||||
AlcoholEffect.makeDrunk(player, liquid.getABV() * fluid.amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxItemUseDuration(final ItemStack stack) {
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAction getItemUseAction(final ItemStack stack) {
|
||||
return this.isDrinkable(stack) ? EnumAction.drink : EnumAction.none;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player) {
|
||||
if (this.isDrinkable(stack)) {
|
||||
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int func_150905_g(final ItemStack p_150905_1_) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float func_150906_h(final ItemStack p_150906_1_) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
private boolean isDrinkable(final ItemStack stack) {
|
||||
final FluidStack fluid = this.getLiquid(stack);
|
||||
final IDrinkLiquid liquid = DrinkManager.getLiquid(fluid);
|
||||
return liquid != null && liquid.isConsumable();
|
||||
}
|
||||
|
||||
static {
|
||||
ItemFluidContainer.LiquidExtraBee = 64;
|
||||
ItemFluidContainer.LiquidExtraTree = 128;
|
||||
ItemFluidContainer.LiquidJuice = 256;
|
||||
ItemFluidContainer.LiquidAlcohol = 384;
|
||||
ItemFluidContainer.LiquidSpirit = 512;
|
||||
ItemFluidContainer.LiquidLiqueuer = 640;
|
||||
ItemFluidContainer.LiquidGenetics = 768;
|
||||
ItemFluidContainer.idToFluid = new HashMap<Integer, String>();
|
||||
ItemFluidContainer.fluidToID = new HashMap<String, Integer>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.liquid;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import binnie.core.ManagerBase;
|
||||
|
||||
public class ManagerLiquid extends ManagerBase
|
||||
{
|
||||
Map<String, IFluidType> fluids;
|
||||
|
||||
public ManagerLiquid() {
|
||||
this.fluids = new LinkedHashMap<String, IFluidType>();
|
||||
}
|
||||
|
||||
public Collection<IFluidType> getFluidTypes() {
|
||||
return this.fluids.values();
|
||||
}
|
||||
|
||||
public void createLiquids(final IFluidType[] liquids, int startID) {
|
||||
for (final IFluidType liquid : liquids) {
|
||||
final BinnieFluid fluid = this.createLiquid(liquid, startID++);
|
||||
if (fluid == null) {
|
||||
throw new RuntimeException("Liquid registered incorrectly - " + liquid.getIdentifier());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BinnieFluid createLiquid(final IFluidType fluid, final int id) {
|
||||
this.fluids.put(fluid.getIdentifier().toLowerCase(), fluid);
|
||||
final BinnieFluid bFluid = new BinnieFluid(fluid);
|
||||
FluidRegistry.registerFluid(bFluid);
|
||||
ItemFluidContainer.registerFluid(fluid, id);
|
||||
return bFluid;
|
||||
}
|
||||
|
||||
public FluidStack getLiquidStack(final String name, final int amount) {
|
||||
return FluidRegistry.getFluidStack(name.toLowerCase(), amount);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void reloadIcons(final IIconRegister register) {
|
||||
for (final IFluidType type : this.fluids.values()) {
|
||||
final Fluid fluid = this.getLiquidStack(type.getIdentifier(), 1).getFluid();
|
||||
type.registerIcon(register);
|
||||
if (fluid == null) {
|
||||
throw new RuntimeException("[Binnie] Liquid not registered properly - " + type.getIdentifier());
|
||||
}
|
||||
fluid.setIcons(type.getIcon());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
for (final IFluidType fluid : this.fluids.values()) {
|
||||
for (final FluidContainer container : FluidContainer.values()) {
|
||||
if (container.isActive() && fluid.canPlaceIn(container)) {
|
||||
container.registerContainerData(fluid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IFluidType getFluidType(final String liquid) {
|
||||
return this.fluids.get(liquid.toLowerCase());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import binnie.core.machines.component.IRender;
|
||||
import java.util.Random;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import binnie.core.BinnieCore;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import binnie.Binnie;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import java.util.List;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
|
||||
class BlockMachine extends BlockContainer implements IBlockMachine
|
||||
{
|
||||
private MachineGroup group;
|
||||
|
||||
public BlockMachine(final MachineGroup group, final String blockName) {
|
||||
super(Material.iron);
|
||||
this.group = group;
|
||||
this.setHardness(1.5f);
|
||||
this.setBlockName(blockName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(final Item par1, final CreativeTabs par2CreativeTabs, final List itemList) {
|
||||
for (final MachinePackage pack : this.group.getPackages()) {
|
||||
if (pack.isActive()) {
|
||||
itemList.add(new ItemStack(this, 1, pack.getMetadata()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return !this.group.customRenderer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return Binnie.Machine.getMachineRenderID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(final World world, final int metadata) {
|
||||
if (this.group.getPackage(metadata) == null) {
|
||||
return null;
|
||||
}
|
||||
return this.group.getPackage(metadata).createTileEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MachinePackage getPackage(final int meta) {
|
||||
return this.group.getPackage(meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMachineName(final int meta) {
|
||||
return (this.getPackage(meta) == null) ? "Unnamed Machine" : this.getPackage(meta).getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(final int par1) {
|
||||
return par1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(final World var1, final int meta) {
|
||||
return this.createTileEntity(var1, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int par6, final float par7, final float par8, final float par9) {
|
||||
if (!BinnieCore.proxy.isSimulating(world)) {
|
||||
return true;
|
||||
}
|
||||
if (player.isSneaking()) {
|
||||
return true;
|
||||
}
|
||||
final TileEntity entity = world.getTileEntity(x, y, z);
|
||||
if (entity instanceof TileEntityMachine) {
|
||||
((TileEntityMachine) entity).getMachine().onRightClick(world, player, x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(final World world, final int i, final int j, final int k, final EntityLivingBase entityliving, final ItemStack stack) {
|
||||
super.onBlockPlacedBy(world, i, j, k, entityliving, stack);
|
||||
if (!BinnieCore.proxy.isSimulating(world)) {
|
||||
return;
|
||||
}
|
||||
final IMachine machine = Machine.getMachine(world.getTileEntity(i, j, k));
|
||||
if (machine == null) {
|
||||
return;
|
||||
}
|
||||
if (entityliving instanceof EntityPlayer) {
|
||||
machine.setOwner(((EntityPlayer) entityliving).getGameProfile());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(final IBlockAccess world, final int x, final int y, final int z, final int side) {
|
||||
final TileEntity entity = world.getTileEntity(x, y, z);
|
||||
if (entity instanceof TileEntityMachine && ((TileEntityMachine) entity).getMachine().hasInterface(IMachineTexturedFaces.class)) {
|
||||
return ((TileEntityMachine) entity).getMachine().getInterface(IMachineTexturedFaces.class).getIcon(side);
|
||||
}
|
||||
return Blocks.dirt.getIcon(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(final World world, final int x, final int y, final int z, final Block par5, final int par6) {
|
||||
final TileEntity tileentity = world.getTileEntity(x, y, z);
|
||||
if (!(tileentity instanceof TileEntityMachine)) {
|
||||
return;
|
||||
}
|
||||
final TileEntityMachine entity = (TileEntityMachine) tileentity;
|
||||
if (entity != null) {
|
||||
entity.onBlockDestroy();
|
||||
}
|
||||
super.breakBlock(world, x, y, z, par5, par6);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(final IIconRegister register) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(final World world, final int x, final int y, final int z, final Random rand) {
|
||||
final IMachine machine = Machine.getMachine(world.getTileEntity(x, y, z));
|
||||
if (machine != null) {
|
||||
for (final IRender.RandomDisplayTick renders : machine.getInterfaces(IRender.RandomDisplayTick.class)) {
|
||||
renders.onRandomDisplayTick(world, x, y, z, rand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(final World world, final int x, final int y, final int z, final int metadata, final int fortune) {
|
||||
return new ArrayList<ItemStack>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(final World world, final EntityPlayer player, final int x, final int y, final int z, final boolean willHarvest) {
|
||||
if (BinnieCore.proxy.isSimulating(world) && this.canHarvestBlock(player, world.getBlockMetadata(x, y, z)) && !player.capabilities.isCreativeMode) {
|
||||
final int metadata = world.getBlockMetadata(x, y, z);
|
||||
final ItemStack stack = new ItemStack(Item.getItemFromBlock(this), 1, this.damageDropped(metadata));
|
||||
this.dropBlockAsItem(world, x, y, z, stack);
|
||||
}
|
||||
return world.setBlockToAir(x, y, z);
|
||||
}
|
||||
|
||||
public interface IMachineTexturedFaces
|
||||
{
|
||||
IIcon getIcon(final int p0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines;
|
||||
|
||||
interface IBlockMachine
|
||||
{
|
||||
MachinePackage getPackage(final int p0);
|
||||
|
||||
String getMachineName(final int p0);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines;
|
||||
|
||||
import java.util.Collection;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IMachine extends IOwnable
|
||||
{
|
||||
void addComponent(final MachineComponent p0);
|
||||
|
||||
MachineUtil getMachineUtil();
|
||||
|
||||
<T> T getInterface(final Class<T> p0);
|
||||
|
||||
void markDirty();
|
||||
|
||||
World getWorld();
|
||||
|
||||
TileEntity getTileEntity();
|
||||
|
||||
<T> Collection<T> getInterfaces(final Class<T> p0);
|
||||
|
||||
MachinePackage getPackage();
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines;
|
||||
|
||||
import binnie.core.network.IOrdinaled;
|
||||
|
||||
public interface IMachineType extends IOrdinaled
|
||||
{
|
||||
Class<? extends MachinePackage> getPackageClass();
|
||||
|
||||
boolean isActive();
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
interface IOwnable
|
||||
{
|
||||
GameProfile getOwner();
|
||||
|
||||
void setOwner(final GameProfile p0);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
|
||||
public class ItemMachine extends ItemBlock
|
||||
{
|
||||
private IBlockMachine associatedBlock;
|
||||
|
||||
public ItemMachine(final Block block) {
|
||||
super(block);
|
||||
this.setMaxDamage(0);
|
||||
this.setHasSubtypes(true);
|
||||
this.associatedBlock = (IBlockMachine) block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(final int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack itemstack) {
|
||||
return this.associatedBlock.getMachineName(itemstack.getItemDamage());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,302 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import binnie.core.network.packet.MessageTileNBT;
|
||||
import binnie.core.network.BinnieCorePacketID;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import binnie.core.machines.power.ITankMachine;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import binnie.core.machines.component.IRender;
|
||||
import binnie.core.machines.component.IInteraction;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import binnie.core.network.packet.PacketPayload;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import binnie.core.BinnieCore;
|
||||
import java.util.Collection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import binnie.core.machines.network.INetwork;
|
||||
import forestry.api.core.INBTTagable;
|
||||
import binnie.core.network.INetworkedEntity;
|
||||
|
||||
public class Machine implements INetworkedEntity, INBTTagable, INetwork.TilePacketSync, IMachine, INetwork.GuiNBT
|
||||
{
|
||||
private MachinePackage machinePackage;
|
||||
private Map<Class, List<MachineComponent>> componentInterfaceMap;
|
||||
private Map<Class<? extends MachineComponent>, MachineComponent> componentMap;
|
||||
private TileEntity tile;
|
||||
private boolean queuedInventoryUpdate;
|
||||
private int nextProgressBarID;
|
||||
private GameProfile owner;
|
||||
|
||||
public Machine(final MachinePackage pack, final TileEntity tile) {
|
||||
this.componentInterfaceMap = new LinkedHashMap<Class, List<MachineComponent>>();
|
||||
this.componentMap = new LinkedHashMap<Class<? extends MachineComponent>, MachineComponent>();
|
||||
this.queuedInventoryUpdate = false;
|
||||
this.nextProgressBarID = 0;
|
||||
this.owner = null;
|
||||
this.tile = tile;
|
||||
pack.createMachine(this);
|
||||
this.machinePackage = pack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addComponent(final MachineComponent component) {
|
||||
if (component == null) {
|
||||
throw new NullPointerException("Can't have a null machine component!");
|
||||
}
|
||||
component.setMachine(this);
|
||||
this.componentMap.put(component.getClass(), component);
|
||||
for (final Class inter : component.getComponentInterfaces()) {
|
||||
if (!this.componentInterfaceMap.containsKey(inter)) {
|
||||
this.componentInterfaceMap.put(inter, new ArrayList<MachineComponent>());
|
||||
}
|
||||
this.componentInterfaceMap.get(inter).add(component);
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<MachineComponent> getComponents() {
|
||||
return this.componentMap.values();
|
||||
}
|
||||
|
||||
public <T extends MachineComponent> T getComponent(final Class<T> componentClass) {
|
||||
return this.hasComponent(componentClass) ? ((T) componentClass.cast(this.componentMap.get(componentClass))) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getInterface(final Class<T> interfaceClass) {
|
||||
if (this.hasInterface(interfaceClass)) {
|
||||
return this.getInterfaces(interfaceClass).get(0);
|
||||
}
|
||||
if (interfaceClass.isInstance(this.getPackage())) {
|
||||
return interfaceClass.cast(this.getPackage());
|
||||
}
|
||||
for (final MachineComponent component : this.getComponents()) {
|
||||
if (interfaceClass.isInstance(component)) {
|
||||
return interfaceClass.cast(component);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<T> getInterfaces(final Class<T> interfaceClass) {
|
||||
final ArrayList<T> interfaces = new ArrayList<T>();
|
||||
if (!this.hasInterface(interfaceClass)) {
|
||||
return interfaces;
|
||||
}
|
||||
for (final MachineComponent component : this.componentInterfaceMap.get(interfaceClass)) {
|
||||
interfaces.add(interfaceClass.cast(component));
|
||||
}
|
||||
return interfaces;
|
||||
}
|
||||
|
||||
public boolean hasInterface(final Class<?> interfaceClass) {
|
||||
return this.componentInterfaceMap.containsKey(interfaceClass);
|
||||
}
|
||||
|
||||
public boolean hasComponent(final Class<? extends MachineComponent> componentClass) {
|
||||
return this.componentMap.containsKey(componentClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity() {
|
||||
return this.tile;
|
||||
}
|
||||
|
||||
public void sendPacket() {
|
||||
if (!BinnieCore.proxy.isSimulating(this.getTileEntity().getWorldObj())) {
|
||||
return;
|
||||
}
|
||||
BinnieCore.proxy.sendNetworkEntityPacket((INetworkedEntity) this.getTileEntity());
|
||||
}
|
||||
|
||||
public Side getSide() {
|
||||
return BinnieCore.proxy.isSimulating(this.getTileEntity().getWorldObj()) ? Side.SERVER : Side.CLIENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToPacket(final PacketPayload payload) {
|
||||
for (final MachineComponent component : this.getComponents()) {
|
||||
if (component instanceof INetworkedEntity) {
|
||||
((INetworkedEntity) component).writeToPacket(payload);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromPacket(final PacketPayload payload) {
|
||||
for (final MachineComponent component : this.getComponents()) {
|
||||
if (component instanceof INetworkedEntity) {
|
||||
((INetworkedEntity) component).readFromPacket(payload);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onRightClick(final World world, final EntityPlayer player, final int x, final int y, final int z) {
|
||||
for (final IInteraction.RightClick component : this.getInterfaces(IInteraction.RightClick.class)) {
|
||||
component.onRightClick(world, player, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
this.queuedInventoryUpdate = true;
|
||||
}
|
||||
|
||||
public void onUpdate() {
|
||||
if (BinnieCore.proxy.isSimulating(this.getWorld())) {
|
||||
for (final MachineComponent component : this.getComponents()) {
|
||||
component.onUpdate();
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (final IRender.DisplayTick renders : this.getInterfaces(IRender.DisplayTick.class)) {
|
||||
renders.onDisplayTick(this.getWorld(), this.getTileEntity().xCoord, this.getTileEntity().yCoord, this.getTileEntity().zCoord, this.getWorld().rand);
|
||||
}
|
||||
}
|
||||
if (this.queuedInventoryUpdate) {
|
||||
for (final MachineComponent component : this.getComponents()) {
|
||||
component.onInventoryUpdate();
|
||||
}
|
||||
this.queuedInventoryUpdate = false;
|
||||
}
|
||||
}
|
||||
|
||||
public IInventory getInventory() {
|
||||
return this.getInterface(IInventory.class);
|
||||
}
|
||||
|
||||
public ITankMachine getTankContainer() {
|
||||
return this.getInterface(ITankMachine.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound nbttagcompound) {
|
||||
for (final MachineComponent component : this.getComponents()) {
|
||||
component.readFromNBT(nbttagcompound);
|
||||
}
|
||||
this.owner = NBTUtil.func_152459_a(nbttagcompound.getCompoundTag("owner"));
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound nbttagcompound) {
|
||||
for (final MachineComponent component : this.getComponents()) {
|
||||
component.writeToNBT(nbttagcompound);
|
||||
}
|
||||
if (this.owner != null) {
|
||||
final NBTTagCompound nbt = new NBTTagCompound();
|
||||
NBTUtil.func_152460_a(nbt, this.owner);
|
||||
nbttagcompound.setTag("owner", nbt);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MachinePackage getPackage() {
|
||||
return this.machinePackage;
|
||||
}
|
||||
|
||||
public static IMachine getMachine(final Object inventory) {
|
||||
if (inventory != null && inventory instanceof IMachine) {
|
||||
return (IMachine) inventory;
|
||||
}
|
||||
if (inventory != null && inventory instanceof TileEntityMachine) {
|
||||
return ((TileEntityMachine) inventory).getMachine();
|
||||
}
|
||||
if (inventory != null && inventory instanceof MachineComponent) {
|
||||
return ((MachineComponent) inventory).getMachine();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T> T getInterface(final Class<T> interfac, final Object inventory) {
|
||||
final IMachine machine = getMachine(inventory);
|
||||
if (machine != null) {
|
||||
return machine.getInterface(interfac);
|
||||
}
|
||||
if (interfac.isInstance(inventory)) {
|
||||
return interfac.cast(inventory);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MachineUtil getMachineUtil() {
|
||||
return new MachineUtil(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return this.getTileEntity().getWorldObj();
|
||||
}
|
||||
|
||||
public void onBlockDestroy() {
|
||||
for (final MachineComponent component : this.getComponents()) {
|
||||
component.onDestruction();
|
||||
}
|
||||
}
|
||||
|
||||
public int getUniqueProgressBarID() {
|
||||
return this.nextProgressBarID++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfile getOwner() {
|
||||
return this.owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOwner(final GameProfile owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public Packet getDescriptionPacket() {
|
||||
final NBTTagCompound nbt = new NBTTagCompound();
|
||||
this.syncToNBT(nbt);
|
||||
if (nbt.hasNoTags()) {
|
||||
return null;
|
||||
}
|
||||
return BinnieCore.instance.getNetworkWrapper().getPacketFrom(new MessageTileNBT(BinnieCorePacketID.TileDescriptionSync.ordinal(), this.getTileEntity(), nbt).GetMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncToNBT(final NBTTagCompound nbt) {
|
||||
for (final INetwork.TilePacketSync comp : this.getInterfaces(INetwork.TilePacketSync.class)) {
|
||||
comp.syncToNBT(nbt);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncFromNBT(final NBTTagCompound nbt) {
|
||||
for (final INetwork.TilePacketSync comp : this.getInterfaces(INetwork.TilePacketSync.class)) {
|
||||
comp.syncFromNBT(nbt);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recieveGuiNBT(final Side side, final EntityPlayer player, final String name, final NBTTagCompound nbt) {
|
||||
for (final INetwork.RecieveGuiNBT recieve : this.getInterfaces(INetwork.RecieveGuiNBT.class)) {
|
||||
recieve.recieveGuiNBT(side, player, name, nbt);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendGuiNBT(final Map<String, NBTTagCompound> nbt) {
|
||||
for (final INetwork.SendGuiNBT recieve : this.getInterfaces(INetwork.SendGuiNBT.class)) {
|
||||
recieve.sendGuiNBT(nbt);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import binnie.core.network.packet.MachinePayload;
|
||||
import binnie.Binnie;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import forestry.api.core.INBTTagable;
|
||||
|
||||
public class MachineComponent implements INBTTagable
|
||||
{
|
||||
private IMachine machine;
|
||||
|
||||
public MachineComponent(final IMachine machine) {
|
||||
this.setMachine(machine);
|
||||
machine.addComponent(this);
|
||||
}
|
||||
|
||||
public void setMachine(final IMachine machine) {
|
||||
this.machine = machine;
|
||||
}
|
||||
|
||||
public IMachine getMachine() {
|
||||
return this.machine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound nbttagcompound) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound nbttagcompound) {
|
||||
}
|
||||
|
||||
public void onUpdate() {
|
||||
}
|
||||
|
||||
public Class[] getComponentInterfaces() {
|
||||
return Binnie.Machine.getComponentInterfaces(this.getClass());
|
||||
}
|
||||
|
||||
public void onInventoryUpdate() {
|
||||
}
|
||||
|
||||
public final MachinePayload getPayload() {
|
||||
return new MachinePayload(Binnie.Machine.getNetworkID(this.getClass()));
|
||||
}
|
||||
|
||||
public void recieveData(final MachinePayload payload) {
|
||||
}
|
||||
|
||||
public MachineUtil getUtil() {
|
||||
return this.getMachine().getMachineUtil();
|
||||
}
|
||||
|
||||
public void onDestruction() {
|
||||
}
|
||||
|
||||
public IInventory getInventory() {
|
||||
return this.getMachine().getInterface(IInventory.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import java.util.Collection;
|
||||
import net.minecraft.block.Block;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import binnie.Binnie;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import binnie.core.AbstractMod;
|
||||
|
||||
public class MachineGroup
|
||||
{
|
||||
private AbstractMod mod;
|
||||
private String blockName;
|
||||
private String uid;
|
||||
private Map<String, MachinePackage> packages;
|
||||
private Map<Integer, MachinePackage> packagesID;
|
||||
private BlockMachine block;
|
||||
public boolean customRenderer;
|
||||
private boolean renderedTileEntity;
|
||||
|
||||
public MachineGroup(final AbstractMod mod, final String uid, final String blockName, final IMachineType[] types) {
|
||||
this.packages = new LinkedHashMap<String, MachinePackage>();
|
||||
this.packagesID = new LinkedHashMap<Integer, MachinePackage>();
|
||||
this.customRenderer = true;
|
||||
this.renderedTileEntity = true;
|
||||
this.mod = mod;
|
||||
this.uid = uid;
|
||||
this.blockName = blockName;
|
||||
for (final IMachineType type : types) {
|
||||
if (type.getPackageClass() != null) {
|
||||
if (type.isActive()) {
|
||||
try {
|
||||
final MachinePackage pack = type.getPackageClass().newInstance();
|
||||
pack.assignMetadata(type.ordinal());
|
||||
pack.setActive(type.isActive());
|
||||
this.addPackage(pack);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to create machine package " + type.toString(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binnie.Machine.registerMachineGroup(this);
|
||||
this.block = new BlockMachine(this, blockName);
|
||||
if (this.block != null) {
|
||||
GameRegistry.registerBlock(this.block, ItemMachine.class, blockName);
|
||||
for (final MachinePackage pack2 : this.getPackages()) {
|
||||
pack2.register();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addPackage(final MachinePackage pack) {
|
||||
this.packages.put(pack.getUID(), pack);
|
||||
this.packagesID.put(pack.getMetadata(), pack);
|
||||
pack.setGroup(this);
|
||||
}
|
||||
|
||||
public Collection<MachinePackage> getPackages() {
|
||||
return this.packages.values();
|
||||
}
|
||||
|
||||
public BlockMachine getBlock() {
|
||||
return this.block;
|
||||
}
|
||||
|
||||
public MachinePackage getPackage(final int metadata) {
|
||||
return this.packagesID.get(metadata);
|
||||
}
|
||||
|
||||
public MachinePackage getPackage(final String name) {
|
||||
return this.packages.get(name);
|
||||
}
|
||||
|
||||
public String getUID() {
|
||||
return this.mod.getModID() + "." + this.uid;
|
||||
}
|
||||
|
||||
public String getShortUID() {
|
||||
return this.uid;
|
||||
}
|
||||
|
||||
boolean isTileEntityRenderered() {
|
||||
return this.renderedTileEntity;
|
||||
}
|
||||
|
||||
public void renderAsBlock() {
|
||||
this.renderedTileEntity = false;
|
||||
}
|
||||
|
||||
public void setCreativeTab(final CreativeTabs tab) {
|
||||
this.block.setCreativeTab(tab);
|
||||
}
|
||||
|
||||
public AbstractMod getMod() {
|
||||
return this.mod;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import binnie.Binnie;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public abstract class MachinePackage
|
||||
{
|
||||
private String uid;
|
||||
private boolean active;
|
||||
boolean powered;
|
||||
private int metadata;
|
||||
private MachineGroup group;
|
||||
|
||||
public String getUID() {
|
||||
return this.uid;
|
||||
}
|
||||
|
||||
protected MachinePackage(final String uid, final boolean powered) {
|
||||
this.active = true;
|
||||
this.powered = false;
|
||||
this.metadata = -1;
|
||||
this.uid = uid;
|
||||
this.powered = powered;
|
||||
}
|
||||
|
||||
public abstract void createMachine(final Machine p0);
|
||||
|
||||
public abstract TileEntity createTileEntity();
|
||||
|
||||
public abstract void register();
|
||||
|
||||
public final String getDisplayName() {
|
||||
return Binnie.Language.localise(this.group.getMod(), "machine." + this.group.getShortUID() + "." + this.getUID());
|
||||
}
|
||||
|
||||
public final Integer getMetadata() {
|
||||
return this.metadata;
|
||||
}
|
||||
|
||||
public void assignMetadata(final int meta) {
|
||||
this.metadata = meta;
|
||||
}
|
||||
|
||||
public MachineGroup getGroup() {
|
||||
return this.group;
|
||||
}
|
||||
|
||||
public void setGroup(final MachineGroup group) {
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
public abstract void renderMachine(final Machine p0, final double p1, final double p2, final double p3, final float p4, final RenderBlocks p5);
|
||||
|
||||
public boolean isActive() {
|
||||
return this.active;
|
||||
}
|
||||
|
||||
public void setActive(final boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
public final String getInformation() {
|
||||
return Binnie.Language.localise(this.group.getMod(), "machine." + this.group.getShortUID() + "." + this.getUID() + ".info");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import binnie.core.resource.BinnieResource;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class MachineRendererBlock
|
||||
{
|
||||
public static MachineRendererBlock instance;
|
||||
private BinnieResource texture;
|
||||
private ModelBlock model;
|
||||
|
||||
public MachineRendererBlock() {
|
||||
this.model = new ModelBlock();
|
||||
}
|
||||
|
||||
public void renderMachine(final BinnieResource texture, final double x, final double y, final double z, final float var8) {
|
||||
this.texture = texture;
|
||||
GL11.glPushMatrix();
|
||||
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.glPopMatrix();
|
||||
}
|
||||
|
||||
static {
|
||||
MachineRendererBlock.instance = new MachineRendererBlock();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import binnie.core.machines.power.IProcess;
|
||||
import binnie.core.machines.inventory.IChargedSlots;
|
||||
import binnie.core.machines.power.PowerSystem;
|
||||
import binnie.core.util.ItemStackSet;
|
||||
import java.util.Random;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import binnie.core.machines.power.IPoweredMachine;
|
||||
import binnie.core.machines.power.ITankMachine;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
public class MachineUtil
|
||||
{
|
||||
private IMachine machine;
|
||||
|
||||
public MachineUtil(final IMachine machine) {
|
||||
this.machine = machine;
|
||||
}
|
||||
|
||||
public IInventory getInventory() {
|
||||
return this.machine.getInterface(IInventory.class);
|
||||
}
|
||||
|
||||
public ITankMachine getTankContainer() {
|
||||
return this.machine.getInterface(ITankMachine.class);
|
||||
}
|
||||
|
||||
public IPoweredMachine getPoweredMachine() {
|
||||
return this.machine.getInterface(IPoweredMachine.class);
|
||||
}
|
||||
|
||||
public boolean isSlotEmpty(final int slot) {
|
||||
return this.getInventory().getStackInSlot(slot) == null;
|
||||
}
|
||||
|
||||
public IFluidTank getTank(final int id) {
|
||||
return this.getTankContainer().getTanks()[id];
|
||||
}
|
||||
|
||||
public boolean spaceInTank(final int id, final int amount) {
|
||||
final IFluidTank tank = this.getTank(id);
|
||||
final int space = tank.getCapacity() - tank.getFluidAmount();
|
||||
return amount <= space;
|
||||
}
|
||||
|
||||
public ItemStack getStack(final int slot) {
|
||||
return this.getInventory().getStackInSlot(slot);
|
||||
}
|
||||
|
||||
public void deleteStack(final int slot) {
|
||||
this.setStack(slot, null);
|
||||
}
|
||||
|
||||
public ItemStack decreaseStack(final int slotWood, final int amount) {
|
||||
return this.getInventory().decrStackSize(slotWood, amount);
|
||||
}
|
||||
|
||||
public void setStack(final int slot, final ItemStack stack) {
|
||||
this.getInventory().setInventorySlotContents(slot, stack);
|
||||
}
|
||||
|
||||
public void fillTank(final int id, final FluidStack liquidStack) {
|
||||
final IFluidTank tank = this.getTank(id);
|
||||
tank.fill(liquidStack, true);
|
||||
}
|
||||
|
||||
public void addStack(final int slot, final ItemStack addition) {
|
||||
if (this.isSlotEmpty(slot)) {
|
||||
this.setStack(slot, addition);
|
||||
}
|
||||
else {
|
||||
final ItemStack merge = this.getStack(slot);
|
||||
if (merge.isItemEqual(addition) && merge.stackSize + addition.stackSize <= merge.getMaxStackSize()) {
|
||||
final ItemStack itemStack = merge;
|
||||
itemStack.stackSize += addition.stackSize;
|
||||
this.setStack(slot, merge);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public FluidStack drainTank(final int tank, final int amount) {
|
||||
return this.getTank(tank).drain(amount, true);
|
||||
}
|
||||
|
||||
public boolean liquidInTank(final int tank, final int amount) {
|
||||
return this.getTank(tank).drain(amount, false) != null && this.getTank(tank).drain(amount, false).amount == amount;
|
||||
}
|
||||
|
||||
public void damageItem(final int slot, final int damage) {
|
||||
final ItemStack item = this.getStack(slot);
|
||||
if (damage < 0) {
|
||||
item.setItemDamage(Math.max(0, item.getItemDamage() + damage));
|
||||
}
|
||||
else if (item.attemptDamageItem(damage, new Random())) {
|
||||
this.setStack(slot, null);
|
||||
}
|
||||
this.setStack(slot, item);
|
||||
}
|
||||
|
||||
public boolean isTankEmpty(final int tankInput) {
|
||||
return this.getTank(tankInput).getFluidAmount() == 0;
|
||||
}
|
||||
|
||||
public FluidStack getFluid(final int tankInput) {
|
||||
return (this.getTank(tankInput).getFluid() == null) ? null : this.getTank(tankInput).getFluid();
|
||||
}
|
||||
|
||||
public ItemStack[] getStacks(final int[] slotGrains) {
|
||||
final ItemStack[] stacks = new ItemStack[slotGrains.length];
|
||||
for (int i = 0; i < slotGrains.length; ++i) {
|
||||
stacks[i] = this.getStack(slotGrains[i]);
|
||||
}
|
||||
return stacks;
|
||||
}
|
||||
|
||||
public ItemStack hasIngredients(final int recipe, final int[] inventory) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasIngredients(final int[] recipe, final int[] inventory) {
|
||||
final ItemStackSet requiredStacks = new ItemStackSet();
|
||||
for (final ItemStack stack : this.getStacks(recipe)) {
|
||||
requiredStacks.add(stack);
|
||||
}
|
||||
final ItemStackSet inventoryStacks = new ItemStackSet();
|
||||
for (final ItemStack stack2 : this.getStacks(inventory)) {
|
||||
inventoryStacks.add(stack2);
|
||||
}
|
||||
requiredStacks.removeAll(inventoryStacks);
|
||||
return requiredStacks.isEmpty();
|
||||
}
|
||||
|
||||
public void useEnergyMJ(final float powerUsage) {
|
||||
this.getPoweredMachine().getInterface().useEnergy(PowerSystem.MJ, powerUsage, true);
|
||||
}
|
||||
|
||||
public boolean hasEnergyMJ(final float powerUsage) {
|
||||
return this.getPoweredMachine().getInterface().useEnergy(PowerSystem.MJ, powerUsage, false) >= powerUsage;
|
||||
}
|
||||
|
||||
public float getSlotCharge(final int slot) {
|
||||
return this.machine.getInterface(IChargedSlots.class).getCharge(slot);
|
||||
}
|
||||
|
||||
public void useCharge(final int slot, final float loss) {
|
||||
this.machine.getInterface(IChargedSlots.class).alterCharge(slot, -loss);
|
||||
}
|
||||
|
||||
public Random getRandom() {
|
||||
return new Random();
|
||||
}
|
||||
|
||||
public void refreshBlock() {
|
||||
this.machine.getWorld().markBlockForUpdate(this.machine.getTileEntity().xCoord, this.machine.getTileEntity().yCoord, this.machine.getTileEntity().zCoord);
|
||||
}
|
||||
|
||||
public IProcess getProcess() {
|
||||
return this.machine.getInterface(IProcess.class);
|
||||
}
|
||||
|
||||
public List<ItemStack> getNonNullStacks(final int[] slotacclimatiser) {
|
||||
final List<ItemStack> stacks = new ArrayList<ItemStack>();
|
||||
for (final ItemStack stack : this.getStacks(slotacclimatiser)) {
|
||||
if (stack != null) {
|
||||
stacks.add(stack);
|
||||
}
|
||||
}
|
||||
return stacks;
|
||||
}
|
||||
|
||||
public boolean isServer() {
|
||||
return BinnieCore.proxy.isSimulating(this.machine.getWorld());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines;
|
||||
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.machines.inventory.ValidatorIcon;
|
||||
import binnie.core.BinnieCore;
|
||||
import java.util.Set;
|
||||
import forestry.api.core.INBTTagable;
|
||||
import java.util.HashSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import binnie.core.ManagerBase;
|
||||
|
||||
public class ManagerMachine extends ManagerBase
|
||||
{
|
||||
private Map<Class<?>, Class<?>[]> componentInterfaceMap;
|
||||
private Map<String, MachineGroup> machineGroups;
|
||||
private Map<Integer, Class<?>> networkIDToComponent;
|
||||
private Map<Class<?>, Integer> componentToNetworkID;
|
||||
private int nextNetworkID;
|
||||
private int machineRenderID;
|
||||
|
||||
public ManagerMachine() {
|
||||
this.componentInterfaceMap = new HashMap<Class<?>, Class<?>[]>();
|
||||
this.machineGroups = new HashMap<String, MachineGroup>();
|
||||
this.networkIDToComponent = new HashMap<Integer, Class<?>>();
|
||||
this.componentToNetworkID = new HashMap<Class<?>, Integer>();
|
||||
this.nextNetworkID = 0;
|
||||
}
|
||||
|
||||
public void registerMachineGroup(final MachineGroup group) {
|
||||
this.machineGroups.put(group.getUID(), group);
|
||||
}
|
||||
|
||||
public MachineGroup getGroup(final String name) {
|
||||
return this.machineGroups.get(name);
|
||||
}
|
||||
|
||||
public MachinePackage getPackage(final String group, final String name) {
|
||||
final MachineGroup machineGroup = this.getGroup(group);
|
||||
return (machineGroup == null) ? null : machineGroup.getPackage(name);
|
||||
}
|
||||
|
||||
private void registerComponentClass(final Class<? extends MachineComponent> component) {
|
||||
if (this.componentInterfaceMap.containsKey(component)) {
|
||||
return;
|
||||
}
|
||||
final Set<Class<?>> interfaces = new HashSet<Class<?>>();
|
||||
for (Class<?> currentClass = component; currentClass != null; currentClass = null) {
|
||||
for (final Class<?> clss : currentClass.getInterfaces()) {
|
||||
interfaces.add(clss);
|
||||
}
|
||||
currentClass = currentClass.getSuperclass();
|
||||
if (currentClass == Object.class) {
|
||||
}
|
||||
}
|
||||
interfaces.remove(INBTTagable.class);
|
||||
this.componentInterfaceMap.put(component, interfaces.toArray(new Class[0]));
|
||||
final int networkID = this.nextNetworkID++;
|
||||
this.networkIDToComponent.put(networkID, component);
|
||||
this.componentToNetworkID.put(component, networkID);
|
||||
}
|
||||
|
||||
public int getNetworkID(final Class<?> component) {
|
||||
return this.componentToNetworkID.get(component);
|
||||
}
|
||||
|
||||
public Class<?> getComponentClass(final int networkID) {
|
||||
return this.networkIDToComponent.get(networkID);
|
||||
}
|
||||
|
||||
public int getMachineRenderID() {
|
||||
return this.machineRenderID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
this.machineRenderID = BinnieCore.proxy.getUniqueRenderID();
|
||||
SlotValidator.IconBee = new ValidatorIcon(BinnieCore.instance, "validator/bee.0", "validator/bee.1");
|
||||
SlotValidator.IconFrame = new ValidatorIcon(BinnieCore.instance, "validator/frame.0", "validator/frame.1");
|
||||
SlotValidator.IconCircuit = new ValidatorIcon(BinnieCore.instance, "validator/circuit.0", "validator/circuit.1");
|
||||
SlotValidator.IconBlock = new ValidatorIcon(BinnieCore.instance, "validator/block.0", "validator/block.1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
BinnieCore.proxy.registerBlockRenderer(BinnieCore.proxy.createObject("binnie.core.machines.RendererMachine"));
|
||||
BinnieCore.proxy.registerTileEntity(TileEntityMachine.class, "binnie.tile.machine", BinnieCore.proxy.createObject("binnie.core.machines.RendererMachine"));
|
||||
}
|
||||
|
||||
public Class<?>[] getComponentInterfaces(final Class<? extends MachineComponent> clss) {
|
||||
if (!this.componentInterfaceMap.containsKey(clss)) {
|
||||
this.registerComponentClass(clss);
|
||||
}
|
||||
return this.componentInterfaceMap.get(clss);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
|
||||
class ModelBlock extends ModelBase
|
||||
{
|
||||
private ModelRenderer Block;
|
||||
|
||||
public ModelBlock() {
|
||||
this.textureWidth = 64;
|
||||
this.textureHeight = 32;
|
||||
(this.Block = new ModelRenderer(this, 0, 0)).addBox(0.0f, 0.0f, 0.0f, 16, 16, 16);
|
||||
this.Block.setRotationPoint(-8.0f, 8.0f, -8.0f);
|
||||
this.Block.setTextureSize(64, 32);
|
||||
this.Block.mirror = true;
|
||||
this.setRotation(this.Block, 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.Block.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,67 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines;
|
||||
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import binnie.Binnie;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
|
||||
public class RendererMachine extends TileEntitySpecialRenderer implements ISimpleBlockRenderingHandler
|
||||
{
|
||||
RenderBlocks blockRenderer;
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(final TileEntity entity, final double x, final double y, final double z, final float var8) {
|
||||
this.renderTileEntity((TileEntityMachine) entity, x, y, z, var8, this.blockRenderer);
|
||||
}
|
||||
|
||||
public void renderTileEntity(final TileEntityMachine entity, final double x, final double y, final double z, final float var8, final RenderBlocks renderer) {
|
||||
if (entity != null && entity.getMachine() != null) {
|
||||
final MachinePackage machinePackage = entity.getMachine().getPackage();
|
||||
machinePackage.renderMachine(entity.getMachine(), x, y, z, var8, renderer);
|
||||
}
|
||||
}
|
||||
|
||||
public void renderInvBlock(final RenderBlocks renderblocks, final Block block, final int i, final int j) {
|
||||
final TileEntity entity = block.createTileEntity((World) null, i);
|
||||
this.renderTileEntity((TileEntityMachine) entity, 0.0, -0.1, 0.0, 0.0625f, renderblocks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(final Block block, final int metadata, final int modelID, final RenderBlocks renderer) {
|
||||
if (modelID == Binnie.Machine.getMachineRenderID()) {
|
||||
this.renderInvBlock(renderer, block, metadata, modelID);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(final IBlockAccess world, final int x, final int y, final int z, final Block block, final int modelId, final RenderBlocks renderer) {
|
||||
final TileEntityMachine tile = (TileEntityMachine) world.getTileEntity(x, y, z);
|
||||
if (tile != null && tile.getMachine() != null && tile.getMachine().getPackage() != null && tile.getMachine().getPackage().getGroup() != null && !tile.getMachine().getPackage().getGroup().customRenderer) {
|
||||
this.renderTileEntity(tile, x, y, z, 1.0f, renderer);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(final int i) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return Binnie.Machine.getMachineRenderID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_147496_a(final World par1World) {
|
||||
this.blockRenderer = new RenderBlocks(par1World);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines;
|
||||
|
||||
import binnie.core.machines.component.IInteraction;
|
||||
import net.minecraft.network.Packet;
|
||||
import binnie.core.network.packet.PacketPayload;
|
||||
import binnie.Binnie;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import binnie.core.network.INetworkedEntity;
|
||||
import binnie.core.machines.base.TileEntityMachineBase;
|
||||
|
||||
public class TileEntityMachine extends TileEntityMachineBase implements INetworkedEntity
|
||||
{
|
||||
private Machine machine;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
if (this.machine != null) {
|
||||
this.machine.onUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
return super.canUpdate();
|
||||
}
|
||||
|
||||
public TileEntityMachine(final MachinePackage pack) {
|
||||
this.setMachine(pack);
|
||||
}
|
||||
|
||||
public TileEntityMachine() {
|
||||
}
|
||||
|
||||
public void setMachine(final MachinePackage pack) {
|
||||
if (pack != null) {
|
||||
this.machine = new Machine(pack, this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound nbtTagCompound) {
|
||||
super.readFromNBT(nbtTagCompound);
|
||||
final String name = nbtTagCompound.getString("name");
|
||||
final String group = nbtTagCompound.getString("group");
|
||||
final MachinePackage pack = Binnie.Machine.getPackage(group, name);
|
||||
if (pack == null) {
|
||||
this.invalidate();
|
||||
return;
|
||||
}
|
||||
this.setMachine(pack);
|
||||
this.getMachine().readFromNBT(nbtTagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound nbtTagCompound) {
|
||||
super.writeToNBT(nbtTagCompound);
|
||||
final String name = this.machine.getPackage().getUID();
|
||||
final String group = this.machine.getPackage().getGroup().getUID();
|
||||
nbtTagCompound.setString("group", group);
|
||||
nbtTagCompound.setString("name", name);
|
||||
this.getMachine().writeToNBT(nbtTagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToPacket(final PacketPayload payload) {
|
||||
this.machine.writeToPacket(payload);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromPacket(final PacketPayload payload) {
|
||||
this.machine.readFromPacket(payload);
|
||||
}
|
||||
|
||||
public Machine getMachine() {
|
||||
return this.machine;
|
||||
}
|
||||
|
||||
public void onBlockDestroy() {
|
||||
if (this.getMachine() != null) {
|
||||
this.getMachine().onBlockDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Packet getDescriptionPacket() {
|
||||
return (this.getMachine() != null) ? this.getMachine().getDescriptionPacket() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
for (final IInteraction.Invalidation c : this.getMachine().getInterfaces(IInteraction.Invalidation.class)) {
|
||||
c.onInvalidation();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
for (final IInteraction.ChunkUnload c : this.getMachine().getInterfaces(IInteraction.ChunkUnload.class)) {
|
||||
c.onChunkUnload();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.base;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.core.machines.inventory.IInventoryMachine;
|
||||
|
||||
class DefaultInventory implements IInventoryMachine
|
||||
{
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(final int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(final int i, final int j) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(final int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(final int i, final ItemStack itemstack) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(final EntityPlayer entityplayer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(final int i, final ItemStack itemstack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(final int var1) {
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(final int i, final ItemStack itemstack, final int j) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(final int i, final ItemStack itemstack, final int j) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly(final int slot) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.base;
|
||||
|
||||
import binnie.core.machines.power.PowerInterface;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import binnie.core.machines.power.PowerInfo;
|
||||
import binnie.core.machines.power.IPoweredMachine;
|
||||
|
||||
class DefaultPower implements IPoweredMachine
|
||||
{
|
||||
@Override
|
||||
public PowerInfo getPowerInfo() {
|
||||
return new PowerInfo(this, 0.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "IC2")
|
||||
public double getDemandedEnergy() {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "IC2")
|
||||
public int getSinkTier() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "IC2")
|
||||
public double injectEnergy(final ForgeDirection directionFrom, final double amount, final double voltage) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "IC2")
|
||||
public boolean acceptsEnergyFrom(final TileEntity emitter, final ForgeDirection direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(final ForgeDirection from, final int maxReceive, final boolean simulate) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(final ForgeDirection from, final int maxExtract, final boolean simulate) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(final ForgeDirection from) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(final ForgeDirection from) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(final ForgeDirection from) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PowerInterface getInterface() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.base;
|
||||
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import binnie.core.machines.inventory.TankSlot;
|
||||
import binnie.core.machines.power.TankInfo;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import binnie.core.machines.power.ITankMachine;
|
||||
|
||||
class DefaultTankContainer implements ITankMachine
|
||||
{
|
||||
@Override
|
||||
public int fill(final ForgeDirection from, final FluidStack resource, final boolean doFill) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(final ForgeDirection from, final int maxDrain, final boolean doDrain) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TankInfo[] getTankInfos() {
|
||||
return new TankInfo[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTankReadOnly(final int tank) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLiquidValidForTank(final FluidStack liquid, final int tank) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TankSlot addTank(final int index, final String name, final int capacity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidTank getTank(final int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TankSlot getTankSlot(final int slot) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(final ForgeDirection from, final FluidStack resource, final boolean doDrain) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(final ForgeDirection from, final Fluid fluid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(final ForgeDirection from, final Fluid fluid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(final ForgeDirection from) {
|
||||
return new FluidTankInfo[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidTank[] getTanks() {
|
||||
return new IFluidTank[0];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,251 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.base;
|
||||
|
||||
import binnie.core.machines.power.PowerInterface;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import binnie.core.machines.inventory.TankSlot;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import binnie.core.machines.power.TankInfo;
|
||||
import binnie.core.machines.power.PowerInfo;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.power.IPoweredMachine;
|
||||
import binnie.core.machines.power.ITankMachine;
|
||||
import binnie.core.machines.inventory.IInventoryMachine;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TileEntityMachineBase extends TileEntity implements IInventoryMachine, ITankMachine, IPoweredMachine
|
||||
{
|
||||
public IInventoryMachine getInventory() {
|
||||
final IInventoryMachine inv = Machine.getInterface(IInventoryMachine.class, this);
|
||||
return (inv == null || inv == this) ? new DefaultInventory() : inv;
|
||||
}
|
||||
|
||||
public ITankMachine getTankContainer() {
|
||||
final ITankMachine inv = Machine.getInterface(ITankMachine.class, this);
|
||||
return (inv == null || inv == this) ? new DefaultTankContainer() : inv;
|
||||
}
|
||||
|
||||
public IPoweredMachine getPower() {
|
||||
final IPoweredMachine inv = Machine.getInterface(IPoweredMachine.class, this);
|
||||
return (inv == null || inv == this) ? new DefaultPower() : inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return this.getInventory().getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(final int index) {
|
||||
return this.getInventory().getStackInSlot(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(final int index, final int amount) {
|
||||
return this.getInventory().decrStackSize(index, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(final int var1) {
|
||||
return this.getInventory().getStackInSlotOnClosing(var1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(final int index, final ItemStack itemStack) {
|
||||
this.getInventory().setInventorySlotContents(index, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return this.getInventory().getInventoryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return this.getInventory().getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(final EntityPlayer entityplayer) {
|
||||
return !this.isInvalid() && this.getWorldObj().getTileEntity(this.xCoord, this.yCoord, this.zCoord) == this && entityplayer.getDistanceSq(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5) <= 64.0 && this.getInventory().isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
this.getInventory().openInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
this.getInventory().closeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return this.getInventory().hasCustomInventoryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
super.markDirty();
|
||||
this.getInventory().markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(final int slot, final ItemStack itemStack) {
|
||||
return this.getInventory().isItemValidForSlot(slot, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(final int var1) {
|
||||
return this.getInventory().getAccessibleSlotsFromSide(var1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(final int i, final ItemStack itemstack, final int j) {
|
||||
return this.getInventory().canInsertItem(i, itemstack, j);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(final int i, final ItemStack itemstack, final int j) {
|
||||
return this.getInventory().canExtractItem(i, itemstack, j);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly(final int slot) {
|
||||
return this.getInventory().isReadOnly(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PowerInfo getPowerInfo() {
|
||||
return this.getPower().getPowerInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TankInfo[] getTankInfos() {
|
||||
return this.getTankContainer().getTankInfos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTankReadOnly(final int tank) {
|
||||
return this.getTankContainer().isTankReadOnly(tank);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLiquidValidForTank(final FluidStack liquid, final int tank) {
|
||||
return this.getTankContainer().isLiquidValidForTank(liquid, tank);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TankSlot addTank(final int index, final String name, final int capacity) {
|
||||
return this.getTankContainer().addTank(index, name, capacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidTank getTank(final int index) {
|
||||
return this.getTankContainer().getTank(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TankSlot getTankSlot(final int index) {
|
||||
return this.getTankContainer().getTankSlot(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(final ForgeDirection from, final FluidStack resource, final boolean doFill) {
|
||||
return this.getTankContainer().fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(final ForgeDirection from, final FluidStack resource, final boolean doDrain) {
|
||||
return this.getTankContainer().drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(final ForgeDirection from, final int maxDrain, final boolean doDrain) {
|
||||
return this.getTankContainer().drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(final ForgeDirection from, final Fluid fluid) {
|
||||
return this.getTankContainer().canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(final ForgeDirection from, final Fluid fluid) {
|
||||
return this.getTankContainer().canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(final ForgeDirection from) {
|
||||
return this.getTankContainer().getTankInfo(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidTank[] getTanks() {
|
||||
return this.getTankContainer().getTanks();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "IC2")
|
||||
public double getDemandedEnergy() {
|
||||
return this.getPower().getDemandedEnergy();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "IC2")
|
||||
public int getSinkTier() {
|
||||
return this.getPower().getSinkTier();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "IC2")
|
||||
public double injectEnergy(final ForgeDirection directionFrom, final double amount, final double voltage) {
|
||||
return this.getPower().injectEnergy(directionFrom, amount, voltage);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "IC2")
|
||||
public boolean acceptsEnergyFrom(final TileEntity emitter, final ForgeDirection direction) {
|
||||
return this.getPower().acceptsEnergyFrom(emitter, direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(final ForgeDirection from, final int maxReceive, final boolean simulate) {
|
||||
return this.getPower().receiveEnergy(from, maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(final ForgeDirection from, final int maxExtract, final boolean simulate) {
|
||||
return this.getPower().extractEnergy(from, maxExtract, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(final ForgeDirection from) {
|
||||
return this.getPower().getEnergyStored(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(final ForgeDirection from) {
|
||||
return this.getPower().getMaxEnergyStored(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(final ForgeDirection from) {
|
||||
return this.getPower().canConnectEnergy(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PowerInterface getInterface() {
|
||||
return this.getPower().getInterface();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.component;
|
||||
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
|
||||
public abstract class ComponentRecipe extends MachineComponent implements IComponentRecipe
|
||||
{
|
||||
public ComponentRecipe(final Machine machine) {
|
||||
super(machine);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.component;
|
||||
|
||||
import buildcraft.api.statements.IActionExternal;
|
||||
import buildcraft.api.statements.IActionReceptor;
|
||||
import binnie.core.triggers.TriggerData;
|
||||
import java.util.List;
|
||||
|
||||
public interface IBuildcraft
|
||||
{
|
||||
public interface TriggerProvider
|
||||
{
|
||||
void getTriggers(final List<TriggerData> p0);
|
||||
}
|
||||
|
||||
public interface ActionProvider extends IActionReceptor
|
||||
{
|
||||
void getActions(final List<IActionExternal> p0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.component;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IComponentRecipe
|
||||
{
|
||||
boolean isRecipe();
|
||||
|
||||
ItemStack doRecipe(final boolean p0);
|
||||
|
||||
ItemStack getProduct();
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.component;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IInteraction
|
||||
{
|
||||
public interface ChunkUnload
|
||||
{
|
||||
void onChunkUnload();
|
||||
}
|
||||
|
||||
public interface Invalidation
|
||||
{
|
||||
void onInvalidation();
|
||||
}
|
||||
|
||||
public interface RightClick
|
||||
{
|
||||
void onRightClick(final World p0, final EntityPlayer p1, final int p2, final int p3, final int p4);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.component;
|
||||
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.Random;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IRender
|
||||
{
|
||||
public interface DisplayTick
|
||||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
void onDisplayTick(final World p0, final int p1, final int p2, final int p3, final Random p4);
|
||||
}
|
||||
|
||||
public interface RandomDisplayTick
|
||||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
void onRandomDisplayTick(final World p0, final int p1, final int p2, final int p3, final Random p4);
|
||||
}
|
||||
|
||||
public interface Render
|
||||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
void renderInWorld(final RenderItem p0, final double p1, final double p2, final double p3);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.inventory;
|
||||
|
||||
enum AccessDirection
|
||||
{
|
||||
Both,
|
||||
In,
|
||||
Out,
|
||||
Neither;
|
||||
|
||||
boolean canInsert() {
|
||||
return this == AccessDirection.Both || this == AccessDirection.In;
|
||||
}
|
||||
|
||||
boolean canExtract() {
|
||||
return this == AccessDirection.Both || this == AccessDirection.Out;
|
||||
}
|
||||
|
||||
boolean canAccess() {
|
||||
return this != AccessDirection.Neither;
|
||||
}
|
||||
|
||||
AccessDirection changeInsert(final boolean b) {
|
||||
if (b) {
|
||||
if (this == AccessDirection.Out) {
|
||||
return AccessDirection.Both;
|
||||
}
|
||||
if (this == AccessDirection.Neither) {
|
||||
return AccessDirection.In;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this == AccessDirection.Both) {
|
||||
return AccessDirection.Out;
|
||||
}
|
||||
if (this == AccessDirection.In) {
|
||||
return AccessDirection.Neither;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
AccessDirection changeExtract(final boolean b) {
|
||||
if (b) {
|
||||
if (this == AccessDirection.In) {
|
||||
return AccessDirection.Both;
|
||||
}
|
||||
if (this == AccessDirection.Neither) {
|
||||
return AccessDirection.Out;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this == AccessDirection.Both) {
|
||||
return AccessDirection.In;
|
||||
}
|
||||
if (this == AccessDirection.Out) {
|
||||
return AccessDirection.Neither;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTextColour() {
|
||||
switch (this) {
|
||||
case Both: {
|
||||
return "§a";
|
||||
}
|
||||
case In: {
|
||||
return "§e";
|
||||
}
|
||||
case Neither: {
|
||||
return "§c";
|
||||
}
|
||||
default: {
|
||||
return "§b";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getShadeColour() {
|
||||
switch (this) {
|
||||
case Both: {
|
||||
return 1431699285;
|
||||
}
|
||||
case In: {
|
||||
return 1442840405;
|
||||
}
|
||||
case Neither: {
|
||||
return 1442796885;
|
||||
}
|
||||
default: {
|
||||
return 1431699455;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.inventory;
|
||||
|
||||
import java.util.Collection;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import java.util.EnumSet;
|
||||
import binnie.core.util.IValidator;
|
||||
import forestry.api.core.INBTTagable;
|
||||
|
||||
public abstract class BaseSlot<T> implements INBTTagable, IValidator<T>
|
||||
{
|
||||
private SidedAccess access;
|
||||
Validator<T> validator;
|
||||
private boolean readOnly;
|
||||
private int index;
|
||||
protected String unlocName;
|
||||
|
||||
public BaseSlot(final int index, final String unlocName) {
|
||||
this.access = new SidedAccess();
|
||||
this.validator = null;
|
||||
this.readOnly = false;
|
||||
this.unlocName = "";
|
||||
this.setIndex(index);
|
||||
this.setUnlocalisedName(unlocName);
|
||||
}
|
||||
|
||||
public void setReadOnly() {
|
||||
this.readOnly = true;
|
||||
this.forbidInsertion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final T item) {
|
||||
return item == null || this.validator == null || this.validator.isValid(item);
|
||||
}
|
||||
|
||||
public abstract T getContent();
|
||||
|
||||
public abstract void setContent(final T p0);
|
||||
|
||||
public void setValidator(final Validator<T> val) {
|
||||
this.validator = val;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this.getContent() == null;
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
return this.readOnly;
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return this.index;
|
||||
}
|
||||
|
||||
private void setIndex(final int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public boolean canInsert() {
|
||||
return !this.access.getInsertionSides().isEmpty();
|
||||
}
|
||||
|
||||
public boolean canExtract() {
|
||||
return !this.access.getExtractionSides().isEmpty();
|
||||
}
|
||||
|
||||
public void forbidInteraction() {
|
||||
this.forbidInsertion();
|
||||
this.forbidExtraction();
|
||||
}
|
||||
|
||||
public void setInputSides(final EnumSet<ForgeDirection> sides) {
|
||||
for (final ForgeDirection side : EnumSet.complementOf(sides)) {
|
||||
if (side != ForgeDirection.UNKNOWN) {
|
||||
this.access.setInsert(side, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setOutputSides(final EnumSet<ForgeDirection> sides) {
|
||||
for (final ForgeDirection side : EnumSet.complementOf(sides)) {
|
||||
if (side != ForgeDirection.UNKNOWN) {
|
||||
this.access.setExtract(side, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void forbidExtraction() {
|
||||
this.access.setExtract(false);
|
||||
this.access.forbidExtractChange();
|
||||
}
|
||||
|
||||
public void forbidInsertion() {
|
||||
this.access.setInsert(false);
|
||||
this.access.forbidInsertChange();
|
||||
}
|
||||
|
||||
public boolean canInsert(final ForgeDirection dir) {
|
||||
return this.access.canInsert(dir);
|
||||
}
|
||||
|
||||
public boolean canExtract(final ForgeDirection dir) {
|
||||
return this.access.canExtract(dir);
|
||||
}
|
||||
|
||||
public Collection<ForgeDirection> getInputSides() {
|
||||
return this.access.getInsertionSides();
|
||||
}
|
||||
|
||||
public Collection<ForgeDirection> getOutputSides() {
|
||||
return this.access.getExtractionSides();
|
||||
}
|
||||
|
||||
public void setUnlocalisedName(final String name) {
|
||||
this.unlocName = name;
|
||||
}
|
||||
|
||||
public abstract String getName();
|
||||
|
||||
public Validator<T> getValidator() {
|
||||
return this.validator;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.inventory;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import java.util.HashMap;
|
||||
import binnie.core.machines.Machine;
|
||||
import java.util.Map;
|
||||
import binnie.core.machines.network.INetwork;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
|
||||
public class ComponentChargedSlots extends MachineComponent implements INetwork.GuiNBT, IChargedSlots
|
||||
{
|
||||
private Map<Integer, Float> charges;
|
||||
|
||||
public ComponentChargedSlots(final Machine machine) {
|
||||
super(machine);
|
||||
this.charges = new HashMap<Integer, Float>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
this.charges.clear();
|
||||
final NBTTagList list = nbttagcompound.getTagList("charges", 10);
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
final NBTTagCompound tag = list.getCompoundTagAt(i);
|
||||
this.charges.put((int) tag.getByte("i"), tag.getByte("v") / 100.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
final NBTTagList chargeList = new NBTTagList();
|
||||
for (final Map.Entry<Integer, Float> entry : this.charges.entrySet()) {
|
||||
final NBTTagCompound chargesNBT = new NBTTagCompound();
|
||||
chargesNBT.setByte("i", (byte) (0 + entry.getKey()));
|
||||
chargesNBT.setByte("v", (byte) (entry.getValue() * 100.0f));
|
||||
chargeList.appendTag(chargesNBT);
|
||||
}
|
||||
nbttagcompound.setTag("charges", chargeList);
|
||||
}
|
||||
|
||||
public void addCharge(final int slot) {
|
||||
this.charges.put(slot, 0.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recieveGuiNBT(final Side side, final EntityPlayer player, final String name, final NBTTagCompound nbt) {
|
||||
if (name.equals("slot-charges")) {
|
||||
for (final int i : this.charges.keySet()) {
|
||||
this.charges.put(i, nbt.getShort("" + i) / 100.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendGuiNBT(final Map<String, NBTTagCompound> nbt) {
|
||||
final NBTTagCompound tag = new NBTTagCompound();
|
||||
for (final int i : this.charges.keySet()) {
|
||||
tag.setShort("" + i, (short) (this.charges.get(i) * 100.0f));
|
||||
}
|
||||
nbt.put("slot-charges", tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getCharge(final int slot) {
|
||||
return this.charges.containsKey(slot) ? this.charges.get(slot) : 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCharge(final int slot, float charge) {
|
||||
if (charge > 1.0f) {
|
||||
charge = 1.0f;
|
||||
}
|
||||
if (charge < 0.0f) {
|
||||
charge = 0.0f;
|
||||
}
|
||||
if (this.charges.containsKey(slot)) {
|
||||
this.charges.put(slot, charge);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
for (final int slot : this.charges.keySet()) {
|
||||
if (this.getCharge(slot) <= 0.0f && this.getUtil().decreaseStack(slot, 1) != null) {
|
||||
this.setCharge(slot, 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void alterCharge(final int slot, final float charge) {
|
||||
this.setCharge(slot, this.getCharge(slot) + charge);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.inventory;
|
||||
|
||||
import binnie.core.machines.IMachine;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
|
||||
public abstract class ComponentInventory extends MachineComponent implements IInventory
|
||||
{
|
||||
public ComponentInventory(final IMachine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
if (this.getMachine() != null) {
|
||||
this.getMachine().markDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.inventory;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import java.util.List;
|
||||
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 net.minecraft.item.ItemStack;
|
||||
import java.util.LinkedHashMap;
|
||||
import binnie.core.machines.IMachine;
|
||||
import java.util.Map;
|
||||
|
||||
public class ComponentInventorySlots extends ComponentInventory implements IInventoryMachine, IInventorySlots
|
||||
{
|
||||
private Map<Integer, InventorySlot> inventory;
|
||||
|
||||
public ComponentInventorySlots(final IMachine machine) {
|
||||
super(machine);
|
||||
this.inventory = new LinkedHashMap<Integer, InventorySlot>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
int size = 0;
|
||||
for (final Integer index : this.inventory.keySet()) {
|
||||
size = Math.max(size, index + 1);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(final int index) {
|
||||
if (this.inventory.containsKey(index)) {
|
||||
return this.inventory.get(index).getContent();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(final int index, final int amount) {
|
||||
if (this.inventory.containsKey(index)) {
|
||||
final ItemStack stack = this.inventory.get(index).decrStackSize(amount);
|
||||
this.markDirty();
|
||||
return stack;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(final int var1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(final int index, final ItemStack itemStack) {
|
||||
if (this.inventory.containsKey(index) && (itemStack == null || this.inventory.get(index).isValid(itemStack))) {
|
||||
this.inventory.get(index).setContent(itemStack);
|
||||
}
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
protected void transferItem(final int indexFrom, final int indexTo) {
|
||||
if (this.inventory.containsKey(indexFrom) && this.inventory.containsKey(indexTo)) {
|
||||
final ItemStack newStack = this.inventory.get(indexFrom).getContent().copy();
|
||||
this.inventory.get(indexFrom).setContent(null);
|
||||
this.inventory.get(indexTo).setContent(newStack);
|
||||
}
|
||||
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() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
if (nbttagcompound.hasKey("inventory")) {
|
||||
final NBTTagList inventoryNBT = nbttagcompound.getTagList("inventory", 10);
|
||||
for (int i = 0; i < inventoryNBT.tagCount(); ++i) {
|
||||
final NBTTagCompound slotNBT = inventoryNBT.getCompoundTagAt(i);
|
||||
int index = slotNBT.getInteger("id");
|
||||
if (slotNBT.hasKey("Slot")) {
|
||||
index = (slotNBT.getByte("Slot") & 0xFF);
|
||||
}
|
||||
if (this.inventory.containsKey(index)) {
|
||||
this.inventory.get(index).readFromNBT(slotNBT);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
final NBTTagList inventoryNBT = new NBTTagList();
|
||||
for (final Map.Entry<Integer, InventorySlot> entry : this.inventory.entrySet()) {
|
||||
final NBTTagCompound slotNBT = new NBTTagCompound();
|
||||
slotNBT.setInteger("id", entry.getKey());
|
||||
entry.getValue().writeToNBT(slotNBT);
|
||||
inventoryNBT.appendTag(slotNBT);
|
||||
}
|
||||
nbttagcompound.setTag("inventory", inventoryNBT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final InventorySlot addSlot(final int index, final String unlocName) {
|
||||
this.inventory.put(index, new InventorySlot(index, unlocName));
|
||||
return this.getSlot(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final InventorySlot[] addSlotArray(final int[] indexes, final String unlocName) {
|
||||
for (final int k : indexes) {
|
||||
this.addSlot(k, unlocName);
|
||||
}
|
||||
return this.getSlots(indexes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventorySlot getSlot(final int index) {
|
||||
if (this.inventory.containsKey(index)) {
|
||||
return this.inventory.get(index);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventorySlot[] getAllSlots() {
|
||||
return this.inventory.values().toArray(new InventorySlot[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventorySlot[] getSlots(final int[] indexes) {
|
||||
final List<InventorySlot> list = new ArrayList<InventorySlot>();
|
||||
for (final int i : indexes) {
|
||||
if (this.getSlot(i) != null) {
|
||||
list.add(this.getSlot(i));
|
||||
}
|
||||
}
|
||||
return list.toArray(new InventorySlot[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly(final int slot) {
|
||||
final InventorySlot iSlot = this.getSlot(slot);
|
||||
return iSlot == null || iSlot.isReadOnly();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(final int slot, final ItemStack itemStack) {
|
||||
final InventorySlot iSlot = this.getSlot(slot);
|
||||
return iSlot != null && (iSlot.isValid(itemStack) && !this.isReadOnly(slot));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestruction() {
|
||||
for (final InventorySlot slot : this.inventory.values()) {
|
||||
final ItemStack stack = slot.getContent();
|
||||
if (!slot.isRecipe() && 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 (stack.stackSize == 0) {
|
||||
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, 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 int[] getAccessibleSlotsFromSide(final int var1) {
|
||||
final List<Integer> slots = new ArrayList<Integer>();
|
||||
for (final InventorySlot slot : this.inventory.values()) {
|
||||
if (slot.canInsert() || slot.canExtract()) {
|
||||
slots.add(slot.getIndex());
|
||||
}
|
||||
}
|
||||
final int[] ids = new int[slots.size()];
|
||||
for (int i = 0; i < slots.size(); ++i) {
|
||||
ids[i] = slots.get(i);
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(final int i, final ItemStack itemstack, final int j) {
|
||||
return this.isItemValidForSlot(i, itemstack) && this.getSlot(i).canInsert(ForgeDirection.getOrientation(j));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(final int i, final ItemStack itemstack, final int j) {
|
||||
return this.getSlot(i).canExtract(ForgeDirection.getOrientation(j));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.inventory;
|
||||
|
||||
import binnie.core.machines.transfer.TransferRequest;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import java.util.ArrayList;
|
||||
import binnie.core.machines.IMachine;
|
||||
import java.util.List;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
|
||||
public class ComponentInventoryTransfer extends MachineComponent
|
||||
{
|
||||
private List<Transfer> transfers;
|
||||
|
||||
public ComponentInventoryTransfer(final IMachine machine) {
|
||||
super(machine);
|
||||
this.transfers = new ArrayList<Transfer>();
|
||||
}
|
||||
|
||||
public void addRestock(final int[] buffer, final int destination, final int limit) {
|
||||
this.transfers.add(new Restock(this.getMachine(), buffer, destination, limit));
|
||||
}
|
||||
|
||||
public void addRestock(final int[] buffer, final int destination) {
|
||||
this.transfers.add(new Restock(this.getMachine(), buffer, destination));
|
||||
}
|
||||
|
||||
public void addStorage(final int source, final int[] destination) {
|
||||
this.transfers.add(new Storage(this.getMachine(), source, destination));
|
||||
}
|
||||
|
||||
public void performTransfer(final int source, final int[] destination) {
|
||||
new Storage(this.getMachine(), source, destination).transfer(this.getMachine().getInterface(IInventoryMachine.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
for (final Transfer transfer : this.transfers) {
|
||||
transfer.transfer(this.getMachine().getInterface(IInventoryMachine.class));
|
||||
}
|
||||
}
|
||||
|
||||
public void addStorage(final int source, final int[] destination, final Condition condition) {
|
||||
this.transfers.add(new Storage(this.getMachine(), source, destination).setCondition(condition));
|
||||
}
|
||||
|
||||
public abstract class Transfer
|
||||
{
|
||||
protected Condition condition;
|
||||
protected IMachine machine;
|
||||
|
||||
private Transfer(final IMachine machine) {
|
||||
this.machine = machine;
|
||||
}
|
||||
|
||||
public final void transfer(final IInventory inv) {
|
||||
if (this.condition == null || this.fufilled(inv)) {
|
||||
this.doTransfer(inv);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean fufilled(final IInventory inv) {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void doTransfer(final IInventory inv) {
|
||||
}
|
||||
|
||||
public final Transfer setCondition(final Condition condition) {
|
||||
this.condition = condition;
|
||||
return condition.transfer = this;
|
||||
}
|
||||
|
||||
public final IMachine getMachine() {
|
||||
return this.machine;
|
||||
}
|
||||
}
|
||||
|
||||
private class Restock extends Transfer
|
||||
{
|
||||
int[] buffer;
|
||||
int destination;
|
||||
int limit;
|
||||
|
||||
private Restock(final IMachine machine, final int[] buffer, final int destination, final int limit) {
|
||||
super(machine);
|
||||
this.buffer = buffer;
|
||||
this.destination = destination;
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
private Restock(final IMachine machine, final int[] buffer, final int destination) {
|
||||
this(machine, buffer, destination, 64);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doTransfer(final IInventory inv) {
|
||||
if (inv.getStackInSlot(this.destination) == null) {
|
||||
for (final int i : this.buffer) {
|
||||
if (inv.getStackInSlot(i) != null) {
|
||||
final ItemStack newStack = inv.decrStackSize(i, this.limit);
|
||||
if (newStack != null) {
|
||||
inv.setInventorySlotContents(this.destination, newStack);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class Storage extends Transfer
|
||||
{
|
||||
int source;
|
||||
int[] destination;
|
||||
|
||||
private Storage(final IMachine machine, final int source, final int[] destination) {
|
||||
super(machine);
|
||||
this.source = source;
|
||||
this.destination = destination;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doTransfer(final IInventory inv) {
|
||||
if (inv.getStackInSlot(this.source) != null) {
|
||||
inv.setInventorySlotContents(this.source, new TransferRequest(inv.getStackInSlot(this.source), inv).setTargetSlots(this.destination).ignoreValidation().transfer(true));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean fufilled(final IInventory inv) {
|
||||
final ItemStack stack = inv.getStackInSlot(this.source);
|
||||
return stack != null && this.condition.fufilled(stack);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract static class Condition
|
||||
{
|
||||
public Transfer transfer;
|
||||
|
||||
public abstract boolean fufilled(final ItemStack p0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.inventory;
|
||||
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import binnie.core.machines.power.TankInfo;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import java.util.LinkedHashMap;
|
||||
import binnie.core.machines.IMachine;
|
||||
import java.util.Map;
|
||||
import binnie.core.machines.power.ITankMachine;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
|
||||
public class ComponentTankContainer extends MachineComponent implements ITankMachine
|
||||
{
|
||||
private Map<Integer, TankSlot> tanks;
|
||||
|
||||
public ComponentTankContainer(final IMachine machine) {
|
||||
super(machine);
|
||||
this.tanks = new LinkedHashMap<Integer, TankSlot>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final TankSlot addTank(final int index, final String name, final int capacity) {
|
||||
final TankSlot tank = new TankSlot(index, name, capacity);
|
||||
this.tanks.put(index, tank);
|
||||
return tank;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int fill(final ForgeDirection from, final FluidStack resource, final boolean doFill) {
|
||||
final int index = this.getTankIndexToFill(from, resource);
|
||||
if (this.tanks.containsKey(index)) {
|
||||
return this.fill(index, resource, doFill);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final FluidStack drain(final ForgeDirection from, final int maxDrain, final boolean doDrain) {
|
||||
final int index = this.getTankIndexToDrain(from, null);
|
||||
if (this.tanks.containsKey(index)) {
|
||||
return this.drain(index, maxDrain, doDrain);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private final int fill(final int tankIndex, final FluidStack resource, final boolean doFill) {
|
||||
if (!this.tanks.containsKey(tankIndex)) {
|
||||
return 0;
|
||||
}
|
||||
if (!this.isLiquidValidForTank(resource, tankIndex)) {
|
||||
return 0;
|
||||
}
|
||||
final TankSlot tank = this.tanks.get(tankIndex);
|
||||
final int filled = tank.getTank().fill(resource, doFill);
|
||||
if (filled > 0) {
|
||||
this.markDirty();
|
||||
}
|
||||
return filled;
|
||||
}
|
||||
|
||||
private final FluidStack drain(final int tankIndex, final int maxDrain, final boolean doDrain) {
|
||||
if (!this.tanks.containsKey(tankIndex)) {
|
||||
return null;
|
||||
}
|
||||
final TankSlot tank = this.tanks.get(tankIndex);
|
||||
final FluidStack drained = tank.getTank().drain(maxDrain, doDrain);
|
||||
if (drained != null) {
|
||||
this.markDirty();
|
||||
}
|
||||
return drained;
|
||||
}
|
||||
|
||||
private int getTankIndexToFill(final ForgeDirection from, final FluidStack resource) {
|
||||
for (final TankSlot tank : this.tanks.values()) {
|
||||
if (tank.isValid(resource) && tank.canInsert(from) && (tank.getContent() == null || tank.getContent().isFluidEqual(resource))) {
|
||||
return tank.getIndex();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private int getTankIndexToDrain(final ForgeDirection from, final FluidStack resource) {
|
||||
for (final TankSlot tank : this.tanks.values()) {
|
||||
if (tank.getContent() != null && tank.canExtract(from) && (resource == null || resource.isFluidEqual(tank.getContent()))) {
|
||||
return tank.getIndex();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
if (nbttagcompound.hasKey("liquidTanks")) {
|
||||
final NBTTagList tanksNBT = nbttagcompound.getTagList("liquidTanks", 10);
|
||||
for (int i = 0; i < tanksNBT.tagCount(); ++i) {
|
||||
final NBTTagCompound tankNBT = tanksNBT.getCompoundTagAt(i);
|
||||
final int index = tankNBT.getInteger("index");
|
||||
if (this.tanks.containsKey(index)) {
|
||||
this.tanks.get(index).readFromNBT(tankNBT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
final NBTTagList tanksNBT = new NBTTagList();
|
||||
for (final Map.Entry<Integer, TankSlot> entry : this.tanks.entrySet()) {
|
||||
final NBTTagCompound tankNBT = new NBTTagCompound();
|
||||
tankNBT.setInteger("index", entry.getKey());
|
||||
entry.getValue().writeToNBT(tankNBT);
|
||||
tanksNBT.appendTag(tankNBT);
|
||||
}
|
||||
nbttagcompound.setTag("liquidTanks", tanksNBT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTankReadOnly(final int tank) {
|
||||
return this.tanks.get(tank).isReadOnly();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLiquidValidForTank(final FluidStack liquid, final int tank) {
|
||||
final TankSlot slot = this.getTankSlot(tank);
|
||||
return slot != null && (slot.isValid(liquid) && !slot.isReadOnly());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TankInfo[] getTankInfos() {
|
||||
return TankInfo.get(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidTank getTank(final int index) {
|
||||
return this.getTanks()[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidTank[] getTanks() {
|
||||
final List<IFluidTank> ltanks = new ArrayList<IFluidTank>();
|
||||
for (final TankSlot tank : this.tanks.values()) {
|
||||
ltanks.add(tank.getTank());
|
||||
}
|
||||
return ltanks.toArray(new IFluidTank[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TankSlot getTankSlot(final int index) {
|
||||
return this.tanks.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(final ForgeDirection from, final FluidStack resource, final boolean doDrain) {
|
||||
final int index = this.getTankIndexToDrain(from, null);
|
||||
if (this.tanks.containsKey(index)) {
|
||||
return this.drain(index, resource.amount, doDrain);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(final ForgeDirection from, final Fluid fluid) {
|
||||
return this.fill(from, new FluidStack(fluid, 1), false) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(final ForgeDirection from, final Fluid fluid) {
|
||||
return this.drain(from, new FluidStack(fluid, 1), false) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(final ForgeDirection from) {
|
||||
final FluidTankInfo[] info = new FluidTankInfo[this.getTanks().length];
|
||||
for (int i = 0; i < info.length; ++i) {
|
||||
info[i] = new FluidTankInfo(this.getTanks()[i]);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
public void markDirty() {
|
||||
if (this.getMachine() != null) {
|
||||
this.getMachine().markDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.inventory;
|
||||
|
||||
public interface IChargedSlots
|
||||
{
|
||||
float getCharge(final int p0);
|
||||
|
||||
void setCharge(final int p0, final float p1);
|
||||
|
||||
void alterCharge(final int p0, final float p1);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.inventory;
|
||||
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
public interface IInventoryMachine extends IInventory, ISidedInventory, IValidatedInventory
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.inventory;
|
||||
|
||||
public interface IInventorySlots
|
||||
{
|
||||
InventorySlot addSlot(final int p0, final String p1);
|
||||
|
||||
InventorySlot[] addSlotArray(final int[] p0, final String p1);
|
||||
|
||||
InventorySlot getSlot(final int p0);
|
||||
|
||||
InventorySlot[] getSlots(final int[] p0);
|
||||
|
||||
InventorySlot[] getAllSlots();
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.inventory;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
interface IValidatedInventory extends IInventory
|
||||
{
|
||||
boolean isReadOnly(final int p0);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.inventory;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public interface IValidatedTankContainer
|
||||
{
|
||||
boolean isTankReadOnly(final int p0);
|
||||
|
||||
boolean isLiquidValidForTank(final FluidStack p0, final int p1);
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.inventory;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.Binnie;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class InventorySlot extends BaseSlot<ItemStack>
|
||||
{
|
||||
private ItemStack itemStack;
|
||||
private Type type;
|
||||
|
||||
public InventorySlot(final int index, final String unlocName) {
|
||||
super(index, unlocName);
|
||||
this.itemStack = null;
|
||||
this.type = Type.Standard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getContent() {
|
||||
return this.itemStack;
|
||||
}
|
||||
|
||||
public ItemStack getItemStack() {
|
||||
return this.getContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContent(final ItemStack itemStack) {
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
|
||||
public ItemStack decrStackSize(final int amount) {
|
||||
if (this.itemStack == null) {
|
||||
return null;
|
||||
}
|
||||
if (this.itemStack.stackSize <= amount) {
|
||||
final ItemStack returnStack = this.itemStack.copy();
|
||||
this.itemStack = null;
|
||||
return returnStack;
|
||||
}
|
||||
final ItemStack returnStack = this.itemStack.copy();
|
||||
final ItemStack itemStack = this.itemStack;
|
||||
itemStack.stackSize -= amount;
|
||||
returnStack.stackSize = amount;
|
||||
return returnStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound slotNBT) {
|
||||
if (slotNBT.hasKey("item")) {
|
||||
final NBTTagCompound itemNBT = slotNBT.getCompoundTag("item");
|
||||
this.itemStack = ItemStack.loadItemStackFromNBT(itemNBT);
|
||||
}
|
||||
else {
|
||||
this.itemStack = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound slotNBT) {
|
||||
final NBTTagCompound itemNBT = new NBTTagCompound();
|
||||
if (this.itemStack != null) {
|
||||
this.itemStack.writeToNBT(itemNBT);
|
||||
}
|
||||
slotNBT.setTag("item", itemNBT);
|
||||
}
|
||||
|
||||
public void setItemStack(final ItemStack duplicate) {
|
||||
this.setContent(duplicate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SlotValidator getValidator() {
|
||||
return (SlotValidator) this.validator;
|
||||
}
|
||||
|
||||
public void setType(final Type type) {
|
||||
this.type = type;
|
||||
if (type == Type.Recipe) {
|
||||
this.setReadOnly();
|
||||
this.forbidInteraction();
|
||||
}
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public boolean isRecipe() {
|
||||
return this.type == Type.Recipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return Binnie.Language.localise(BinnieCore.instance, "gui.slot." + this.unlocName);
|
||||
}
|
||||
|
||||
public enum Type
|
||||
{
|
||||
Standard,
|
||||
Recipe;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.inventory;
|
||||
|
||||
import java.util.Collection;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class MachineSide
|
||||
{
|
||||
private static EnumSet<ForgeDirection> All;
|
||||
public static EnumSet<ForgeDirection> TopAndBottom;
|
||||
public static EnumSet<ForgeDirection> None;
|
||||
public static EnumSet<ForgeDirection> Top;
|
||||
public static EnumSet<ForgeDirection> Bottom;
|
||||
public static EnumSet<ForgeDirection> Sides;
|
||||
|
||||
public static String asString(final Collection<ForgeDirection> sides) {
|
||||
if (sides.containsAll(MachineSide.All)) {
|
||||
return "Any";
|
||||
}
|
||||
if (sides.isEmpty()) {
|
||||
return "None";
|
||||
}
|
||||
String text = "";
|
||||
if (sides.contains(ForgeDirection.UP)) {
|
||||
if (sides.size() > 0) {
|
||||
text += ", ";
|
||||
}
|
||||
text += "Up";
|
||||
}
|
||||
if (sides.contains(ForgeDirection.DOWN)) {
|
||||
if (sides.size() > 0) {
|
||||
text += ", ";
|
||||
}
|
||||
text += "Down";
|
||||
}
|
||||
if (sides.containsAll(MachineSide.Sides)) {
|
||||
if (sides.size() > 0) {
|
||||
text += ", ";
|
||||
}
|
||||
text += "Sides";
|
||||
}
|
||||
else {
|
||||
if (sides.contains(ForgeDirection.NORTH)) {
|
||||
if (sides.size() > 0) {
|
||||
text += ", ";
|
||||
}
|
||||
text += "North";
|
||||
}
|
||||
if (sides.contains(ForgeDirection.EAST)) {
|
||||
if (sides.size() > 0) {
|
||||
text += ", ";
|
||||
}
|
||||
text += "East";
|
||||
}
|
||||
if (sides.contains(ForgeDirection.SOUTH)) {
|
||||
if (sides.size() > 0) {
|
||||
text += ", ";
|
||||
}
|
||||
text += "South";
|
||||
}
|
||||
if (sides.contains(ForgeDirection.WEST)) {
|
||||
if (sides.size() > 0) {
|
||||
text += ", ";
|
||||
}
|
||||
text += "West";
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
static {
|
||||
MachineSide.All = EnumSet.of(ForgeDirection.UP, ForgeDirection.DOWN, ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.EAST, ForgeDirection.WEST);
|
||||
MachineSide.TopAndBottom = EnumSet.of(ForgeDirection.UP, ForgeDirection.DOWN);
|
||||
MachineSide.None = EnumSet.noneOf(ForgeDirection.class);
|
||||
MachineSide.Top = EnumSet.of(ForgeDirection.UP);
|
||||
MachineSide.Bottom = EnumSet.of(ForgeDirection.DOWN);
|
||||
MachineSide.Sides = EnumSet.of(ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.EAST, ForgeDirection.WEST);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.inventory;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SetList<E> extends ArrayList<E> implements Set<E>
|
||||
{
|
||||
private static final long serialVersionUID = 1277112003159980135L;
|
||||
|
||||
@Override
|
||||
public boolean add(final E e) {
|
||||
return !this.contains(e) && super.add(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(final int index, final E e) {
|
||||
if (!this.contains(e)) {
|
||||
super.add(index, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(final Collection<? extends E> c) {
|
||||
return this.addAll(this.size(), c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(final int index, final Collection<? extends E> c) {
|
||||
final Collection<E> copy = new ArrayList<E>(c);
|
||||
copy.removeAll(this);
|
||||
return super.addAll(index, copy);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.inventory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import java.util.Map;
|
||||
|
||||
class SidedAccess
|
||||
{
|
||||
private Map<ForgeDirection, AccessDirection> accesses;
|
||||
private AccessDirection base;
|
||||
private boolean insertLocked;
|
||||
private boolean extractLocked;
|
||||
|
||||
public SidedAccess() {
|
||||
this.accesses = new HashMap<ForgeDirection, AccessDirection>();
|
||||
this.base = AccessDirection.Both;
|
||||
this.insertLocked = false;
|
||||
this.extractLocked = false;
|
||||
}
|
||||
|
||||
public AccessDirection getAccess(final ForgeDirection side) {
|
||||
return this.accesses.containsKey(side) ? this.accesses.get(side) : this.base;
|
||||
}
|
||||
|
||||
public boolean canInsert(final ForgeDirection side) {
|
||||
return this.getAccess(side).canInsert();
|
||||
}
|
||||
|
||||
public boolean canExtract(final ForgeDirection side) {
|
||||
return this.getAccess(side).canExtract();
|
||||
}
|
||||
|
||||
public boolean canAccess(final ForgeDirection side) {
|
||||
return this.getAccess(side).canAccess();
|
||||
}
|
||||
|
||||
public boolean canChangeInsert() {
|
||||
return !this.insertLocked;
|
||||
}
|
||||
|
||||
public boolean canChangeExtract() {
|
||||
return !this.extractLocked;
|
||||
}
|
||||
|
||||
public void forbidInsertChange() {
|
||||
this.insertLocked = true;
|
||||
}
|
||||
|
||||
public void forbidExtractChange() {
|
||||
this.extractLocked = true;
|
||||
}
|
||||
|
||||
public Collection<ForgeDirection> getInsertionSides() {
|
||||
final List<ForgeDirection> dirs = new ArrayList<ForgeDirection>();
|
||||
for (final ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
if (this.getAccess(dir).canInsert()) {
|
||||
dirs.add(dir);
|
||||
}
|
||||
}
|
||||
return dirs;
|
||||
}
|
||||
|
||||
public Collection<ForgeDirection> getExtractionSides() {
|
||||
final List<ForgeDirection> dirs = new ArrayList<ForgeDirection>();
|
||||
for (final ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
if (this.getAccess(dir).canExtract()) {
|
||||
dirs.add(dir);
|
||||
}
|
||||
}
|
||||
return dirs;
|
||||
}
|
||||
|
||||
public void setInsert(final ForgeDirection side, final boolean b) {
|
||||
if (this.getAccess(side).canInsert() != b) {
|
||||
this.accesses.put(side, this.getAccess(side).changeInsert(b));
|
||||
}
|
||||
}
|
||||
|
||||
public void setExtract(final ForgeDirection side, final boolean b) {
|
||||
if (this.getAccess(side).canExtract() != b) {
|
||||
this.accesses.put(side, this.getAccess(side).changeExtract(b));
|
||||
}
|
||||
}
|
||||
|
||||
public void setInsert(final boolean b) {
|
||||
if (this.base.canInsert() != b) {
|
||||
this.base = this.base.changeInsert(b);
|
||||
}
|
||||
}
|
||||
|
||||
public void setExtract(final boolean b) {
|
||||
if (this.base.canExtract() != b) {
|
||||
this.base = this.base.changeExtract(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.inventory;
|
||||
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class SlotValidator extends Validator<ItemStack>
|
||||
{
|
||||
public static ValidatorIcon IconBee;
|
||||
public static ValidatorIcon IconFrame;
|
||||
public static ValidatorIcon IconCircuit;
|
||||
public static ValidatorIcon IconBlock;
|
||||
private ValidatorIcon icon;
|
||||
|
||||
public SlotValidator(final ValidatorIcon icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public IIcon getIcon(final boolean input) {
|
||||
return (this.icon == null) ? null : this.icon.getIcon(input).getIcon();
|
||||
}
|
||||
|
||||
public static class Item extends SlotValidator
|
||||
{
|
||||
private ItemStack target;
|
||||
|
||||
public Item(final ItemStack target, final ValidatorIcon icon) {
|
||||
super(icon);
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final ItemStack itemStack) {
|
||||
return itemStack.isItemEqual(this.target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return this.target.getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Individual extends SlotValidator
|
||||
{
|
||||
public Individual() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final ItemStack itemStack) {
|
||||
return AlleleManager.alleleRegistry.getIndividual(itemStack) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Breedable Individual";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.inventory;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.Binnie;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class TankSlot extends BaseSlot<FluidStack>
|
||||
{
|
||||
public static final String NameJuice = "Juice Tank";
|
||||
public static final String NameWater = "Water Tank";
|
||||
public static String NameCupboard;
|
||||
private FluidTank tank;
|
||||
|
||||
public TankSlot(final int index, final String name, final int capacity) {
|
||||
super(index, name);
|
||||
this.tank = new FluidTank(capacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound nbttagcompound) {
|
||||
final FluidStack liquid = FluidStack.loadFluidStackFromNBT(nbttagcompound);
|
||||
this.setContent(liquid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound nbttagcompound) {
|
||||
if (this.getContent() != null) {
|
||||
this.getContent().writeToNBT(nbttagcompound);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack getContent() {
|
||||
return this.tank.getFluid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContent(final FluidStack itemStack) {
|
||||
this.tank.setFluid(itemStack);
|
||||
}
|
||||
|
||||
public IFluidTank getTank() {
|
||||
return this.tank;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return Binnie.Language.localise(BinnieCore.instance, "gui.slot." + this.unlocName);
|
||||
}
|
||||
|
||||
static {
|
||||
TankSlot.NameCupboard = "Cupboard Slot";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.inventory;
|
||||
|
||||
import binnie.Binnie;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public abstract class TankValidator extends Validator<FluidStack>
|
||||
{
|
||||
@Override
|
||||
public abstract boolean isValid(final FluidStack p0);
|
||||
|
||||
public static class Basic extends TankValidator
|
||||
{
|
||||
private Fluid fluid;
|
||||
|
||||
public Basic(final String name) {
|
||||
this.fluid = Binnie.Liquid.getLiquidStack(name, 1).getFluid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final FluidStack stack) {
|
||||
return new FluidStack(this.fluid, 1).isFluidEqual(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return new FluidStack(this.fluid, 1).getLocalizedName();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.inventory;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import binnie.core.machines.Machine;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import binnie.core.machines.power.ITankMachine;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class TransferHandler
|
||||
{
|
||||
public static ItemStack transfer(final ItemStack item, final IInventory origin, final IInventory destination, final boolean doAdd) {
|
||||
ItemStack ret = transferItemToInventory(item, destination, doAdd);
|
||||
if (destination instanceof ITankMachine) {
|
||||
ret = transferContainerIntoTank(ret, origin, (ITankMachine) destination, doAdd);
|
||||
ret = transferTankIntoContainer(ret, origin, (ITankMachine) destination, doAdd);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static ItemStack transferItemToInventory(final ItemStack item, final IInventory destination, final boolean doAdd) {
|
||||
if (item == null || destination == null) {
|
||||
return item;
|
||||
}
|
||||
ItemStack addition = item.copy();
|
||||
for (int i = 0; i < destination.getSizeInventory(); ++i) {
|
||||
addition = transferToInventory(addition, destination, new int[] { i }, doAdd, false);
|
||||
if (addition == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return addition;
|
||||
}
|
||||
|
||||
public static ItemStack transferToInventory(ItemStack item, final IInventory destination, final int[] targetSlots, final boolean doAdd, final boolean ignoreValidation) {
|
||||
for (final int i : targetSlots) {
|
||||
if (destination.isItemValidForSlot(i, item) || ignoreValidation) {
|
||||
if (destination.getStackInSlot(i) == null) {
|
||||
if (doAdd) {
|
||||
destination.setInventorySlotContents(i, item.copy());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (item.isStackable()) {
|
||||
final ItemStack merged = destination.getStackInSlot(i).copy();
|
||||
final ItemStack[] newStacks = mergeStacks(item.copy(), merged.copy());
|
||||
item = newStacks[0];
|
||||
if (doAdd) {
|
||||
destination.setInventorySlotContents(i, newStacks[1]);
|
||||
}
|
||||
if (item == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public static ItemStack[] mergeStacks(ItemStack itemstack, final ItemStack merged) {
|
||||
if (ItemStack.areItemStackTagsEqual(itemstack, merged) && itemstack.isItemEqual(merged)) {
|
||||
final int space = merged.getMaxStackSize() - merged.stackSize;
|
||||
if (space > 0) {
|
||||
if (itemstack.stackSize > space) {
|
||||
final ItemStack itemStack = itemstack;
|
||||
itemStack.stackSize -= space;
|
||||
merged.stackSize += space;
|
||||
}
|
||||
else if (itemstack.stackSize <= space) {
|
||||
merged.stackSize += itemstack.stackSize;
|
||||
itemstack = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ItemStack[] { itemstack, merged };
|
||||
}
|
||||
|
||||
public static ItemStack transferContainerIntoTank(final ItemStack item, final IInventory origin, final ITankMachine destination, final boolean doAdd) {
|
||||
if (item == null) {
|
||||
return null;
|
||||
}
|
||||
final IFluidTank[] tanks = destination.getTanks();
|
||||
ItemStack stack = item.copy();
|
||||
for (int i = 0; i < tanks.length; ++i) {
|
||||
stack = transferToTank(stack, origin, destination, i, doAdd);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
public static ItemStack transferTankIntoContainer(final ItemStack item, final IInventory origin, final ITankMachine destination, final boolean doAdd) {
|
||||
if (item == null) {
|
||||
return null;
|
||||
}
|
||||
final IFluidTank[] tanks = destination.getTanks();
|
||||
ItemStack stack = item.copy();
|
||||
for (int i = 0; i < tanks.length; ++i) {
|
||||
stack = transferFromTank(stack, origin, destination, i, doAdd);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
public static ItemStack transferToTank(final ItemStack item, final IInventory origin, final ITankMachine destination, final int tankID, final boolean doAdd) {
|
||||
if (item == null) {
|
||||
return item;
|
||||
}
|
||||
FluidStack containerLiquid = null;
|
||||
FluidContainerRegistry.FluidContainerData containerLiquidData = null;
|
||||
for (final FluidContainerRegistry.FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) {
|
||||
if (data.filledContainer.isItemEqual(item)) {
|
||||
containerLiquidData = data;
|
||||
containerLiquid = data.fluid.copy();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (containerLiquid == null) {
|
||||
return item;
|
||||
}
|
||||
final IFluidTank tank = destination.getTanks()[tankID];
|
||||
final IValidatedTankContainer validated = Machine.getInterface(IValidatedTankContainer.class, destination);
|
||||
if (validated != null && !validated.isLiquidValidForTank(containerLiquid, tankID)) {
|
||||
return item;
|
||||
}
|
||||
final FluidStack largeAmountOfLiquid = containerLiquid.copy();
|
||||
largeAmountOfLiquid.amount = tank.getCapacity();
|
||||
final int amountAdded = tank.fill(largeAmountOfLiquid, false);
|
||||
int numberOfContainersToAdd = amountAdded / containerLiquid.amount;
|
||||
if (numberOfContainersToAdd > item.stackSize) {
|
||||
numberOfContainersToAdd = item.stackSize;
|
||||
}
|
||||
final ItemStack copy;
|
||||
ItemStack leftOverContainers = copy = item.copy();
|
||||
copy.stackSize -= numberOfContainersToAdd;
|
||||
if (leftOverContainers.stackSize <= 0) {
|
||||
leftOverContainers = null;
|
||||
}
|
||||
ItemStack emptyContainers = containerLiquidData.emptyContainer.copy();
|
||||
emptyContainers.stackSize = 0;
|
||||
final ItemStack itemStack = emptyContainers;
|
||||
itemStack.stackSize += numberOfContainersToAdd;
|
||||
if (emptyContainers.stackSize <= 0) {
|
||||
emptyContainers = null;
|
||||
}
|
||||
final ItemStack containersThatCantBeDumped = transferItemToInventory(emptyContainers, origin, false);
|
||||
if (containersThatCantBeDumped != null) {
|
||||
return item;
|
||||
}
|
||||
if (doAdd) {
|
||||
final FluidStack copy2;
|
||||
final FluidStack liquidToFillTank = copy2 = containerLiquid.copy();
|
||||
copy2.amount *= numberOfContainersToAdd;
|
||||
tank.fill(liquidToFillTank, true);
|
||||
transferItemToInventory(emptyContainers, origin, true);
|
||||
}
|
||||
return leftOverContainers;
|
||||
}
|
||||
|
||||
public static ItemStack transferFromTank(final ItemStack item, final IInventory origin, final ITankMachine destination, final int tankID, final boolean doAdd) {
|
||||
if (item == null) {
|
||||
return item;
|
||||
}
|
||||
final IFluidTank tank = destination.getTanks()[tankID];
|
||||
final FluidStack liquidInTank = tank.getFluid();
|
||||
if (liquidInTank == null) {
|
||||
return item;
|
||||
}
|
||||
FluidContainerRegistry.FluidContainerData containerLiquidData = null;
|
||||
for (final FluidContainerRegistry.FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) {
|
||||
if (data.emptyContainer.isItemEqual(item) && liquidInTank.isFluidEqual(data.fluid)) {
|
||||
containerLiquidData = data;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (containerLiquidData == null) {
|
||||
return item;
|
||||
}
|
||||
final int maximumExtractedLiquid = item.stackSize * containerLiquidData.fluid.amount;
|
||||
final FluidStack drainedLiquid = tank.drain(maximumExtractedLiquid, false);
|
||||
final int amountInTank = (drainedLiquid == null) ? 0 : drainedLiquid.amount;
|
||||
int numberOfContainersToFill = amountInTank / containerLiquidData.fluid.amount;
|
||||
if (numberOfContainersToFill > item.stackSize) {
|
||||
numberOfContainersToFill = item.stackSize;
|
||||
}
|
||||
final ItemStack copy;
|
||||
ItemStack leftOverContainers = copy = item.copy();
|
||||
copy.stackSize -= numberOfContainersToFill;
|
||||
if (leftOverContainers.stackSize <= 0) {
|
||||
leftOverContainers = null;
|
||||
}
|
||||
ItemStack filledContainers = containerLiquidData.filledContainer.copy();
|
||||
filledContainers.stackSize = 0;
|
||||
final ItemStack itemStack = filledContainers;
|
||||
itemStack.stackSize += numberOfContainersToFill;
|
||||
if (filledContainers.stackSize <= 0) {
|
||||
filledContainers = null;
|
||||
}
|
||||
final ItemStack containersThatCantBeDumped = transferItemToInventory(filledContainers, origin, false);
|
||||
if (containersThatCantBeDumped != null) {
|
||||
return item;
|
||||
}
|
||||
if (doAdd) {
|
||||
tank.drain(maximumExtractedLiquid, true);
|
||||
transferItemToInventory(filledContainers, origin, true);
|
||||
}
|
||||
return leftOverContainers;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.inventory;
|
||||
|
||||
import binnie.core.util.IValidator;
|
||||
|
||||
public abstract class Validator<T> implements IValidator<T>
|
||||
{
|
||||
public abstract String getTooltip();
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.inventory;
|
||||
|
||||
import binnie.Binnie;
|
||||
import java.util.ArrayList;
|
||||
import binnie.core.AbstractMod;
|
||||
import binnie.core.resource.BinnieIcon;
|
||||
import java.util.List;
|
||||
|
||||
public class ValidatorIcon
|
||||
{
|
||||
private List<BinnieIcon> iconsInput;
|
||||
private List<BinnieIcon> iconsOutput;
|
||||
|
||||
public ValidatorIcon(final AbstractMod mod, final String pathInput, final String pathOutput) {
|
||||
this.iconsInput = new ArrayList<BinnieIcon>();
|
||||
this.iconsOutput = new ArrayList<BinnieIcon>();
|
||||
this.iconsInput.add(Binnie.Resource.getItemIcon(mod, pathInput));
|
||||
this.iconsOutput.add(Binnie.Resource.getItemIcon(mod, pathOutput));
|
||||
}
|
||||
|
||||
public BinnieIcon getIcon(final boolean input) {
|
||||
return input ? this.iconsInput.get(0) : this.iconsOutput.get(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.network;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import java.util.Map;
|
||||
|
||||
public interface INetwork
|
||||
{
|
||||
public interface SendGuiNBT
|
||||
{
|
||||
void sendGuiNBT(final Map<String, NBTTagCompound> p0);
|
||||
}
|
||||
|
||||
public interface TilePacketSync
|
||||
{
|
||||
void syncToNBT(final NBTTagCompound p0);
|
||||
|
||||
void syncFromNBT(final NBTTagCompound p0);
|
||||
}
|
||||
|
||||
public interface RecieveGuiNBT
|
||||
{
|
||||
void recieveGuiNBT(final Side p0, final EntityPlayer p1, final String p2, final NBTTagCompound p3);
|
||||
}
|
||||
|
||||
public interface GuiNBT extends RecieveGuiNBT, SendGuiNBT
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.power;
|
||||
|
||||
import ic2.api.energy.event.EnergyTileUnloadEvent;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import ic2.api.energy.event.EnergyTileLoadEvent;
|
||||
import ic2.api.energy.tile.IEnergyTile;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import binnie.core.Mods;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import binnie.core.triggers.TriggerPower;
|
||||
import binnie.core.triggers.TriggerData;
|
||||
import java.util.List;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import binnie.core.machines.IMachine;
|
||||
import java.util.LinkedList;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import binnie.core.machines.component.IInteraction;
|
||||
import binnie.core.machines.component.IBuildcraft;
|
||||
import binnie.core.machines.MachineComponent;
|
||||
|
||||
@Optional.Interface(iface = "binnie.core.machines.component.IBuildcraft.TriggerProvider", modid = "BuildCraft|Silicon")
|
||||
public class ComponentPowerReceptor extends MachineComponent implements IPoweredMachine, IBuildcraft.TriggerProvider, IInteraction.ChunkUnload, IInteraction.Invalidation
|
||||
{
|
||||
private boolean registeredToIC2EnergyNet;
|
||||
float previousPower;
|
||||
LinkedList<Float> inputs;
|
||||
static final int inputAverageTicks = 20;
|
||||
private PowerInterface container;
|
||||
|
||||
public ComponentPowerReceptor(final IMachine machine) {
|
||||
this(machine, 1000);
|
||||
}
|
||||
|
||||
public ComponentPowerReceptor(final IMachine machine, final int storage) {
|
||||
super(machine);
|
||||
this.registeredToIC2EnergyNet = false;
|
||||
this.previousPower = 0.0f;
|
||||
this.inputs = new LinkedList<Float>();
|
||||
this.container = new PowerInterface(storage);
|
||||
if (!this.registeredToIC2EnergyNet) {
|
||||
this.addToEnergyNet();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
this.container.readFromNBT(nbttagcompound);
|
||||
if (!this.registeredToIC2EnergyNet) {
|
||||
this.addToEnergyNet();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
this.container.writeToNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
if (!this.registeredToIC2EnergyNet && !this.getMachine().getTileEntity().isInvalid()) {
|
||||
this.addToEnergyNet();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PowerInfo getPowerInfo() {
|
||||
return new PowerInfo(this, 0.0f);
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "BuildCraft|Silicon")
|
||||
@Override
|
||||
public final void getTriggers(final List<TriggerData> triggers) {
|
||||
triggers.add(TriggerPower.powerNone(this));
|
||||
triggers.add(TriggerPower.powerLow(this));
|
||||
triggers.add(TriggerPower.powerMedium(this));
|
||||
triggers.add(TriggerPower.powerHigh(this));
|
||||
triggers.add(TriggerPower.powerFull(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "IC2")
|
||||
public double getDemandedEnergy() {
|
||||
return this.container.getEnergySpace(PowerSystem.EU);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "IC2")
|
||||
public int getSinkTier() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "IC2")
|
||||
public double injectEnergy(final ForgeDirection directionFrom, final double amount, final double voltage) {
|
||||
this.container.addEnergy(PowerSystem.EU, amount, true);
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "IC2")
|
||||
public boolean acceptsEnergyFrom(final TileEntity emitter, final ForgeDirection direction) {
|
||||
return this.acceptsPowerSystem(PowerSystem.EU);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(final ForgeDirection from, final int maxReceive, final boolean simulate) {
|
||||
return (int) this.container.addEnergy(PowerSystem.RF, maxReceive, !simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(final ForgeDirection from, final int maxExtract, final boolean simulate) {
|
||||
return this.container.useEnergy(maxExtract, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(final ForgeDirection from) {
|
||||
return (int) this.container.getEnergy(PowerSystem.RF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(final ForgeDirection from) {
|
||||
return (int) this.container.getCapacity(PowerSystem.RF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(final ForgeDirection from) {
|
||||
final boolean can = this.acceptsPowerSystem(PowerSystem.RF);
|
||||
return can;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PowerInterface getInterface() {
|
||||
return this.container;
|
||||
}
|
||||
|
||||
private boolean acceptsPowerSystem(final PowerSystem system) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInvalidation() {
|
||||
this.removeFromEnergyNet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
this.removeFromEnergyNet();
|
||||
}
|
||||
|
||||
private void addToEnergyNet() {
|
||||
if (this.getMachine().getWorld() == null) {
|
||||
return;
|
||||
}
|
||||
if (Mods.IC2.active()) {
|
||||
this.do_addToEnergyNet();
|
||||
}
|
||||
}
|
||||
|
||||
private void removeFromEnergyNet() {
|
||||
if (this.getMachine().getWorld() == null) {
|
||||
return;
|
||||
}
|
||||
if (Mods.IC2.active()) {
|
||||
this.do_removeFromEnergyNet();
|
||||
}
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "IC2")
|
||||
private void do_addToEnergyNet() {
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent((IEnergyTile) this.getMachine().getTileEntity()));
|
||||
this.registeredToIC2EnergyNet = true;
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "IC2")
|
||||
private void do_removeFromEnergyNet() {
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile) this.getMachine().getTileEntity()));
|
||||
this.registeredToIC2EnergyNet = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.machines.power;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import binnie.core.machines.IMachine;
|
||||
|
||||
public abstract class ComponentProcess extends ComponentProcessIndefinate implements IProcessTimed
|
||||
{
|
||||
private float progressAmount;
|
||||
|
||||
public ComponentProcess(final IMachine machine) {
|
||||
super(machine, 0.0f);
|
||||
this.progressAmount = 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEnergyPerTick() {
|
||||
return this.getProcessEnergy() / this.getProcessLength();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProgressPerTick() {
|
||||
return 100.0f / this.getProcessLength();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStartTask() {
|
||||
this.progressAmount += 0.01f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCancelTask() {
|
||||
this.progressAmount = 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
if (this.progressAmount >= 100.0f) {
|
||||
this.onFinishTask();
|
||||
this.progressAmount = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public void alterProgress(final float f) {
|
||||
this.progressAmount += f;
|
||||
}
|
||||
|
||||
public void setProgress(final float f) {
|
||||
this.progressAmount = f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void progressTick() {
|
||||
super.progressTick();
|
||||
this.alterProgress(this.getProgressPerTick());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inProgress() {
|
||||
return this.progressAmount > 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProgress() {
|
||||
return this.progressAmount;
|
||||
}
|
||||
|
||||
protected void onFinishTask() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
this.progressAmount = nbt.getFloat("progress");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setFloat("progress", this.progressAmount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract int getProcessLength();
|
||||
|
||||
@Override
|
||||
public abstract int getProcessEnergy();
|
||||
}
|
||||
Loaded 100 of 3697 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user