Jump to content

Recommended Posts

Posted

Now i have a problem with my Ghost item.

 

It does Dissapier after you relog the game.

 

Here is my code. i did find out which function it is but not directly what directly the problem is.

 

 

Here my Tile Entity. I know it is a tile problem.

package speiger.src.tinychest.common.tileentity.tinychest;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class TransDimensionaleTinyChest extends TileEntity implements IInventory
{
public ItemStack[] chest;
public String invName;
public int facing = 0;
public int[] storedItemStackSize = new int[9];
public ItemStack[] ID = new ItemStack[9];
public int sizes;
public int MaxStackSize = 64;
public boolean update = false;

public TransDimensionaleTinyChest(String name, int size)
{
	chest = new ItemStack[(size*3)];
	invName = name;
	sizes = size;
}

@SideOnly(Side.CLIENT)
public int getStorage(int par1)
{
	return (int)storedItemStackSize[par1];
}


@Override
public int getSizeInventory()
{
	return chest.length;
}


    public ItemStack getStackInSlot(int par1)
    {
        return this.chest[par1];
    }


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

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

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

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

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

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

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

    
    public String getInvName()
    {
        return invName;
    }



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


public void openChest() 
{
}

@Override
    public void readFromNBT(NBTTagCompound par1NBTTagCompound)
    {
        super.readFromNBT(par1NBTTagCompound);
        
        NBTTagList var5 = par1NBTTagCompound.getTagList("Items2");
        this.ID = new ItemStack[this.getSizeInventory()];

        for (int var6 = 0; var6 < var5.tagCount(); ++var6)
        {
            NBTTagCompound var7 = (NBTTagCompound)var5.tagAt(var6);
            byte var8 = var7.getByte("Slot2");

            if (var8 >= 0 && var8 < this.ID.length)
            {
                this.ID[var8] = ItemStack.loadItemStackFromNBT(var7);
            }
        }
        
        
        NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
        this.chest = new ItemStack[this.getSizeInventory()];
        for (int var3 = 0; var3 < var2.tagCount(); ++var3)
        {
            NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
            byte var6 = var4.getByte("Slot");

            if (var6 >= 0 && var6 < this.chest.length)
            {
                this.chest[var6] = ItemStack.loadItemStackFromNBT(var4);
            }
        }
        

        
        for(int i = 0;i<this.storedItemStackSize.length;i++)
        {
        	this.storedItemStackSize[i] = par1NBTTagCompound.getInteger("StoredItems"+i);
        }
        
        facing = par1NBTTagCompound.getInteger("faceing");
        MaxStackSize = par1NBTTagCompound.getInteger("MaxStackSizes");
    }

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

        
        NBTTagList var5 = new NBTTagList();
        for (int var6 = 0; var6 < this.ID.length; ++var6)
        {
            if (this.ID[var6] != null)
            {
                NBTTagCompound var7 = new NBTTagCompound();
                var7.setByte("Slot2", (byte)var6);
                this.ID[var6].writeToNBT(var7);
                var5.appendTag(var7);
            }
        }
        par1NBTTagCompound.setTag("Items2", var5);
        
        NBTTagList var2 = new NBTTagList();
        for (int var3 = 0; var3 < this.chest.length; ++var3)
        {
            if (this.chest[var3] != null)
            {
                NBTTagCompound var4 = new NBTTagCompound();
                var4.setByte("Slot", (byte)var3);
                this.chest[var3].writeToNBT(var4);
                var2.appendTag(var4);
            }
        }
        par1NBTTagCompound.setTag("Items", var2);
        
        for(int i = 0;i<this.storedItemStackSize.length;i++)
        {
        	par1NBTTagCompound.setInteger("StoredItems"+i, this.storedItemStackSize[i]);
        }
        par1NBTTagCompound.setInteger("faceing", facing);
        par1NBTTagCompound.setInteger("MaxStackSizes", MaxStackSize);
    }

public void closeChest() 
{
}


@Override
public int getInventoryStackLimit()
{
	return 64;
}

    @Override
public Packet getDescriptionPacket() 
    {
    	NBTTagCompound var1 = new NBTTagCompound();
    	super.writeToNBT(var1);
    	var1.setInteger("faceing", facing);
        for(int i = 0;i<this.storedItemStackSize.length;i++)
        {
        	var1.setInteger("StoredItems"+i, this.storedItemStackSize[i]);
        }
    	return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, var1);
}

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

