Jump to content

[1.4.7]Transfer stack in slot problems [solved]


Moritz

Recommended Posts

Hello. I have a big problem.

 

I hope you can help me.

The problem is with stack in slot. I made a special machine which is very modular!

I mean modularer as From Thermal Expansion (the gui clicking and he get his output/input changed)

 

So the tile works container is ok too but the thing is too modular for me.

 

I do not get the stack in slot finish every time i tried it Crash.

Here is the code: (Because i am afraid somebody steal my code i change a view names and things lile that).

 

package bla bla

import java.util.Iterator;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

import speiger.src.api.common.slots.SlotBlocked;
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;
import net.minecraft.item.crafting.FurnaceRecipes;

public class Container extends Container {

private TileEntity tile;
private int fuelnow = 0;
private int[] progressnow = new int[] {0,0,0,0};
private int energienow = 0;

public Container(InventoryPlayer par1, TileEntity par2) 
{
	tile = par2;
	//Input Slots
	addSlotToContainer(new Slot(par2, 0, 47, 9));
	addSlotToContainer(new Slot(par2, 1, 66, 9));
	addSlotToContainer(new Slot(par2, 2, 85, 9));
	addSlotToContainer(new Slot(par2, 3, 104, 9));

	//Output Slots //First Row

	addSlotToContainer(new SlotBlocked(par2, 4, 47, 53));
	addSlotToContainer(new SlotBlocked(par2, 5, 66, 53));
	addSlotToContainer(new SlotBlocked(par2, 6, 85, 53));
	addSlotToContainer(new SlotBlocked(par2, 7, 104, 53));

	//Output Slots //Second Row

	addSlotToContainer(new SlotBlocked(par2, 8, 47, 73));
	addSlotToContainer(new SlotBlocked(par2, 9, 66, 73));
	addSlotToContainer(new SlotBlocked(par2, 10, 85, 73));
	addSlotToContainer(new SlotBlocked(par2, 11, 104, 73));

	//Modul Slots

	addSlotToContainer(new Slot(par2, 12, 47, 102));
	addSlotToContainer(new Slot(par2, 13, 66, 102));
	addSlotToContainer(new Slot(par2, 14, 85, 102));
	addSlotToContainer(new Slot(par2, 15, 104, 102));
	addSlotToContainer(new Slot(par2, 16, 151, 102));

	//Fuel Slot

	addSlotToContainer(new Slot(par2, 17, 8, 102));



        int var3;

        for (var3 = 0; var3 < 3; ++var3)
        {
            for (int var4 = 0; var4 < 9; ++var4)
            {
                this.addSlotToContainer(new Slot(par1, var4 + var3 * 9 + 9, 8 + var4 * 18, 140 + var3 * 18));
            }
        }

        for (var3 = 0; var3 < 9; ++var3)
        {
            this.addSlotToContainer(new Slot(par1, var3, 8 + var3 * 18, 198));
        }
}



@Override
    public void detectAndSendChanges()
    {
        super.detectAndSendChanges();
        Iterator var1 = this.crafters.iterator();

        while (var1.hasNext())
        {
            ICrafting var2 = (ICrafting)var1.next();
            
            if(fuelnow != tile.fuel)var2.sendProgressBarUpdate(this, 0, tile.fuel);
            if(progressnow[0] != tile.progress[0])var2.sendProgressBarUpdate(this, 1, tile.progress[0]);
            if(progressnow[1] != tile.progress[1])var2.sendProgressBarUpdate(this, 2, tile.progress[1]);
            if(progressnow[2] != tile.progress[2])var2.sendProgressBarUpdate(this, 3, tile.progress[2]);
            if(progressnow[3] != tile.progress[3])var2.sendProgressBarUpdate(this, 4, tile.progress[3]);
            if(energienow != tile.energie)var2.sendProgressBarUpdate(this, 5, tile.energie);
       
        }
        fuelnow = tile.fuel;
        progressnow[0] = tile.progress[0];
        progressnow[1] = tile.progress[1];
        progressnow[2] = tile.progress[2];
        progressnow[3] = tile.progress[3];
        energienow = tile.energie;
    }


