Слоты = краш + белый фон

Версия Minecraft
1.7.10
Как исправить чтобы вылет изза ID Слотов перестал появляться, и еще когда навожу на слот получаю белый фон.

Код:
       for (int j = 0; j < 9; ++j)
        //for (int j = 0; j < Количество слотов не больше 9 иначе краш клиента; ++j)
        {
            //this.addSlotToContainer(new Slot(this.tileEntity, j, 8 + j * 16, 0));
            //this.addSlotToContainer(new Slot(this.tileEntity, j, 8 + j * 16, 16));
            // 7
         this.addSlotToContainer(new SlotCustom(te, 1001, 9, 7));
         this.addSlotToContainer(new SlotCustom(te, 1002, 27, 7));
         this.addSlotToContainer(new SlotCustom(te, 1003, 45, 7));
         this.addSlotToContainer(new SlotCustom(te, 1004, 63, 7));
         this.addSlotToContainer(new SlotCustom(te, 1005, 81, 7));
         this.addSlotToContainer(new SlotCustom(te, 1006, 99, 7));
         this.addSlotToContainer(new SlotCustom(te, 1008, 117, 7));
         this.addSlotToContainer(new SlotCustom(te, 1009, 135, 7));
         this.addSlotToContainer(new SlotCustom(te, 1010, 153, 7));
         this.addSlotToContainer(new SlotCustom(te, 1011, 171, 7));
         this.addSlotToContainer(new SlotCustom(te, 1012, 189, 7));
         // 25
         this.addSlotToContainer(new SlotCustom(te, 1013, 9, 25));
         this.addSlotToContainer(new SlotCustom(te, 1014, 27, 25));
         this.addSlotToContainer(new SlotCustom(te, 1015, 45, 25));
         this.addSlotToContainer(new SlotCustom(te, 1016, 63, 25));
         this.addSlotToContainer(new SlotCustom(te, 1017, 81, 25));
         this.addSlotToContainer(new SlotCustom(te, 1018, 99, 25));
         this.addSlotToContainer(new SlotCustom(te, 1019, 117, 25));
         this.addSlotToContainer(new SlotCustom(te, 1020, 135, 25));
         this.addSlotToContainer(new SlotCustom(te, 1021, 153, 25));
         this.addSlotToContainer(new SlotCustom(te, 1022, 171, 25));
         this.addSlotToContainer(new SlotCustom(te, 1023, 189, 25));
         //43
         this.addSlotToContainer(new SlotCustom(te, 1024, 9, 43));
         this.addSlotToContainer(new SlotCustom(te, 1025, 27, 43));
         this.addSlotToContainer(new SlotCustom(te, 1026, 45, 43));
         this.addSlotToContainer(new SlotCustom(te, 1027, 63, 43));
         this.addSlotToContainer(new SlotCustom(te, 1028, 81, 43));
         this.addSlotToContainer(new SlotCustom(te, 1029, 99, 43));
         this.addSlotToContainer(new SlotCustom(te, 1030, 117, 43));
         this.addSlotToContainer(new SlotCustom(te, 1031, 135, 43));
         this.addSlotToContainer(new SlotCustom(te, 1032, 153, 43));
         this.addSlotToContainer(new SlotCustom(te, 1033, 171, 43));
         this.addSlotToContainer(new SlotCustom(te, 1034, 189, 43));
         //61
         this.addSlotToContainer(new SlotCustom(te, 1035, 9, 61));
         this.addSlotToContainer(new SlotCustom(te, 1036, 27, 61));
         this.addSlotToContainer(new SlotCustom(te, 1037, 45, 61));
         this.addSlotToContainer(new SlotCustom(te, 1038, 63, 61));
         this.addSlotToContainer(new SlotCustom(te, 1039, 81, 61));
         this.addSlotToContainer(new SlotCustom(te, 1040, 99, 61));
         this.addSlotToContainer(new SlotCustom(te, 1041, 117, 61));
         this.addSlotToContainer(new SlotCustom(te, 1042, 135, 61));
         this.addSlotToContainer(new SlotCustom(te, 1043, 153, 61));
         this.addSlotToContainer(new SlotCustom(te, 1044, 171, 61));
         this.addSlotToContainer(new SlotCustom(te, 1045, 189, 61));
            //this.addSlotToContainer(new Slot(this.tileEntity, j, 8 + j * Растояние между слотами, высота));
        }

        this.bindPlayerInventory(inventoryPlayer);
    }
