Chemplant GUI, TE frame and chemistry template

This commit is contained in:
HbmMods 2017-07-25 21:33:56 +02:00
parent ea87da99e4
commit 0626d11da9
13 changed files with 902 additions and 19 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 B

View File

@ -54,8 +54,8 @@ public class MachineChemplant extends BlockContainer implements IMultiblock {
if (i == 0) {
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
if(MultiblockHandler.checkSpace(world, x, y, z, MultiblockHandler.assemblerDimensionEast)) {
MultiblockHandler.fillUp(world, x, y, z, MultiblockHandler.assemblerDimensionEast, ModBlocks.dummy_block_chemplant);
if(MultiblockHandler.checkSpace(world, x, y, z, MultiblockHandler.chemplantDimensionEast)) {
MultiblockHandler.fillUp(world, x, y, z, MultiblockHandler.chemplantDimensionEast, ModBlocks.dummy_block_chemplant);
//
DummyBlockChemplant.safeBreak = true;
@ -99,8 +99,8 @@ public class MachineChemplant extends BlockContainer implements IMultiblock {
}
if (i == 1) {
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
if(MultiblockHandler.checkSpace(world, x, y, z, MultiblockHandler.assemblerDimensionSouth)) {
MultiblockHandler.fillUp(world, x, y, z, MultiblockHandler.assemblerDimensionSouth, ModBlocks.dummy_block_chemplant);
if(MultiblockHandler.checkSpace(world, x, y, z, MultiblockHandler.chemplantDimensionSouth)) {
MultiblockHandler.fillUp(world, x, y, z, MultiblockHandler.chemplantDimensionSouth, ModBlocks.dummy_block_chemplant);
//
DummyBlockChemplant.safeBreak = true;
@ -144,8 +144,8 @@ public class MachineChemplant extends BlockContainer implements IMultiblock {
}
if (i == 2) {
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
if(MultiblockHandler.checkSpace(world, x, y, z, MultiblockHandler.assemblerDimensionWest)) {
MultiblockHandler.fillUp(world, x, y, z, MultiblockHandler.assemblerDimensionWest, ModBlocks.dummy_block_chemplant);
if(MultiblockHandler.checkSpace(world, x, y, z, MultiblockHandler.chemplantDimensionWest)) {
MultiblockHandler.fillUp(world, x, y, z, MultiblockHandler.chemplantDimensionWest, ModBlocks.dummy_block_chemplant);
//
DummyBlockChemplant.safeBreak = true;
@ -189,8 +189,8 @@ public class MachineChemplant extends BlockContainer implements IMultiblock {
}
if (i == 3) {
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
if(MultiblockHandler.checkSpace(world, x, y, z, MultiblockHandler.assemblerDimensionNorth)) {
MultiblockHandler.fillUp(world, x, y, z, MultiblockHandler.assemblerDimensionNorth, ModBlocks.dummy_block_chemplant);
if(MultiblockHandler.checkSpace(world, x, y, z, MultiblockHandler.chemplantDimensionNorth)) {
MultiblockHandler.fillUp(world, x, y, z, MultiblockHandler.chemplantDimensionNorth, ModBlocks.dummy_block_chemplant);
//
DummyBlockChemplant.safeBreak = true;

View File

@ -17,6 +17,7 @@ import com.hbm.inventory.container.ContainerLaunchPadTier1;
import com.hbm.inventory.container.ContainerMachineAssembler;
import com.hbm.inventory.container.ContainerMachineBattery;
import com.hbm.inventory.container.ContainerMachineCMBFactory;
import com.hbm.inventory.container.ContainerMachineChemplant;
import com.hbm.inventory.container.ContainerMachineCoal;
import com.hbm.inventory.container.ContainerMachineCyclotron;
import com.hbm.inventory.container.ContainerMachineDeuterium;
@ -59,6 +60,7 @@ import com.hbm.inventory.gui.GUIMachineAssembler;
import com.hbm.inventory.gui.GUIMachineBattery;
import com.hbm.inventory.gui.GUIMachineCMBFactory;
import com.hbm.inventory.gui.GUIMachineCentrifuge;
import com.hbm.inventory.gui.GUIMachineChemplant;
import com.hbm.inventory.gui.GUIMachineCoal;
import com.hbm.inventory.gui.GUIMachineCyclotron;
import com.hbm.inventory.gui.GUIMachineDeuterium;
@ -107,6 +109,7 @@ import com.hbm.tileentity.TileEntityMachineAssembler;
import com.hbm.tileentity.TileEntityMachineBattery;
import com.hbm.tileentity.TileEntityMachineCMBFactory;
import com.hbm.tileentity.TileEntityMachineCentrifuge;
import com.hbm.tileentity.TileEntityMachineChemplant;
import com.hbm.tileentity.TileEntityMachineCoal;
import com.hbm.tileentity.TileEntityMachineCyclotron;
import com.hbm.tileentity.TileEntityMachineDeuterium;
@ -510,6 +513,14 @@ public class GUIHandler implements IGuiHandler {
return new ContainerMachineAssembler(player.inventory, (TileEntityMachineAssembler) entity);
}
}
case ModBlocks.guiID_machine_chemplant:
{
if(entity instanceof TileEntityMachineChemplant)
{
return new ContainerMachineChemplant(player.inventory, (TileEntityMachineChemplant) entity);
}
}
}
return null;
}
@ -882,6 +893,14 @@ public class GUIHandler implements IGuiHandler {
return new GUIMachineAssembler(player.inventory, (TileEntityMachineAssembler) entity);
}
}
case ModBlocks.guiID_machine_chemplant:
{
if(entity instanceof TileEntityMachineChemplant)
{
return new GUIMachineChemplant(player.inventory, (TileEntityMachineChemplant) entity);
}
}
}
}
return null;

View File

@ -38,6 +38,7 @@ public class MultiblockHandler {
}
//Approved!
//pos x, neg x, pos y, neg y, pos z, neg z
public static final int[] iGenDimensionNorth = new int[] { 1, 1, 2, 0, 3, 2 };
public static final int[] iGenDimensionEast = new int[] { 2, 3, 2, 0, 1, 1 };
public static final int[] iGenDimensionSouth = new int[] { 1, 1, 2, 0, 2, 3 };
@ -47,10 +48,14 @@ public class MultiblockHandler {
public static final int[] wellDimension = new int[] { 1, 1, 5, 0, 1, 1 };
public static final int[] flareDimension = new int[] { 1, 1, 9, 0, 1, 1 };
public static final int[] drillDimension = new int[] { 1, 1, 3, 0, 1, 1 };
public static final int[] assemblerDimensionNorth = new int[] { 2, 1, 1, 0, 1, 2 };
public static final int[] assemblerDimensionEast = new int[] { 2, 1, 1, 0, 2, 1 };
public static final int[] assemblerDimensionSouth = new int[] { 1, 2, 1, 0, 2, 1 };
public static final int[] assemblerDimensionWest = new int[] { 1, 2, 1, 0, 1, 2 };
public static final int[] assemblerDimensionNorth = new int[] { 2, 1, 2, 0, 1, 2 };
public static final int[] assemblerDimensionEast = new int[] { 2, 1, 2, 0, 2, 1 };
public static final int[] assemblerDimensionSouth = new int[] { 1, 2, 2, 0, 2, 1 };
public static final int[] assemblerDimensionWest = new int[] { 1, 2, 2, 0, 1, 2 };
public static final int[] chemplantDimensionNorth = new int[] { 2, 1, 2, 0, 1, 2 };
public static final int[] chemplantDimensionEast = new int[] { 2, 1, 2, 0, 2, 1 };
public static final int[] chemplantDimensionSouth = new int[] { 1, 2, 2, 0, 2, 1 };
public static final int[] chemplantDimensionWest = new int[] { 1, 2, 2, 0, 1, 2 };
//Approved!
public static boolean checkSpace(World world, int x, int y, int z, int[] i) {

View File

@ -20,7 +20,7 @@ public class FluidTank {
int maxFluid;
public boolean takeIn = true;
public boolean letOut = false;
int index;
public int index;
public FluidTank(FluidType type, int maxFluid, int index) {
this.type = type;

View File

@ -70,16 +70,15 @@ private TileEntityMachineAssembler nukeBoy;
ItemStack var5 = var4.getStack();
var3 = var5.copy();
if (par2 <= 12) {
if (!this.mergeItemStack(var5, 13, this.inventorySlots.size(), true))
if (par2 <= 17) {
if (!this.mergeItemStack(var5, 18, this.inventorySlots.size(), true))
{
return null;
}
}
else if (!this.mergeItemStack(var5, 0, 13, false))
{
else if (!this.mergeItemStack(var5, 6, 18, false))
if (!this.mergeItemStack(var5, 0, 4, false))
return null;
}
if (var5.stackSize == 0)
{

View File

@ -0,0 +1,154 @@
package com.hbm.inventory.container;
import com.hbm.inventory.SlotMachineOutput;
import com.hbm.tileentity.TileEntityMachineAssembler;
import com.hbm.tileentity.TileEntityMachineChemplant;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerMachineChemplant extends Container {
private TileEntityMachineChemplant nukeBoy;
private int power;
private int progress;
private int maxProgress;
public ContainerMachineChemplant(InventoryPlayer invPlayer, TileEntityMachineChemplant tedf) {
nukeBoy = tedf;
//Battery
this.addSlotToContainer(new Slot(tedf, 0, 80, 18));
//Upgrades
this.addSlotToContainer(new Slot(tedf, 1, 116, 18));
this.addSlotToContainer(new Slot(tedf, 2, 116, 36));
this.addSlotToContainer(new Slot(tedf, 3, 116, 54));
//Schematic
this.addSlotToContainer(new Slot(tedf, 4, 80, 54));
//Outputs
this.addSlotToContainer(new SlotMachineOutput(invPlayer.player, tedf, 5, 134, 90));
this.addSlotToContainer(new SlotMachineOutput(invPlayer.player, tedf, 6, 152, 90));
this.addSlotToContainer(new SlotMachineOutput(invPlayer.player, tedf, 7, 134, 108));
this.addSlotToContainer(new SlotMachineOutput(invPlayer.player, tedf, 8, 152, 108));
//Fluid Output In
this.addSlotToContainer(new Slot(tedf, 9, 134, 54));
this.addSlotToContainer(new Slot(tedf, 10, 152, 54));
//Fluid Outputs Out
this.addSlotToContainer(new SlotMachineOutput(invPlayer.player, tedf, 11, 134, 72));
this.addSlotToContainer(new SlotMachineOutput(invPlayer.player, tedf, 12, 152, 72));
//Input
this.addSlotToContainer(new Slot(tedf, 13, 8, 90));
this.addSlotToContainer(new Slot(tedf, 14, 26, 90));
this.addSlotToContainer(new Slot(tedf, 15, 8, 108));
this.addSlotToContainer(new Slot(tedf, 16, 26, 108));
//Fluid Input In
this.addSlotToContainer(new Slot(tedf, 17, 8, 54));
this.addSlotToContainer(new Slot(tedf, 18, 26, 54));
//Fluid Input Out
this.addSlotToContainer(new SlotMachineOutput(invPlayer.player, tedf, 19, 8, 72));
this.addSlotToContainer(new SlotMachineOutput(invPlayer.player, tedf, 20, 26, 72));
for(int i = 0; i < 3; i++)
{
for(int j = 0; j < 9; j++)
{
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18 + 56));
}
}
for(int i = 0; i < 9; i++)
{
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 142 + 56));
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int par2)
{
ItemStack var3 = null;
Slot var4 = (Slot) this.inventorySlots.get(par2);
if (var4 != null && var4.getHasStack())
{
ItemStack var5 = var4.getStack();
var3 = var5.copy();
if (par2 <= 17) {
if (!this.mergeItemStack(var5, 18, this.inventorySlots.size(), true))
{
return null;
}
}
else if (!this.mergeItemStack(var5, 6, 18, false))
if (!this.mergeItemStack(var5, 0, 4, false))
return null;
if (var5.stackSize == 0)
{
var4.putStack((ItemStack) null);
}
else
{
var4.onSlotChanged();
}
}
return var3;
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return nukeBoy.isUseableByPlayer(player);
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
for(int i = 0; i < this.crafters.size(); i++)
{
ICrafting par1 = (ICrafting)this.crafters.get(i);
if(this.power != this.nukeBoy.power)
{
par1.sendProgressBarUpdate(this, 0, this.nukeBoy.power);
}
if(this.progress != this.nukeBoy.progress)
{
par1.sendProgressBarUpdate(this, 1, this.nukeBoy.progress);
}
if(this.maxProgress != this.nukeBoy.maxProgress)
{
par1.sendProgressBarUpdate(this, 2, this.nukeBoy.maxProgress);
}
}
this.power = this.nukeBoy.power;
this.progress= this.nukeBoy.progress;
this.maxProgress= this.nukeBoy.maxProgress;
}
@Override
public void updateProgressBar(int i, int j) {
if(i == 0)
{
nukeBoy.power = j;
}
if(i == 1)
{
nukeBoy.progress = j;
}
if(i == 2)
{
nukeBoy.maxProgress = j;
}
}
}

View File

@ -0,0 +1,50 @@
package com.hbm.inventory.gui;
import org.lwjgl.opengl.GL11;
import com.hbm.inventory.container.ContainerMachineAssembler;
import com.hbm.inventory.container.ContainerMachineChemplant;
import com.hbm.lib.RefStrings;
import com.hbm.tileentity.TileEntityMachineAssembler;
import com.hbm.tileentity.TileEntityMachineChemplant;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
public class GUIMachineChemplant extends GuiContainer {
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/gui_chemplant.png");
private TileEntityMachineChemplant assembler;
public GUIMachineChemplant(InventoryPlayer invPlayer, TileEntityMachineChemplant tedf) {
super(new ContainerMachineChemplant(invPlayer, tedf));
assembler = tedf;
this.xSize = 176;
this.ySize = 222;
}
@Override
protected void drawGuiContainerForegroundLayer( int i, int j) {
String name = this.assembler.hasCustomInventoryName() ? this.assembler.getInventoryName() : I18n.format(this.assembler.getInventoryName());
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
int i = assembler.getPowerScaled(52);
drawTexturedModalRect(guiLeft + 116, guiTop + 70 - i, 176, 52 - i, 16, i);
int j = assembler.getProgressScaled(83);
drawTexturedModalRect(guiLeft + 45, guiTop + 82, 2, 222, j, 32);
}
}

View File

@ -506,6 +506,7 @@ public class ModItems {
public static Item oil_detector;
public static Item assembly_template;
public static Item chemistry_template;
public static Item fluid_identifier;
public static Item missile_generic;
@ -1663,6 +1664,7 @@ public class ModItems {
oil_detector = new ItemOilDetector().setUnlocalizedName("oil_detector").setMaxStackSize(1).setCreativeTab(MainRegistry.tabNuke).setTextureName(RefStrings.MODID + ":oil_detector");
assembly_template = new ItemAssemblyTemplate().setUnlocalizedName("assembly_template").setMaxStackSize(1).setCreativeTab(MainRegistry.tabMachine).setTextureName(RefStrings.MODID + ":assembly_template");
chemistry_template = new ItemChemistryTemplate().setUnlocalizedName("chemistry_template").setMaxStackSize(1).setCreativeTab(MainRegistry.tabMachine).setTextureName(RefStrings.MODID + ":chemistry_template");
fluid_identifier = new ItemFluidIdentifier().setUnlocalizedName("fluid_identifier").setMaxStackSize(1).setCreativeTab(MainRegistry.tabMachine).setTextureName(RefStrings.MODID + ":fluid_identifier");
euphemium_helmet = new ArmorEuphemium(MainRegistry.enumArmorMaterialEuphemium, 6, 0).setUnlocalizedName("astatine_helmet").setMaxStackSize(1).setTextureName(RefStrings.MODID + ":euphemium_helmet");
@ -2280,6 +2282,7 @@ public class ModItems {
//Machine Templates
GameRegistry.registerItem(fluid_identifier, fluid_identifier.getUnlocalizedName());
GameRegistry.registerItem(assembly_template, assembly_template.getUnlocalizedName());
GameRegistry.registerItem(chemistry_template, chemistry_template.getUnlocalizedName());
//Machine Items
GameRegistry.registerItem(fuse, fuse.getUnlocalizedName());

View File

@ -0,0 +1,94 @@
package com.hbm.items.tool;
import java.util.List;
import com.hbm.inventory.MachineRecipes;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class ItemChemistryTemplate extends Item {
public enum EnumChemistryTemplate {
TEST;
public static EnumChemistryTemplate getEnum(int i) {
return EnumChemistryTemplate.values()[i];
}
public String getName() {
return this.toString();
}
}
public ItemChemistryTemplate()
{
this.setHasSubtypes(true);
this.setMaxDamage(0);
}
@Override
public String getUnlocalizedName(ItemStack stack)
{
int i = stack.getItemDamage();
return super.getUnlocalizedName() + "." + EnumChemistryTemplate.getEnum(i).getName();
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tabs, List list)
{
for (int i = 0; i < EnumChemistryTemplate.values().length; ++i)
{
list.add(new ItemStack(item, 1, i));
}
}
public static int getProcessTime(ItemStack stack) {
if(!(stack.getItem() instanceof ItemChemistryTemplate))
return 100;
int i = stack.getItemDamage();
EnumChemistryTemplate enum1 = EnumChemistryTemplate.getEnum(i);
switch (enum1) {
case TEST:
return 200;
default:
return 100;
}
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool)
{
/*if(!(stack.getItem() instanceof ItemChemistryTemplate))
return;
List<ItemStack> stacks = MachineRecipes.getRecipeFromTempate(stack);
ItemStack out = MachineRecipes.getOutputFromTempate(stack);
try {
list.add("Output:");
list.add(out.stackSize + "x " + out.getDisplayName());
list.add("Inputs:");
for(int i = 0; i < stacks.size(); i++) {
if(stacks.get(i) != null)
list.add(stacks.get(i).stackSize + "x " + stacks.get(i).getDisplayName());
}
list.add("Production time:");
list.add(Math.floor((float)(getProcessTime(stack)) / 20 * 100) / 100 + " seconds");
} catch(Exception e) {
list.add("###INVALID###");
list.add("0x334077-0x6A298F-0xDF3795-0x334077");
}*/
}
}

View File

@ -367,6 +367,8 @@ public class MainRegistry
Library.superuser.add("3af1c262-61c0-4b12-a4cb-424cc3a9c8c0");
Library.superuser.add("4729b498-a81c-42fd-8acd-20d6d9f759e0");
Library.superuser.add("c3f5e449-6d8c-4fe3-acc9-47ef50e7e7ae");
//until he manages to do the most basic thing and INSTALL NEI
//Library.superuser.add("122fe98f-be19-49ca-a96b-d4dee4f0b22e");
Library.initBooks();

View File

@ -1,7 +1,564 @@
package com.hbm.tileentity;
import java.util.List;
import java.util.Random;
import com.hbm.handler.FluidTypeHandler.FluidType;
import com.hbm.interfaces.IConsumer;
import com.hbm.interfaces.IFluidContainer;
import com.hbm.inventory.FluidTank;
import com.hbm.inventory.MachineRecipes;
import com.hbm.items.ModItems;
import com.hbm.items.special.ItemBattery;
import com.hbm.items.tool.ItemAssemblyTemplate;
import com.hbm.lib.Library;
import com.hbm.packet.PacketDispatcher;
import com.hbm.packet.TEAssemblerPacket;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.tileentity.TileEntityHopper;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.oredict.OreDictionary;
public class TileEntityMachineChemplant extends TileEntity {
public class TileEntityMachineChemplant extends TileEntity implements ISidedInventory, IConsumer, IFluidContainer {
private ItemStack slots[];
public int power;
public static final int maxPower = 100000;
public int progress;
public int maxProgress = 100;
public float rotation = 0;
int age = 0;
int consumption = 100;
int speed = 100;
public FluidTank[] tanks;
Random rand = new Random();
private String customName;
public TileEntityMachineChemplant() {
slots = new ItemStack[21];
tanks = new FluidTank[4];
tanks[0] = new FluidTank(FluidType.NONE, 16000, 0);
tanks[1] = new FluidTank(FluidType.NONE, 16000, 0);
tanks[2] = new FluidTank(FluidType.NONE, 16000, 0);
tanks[3] = new FluidTank(FluidType.NONE, 16000, 0);
tanks[0].index = 0;
tanks[1].index = 1;
tanks[2].index = 2;
tanks[3].index = 3;
tanks[0].takeIn = true;
tanks[1].takeIn = true;
tanks[2].takeIn = false;
tanks[3].takeIn = false;
tanks[0].letOut = false;
tanks[1].letOut = false;
tanks[2].letOut = true;
tanks[3].letOut = true;
}
@Override
public int getSizeInventory() {
return slots.length;
}
@Override
public ItemStack getStackInSlot(int i) {
return slots[i];
}
@Override
public ItemStack getStackInSlotOnClosing(int i) {
if(slots[i] != null)
{
ItemStack itemStack = slots[i];
slots[i] = null;
return itemStack;
} else {
return null;
}
}
@Override
public void setInventorySlotContents(int i, ItemStack itemStack) {
slots[i] = itemStack;
if(itemStack != null && itemStack.stackSize > getInventoryStackLimit())
{
itemStack.stackSize = getInventoryStackLimit();
}
}
@Override
public String getInventoryName() {
return this.hasCustomInventoryName() ? this.customName : "container.chemplant";
}
@Override
public boolean hasCustomInventoryName() {
return this.customName != null && this.customName.length() > 0;
}
public void setCustomName(String name) {
this.customName = name;
}
@Override
public int getInventoryStackLimit() {
return 64;
}
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
if(worldObj.getTileEntity(xCoord, yCoord, zCoord) != this)
{
return false;
}else{
return player.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <=128;
}
}
//You scrubs aren't needed for anything (right now)
@Override
public void openInventory() {}
@Override
public void closeInventory() {}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemStack) {
if(i == 0)
if(itemStack.getItem() instanceof ItemBattery)
return true;
if(i == 1)
return true;
return false;
}
@Override
public ItemStack decrStackSize(int i, int j) {
if(slots[i] != null)
{
if(slots[i].stackSize <= j)
{
ItemStack itemStack = slots[i];
slots[i] = null;
return itemStack;
}
ItemStack itemStack1 = slots[i].splitStack(j);
if (slots[i].stackSize == 0)
{
slots[i] = null;
}
return itemStack1;
} else {
return null;
}
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
NBTTagList list = nbt.getTagList("items", 10);
this.power = nbt.getInteger("powerTime");
slots = new ItemStack[getSizeInventory()];
for(int i = 0; i < list.tagCount(); i++)
{
NBTTagCompound nbt1 = list.getCompoundTagAt(i);
byte b0 = nbt1.getByte("slot");
if(b0 >= 0 && b0 < slots.length)
{
slots[b0] = ItemStack.loadItemStackFromNBT(nbt1);
}
}
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setInteger("powerTime", power);
NBTTagList list = new NBTTagList();
for(int i = 0; i < slots.length; i++)
{
if(slots[i] != null)
{
NBTTagCompound nbt1 = new NBTTagCompound();
nbt1.setByte("slot", (byte)i);
slots[i].writeToNBT(nbt1);
list.appendTag(nbt1);
}
}
nbt.setTag("items", list);
}
@Override
public int[] getAccessibleSlotsFromSide(int p_94128_1_)
{
return new int[] { 0 };
}
@Override
public boolean canInsertItem(int i, ItemStack itemStack, int j) {
return this.isItemValidForSlot(i, itemStack);
}
@Override
public boolean canExtractItem(int i, ItemStack itemStack, int j) {
return false;
}
public int getPowerScaled(int i) {
return (power * i) / maxPower;
}
public int getProgressScaled(int i) {
return (progress * i) / maxProgress;
}
@Override
public void updateEntity() {
if(!worldObj.isRemote)
{
power = Library.chargeTEFromItems(slots, 0, power, maxPower);
tanks[0].loadTank(17, 19, slots);
tanks[1].loadTank(18, 20, slots);
tanks[2].unloadTank(9, 11, slots);
tanks[3].unloadTank(10, 12, slots);
}
}
//I can't believe that worked.
public ItemStack[] cloneItemStackProper(ItemStack[] array) {
ItemStack[] stack = new ItemStack[array.length];
for(int i = 0; i < array.length; i++)
if(array[i] != null)
stack[i] = array[i].copy();
else
stack[i] = null;
return stack;
}
//Unloads output into chests
public boolean tryFillContainer(IInventory inventory, int slot) {
int size = inventory.getSizeInventory();
for(int i = 0; i < size; i++) {
if(inventory.getStackInSlot(i) != null) {
if(slots[slot] == null)
return false;
ItemStack sta1 = inventory.getStackInSlot(i).copy();
ItemStack sta2 = slots[slot].copy();
if(sta1 != null && sta2 != null) {
sta1.stackSize = 1;
sta2.stackSize = 1;
if(ItemStack.areItemStacksEqual(sta1, sta2) && ItemStack.areItemStackTagsEqual(sta1, sta2) && inventory.getStackInSlot(i).stackSize < inventory.getStackInSlot(i).getMaxStackSize()) {
slots[slot].stackSize--;
if(slots[slot].stackSize <= 0)
slots[slot] = null;
ItemStack sta3 = inventory.getStackInSlot(i).copy();
sta3.stackSize++;
inventory.setInventorySlotContents(i, sta3);
return true;
}
}
}
}
for(int i = 0; i < size; i++) {
if(slots[slot] == null)
return false;
ItemStack sta2 = slots[slot].copy();
if(inventory.getStackInSlot(i) == null && sta2 != null) {
sta2.stackSize = 1;
slots[slot].stackSize--;
if(slots[slot].stackSize <= 0)
slots[slot] = null;
inventory.setInventorySlotContents(i, sta2);
return true;
}
}
return false;
}
//Loads assembler's input queue from chests
public boolean tryFillAssembler(IInventory inventory, int slot) {
if(MachineRecipes.getOutputFromTempate(slots[4]) == null || MachineRecipes.getRecipeFromTempate(slots[4]) == null)
return false;
else {
List<ItemStack> list = MachineRecipes.getRecipeFromTempate(slots[4]);
for(int i = 0; i < list.size(); i++)
list.get(i).stackSize = 1;
if(inventory.getStackInSlot(slot) == null)
return false;
ItemStack stack = inventory.getStackInSlot(slot).copy();
stack.stackSize = 1;
boolean flag = false;
for(int i = 0; i < list.size(); i++)
if(ItemStack.areItemStacksEqual(stack, list.get(i)) && ItemStack.areItemStackTagsEqual(stack, list.get(i)))
flag = true;
if(!flag)
return false;
}
for(int i = 6; i < 18; i++) {
if(slots[i] != null) {
ItemStack sta1 = inventory.getStackInSlot(slot).copy();
ItemStack sta2 = slots[i].copy();
if(sta1 != null && sta2 != null) {
sta1.stackSize = 1;
sta2.stackSize = 1;
if(ItemStack.areItemStacksEqual(sta1, sta2) && ItemStack.areItemStackTagsEqual(sta1, sta2) && slots[i].stackSize < slots[i].getMaxStackSize()) {
ItemStack sta3 = inventory.getStackInSlot(slot).copy();
sta3.stackSize--;
if(sta3.stackSize <= 0)
sta3 = null;
inventory.setInventorySlotContents(slot, sta3);
slots[i].stackSize++;
return true;
}
}
}
}
for(int i = 6; i < 18; i++) {
ItemStack sta2 = inventory.getStackInSlot(slot).copy();
if(slots[i] == null && sta2 != null) {
sta2.stackSize = 1;
slots[i] = sta2.copy();
ItemStack sta3 = inventory.getStackInSlot(slot).copy();
sta3.stackSize--;
if(sta3.stackSize <= 0)
sta3 = null;
inventory.setInventorySlotContents(slot, sta3);
return true;
}
}
return false;
}
public boolean hasSpace(ItemStack stack) {
ItemStack st = stack.copy();
if(st == null)
return true;
for(int i = 1; i < 10; i++) {
if(slots[i] == null)
return true;
}
int size = st.stackSize;
st.stackSize = 1;
ItemStack[] fakeArray = slots.clone();
boolean flag = true;
for(int i = 0; i < stack.stackSize; i++) {
if(!canAddItemToArray(st, fakeArray))
flag = false;
}
return flag;
}
public void addItemToInventory(ItemStack stack) {
ItemStack st = stack.copy();
if(st == null)
return;
int size = st.stackSize;
st.stackSize = 1;
for(int i = 0; i < size; i++)
canAddItemToArray(st, this.slots);
}
public boolean canAddItemToArray(ItemStack stack, ItemStack[] array) {
ItemStack st = stack.copy();
if(st == null)
return true;
for(int i = 1; i < 10; i++) {
if(array[i] != null) {
ItemStack sta = array[i].copy();
if(sta != null && sta.getItem() == st.getItem() && sta.stackSize < st.getMaxStackSize()) {
array[i].stackSize++;
return true;
}
}
}
for(int i = 1; i < 10; i++) {
if(array[i] == null) {
array[i] = stack.copy();
return true;
}
}
return false;
}
//boolean true: remove items, boolean false: simulation mode
public boolean removeItems(List<ItemStack> stack, ItemStack[] array) {
if(stack == null)
return false;
for(int i = 0; i < stack.size(); i++) {
for(int j = 0; j < stack.get(i).stackSize; j++) {
ItemStack sta = stack.get(i).copy();
sta.stackSize = 1;
if(!canRemoveItemFromArray(sta, array))
return false;
}
}
return true;
}
public boolean canRemoveItemFromArray(ItemStack stack, ItemStack[] array) {
ItemStack st = stack.copy();
if(st == null)
return true;
for(int i = 6; i < 18; i++) {
if(array[i] != null) {
ItemStack sta = array[i].copy();
sta.stackSize = 1;
if(sta != null && isItemAcceptible(sta, st) && array[i].stackSize > 0) {
array[i].stackSize--;
if(array[i].stackSize <= 0)
array[i] = null;
return true;
}
}
}
return false;
}
public boolean isItemAcceptible(ItemStack stack1, ItemStack stack2) {
if(stack1 != null && stack2 != null) {
if(ItemStack.areItemStacksEqual(stack1, stack2))
return true;
int[] ids1 = OreDictionary.getOreIDs(stack1);
int[] ids2 = OreDictionary.getOreIDs(stack2);
if(ids1 != null && ids2 != null && ids1.length > 0 && ids2.length > 0) {
for(int i = 0; i < ids1.length; i++)
for(int j = 0; j < ids2.length; j++)
if(ids1[i] == ids2[j])
return true;
}
}
return false;
}
@Override
public void setPower(int i) {
power = i;
}
@Override
public int getPower() {
return power;
}
@Override
public int getMaxPower() {
return maxPower;
}
@Override
public AxisAlignedBB getRenderBoundingBox() {
return TileEntity.INFINITE_EXTENT_AABB;
}
@Override
@SideOnly(Side.CLIENT)
public double getMaxRenderDistanceSquared()
{
return 65536.0D;
}
@Override
public void setFillstate(int fill, int index) {
if(index < 4 && tanks[index] != null)
tanks[index].setFill(fill);
}
@Override
public void setType(FluidType type, int index) {
if(index < 4 && tanks[index] != null)
tanks[index].setTankType(type);
}
}