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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • SLOT DANA : Situs Slot Gacor Nagaliga Deposit Via DANA 10.000
    • NAGALIGA :  Agen Taruhan Mix Parlay Bola EURO Terpercaya Di Indonesia Nagaliga merupakan situs taruhan  judi bola euro dan slot gacor terbaik menyediakan link alternatif terbaik dan pastinya bisa di akses di seluruh penjuru dunia. Ayo meriahkan EURO bersama situs Nagaliga kemenangan berapapun pasti dibayar lunas tanpa ada kendala.
    • I have no idea how a UI mod crashed a whole world but HUGE props to you man, just saved me +2 months of progress!  
    • So i know for a fact this has been asked before but Render stuff troubles me a little and i didnt find any answer for recent version. I have a custom nausea effect. Currently i add both my nausea effect and the vanilla one for the effect. But the problem is that when I open the inventory, both are listed, while I'd only want mine to show up (both in the inv and on the GUI)   I've arrived to the GameRender (on joined/net/minecraft/client) and also found shaders on client-extra/assets/minecraft/shaders/post and client-extra/assets/minecraft/shaders/program but I'm lost. I understand that its like a regular screen, where I'd render stuff "over" the game depending on data on the server, but If someone could point to the right client and server classes that i can read to see how i can manage this or any tip would be apreciated
    • Let me try and help you with love spells, traditional healing, native healing, fortune telling, witchcraft, psychic readings, black magic, voodoo, herbalist healing, or any other service your may desire within the realm of african native healing, the spirits and the ancestors. I am a sangoma and healer. I could help you to connect with the ancestors , interpret dreams, diagnose illness through divination with bones, and help you heal both physical and spiritual illness. We facilitate the deepening of your relationship to the spirit world and the ancestors. Working in partnership with one\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’s ancestors is a gift representing a close link with the spirit realm as a mediator between the worlds.*   Witchdoctors, or sorcerers, are often purveyors of mutis and charms that cause harm to people. we believe that we are here for only one purpose, to heal through love and compassion.*   African people share a common understanding of the importance of ancestors in daily life. When they have lost touch with their ancestors, illness may result or bad luck. Then a traditional healer, or sangoma, is sought out who may prescribe herbs, changes in lifestyle, a career change, or changes in relationships. The client may also be told to perform a ceremony or purification ritual to appease the ancestors.*   Let us solve your problems using powerful African traditional methods. We believe that our ancestors and spirits give us enlightenment, wisdom, divine guidance, enabling us to overcome obstacles holding your life back. Our knowledge has been passed down through centuries, being refined along the way from generation to generation. We believe in the occult, the paranormal, the spirit world, the mystic world.*   The services here are based on the African Tradition Value system/religion,where we believe the ancestors and spirits play a very important role in society. The ancestors and spirits give guidance and counsel in society. They could enable us to see into the future and give solutions to the problems affecting us. We use rituals, divination, spells, chants and prayers to enable us tackle the task before us.*   I have experience in helping and guiding many people from all over the world. My psychic abilities may help you answer and resolve many unanswered questions
  • Topics

×
×
  • Create New...

Important Information

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