Jump to content

Recommended Posts

Posted

My tanks have problems with storing the Fluid. its always null but he know what is inside of him.

I mean when i put 1 water bucket and 1 lava bucket in then i get these back if i extract it.

But when i want to display it on my GUI then the fluid is always null.

 

here my code:

 

GUI:

package speiger.src.api.client.gui;

import net.minecraft.block.Block;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;

import org.lwjgl.opengl.GL11;

import speiger.src.api.common.container.ContainerCompressor;
import speiger.src.api.common.tile.BasicCompressor;
import cpw.mods.fml.common.Loader;

public class GuiCompressor extends GuiContainer
{
private BasicCompressor tile;

    public GuiCompressor(InventoryPlayer par1, BasicCompressor par2)
{
	super(new ContainerCompressor(par1, par2));
	tile = par2;
	this.ySize = 178;
}

protected void drawGuiContainerForegroundLayer(int par1, int par2)
    {
        this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
	int cornerX = (width - xSize) / 2;
	int cornerY = (height - ySize) / 2;
	int textID = codeID(par1 - cornerX, par2 - cornerY);
	switch(textID)
	{
		case 1:
			if(Loader.isModLoaded("BuildCraft|Energy"))this.drawCreativeTabHoveringText("Energy: "+tile.fuel+"MJ / "+3000+"MJ", par1-cornerX, par2-cornerY);
			else this.drawCreativeTabHoveringText("Energy: "+tile.fuel+"  / "+3000, par1-cornerX, par2-cornerY);
			break;
		case 2:
			if(tile.first.getFluid() == null || tile.first.getFluid().fluidID == 0) this.drawCreativeTabHoveringText("Empty Tank: "+"0mB / "+tile.first.getCapacity()+"mB", par1-cornerX, par2-cornerY);
			else if(tile.first.getFluid() != null && new ItemStack(tile.first.getFluid().fluidID, 1, 0) != null) this.drawCreativeTabHoveringText("Filled Tank: "+new ItemStack(tile.first.getFluid().fluidID, 1, 0)+" "+tile.first.getFluid().amount+"mB / "+tile.first.getCapacity()+"mB", par1-cornerX, par2-cornerY);
			else this.drawCreativeTabHoveringText("Filled Tank: "+"Unknowen Liquid"+" "+tile.first.getFluid().amount+"mB / "+tile.first.getCapacity()+"mB", par1-cornerX, par2-cornerY);
			break;
		case 3:
			if(tile.second.getFluid() == null || tile.second.getFluid().fluidID == 0) this.drawCreativeTabHoveringText("Empty Tank: "+"0mB / "+tile.second.getCapacity()+"mB", par1-cornerX, par2-cornerY);
			else if(tile.second.getFluid() != null && new ItemStack(tile.second.getFluid().fluidID, 1, 0) != null) this.drawCreativeTabHoveringText("Filled Tank: "+new ItemStack(tile.second.getFluid().fluidID, 1, 0)+" "+tile.second.getFluid().amount+"mB / "+tile.second.getCapacity()+"mB", par1-cornerX, par2-cornerY);
			else this.drawCreativeTabHoveringText("Filled Tank: "+"Unknowen Liquid"+" "+tile.second.getFluid().amount+"mB / "+tile.second.getCapacity()+"mB", par1-cornerX, par2-cornerY);

	}
    }


    private static final ResourceLocation var4 = new ResourceLocation("spmodapi:textures/gui/SqueezingCompressor.png");


    protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
    {
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        this.mc.renderEngine.bindTexture(var4);
        int var5 = (this.width - this.xSize) / 2;
        int var6 = (this.height - this.ySize) / 2;
        this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize);
        
        if(tile.progress > 0)
        {
        	this.drawTexturedModalRect(var5+49, var6+29, 55, 181, tile.progress / 12, 21);	
        }
        
        if(tile.fuel > 0)
        {
        	int fuel = tile.fuel / 190;
        	this.drawTexturedModalRect(var5+134, var6+75+16-fuel, 176, 84+16-fuel, 12, fuel);
        }
        