//Eloraams code (1.2.5)
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();
        }
    }


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

}

   
//This function is the problem
public void showItems()
{


	for(int i = 0;i<sizes;i++)
	{
		if(ID[i] != null)
		{
			chest[i+(sizes*2)] = new ItemStack(ID[i].itemID, 1, ID[i].getItemDamage());
			update = true;
		}
		else
		{
			chest[i+(sizes*2)] = null;
			update = true;
		}
	}
}


public void eatItems()
{
	for(int i = 0; i<sizes;i++)
	{
		if(storedItemStackSize[i] < MaxStackSize)
		{
			ItemStack current = ID[i];
			if(chest[i] != null)
			{
				if(current != null && chest[i].itemID == current.itemID && chest[i].getItemDamage() == current.getItemDamage())
				{
					if(storedItemStackSize[i] + 1 <= MaxStackSize)
					{
						storedItemStackSize[i]+=1;
						chest[i].stackSize--;
						update = true;
						if(chest[i].stackSize <= 0)
						{
							chest[i] = null;
							update = true;
						}
					}
				}
				else if(current == null)
				{
					ID[i] = new ItemStack(chest[i].getItem(), 1, chest[i].getItemDamage());
					storedItemStackSize[i]+=1;
					chest[i].stackSize--;
					update = true;
					if(chest[i].stackSize <= 0)
					{
						chest[i] = null;
						update = true;
					}
				}
			}
		}
	}
}


public void addItems()
{
	for(int i = 0; i<sizes;i++)
	{
		ItemStack current = ID[i];
		if(current != null)
		{
			if(this.storedItemStackSize[i] > 0)
			{
				if(chest[i+sizes] != null && chest[i+sizes].itemID == current.itemID && chest[i+sizes].getItemDamage() == current.getItemDamage())
				{
					if(chest[i+sizes].stackSize + 1 <= 64 && chest[i+sizes].stackSize + 1 <= chest[i+sizes].getMaxStackSize())
					{
						chest[i+sizes].stackSize++;
						this.storedItemStackSize[i]-=1;
						update = true;
						if(this.storedItemStackSize[i] <= 0)
						{
							ID[i] = null;
							update = true;
						}
					}
				}
				else if(chest[i+sizes] == null)
				{
					chest[i+sizes] = new ItemStack(current.itemID, 1, current.getItemDamage());
					this.storedItemStackSize[i]-=1;
					update = true;
					if(this.storedItemStackSize[i] <= 0)
					{
						ID[i] = null;
						update = true;
					}
				}
			}
		}
	}
}
                
                //This function is will called by my packethandler
public void addStorage(int storage)
{
	int between = 64;

	between *= storage;
	between = between / 2;
	int secand = between / sizes;
	this.MaxStackSize += secand;

}
    
    

}


 

Here an extra video what showes the problem.

 

 

 

i hope you can help me.

 

Speiger.

Posted

Well I see what you mean in the video, not sure exactly what's causing your problem, but what I can tell you is what I know about containers.

 

You do not need packets to sync items from client to server, whatever is placed inside a slot that's inside a container actually gets sync via the container class you have to create for your block.

 

So for instance on your block class file you would have a function called onBlockActivated and inside there you call your gui

you need to setup a guihandler that would switch between server and client and handle the packets for you. Now you most likely got all of this, but the syncing of items in the container takes place via the server side container class.

 

Secondly on your code you have public ItemStack[] chest; and public ItemStack[] ID = new ItemStack[9];

you then set your chest to a sizex3 and I have no idea what that size it suppose that depends on some condition.

 

Now you only still only have 1 container class assuming you are using a guihandler that is used for this and my guess is somewhere in there your container server side class file does not know what to do with all your slots, because it might not be mapped correctly or updated correctly. That woudl explain why once you close your gui and reopen it the gui doesn't display your item, so check inside the server side container file you created for this Tile Entity you will find your answer there.

 

 

Posted

Ghost anything is almost always due to a mismatch between server and client.

When you log on again the server tells the client what it's inventor contains.

 

I'm guessing that you are giving the player the item on the Client side and noth on server/both :P

  Quote

