Jump to content

[1.10.2] {Solved...?} Shift-Clicking Duplicates


EscapeMC

Recommended Posts

Alright, so I asked about this earlier, but I thought I would make a new thread for it, because I marked the other as solved (blah blah yes I know I could mark it as unsolved but I just thought to make a new one)

 

Whenever I shift-click an item (from my hotbar only) into any of my custom chests, it doubles it (up to 64)

 

I remember diesieben07 had said something about the fact that I have both transferStackInSlot and mergeItemStack. Would this be the problem?

 

Second thing: Whenever I shift right click and item to put it in my chest (from anywhere), it puts it to the bottom right-most slot. Is there a way to fix this, so it acts normally and puts it to the top left like a normal chest? (I cannot figure it out)

 

 

Git is ThingsMod in my signature.

I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But......

https://www.youtube.com/watch?v=6t0GlXWx_PY

 

ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2

 

TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2

 

If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.

Link to comment
Share on other sites

Anyone know the answer? I am still clueless after spending more time looking.

I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But......

https://www.youtube.com/watch?v=6t0GlXWx_PY

 

ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2

 

TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2

 

If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.

Link to comment
Share on other sites

Hello?

 

Well, I've deduced (I think) it has to do with my transferStackInSlot

 

 

This is what I have currently,

	@Override
    @Nullable
    public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
    {
        ItemStack itemstack = null;
        Slot slot = (Slot)this.inventorySlots.get(index);

        if (slot != null && slot.getHasStack())
        {
            ItemStack itemstack1 = slot.getStack();
            itemstack = itemstack1.copy();

            if (index < this.numRows * 9)
            {
                if (!this.mergeItemStack(itemstack1, this.numRows * 9, this.inventorySlots.size(), true))
                {
                    return null;
                }
            }
            else if (!this.mergeItemStack(itemstack1, 0, this.numRows * 9, false))
            {
                return null;
            }

            if (itemstack1.stackSize == 0)
            {
                slot.putStack((ItemStack)null);
            }
            else
            {
                slot.onSlotChanged();
            }
        }

        return itemstack;
    }

 

 

Is something wrong with that?

Or is it something else I am missing?

 

 

EIDT: Nevermind. Its not that part. Not that at all I believe...

I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But......

https://www.youtube.com/watch?v=6t0GlXWx_PY

 

ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2

 

TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2

 

If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.

Link to comment
Share on other sites

Still no clue to solving this. Someone please?

I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But......

https://www.youtube.com/watch?v=6t0GlXWx_PY

 

ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2

 

TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2

 

If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.

Link to comment
Share on other sites

Is there a reason you have overrided mergeItemStack? And here is a transfer stack in slot tutorial

http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571051-custom-container-how-to-properly-override-shift

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Well, I couldn't really get too much out of that tutorial for transferStackInSlot, as the method he was doing transferStackInSlot for was a furnace. I couldn't really figure out what I would need to change, delete, and redo from his transferStackInSlot that he gave.

 

Could anyone help me understand what I would need to do with

 

/**
* Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that.
*/
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2)
{
ItemStack itemstack = null;
Slot slot = (Slot)this.inventorySlots.get(par2);

if (slot != null && slot.getHasStack())
{
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();

// If itemstack is in Output stack
if (par2 == OUTPUT)
{
// try to place in player inventory / action bar; add 36+1 because mergeItemStack uses < index,
// so the last slot in the inventory won't get checked if you don't add 1
if (!this.mergeItemStack(itemstack1, OUTPUT+1, OUTPUT+36+1, true))
{
return null;
}

slot.onSlotChange(itemstack1, itemstack);
}
// itemstack is in player inventory, try to place in appropriate furnace slot
else if (par2 != FUEL && par2 != INPUT_1 && par2 != INPUT_2)
{
// if it can be smelted, place in the input slots
if (ArcaneInfuserRecipes.infusing().getInfusingResult(itemstack1) != null)
{
// try to place in either Input slot; add 1 to final input slot because mergeItemStack uses < index
if (!this.mergeItemStack(itemstack1, INPUT_1, INPUT_2+1, false))
{
return null;
}
}
// if it's an energy source, place in Fuel slot
else if (TileEntityArcaneInfuser.isItemFuel(itemstack1))
{
if (!this.mergeItemStack(itemstack1, FUEL, FUEL+1, false))
{
return null;
}
}
// item in player's inventory, but not in action bar
else if (par2 >= OUTPUT+1 && par2 < OUTPUT+28)
{
// place in action bar
if (!this.mergeItemStack(itemstack1, OUTPUT+28, OUTPUT+37, false))
{
return null;
}
}
// item in action bar - place in player inventory
else if (par2 >= OUTPUT+28 && par2 < OUTPUT+37 && !this.mergeItemStack(itemstack1, OUTPUT+1, OUTPUT+28, false))
{
return null;
}
}
// In one of the infuser slots; try to place in player inventory / action bar
else if (!this.mergeItemStack(itemstack1, OUTPUT+1, OUTPUT+37, false))
{
return null;
}

if (itemstack1.stackSize == 0)
{
slot.putStack((ItemStack)null);
}
else
{
slot.onSlotChanged();
}

if (itemstack1.stackSize == itemstack.stackSize)
{
return null;
}

slot.onPickupFromSlot(par1EntityPlayer, itemstack1);
}
return itemstack;
}
}

 

to change it to work with a (large) chest?

 

I don't want copy pasta from you, I would just appreciate you going through this, highlighting things (or something), and telling me what I might need to do with it.

 

Thanks!

I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But......

https://www.youtube.com/watch?v=6t0GlXWx_PY

 

ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2

 

TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2

 

If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.

Link to comment
Share on other sites

So I somehow figured it out myself. Oh well, thanks anyway everyone!  ;D:D

I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But......

https://www.youtube.com/watch?v=6t0GlXWx_PY

 

ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2

 

TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2

 

If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.

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.