SlotCustom
Код:
public class SlotCustom extends Slot
{
 public SlotCustom(IInventory Inventory, int id, int x, int y) {
 super(Inventory, id, x, y);
 }
 
 @Override
 public boolean isItemValid (ItemStack par1ItemStack)
 {
 return true;
 }
 
 @Override
 public int getSlotStackLimit()
 {
 return 64;
 }
}
 
3,005
192
592
Может потому что слоты должны начинаться с 0 до твоего количества в тайле? А не касарь и пошел...
 

timaxa007

Модератор
5,831
409
672
Это не совсем белый фон, это полупрозрачное выделения предмета в слоте.
alcatrass2408 написал(а):
Код:
this.addSlotToContainer(new SlotCustom(te, 1001, 9, 7));
1001 - типа обычно id слота твоего инвентаря.
 
timaxa007 написал(а):
Это не совсем белый фон, это полупрозрачное выделения предмета в слоте.
alcatrass2408 написал(а):
Код:
this.addSlotToContainer(new SlotCustom(te, 1001, 9, 7));
1001 - типа обычно id слота твоего инвентаря.

Просто понимаешь когда я с 0 и до 43 всё ровно вылетает
 

timaxa007

Модератор
5,831
409
672
alcatrass2408 написал(а):
Просто понимаешь когда я с 0 и до 43 всё ровно вылетает
А в инвентаре всё для этого сделано, чтобы он работал с этими слотами.
 
timaxa007 написал(а):
alcatrass2408 написал(а):
Просто понимаешь когда я с 0 и до 43 всё ровно вылетает
А в инвентаре всё для этого сделано, чтобы он работал с этими слотами.

В смысле да вроде бы всё отличие в том что когда во всех слотах ID 0 то не вылетает но блин предметы визуально дублируються
 
Dahaka написал(а):
Это не айдишники слотов, а индекс стака в инвентаре. Зачем ты начинаешь с 1000?
Это я для теста сделал думал возможно не вылетит обычно с 0-ля


Doc написал(а):
Может дело не в слотах, а в тайле?

Я без понятия 
Код:
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
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.tileentity.TileEntity;

public class TileEntityStash extends TileEntity implements IInventory {
   public ItemStack[] inv = new ItemStack[9];

    @SideOnly(Side.CLIENT)
    public double getMaxRenderDistanceSquared()
    {
        return 512.0D;
    }

    /**
     * Returns the number of slots in the inventory.
     */
    public int getSizeInventory()
    {
        return this.inv.length;
    }

    /**
     * Returns the stack in slot i
     */
    public ItemStack getStackInSlot(int slot)
    {
        return this.inv[slot];
    }