If you guys dont get it.. then well ya.. try harder...

Posted

Ok my block activate function which has client/server packet inside is only for extending the storage. (MaxStackSize).

That is what my packet handler does.

 

The sizes*3 is the is only the thing what my chest.

I made the same system as ironchest.

The size of the chest has always 3 or you can / 3.

But thats not the problem.

 

Now to the ID thing. The ID stores the id of the item which is iniside of the inifinet extende able storage.

Thats it.

 

Now Mazetars comments:

 

I use an extra slot for the items. And i do block the slot so you can not click on it.

Thats why i could not get items out of my inventory as i opened the big version of the

Transdimensional tiny chest^^"

 

So what could be the problem^^?

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I never thought I’d fall for it but I did. It all started with what seemed like a promising crypto investment opportunity I found through a popular social media platform. The project looked legitimate, with a sleek website, professional looking team profiles, and glowing testimonials. After doing what I thought was enough due diligence, I invested. First $5,000. Then $10,000. Over the next few months, I put in a total of $153,000. The returns were amazing on paper. My account showed massive gains, and I was told I could “withdraw soon.” But when I tried to cash out, I was hit with endless delays, excuses, and requests for additional “verification fees.” That’s when the panic set in: I realized I’d been scammed. I felt sick. Devastated. Embarrassed. After days of searching online, I came across Malice Cyber Recovery, a firm that specialized in tracing and recovering lost digital assets. I was skeptical at first I’d already lost so much, and I wasn’t ready to be taken advantage of again. But their team was incredibly professional and transparent from the start. They explained the recovery process in detail and didn’t make any unrealistic promises. They began with a full investigation, tracing the blockchain transactions and identifying the wallet addresses involved. Within a week, they had compiled enough evidence to begin their recovery strategy. It wasn’t easy and it wasn’t overnight but within a matter of weeks, I received the news I never thought I’d hear They had recovered my $153,000. I cried. Not just because I got my money back but because someone actually cared enough to help me. If you’ve fallen victim to a crypto scam, don’t suffer in silence. Malice Cyber Recovery gave me my life back and they just might be able to do the same for you  
    • Maximizing savings on  Temu  has never been easier! With the exclusive 70% Off Coupon Code [acu729640], you can enjoy unparalleled discounts on a vast array of trending products. This offer, coupled with fast delivery and free shipping across 67 countries, ensures that shoppers receive high-quality items at remarkably reduced prices. Exclusive  Temu  Coupon Codes for Maximum Savings Enhance your shopping experience by applying these verified Coupon Codes: acu729640 – Enjoy a 70% discount on your order. acu729640 – Receive an extra 30% off on select items. acu729640 – Benefit from free shipping on all purchases. acu729640 – Save $10 on orders exceeding $50. acu729640 – Unlock special discounts on newly launched products. What is the  Temu  70% Off Coupon Code [acu729640]? The 70% Off Coupon Code [acu729640] is a premier promotional tool that significantly reduces the cost of various products across  Temu 's extensive marketplace. Whether you are a first-time buyer or a returning customer, applying this Code at checkout guarantees exceptional discounts on categories such as apparel, electronics, home essentials, and more. How Does the 70% Off Coupon Code [acu729640] Work on  Temu ? Leveraging the 70% Off Coupon Code [acu729640] is effortless: Browse  Temu ’s diverse product range. Select and add desired items to your shopping cart. Enter [acu729640] at checkout. Instantly receive a 70% discount. Complete your transaction and enjoy expedited, reliable shipping. Is the  Temu  70% Off Coupon Code [acu729640] Legitimate? Absolutely! The  Temu  70% Off Coupon Code [acu729640] is an authentic and verified discount, actively used by thousands of savvy shoppers. Unlike misleading online offers, this Coupon is officially endorsed by  Temu , ensuring its seamless functionality across multiple product categories. Latest  Temu  Coupon Code 70% Off [acu729640] + Additional 30% Discount  Temu  continually updates its promotional lineup. In addition to the 70% Off Coupon Code [acu729640], customers can utilize to obtain an extra 30% discount on selected items. These stacked savings empower users to optimize their purchases and maximize financial benefits.  Temu  Coupon Code 70% Off United States [acu729640] For 2025 For customers residing in the United States, the  Temu  Coupon Code 70% Off [acu729640] remains a top-tier deal in 2025. Coupled with nationwide free shipping, this offer presents an unparalleled opportunity to secure premium products at a fraction of their original cost.  Temu  70% Off Coupon Code [acu729640] + Free Shipping In addition to receiving 70% off, users also enjoy complimentary shipping when applying the  Temu  70% Off Coupon Code [acu729640]. This combination of discounts and free shipping eliminates hidden costs, reinforcing  Temu ’s dedication to customer satisfaction and affordability. More Exclusive  Temu  Coupon Codes for Additional Savings Maximize your savings with these additional discount Codes: acu729640 – Unlock a 70% discount instantly. acu729640 – Avail extra savings for new users. acu729640 – Get free shipping on all orders. acu729640 – Enjoy bulk purchase discounts. acu729640 – Access exclusive markdowns on premium collections. Why Should You Use the  Temu  70% Off Coupon Code [acu729640]? Substantial savings across multiple product categories. Exclusive discounts for new and returning customers. Verified and legitimate Coupon Codes with immediate application. Complimentary shipping available across 67 countries. Expedited delivery and a seamless shopping experience. Final Note: Use The Latest  Temu  Coupon Code [acu729640] 70% Off The  Temu  Coupon Code [acu729640] 70% off offers an unparalleled opportunity to save significantly on high-quality products. Secure this deal now to maximize your benefits in July 2025. With the  Temu  Coupon 70% off, you can access exceptional discounts and unbeatable pricing. Apply the Code today and transform your shopping experience. Summary:  Temu  Coupon Code 70% Off  Temu  70% Off Coupon Code acu729640 70% Off Coupon Code acu729640  Temu   Temu  Coupon Code 70% Off United States 2025 Latest  Temu  Coupon Code 70% Off acu729640  Temu  70% Off Coupon Code legit How to use  Temu  70% Off Coupon Code Temu  70% Off Coupon Code free shipping Best  Temu  discount Codes 2025  Temu  promo Codes July 2025 FAQs About the  Temu  70% Off Coupon What is the 70% Off Coupon Code [acu729640] on  Temu ? The 70% Off Coupon Code [acu729640] is a promotional tool enabling shoppers to secure up to 70% savings on a vast selection of  Temu  products. How can I apply the  Temu  70% Off Coupon Code [acu729640]? To redeem the Coupon, simply add your chosen items to the cart, enter [acu729640] at checkout, and enjoy the automatic discount. Is the  Temu  70% Off Coupon Code [acu729640] available for all users? Yes! Both first-time and returning customers can leverage the 70% Off Coupon Code [acu729640] to access incredible savings. Does the 70% Off Coupon Code [acu729640] include free shipping? Yes! Applying [acu729640] at checkout not only provides a 70% discount but also ensures free shipping across applicable regions. Can the  Temu  70% Off Coupon Code [acu729640] be used multiple times? The validity and frequency of Coupon usage are subject to  Temu ’s promotional policies. Many users report success in applying the Coupon across multiple transactions, maximizing their overall savings potential.  
    • Temu Gutscheincode 100 € RABATT → [acu729640] für die USA im Juli  Spare riesig mit dem Temu Gutscheincode 100 € RABATT → [acu729640] im Juli 2025 Im Juli 2025 bringt Temu unglaubliche Rabatte für seine treuen Kunden mit einem exklusiven Gutscheincode (acu729640), der dir beeindruckende 100 € Rabatt auf deinen Einkauf gewährt. Egal, ob du Neukunde oder Stammkunde bist – du kannst bei einer riesigen Auswahl an Artikeln sparen, darunter Elektronik, Mode, Haushaltswaren und vieles mehr! Jetzt ist der perfekte Zeitpunkt, um satte Rabatte zu genießen und zu erleben, warum Temu eine der führenden globalen E-Commerce-Plattformen ist. Was macht Temu so besonders? Temu ist bekannt für eine riesige Auswahl an trendigen Produkten zu unschlagbaren Preisen. Von den neuesten Technik-Gadgets bis zu stylischer Kleidung und Haushaltsbedarf – hier findest du alles. Außerdem bietet Temu kostenlosen Versand in über 67 Länder, schnelle Lieferung und Rabatte von bis zu 90 % auf ausgewählte Produkte. Mit dem Gutscheincode (acu729640) erhältst du zusätzliche Rabatte! So verwendest du den Temu Gutscheincode (acu729640) im Juli 2025 So nutzt du das 100 €-Angebot mit dem Temu Gutscheincode (acu729640): Registrieren oder Einloggen bei Temu: Ob neu oder bereits Kunde – du musst dich anmelden oder ein Konto erstellen, um den Gutscheincode einzulösen. Durchstöbere die große Temu-Auswahl: Entdecke Temus umfangreiches Produktsortiment – von Haushaltsartikeln, Beauty-Produkten, Mode bis hin zu Hightech-Gadgets. Gutscheincode eingeben (acu729640): Gib den Code im Feld "Promo Code" beim Checkout ein, um die 100 € sofort abzuziehen. Zusätzliche Rabatte sichern: Neben den 100 € Rabatt gibt es bis zu 40 % Rabatt auf ausgewählte Artikel oder kombinierbare Gutscheinpakete. Bestellung abschließen: Überprüfe deinen Warenkorb und schließe die Bestellung ab – inklusive kostenlosem Versand in über 67 Länder! Warum du den Temu Gutscheincode (acu729640) verwenden solltest Der Temu Gutscheincode (acu729640) bietet viele Vorteile – egal ob Neukunde oder Bestandskunde: 100 € Rabatt für Neukunden: Spare 100 € bei deiner ersten Bestellung. 100 € Rabatt für Bestandskunden: Auch wiederkehrende Kunden profitieren mit acu729640 von 100 € Rabatt. 40 % zusätzlicher Rabatt: Auf ausgewählte Produkte gibt es bis zu 40 % zusätzlich. Gratisgeschenk für Neukunden: Neukunden erhalten ein kostenloses Geschenk beim Einsatz des Gutscheins. 100 € Gutscheinpaket: Spare noch mehr mit gebündelten Gutscheinen für Technik, Mode, Haushaltswaren und mehr. Temu Neukunden-Rabatte & Angebote Perfekt für Neueinsteiger! Als Neukunde bekommst du: 100 € Rabatt auf die erste Bestellung mit dem Code (acu729640). Kostenloser Versand in über 67 Länder. Exklusive Promo-Codes je nach Produktkategorie. Zusätzliche Temu Gutscheine speziell für Neukunden im Juli 2025. Temu Gutscheine für Bestandskunden Auch bestehende Kunden gehen nicht leer aus: 100 € Rabatt mit acu729640 auf die nächste Bestellung. 40 % Rabatt auf ausgewählte Produkte in vielen Kategorien. Gutscheinpaket für Bestandskunden, ideal für größere Einkäufe. Weitere Rabattcodes für beliebte Produkte und Aktionen. Neue Temu-Angebote im Juli 2025 Temu überrascht immer wieder mit frischen Angeboten. Im Juli 2025 gibt es: 100 € Rabatt für Neu- und Bestandskunden mit dem Code acu729640. Bis zu 40 % Rabatt auf Elektronik, Beauty, Deko und mehr. Neukunden-Coupons inklusive Gratisgeschenk und Sonderaktionen. Laufend neue Angebote den ganzen Juli über – regelmäßig reinschauen lohnt sich! Spare in verschiedenen Ländern & Kategorien mit Temu Gutscheinen Beispiele, wie Temu-Codes weltweit funktionieren: USA: 100 € Rabatt mit acu729640 auf Bestellungen in den USA. Kanada: Kanadier erhalten 100 € Rabatt bei Erst- oder Folgebestellung. UK: Auch britische Kunden sparen 100 € mit dem Code. Japan: Japanische Kunden erhalten 100 € Rabatt plus Sonderaktionen. Mexiko, Brasilien, Spanien, Deutschland: Bis zu 40 % Rabatt auf ausgewählte Artikel mit acu729640. Fazit Ob neu oder treu – der Temu Gutscheincode (acu729640) bringt dir im Juli 2025 satte Rabatte:  100 € sparen, 40 % auf ausgewählte Artikel und kostenloser Versand weltweit. Temu bietet großartige Preise, eine riesige Auswahl und jede Menge Aktionen. Jetzt zuschlagen: Code acu729640 im Warenkorb eingeben und sparen!  
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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