        if(tile.getTankScaled(58, true) > 0)
        {
        	this.displayGauge(var5, var6, 18, 68, tile.getTankScaled(58, true), tile.getLiquidID(true));
        }
        
        if(tile.getTankScaled(58, false) > 0)
        {
        	this.displayGauge(var5, var6, 18, 92, tile.getTankScaled(58, false), tile.getLiquidID(false));
        }
        

        
    }

private static final ResourceLocation BLOCK_TEXTURE = TextureMap.locationBlocksTexture;
    
private void displayGauge(int j, int k, int line, int col, int squaled, FluidStack liquid) {
	if (liquid == null) {
		return;
	}
	int start = 0;

	Icon liquidIcon = null;
	Fluid fluid = liquid.getFluid();
	if (fluid != null && fluid.getStillIcon() != null) {
		liquidIcon = fluid.getStillIcon();
	}
	mc.renderEngine.bindTexture(BLOCK_TEXTURE);

	if (liquidIcon != null) {
		while (true) {
			int x;

			if (squaled > 16) {
				x = 16;
				squaled -= 16;
			} else {
				x = squaled;
				squaled = 0;
			}

			drawTexturedModelRectFromIcon(j + col, k + line + 58 - x - start, liquidIcon, 16, 16 - (16 - x));
			start = start + 16;

			if (x == 0 || squaled == 0) {
				break;
			}
		}
	}

	mc.renderEngine.bindTexture(var4);
	drawTexturedModalRect(j + col, k + line, 176, 0, 16, 60);
}




public int codeID(int x, int y)
{
	if(x >=135 && x <=145 && y >= 76 && y <= 88)return 1;
	if(x >=68 && x<=83 && y>=18 && y<=75) return 2;
	if(x >=92 && x<=107 && y>=18 && y<=75) return 3;
	return -1;
}



}

 

TileEntity:

package speiger.src.api.common.tile;

import java.util.ArrayList;
import java.util.Random;

import cpw.mods.fml.common.FMLLog;

import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ICrafting;
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.network.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.liquids.LiquidContainerRegistry;
import net.minecraftforge.liquids.LiquidStack;
import speiger.src.api.api.recipes.EnumRecipeType;
import speiger.src.api.api.recipes.recipe.INormalRecipe;
import speiger.src.api.api.recipes.result.Result;
import speiger.src.api.client.core.PathProxyClient;
import speiger.src.api.common.container.ContainerCompressor;
import speiger.src.api.common.debug.DebugCore;
import speiger.src.api.common.functions.MachineRecipeMaker;
import speiger.src.api.common.functions.WorldReading;

public class BasicCompressor extends TileFacing implements IFluidHandler, IInventory, ISidedInventory
{
public Random rand = new Random();
public int progress = 0;
public int fuel = 0;
public int mode = 0;
public int cound = 0;
public FluidTank first = new FluidTank(16000);
public FluidTank second = new FluidTank(16000);
public ItemStack[] inventory = new ItemStack[14];
public boolean update = false;
public boolean naturalEnergy = false;
MachineRecipeMaker recipes = MachineRecipeMaker.getRecipes();
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
ArrayList<FluidStack> liquidDrops = new ArrayList<FluidStack>();


@Override
public int getTextureFromTile(int meta, int side)
{
	if(side == 0 || side == 1)return 133;
	else if(side == ForgeDirection.getOrientation(facing).ordinal())return 131;
	else if(side == ForgeDirection.getOrientation(facing).getOpposite().ordinal())return 132;
	else return 134;
}



@Override
public Packet getDescriptionPacket()
{
    	NBTTagCompound var1 = new NBTTagCompound();
    	super.writeToNBT(var1);
    	var1.setInteger("rotation", facing);
    	var1.setInteger("Progress", progress);
    	var1.setInteger("Fuels", fuel);
    	var1.setInteger("Mode", mode);
	if (first.getFluid() != null) {
		var1.setTag("FirstTank", first.getFluid().writeToNBT(new NBTTagCompound()));
	}
	if (second.getFluid() != null) {
		var1.setTag("Second", second.getFluid().writeToNBT(new NBTTagCompound()));
	}
    	return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, var1);
}