    /**
     * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
     */
    public void setInventorySlotContents(int slot, ItemStack stack)
    {
        this.inv[slot] = stack;

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

    /**
     * Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a
     * new stack.
     */
    public ItemStack decrStackSize(int slot, int amt)
    {
        ItemStack stack = this.getStackInSlot(slot);

        if (stack != null)
        {
            if (stack.stackSize <= amt)
            {
                this.setInventorySlotContents(slot, (ItemStack)null);
            }
            else
            {
                stack = stack.splitStack(amt);

                if (stack.stackSize == 0)
                {
                    this.setInventorySlotContents(slot, (ItemStack)null);
                }
            }
        }

        return stack;
    }

    /**
     * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem -
     * like when you close a workbench GUI.
     */
    public ItemStack getStackInSlotOnClosing(int slot)
    {
        ItemStack stack = this.getStackInSlot(slot);

        if (stack != null)
        {
            this.setInventorySlotContents(slot, (ItemStack)null);
        }

        return stack;
    }

    /**
     * Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended. *Isn't
     * this more of a set than a get?*
     */
    public int getInventoryStackLimit()
    {
        return 64;
    }

    /**
     * Do not make give this method the name canInteractWith because it clashes with Container
     */
    public boolean isUseableByPlayer(EntityPlayer player)
    {
        return super.worldObj.getBlockTileEntity(super.xCoord, super.yCoord, super.zCoord) == this && player.getDistanceSq((double)super.xCoord + 0.5D, (double)super.yCoord + 0.5D, (double)super.zCoord + 0.5D) < 64.0D;
    }

    public void openChest() {}

    public void closeChest() {}

    /**
     * Reads a tile entity from NBT.
     */
    public void readFromNBT(NBTTagCompound tagCompound)
    {
        super.readFromNBT(tagCompound);
        NBTTagList tagList = tagCompound.getTagList("Inventory");

        for (int i = 0; i < tagList.tagCount(); ++i)
        {
            NBTTagCompound tag = (NBTTagCompound)tagList.tagAt(i);
            byte slot = tag.getByte("Slot");

            if (slot >= 0 && slot < this.inv.length)
            {
                this.inv[slot] = ItemStack.loadItemStackFromNBT(tag);
            }
        }
    }

    /**
     * Writes a tile entity to NBT.
     */
    public void writeToNBT(NBTTagCompound tagCompound)
    {
        super.writeToNBT(tagCompound);
        NBTTagList itemList = new NBTTagList();

        for (int i = 0; i < this.inv.length; ++i)
        {
            ItemStack stack = this.inv[i];

            if (stack != null)
            {
                NBTTagCompound tag = new NBTTagCompound();
                tag.setByte("Slot", (byte)i);
                stack.writeToNBT(tag);
                itemList.appendTag(tag);
            }
        }

        tagCompound.setTag("Inventory", itemList);
    }

    /**
     * Returns the name of the inventory.
     */
    public String getInvName()
    {
        return "\u0422\u0440\u0443\u043f";
    }

    /**
     * If this returns false, the inventory name will be used as an unlocalized name, and translated into the player's
     * language. Otherwise it will be used directly.
     */
    public boolean isInvNameLocalized()
    {
        return false;
    }

    /**
     * Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot.
     */
    public boolean isItemValidForSlot(int i, ItemStack itemstack)
    {
        return false;
    }
}
 
3,005
192
592
alcatrass2408 написал(а):
Код:
  public ItemStack[] inv = new ItemStack[9];

У тебя в тайле 9 слотов.
Ты же добавляешь 9*45 слотов.
 
3,005
192
592
Код:
        this.addSlotToContainer(new SlotCustom(te, 0, 9, 7));
        this.addSlotToContainer(new SlotCustom(te, 1, 27, 7));
        this.addSlotToContainer(new SlotCustom(te, 2, 45, 7));
        this.addSlotToContainer(new SlotCustom(te, 3, 63, 7));
        this.addSlotToContainer(new SlotCustom(te, 4, 81, 7));
        this.addSlotToContainer(new SlotCustom(te, 5, 99, 7));
        this.addSlotToContainer(new SlotCustom(te, 6, 117, 7));
        this.addSlotToContainer(new SlotCustom(te, 7, 135, 7));
        this.addSlotToContainer(new SlotCustom(te, 8, 153, 7));
Как-то так.
 
Doc написал(а):
Код:
        this.addSlotToContainer(new SlotCustom(te, 0, 9, 7));
        this.addSlotToContainer(new SlotCustom(te, 1, 27, 7));
        this.addSlotToContainer(new SlotCustom(te, 2, 45, 7));
        this.addSlotToContainer(new SlotCustom(te, 3, 63, 7));
        this.addSlotToContainer(new SlotCustom(te, 4, 81, 7));
        this.addSlotToContainer(new SlotCustom(te, 5, 99, 7));
        this.addSlotToContainer(new SlotCustom(te, 6, 117, 7));
        this.addSlotToContainer(new SlotCustom(te, 7, 135, 7));
        this.addSlotToContainer(new SlotCustom(te, 8, 153, 7));
Как-то так.

Это понятно но вот как дальше если я так буду делать то предметы будут всё ровно визуально дублироваться а я хочу чтобы в каждом слоте был свой уникальный ID.
 
3,005
192
592
Дать тайлу столько слотов, сколько тебе нужно. Потом в контейнере добавлять столько же слотов. (Учитывая, что в тайле идет счет 1-X, а добавлять надо на 1 меньше)
 
Ура сработало нужно было просто в public ItemStack[] inv = new ItemStack[9]; дописать (* 53) закрывайте тему.


или просто public ItemStack[] inv = new ItemStack[53]; да но предметы начали дюпатся не визуально а реально.


как решишь одну проблему так появиться другая -_-
 
JustAGod написал(а):
Может проблема в не переопределеном transferStack()...

Возможно но не знаю крч когда зажимаю шифт из тайла в последний не занятый слот худбара перетаскивается блок который я забрал в стаках то есть был 1 стал 64.
 
Сверху