Обновление в контейнере

Версия Minecraft
1.7.10
61
0
Всем привет, кто-то может мне сказать почему контейнер обновляется только после открытия/закрытия?
Java:
  if (player.inventory.getStackInSlot(35) != null && player.inventory.getStackInSlot(35).getItem() instanceof ItemAmylet){
            this.xDisplayPosition = 230;
    } else {
            
           this.xDisplayPosition = 10000;     
            }
        addSlotToContainer(new Slot(player.inventory, 34, xDisplayPosition, 110));
        detectAndSendChanges();
}
 
61
0
fane4qa, Достал слоты, но при открытии инвентаря теперь крашит.
Java:
 @Override
    public void drawScreen(int mouseX, int mouseY, float f) {
        Slot slot = this.inventorySlots.getSlot(35);
         Slot slot1 = this.inventorySlots.getSlot(34);
            if(slot.getStack() == null){
              slot1.xDisplayPosition = 10000;
            }
              else{
                  slot1.xDisplayPosition = 230;
                  }  
    }
Java:
---- Minecraft Crash Report ----
// Daisy, daisy...

Time: 21.08.19 12:45
Description: Rendering screen

java.lang.IndexOutOfBoundsException: Index: 35, Size: 33
    at java.util.ArrayList.rangeCheck(Unknown Source)
    at java.util.ArrayList.get(Unknown Source)
    at net.minecraft.inventory.Container.getSlot(Container.java:130)
    at ru.netweek.tldmod.novii_inv.GuiPlayerInventoryCustomX.drawScreen(GuiPlayerInventoryCustomX.java:58)
    at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1137)
    at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1067)
    at net.minecraft.client.Minecraft.run(Minecraft.java:962)
    at net.minecraft.client.main.Main.main(Main.java:164)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
    at GradleStart.main(Unknown Source)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
    at java.util.ArrayList.rangeCheck(Unknown Source)
    at java.util.ArrayList.get(Unknown Source)
    at net.minecraft.inventory.Container.getSlot(Container.java:130)
    at ru.netweek.tldmod.novii_inv.GuiPlayerInventoryCustomX.drawScreen(GuiPlayerInventoryCustomX.java:58)

-- Screen render details --
Details:
    Screen name: ru.netweek.tldmod.novii_inv.GuiPlayerInventoryCustomX
    Mouse location: Scaled: (213, 119). Absolute: (427, 240)
    Screen size: Scaled: (427, 240). Absolute: (854, 480). Scale factor of 2
at ru.netweek.tldmod.novii_inv.GuiPlayerInventoryCustomX.drawScreen(GuiPlayerInventoryCustomX.java:58)
---Slot slot = this.inventorySlots.getSlot(35);
 
Последнее редактирование:
Сверху