@Override
public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt)
{
	this.readFromNBT(pkt.data);
}







@Override
public void updateEntity()
{
	super.updateEntity();
	if(update)
	{
		update = false;
		this.onInventoryChanged();
	}





	updateBlock();
	if(!this.worldObj.isRemote)
	{
		EntityPlayer player = this.worldObj.getClosestPlayer(xCoord, yCoord, zCoord, DebugCore.detectRange);

		if(progress > 0 && fuel > 0)
		{
			if(cound >= DebugCore.tickrate)
			{
				if(player != null)
				{
					this.worldObj.playSoundEffect(xCoord, yCoord, zCoord, this.getSoundFromMode(mode), DebugCore.loudness, DebugCore.range);
				}

				cound = 0;
			}
			else
			{
				cound++;
			}
		}

		if(first.getFluid() != null && first.getFluid().amount <= 0)
		{
			first.setFluid(null);
		}
		if(second.getFluid() != null && second.getFluid().amount <= 0)
		{
			second.setFluid(null);
		}

		updateSlots();
		onBCUpdate();
		onRedstoneUpdate();
		fillBuckets();
		doSomething();
		createSymbol();
		if(!drops.isEmpty() || !liquidDrops.isEmpty())
		{
			if(!drops.isEmpty())
			{
				emptyItemArray();
			}
			if(!liquidDrops.isEmpty())
			{
				emptyLiquidArray();
			}
		}
		update = true;
	}
}


public String getSoundFromMode(int par1)
{
	if(par1 == 0) return "textures.compressorSound";
	else if(par1 == 1) return "textures.sqeezerSound";
	else return "textures.mixerSound";
}

public void createSymbol()
{
	ItemStack display = new ItemStack(Block.pistonStickyBase);
	NBTTagCompound nbt = new NBTTagCompound();
	nbt.setCompoundTag("display", new NBTTagCompound());
	nbt.getCompoundTag("display").setString("Name", "Sqeezing Compressor");
	display.setTagCompound(nbt);
	switch(mode)
	{
		case 0:
			PathProxyClient.addItemToolTip(display, "tip", "Compressing Mode");
			break;
		case 1:
			PathProxyClient.addItemToolTip(display, "tip", "Sqeezing Mode");
			break;
		case 2:
			PathProxyClient.addItemToolTip(display, "tip", "Mixing Mode");
	}


	inventory[13] = display.copy();
}