    @SideOnly(Side.CLIENT)
    public void updateProgressBar(int par1, int par2)
    {
    	if(par1 == 0)tile.fuel = par2;
    	if(par1 == 1)tile.progress[0] = par2;
    	if(par1 == 2)tile.progress[1] = par2;
    	if(par1 == 3)tile.progress[2] = par2;
    	if(par1 == 4)tile.progress[3] = par2;
    	if(par1 == 5)tile.energie = par2;
    }



public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, 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 >= 4 && <= 12)
            {
                if (!this.mergeItemStack(var5, 4, 12, true))
                {
                    return null;
                }

                var4.onSlotChange(var5, var3);
            }
            else if (tile.getRecipeFromModulID(var5, tile.modulID[1-4])//and this here is my problem i just coppied it out of the furnace.
            {
                if (FurnaceRecipes.smelting().getSmeltingResult(var5) != null)
                {
                    if (!this.mergeItemStack(var5, 0, 1, false))
                    {
                        return null;
                    }
                }
                else if (tile.isItemFuel(var5))
                {
                    if (!this.mergeItemStack(var5, 17, 18, false))
                    {
                        return null;
                    }
                }
                else if (par2 >= 3 && par2 < 30)
                {
                    if (!this.mergeItemStack(var5, 30, 39, false))
                    {
                        return null;
                    }
                }
                else if (par2 >= 30 && par2 < 39 && !this.mergeItemStack(var5, 3, 30, false))
                {
                    return null;
                }
            }
            else if (!this.mergeItemStack(var5, 3, 39, false))
            {
                return null;
            }

            if (var5.stackSize == 0)
            {
                var4.putStack((ItemStack)null);
            }
            else
            {
                var4.onSlotChanged();
            }

            if (var5.stackSize == var3.stackSize)
            {
                return null;
            }

            var4.onPickupFromSlot(par1EntityPlayer, var5);
        }

        return var3;

    } 

@Override
public boolean canInteractWith(EntityPlayer var1) 
{
	return true;
}

}

 

I had deleted the problem code and i do write fast a new version of it.

 

So my problem is: That its to modular. I have more than one recipe path.

Thats the thing i want to do:

That items which you shift click (and a modul is in the slot) (and recipes are loaded) transfer into the right slot. Also when its finish that when you shiftclick on the ouput that it transfer it into the player inventory.

Also i when you right click on the modul and its a recipe modul than it place it in the first free modulslot it can find.

 

Also when there is a fuelmodul that i place that inside of the fuelslot.

 

 

I know i give low information and want much help. But i hope you can help me.

 

Can someone help me?

Link to comment
Share on other sites

It happends again xD I solved by myself.

 

But how i can not explain it without showing my sourcecode. And i do not want to show it^^" but thanks fro reading^^

 

I've been checking this post for the past day or so hoping to find a solution to this same problem... can you share how you did it at least, if not your code?  Or PM me?

Link to comment
Share on other sites

It happends again xD I solved by myself.

 

But how i can not explain it without showing my sourcecode. And i do not want to show it^^" but thanks fro reading^^

 

I've been checking this post for the past day or so hoping to find a solution to this same problem... can you share how you did it at least, if not your code?  Or PM me?

 

xD there is a little problem. The Container ask very much the tileEntity What is todo. And you have to read the tile entity to understand. And i will not show it until i can released in my mod^^" I am afraid of someone steals my code.

What i did was extending only the furnace stacking. I made it modular. Not more.

 

Link to comment
Share on other sites

It happends again xD I solved by myself.

 

But how i can not explain it without showing my sourcecode. And i do not want to show it^^" but thanks fro reading^^

 

I've been checking this post for the past day or so hoping to find a solution to this same problem... can you share how you did it at least, if not your code?  Or PM me?

 

xD there is a little problem. The Container ask very much the tileEntity What is todo. And you have to read the tile entity to understand. And i will not show it until i can released in my mod^^" I am afraid of someone steals my code.

What i did was extending only the furnace stacking. I made it modular. Not more.

 

I see, actually I think the issue I'm having is only a bit similar but not the same.  Thanks for replying.  :)

Link to comment
Share on other sites

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.