public void fillBuckets()
{
	if(inventory[1] != null)
	{
		if(FluidContainerRegistry.isBucket(inventory[1]) || FluidContainerRegistry.isContainer(inventory[1]))
		{
			if(FluidContainerRegistry.isEmptyContainer(inventory[1]) && drops.isEmpty())
			{
				if(first.getFluid() != null && first.getFluid().amount > 0)
				{
					ItemStack stack = FluidContainerRegistry.fillFluidContainer(first.getFluid(), inventory[1]);
					if(stack != null)
					{
						int size = FluidContainerRegistry.getFluidForFilledItem(stack).amount;
						if(first.getFluid().amount >= size)
						{
							inventory[1].stackSize--;
							if(inventory[1].stackSize <= 0)
							{
								inventory[1] = null;
							}
							first.drain(size, true);
							drops.add(stack.copy());
							return;
						}
					}
				}
			}
			if(FluidContainerRegistry.isFilledContainer(inventory[1]))
			{
				if(liquidDrops.isEmpty() && drops.isEmpty())
				{
					FluidStack stack = FluidContainerRegistry.getFluidForFilledItem(inventory[1]);
					if(stack != null)
					{
						inventory[1].stackSize--;
						liquidDrops.add(stack.copy());
						ItemStack chance = inventory[1].getItem().getContainerItemStack(inventory[1]);
						if(chance != null)
						{
							drops.add(chance.copy());
						}
						if(inventory[1].stackSize <= 0)
						{
							inventory[1] = null;
						}
						return;
					}
				}
			}
		}
	}
	if(inventory[2] != null)
	{
		if(FluidContainerRegistry.isBucket(inventory[2]) || FluidContainerRegistry.isContainer(inventory[2]))
		{
			if(FluidContainerRegistry.isEmptyContainer(inventory[2]) && drops.isEmpty())
			{
				if(second.getFluid() != null && second.getFluid().amount > 0)
				{
					ItemStack stack = FluidContainerRegistry.fillFluidContainer(second.getFluid(), inventory[2]);
					if(stack != null)
					{
						int size = FluidContainerRegistry.getFluidForFilledItem(stack).amount;
						if(second.getFluid().amount >= size)
						{
							inventory[2].stackSize--;
							if(inventory[2].stackSize <= 0)
							{
								inventory[2] = null;
							}
							second.drain(size, true);
							drops.add(stack.copy());
							return;
						}
					}
				}
			}
			if(FluidContainerRegistry.isFilledContainer(inventory[2]))
			{
				if(liquidDrops.isEmpty() && drops.isEmpty())
				{
					FluidStack stack = FluidContainerRegistry.getFluidForFilledItem(inventory[2]);
					if(stack != null)
					{
						inventory[2].stackSize--;
						liquidDrops.add(stack.copy());
						ItemStack chance = inventory[2].getItem().getContainerItemStack(inventory[2]);
						if(chance != null)
						{
							drops.add(chance.copy());
						}
						if(inventory[2].stackSize <= 0)
						{
							inventory[2] = null;
						}
						return;
					}
				}
			}
		}
	}

}

    public void updateBlock()
    {
        int var1 = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord);
        this.worldObj.markBlockForRenderUpdate(this.xCoord, this.yCoord, this.zCoord);
        markBlockDirty(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
    }

    public void markBlockDirty(World var0, int var1, int var2, int var3)
    {
        if (var0.blockExists(var1, var2, var3))
        {
            var0.getChunkFromBlockCoords(var1, var3).setChunkModified();
        }
    }

public void onRedstoneUpdate()
{
	if(fuel < 3000)
	{
		if(this.naturalEnergy && !isPowered())
		{
			fuel+=10;
			naturalEnergy = false;
		}
		if(!this.naturalEnergy && isPowered())
		{
			this.naturalEnergy = true;
		}
	}
}

public boolean isPowered()
{
	return WorldReading.isGettingPowered(worldObj, xCoord, yCoord, zCoord) || this.worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
}

public void emptyLiquidArray()
{
	for(int i = 0;i<liquidDrops.size();i++)
	{
		if(first.getFluid() == null)
		{
			first.fill(liquidDrops.get(i), true);
			liquidDrops.remove(i);
			continue;
		}
		else
		{
			if(first.fill(liquidDrops.get(i), false) > 0)
			{
				first.fill(liquidDrops.get(i), true);
				liquidDrops.remove(i);
				continue;
			}
		}

		if(second.getFluid() == null)
		{
			second.fill(liquidDrops.get(i), true);
			liquidDrops.remove(i);
			continue;
		}
		else
		{
			if(second.fill(liquidDrops.get(i), false) > 0)
			{
				second.fill(liquidDrops.get(i), true);
				liquidDrops.remove(i);
				continue;
			}
		}

	}
}

public void emptyItemArray()
{
	for(int i = 0;i<drops.size();i++)
	{
		if(inventory[8] == null)
		{
			inventory[8] = drops.get(i).copy();
			drops.remove(i);
		}
	}
}

public void updateSlots()
{
	transferItems(3, 4);
	transferItems(4, 5);
	transferItems(5, 6);
	transferItems(6, 7);

	transferItems(8, 9);
	transferItems(8, 10);
	transferItems(8, 11);
	transferItems(8, 12);
	transferItems(9, 10);
	transferItems(9, 12);
	transferItems(9, 11);
	transferItems(10, 11);
	transferItems(10, 12);
	transferItems(11, 12);
}



public void transferItems(int slot0, int slot1)
{
	if(inventory[slot0] != null)
	{
		if(inventory[slot1] == null)
		{
			inventory[slot1] = inventory[slot0].copy();
			inventory[slot0] = null;
			update = true;
		}
		else if(inventory[slot1] != null && inventory[slot1].isItemEqual(inventory[slot0]))
		{
			if(inventory[slot1].stackSize + inventory[slot0].stackSize <= 64)
			{
				inventory[slot1].stackSize += inventory[slot0].stackSize;
				inventory[slot0] = null;
				update = true;
			}
			else
			{
				int stacksize = (inventory[slot1].stackSize + inventory[slot0].stackSize) - 64;
				inventory[slot1].stackSize = 64;
				inventory[slot0].stackSize = stacksize;
				update = true;
			}
		}
	}
}

public void doSomething()
{
	int speed = getSpeedValue();
	if(speed == 0) return;

	EnumRecipeType type = getRecipeTypeFromMode(mode);
	if(type == null)return;


	if(inventory[7] != null && recipes.hasMatchingRecipe(type, inventory[7].copy(), first, second, worldObj))
	{
		if(fuel > 0 && drops.isEmpty() && liquidDrops.isEmpty())
		{
			progress+=speed;
			fuel-=speed;
			if(progress >= 1000)
			{
				INormalRecipe recipe = recipes.getRecipe(type, inventory[7].copy(), first, second, worldObj);
				if(recipe != null && recipe.getResult() != null)
				{
					Result[] output = recipe.getResult();
					for(int i = 0;i<output.length;i++)
					{
						Result current = output[i];
						if(current.hasItemResult(this.worldObj) && current.getItemResult(this.worldObj) != null && rand.nextInt(100) < current.getItemResultChance(this.worldObj))
						{
							drops.add(current.getItemResult(this.worldObj));
						}
						if(current.hasLiquidResult(this.worldObj) && current.getLiquidResult(this.worldObj) != null && rand.nextInt(100) < current.getLiquidResultChance(this.worldObj))
						{
							liquidDrops.add(current.getLiquidResult(this.worldObj));
						}

					}
					recipe.runResult(inventory[7], first, second, worldObj);
					if(inventory[7].stackSize <= 0)
					{
						inventory[7] = inventory[7].getItem().getContainerItemStack(inventory[7]);
					}
					progress = 0;
				}
				else
				{
					progress = 0;
				}
			}
		}
	}
	else
	{
		progress = 0;
	}


}

public void onBCUpdate()
{

}


public EnumRecipeType getRecipeTypeFromMode(int i)
{
	if(i == 0)
	{
		return EnumRecipeType.Compressor;
	}
	if(i == 1)
	{
		return EnumRecipeType.Sqeezer;
	}
	if(i == 2)
	{
		return EnumRecipeType.Mixer;
	}
	return null;
}


public int getSpeedValue()
{
	if(fuel > 0)
	{
		if(fuel > 100)
		{
			if(fuel > 500)
			{
				if(fuel > 1000)
				{
					return 4;
				}
				else
				{
					return 3;
				}
			}
			else
			{
				return 2;
			}
		}
		else
		{
			return 1;
		}
	}
	else
	{
		return 0;
	}
}

    public int getSizeInventory()
    {
        return this.inventory.length;
    }
    
    public ItemStack getStackInSlot(int par1)
    {
        return this.inventory[par1];
    }


    public ItemStack decrStackSize(int par1, int par2)
    {
        if (this.inventory[par1] != null)
        {
            ItemStack var3;

            if (this.inventory[par1].stackSize <= par2)
            {
                var3 = this.inventory[par1];
                this.inventory[par1] = null;
                return var3;
            }
            else
            {
                var3 = this.inventory[par1].splitStack(par2);

                if (this.inventory[par1].stackSize == 0)
                {
                    this.inventory[par1] = null;
                }

                return var3;
            }
        }
        else
        {
            return null;
        }
    }

    
    public ItemStack getStackInSlotOnClosing(int par1)
    {
        if (this.inventory[par1] != null)
        {
            ItemStack var2 = this.inventory[par1];
            this.inventory[par1] = null;
            return var2;
        }
        else
        {
            return null;
        }
    }

    
    public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
    {
        this.inventory[par1] = par2ItemStack;

        if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
        {
            par2ItemStack.stackSize = this.getInventoryStackLimit();
        }
    }

    
    public String getInvName()
    {
        return "Special Compressor";
    }

public int getInventoryStackLimit() 
{
	return 64;
}


public boolean isUseableByPlayer(EntityPlayer var1) 
{
	return true;
}


public void openChest() 
{
}

@Override
    public void readFromNBT(NBTTagCompound par1NBTTagCompound)
    {
        super.readFromNBT(par1NBTTagCompound);
        NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
        this.inventory = new ItemStack[this.getSizeInventory()];

        for (int var3 = 0; var3 < var2.tagCount(); ++var3)
        {
            NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
            byte var5 = var4.getByte("Slot");

            if (var5 >= 0 && var5 < this.inventory.length)
            {
                this.inventory[var5] = ItemStack.loadItemStackFromNBT(var4);
            }
        }
        
        if (par1NBTTagCompound.hasKey("FirstTank")) {
        	
        	FluidStack stack = FluidStack.loadFluidStackFromNBT(par1NBTTagCompound.getCompoundTag("FirstTank"));
        	
        	if(stack != null)
        	{
        		first.setFluid(stack);
        	}
        	
        	
	}
        if (par1NBTTagCompound.hasKey("Second")) {
        	
        	FluidStack fluid = FluidStack.loadFluidStackFromNBT(par1NBTTagCompound.getCompoundTag("Second"));
        	
        	if(fluid != null)
        	{
        		second.setFluid(fluid);
        	}
        	
	}
        progress = par1NBTTagCompound.getInteger("Progress");
        fuel = par1NBTTagCompound.getInteger("Fuels");
        mode = par1NBTTagCompound.getInteger("Mode");
    }

    /**
     * Writes a tile entity to NBT.
     */
@Override
    public void writeToNBT(NBTTagCompound par1NBTTagCompound)
    {
        super.writeToNBT(par1NBTTagCompound);
       
        NBTTagList var2 = new NBTTagList();

        for (int var3 = 0; var3 < this.inventory.length; ++var3)
        {
            if (this.inventory[var3] != null)
            {
                NBTTagCompound var4 = new NBTTagCompound();
                var4.setByte("Slot", (byte)var3);
                this.inventory[var3].writeToNBT(var4);
                var2.appendTag(var4);
            }
        }

        par1NBTTagCompound.setTag("Items", var2);
    	par1NBTTagCompound.setInteger("rotation", facing);
	if (first.getFluid() != null) {
		par1NBTTagCompound.setTag("FirstTank", first.getFluid().writeToNBT(par1NBTTagCompound));
	}
	if (second.getFluid() != null) {
		par1NBTTagCompound.setTag("Second", second.getFluid().writeToNBT(par1NBTTagCompound));
	}
    	par1NBTTagCompound.setInteger("Progress", progress);
    	par1NBTTagCompound.setInteger("Fuels", fuel);
    	par1NBTTagCompound.setInteger("Mode", mode);
    }

public void closeChest() 
{
}

public FluidStack getLiquidID(boolean firsts)
{
	if(firsts)
	{
		return first.getFluid();
	}
	else
	{
		return second.getFluid();
	}
}


public int getTankScaled(int i, boolean firsts) 
{
	if(firsts)
	{
		return first.getFluid() != null ?  ((first.getFluid().amount / (275))) : 0;
	}
	else
	{
		return second.getFluid() != null ? ((second.getFluid().amount / (275))) : 0;
	}
}

public void getInfoData(int key, int value)
{
	switch(key)
	{
		case 0:
			progress = value;
			break;
		case 1:
			fuel = value;
			break;
		case 2:
			mode = value;
			break;
		case 3:
			if (first.getFluid() == null) 
			{
				first.setFluid(new FluidStack(value, 0));
			} 
			else 
			{
				first.getFluid().fluidID = value;
			}
			break;
		case 4:
			if (first.getFluid() == null) 
			{
				first.setFluid(new FluidStack(0, value));
			} 
			else 
			{
				first.getFluid().amount = value;
			}
			break;
		case 5:
			if (second.getFluid() == null) 
			{
				second.setFluid(new FluidStack(value, 0));
			}
			else 
			{
				second.getFluid().fluidID = value;
			}
			break;
		case 6:
			if (second.getFluid() == null) 
			{
				second.setFluid(new FluidStack(0, value));
			} 
			else 
			{
				second.getFluid().amount = value;
			}
			break;
		case 7:
			this.cound = value;

	}
}

public void sendGuiInfoData(ContainerCompressor par1, ICrafting par2)
{
	par2.sendProgressBarUpdate(par1, 0, progress);
	par2.sendProgressBarUpdate(par1, 1, fuel);
	par2.sendProgressBarUpdate(par1, 2, mode);
	par2.sendProgressBarUpdate(par1, 3, first.getFluid() != null ? first.getFluid().fluidID : 0);
	par2.sendProgressBarUpdate(par1, 4, first.getFluid() != null ? first.getFluid().amount : 0);
	par2.sendProgressBarUpdate(par1, 5, second.getFluid() != null ? second.getFluid().fluidID : 0);
	par2.sendProgressBarUpdate(par1, 3, second.getFluid() != null ? second.getFluid().amount : 0);
	par2.sendProgressBarUpdate(par1, 6, cound);
}




public void breaks()
{
	this.inventory[13] = null;
	this.worldObj.playSoundEffect(xCoord, yCoord, zCoord, (String)null, 0, 0);
}



@Override
public int[] getAccessibleSlotsFromSide(int var1) 
{
	if(var1 == 0 || var1 == 1)
	{
		return new int[]{3};
	}
	return new int[]{12};
}



@Override
public boolean canInsertItem(int i, ItemStack itemstack, int j) 
{
	if(j == 0 || j == 1)
	{
		return true;
	}
	return false;
}



@Override
public boolean canExtractItem(int i, ItemStack itemstack, int j) 
{
	if(j == 0 || j == 1)
	{
		return false;
	}
	return true;
}



@Override
public boolean isInvNameLocalized() 
{
	return false;
}



@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack)
{
	return true;
}



@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) 
{

	if(from.ordinal() == ForgeDirection.EAST.ordinal() || from.ordinal() == ForgeDirection.WEST.ordinal())
	{
		if(first.fill(resource, false) > 0)
		{
			return first.fill(resource, doFill);
		}
		return 0;
	}
	if(from.ordinal() == ForgeDirection.NORTH.ordinal() || from.ordinal() == ForgeDirection.SOUTH.ordinal())
	{
		if(second.fill(resource, false) > 0)
		{
			return second.fill(resource, doFill);
		}
		return 0;
	}
	if(first.fill(resource, false) > 0)
	{
		return first.fill(resource, doFill);
	}
	if(second.fill(resource, false) > 0)
	{
		return second.fill(resource, doFill);
	}
	return 0;
}



@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) 
{
	return this.drain(from, resource.amount, doDrain);
}



@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) 
{
	if(from.ordinal() == ForgeDirection.EAST.ordinal() || from.ordinal() == ForgeDirection.WEST.ordinal())
	{
		if(first.drain(maxDrain, false) != null)
		{
			return first.drain(maxDrain, doDrain);
		}
		return null;
	}
	if(from.ordinal() == ForgeDirection.NORTH.ordinal() || from.ordinal() == ForgeDirection.SOUTH.ordinal())
	{
		if(second.drain(maxDrain, false) != null)
		{
			return second.drain(maxDrain, doDrain);
		}
		return null;
	}

	if(first.drain(maxDrain, false) != null)
	{
		return first.drain(maxDrain, doDrain);
	}

	if(second.drain(maxDrain, false) != null)
	{
		return second.drain(maxDrain, doDrain);
	}


	return null;	
}



@Override
public boolean canFill(ForgeDirection from, Fluid fluid) 
{
	return true;
}



@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) 
{
	return true;
}



@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) 
{
	return new FluidTankInfo[]{first.getInfo(), second.getInfo()};
}



}

 

What could be the problem?

 

Posted

I did that. You find it at the getDiscription Packet

And the Container Sync is are in the functions "getInfoData" and "sendGuiInfoData" which are called from the container.

So that could not be the problem.

another Idea diesieben?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.