Jump to content

1 slot inventory crashing in 1.11


Raycoms

Recommended Posts

I have a problem with my 1 slot special inventory crashing on adding an item in 1.11

 

The field inventory code:

 

package com.minecolonies.coremod.inventory;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraftforge.common.util.Constants;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
* The custom chest of the field.
*/
public class InventoryField implements IInventory
{
    /**
     * NBTTag to store the slot.
     */
    private static final String TAG_SLOT = "slot";

    /**
     * NBTTag to store the items.
     */
    private static final String TAG_ITEMS = "items";

    /**
     * NBTTag to store the custom name.
     */
    private static final String TAG_CUSTOM_NAME = "name";

    /**
     * NBTTag to store the inventory.
     */
    private static final String TAG_INVENTORY = "inventory";

    /**
     * Returned slot if no slat has been found.
     */
    private static final int NO_SLOT = -1;

    /**
     * The inventory stack.
     */
    @NotNull
    private ItemStack[] stackResult = new ItemStack[1];

    /**
     * The custom name of the inventory.
     */
    private String customName = "";

    /**
     * Updated after the inventory has been changed.
     */
    private boolean inventoryChanged = false;

    /**
     * Creates the inventory of the citizen.
     *
     * @param title Title of the inventory.
     */
    public InventoryField(final String title)
    {
        super();
        this.customName = title;
        stackResult[0] = ItemStack.EMPTY;
    }

    /**
     * Checks if the inventory has been changed and then resets the boolean.
     *
     * @return true if it changed.
     */
    public boolean hasInventoryChanged()
    {
        if (inventoryChanged)
        {
            inventoryChanged = false;
            return true;
        }
        return false;
    }

    /**
     * Used to retrieve variables.
     *
     * @param compound with the give tag.
     */
    public void readFromNBT(@NotNull final NBTTagCompound compound)
    {
        final NBTTagList nbttaglist = compound.getTagList(TAG_ITEMS, Constants.NBT.TAG_COMPOUND);
        this.stackResult = new ItemStack[this.getSizeInventory()];

        for (int i = 0; i < nbttaglist.tagCount(); ++i)
        {
            final NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
            final int j = nbttagcompound.getByte(TAG_SLOT) & Byte.MAX_VALUE;

            if (j != NO_SLOT && j < this.stackResult.length)
            {
                stackResult[j] = new ItemStack(nbttagcompound);
            }
        }

        if(stackResult[0] == null)
        {
            stackResult[0] = ItemStack.EMPTY;
        }

        if (compound.hasKey(TAG_CUSTOM_NAME, Constants.NBT.TAG_STRING))
        {
            this.customName = compound.getString(TAG_CUSTOM_NAME);
        }
    }

    @Override
    public int getSizeInventory()
    {
        return 1;
    }

    @Override
    public boolean isEmpty()
    {
        return stackResult[0] == null || stackResult[0] == ItemStack.EMPTY;
    }

    /**
     * Getter for the stack in the inventory. Since there is only one slot return always that one.
     *
     * @param index the slot.
     * @return the itemStack in it.
     */
    @Override
    public ItemStack getStackInSlot(final int index)
    {
        return this.stackResult[0];
    }

    @Nullable
    @Override
    public ItemStack decrStackSize(final int index, final int count)
    {
        if (this.stackResult[index] == null || this.stackResult[index] == ItemStack.EMPTY)
        {
            return ItemStack.EMPTY;
        }

        if (this.stackResult[index].getCount() <= count)
        {
            final ItemStack itemStack1 = this.stackResult[index];
            this.stackResult[index] = ItemStack.EMPTY;
            this.markDirty();
            return itemStack1;
        }
        else
        {
            @NotNull final ItemStack itemstack = this.stackResult[index].splitStack(count);

            if (this.stackResult[index].getCount() == 0)
            {
                this.stackResult[index] = ItemStack.EMPTY;
            }

            this.markDirty();
            return itemstack;
        }
    }

    @Nullable
    @Override
    public ItemStack removeStackFromSlot(final int index)
    {
        if (this.stackResult[index] == null || this.stackResult[index] == ItemStack.EMPTY)
        {
            return ItemStack.EMPTY;
        }

        final ItemStack itemstack = this.stackResult[index];
        this.stackResult[index] = ItemStack.EMPTY;
        return itemstack;
    }

    /**
     * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
     *
     * @param index the slot to set the itemStack.
     * @param stack the itemStack to set.
     */
    @Override
    public void setInventorySlotContents(final int index, @NotNull final ItemStack stack)
    {
        this.stackResult[index] = stack;

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

        this.markDirty();
    }

    @Override
    public int getInventoryStackLimit()
    {
        return 1;
    }

    @Override
    public void markDirty()
    {
        this.inventoryChanged = true;
    }

    @Override
    public boolean isUsableByPlayer(final EntityPlayer entityPlayer)
    {
        return true;
    }

    /**
     * Called when inventory is opened by a player.
     *
     * @param entityPlayer the player who opened the inventory.
     */
    @Override
    public void openInventory(final EntityPlayer entityPlayer)
    {
        /*
         * This may be filled in order to specify some custom handling.
         */
    }

    /**
     * Called after the inventory has been closed by a player.
     *
     * @param entityPlayer the player who opened the inventory.
     */
    @Override
    public void closeInventory(final EntityPlayer entityPlayer)
    {
        /*
         * This may be filled in order to specify some custom handling.
         */
    }

    @Override
    public boolean isItemValidForSlot(final int index, @Nullable final ItemStack itemStack)
    {
        return index == 0 && itemStack != null && itemStack.getItem() instanceof ItemSeeds && itemStack != ItemStack.EMPTY;
    }

    /**
     * This may be used in order to return values of different GUI areas like the ones in the beacon.
     *
     * @param id the id of the field.
     * @return the value of the field.
     */
    @Override
    public int getField(final int id)
    {
        return 0;
    }

    /**
     * This may be used to set GUI areas with a certain id and value.
     *
     * @param id    some id.
     * @param value some value.
     */
    @Override
    public void setField(final int id, final int value)
    {
        /*
         * We currently need no fields.
         */
    }

    /**
     * Returns the number of fields.
     *
     * @return the amount.
     */
    @Override
    public int getFieldCount()
    {
        return 0;
    }

    /**
     * Completely clears the inventory.
     */
    @Override
    public void clear()
    {
        for (int i = 0; i < this.stackResult.length; ++i)
        {
            this.stackResult[i] = ItemStack.EMPTY;
        }
    }

    /**
     * Used to store variables.
     *
     * @param compound with the given tag.
     */
    public void writeToNBT(@NotNull final NBTTagCompound compound)
    {
        @NotNull final NBTTagList nbttaglist = new NBTTagList();

        for (int i = 0; i < this.stackResult.length; ++i)
        {
            if (this.stackResult[i] != null)
            {
                @NotNull final NBTTagCompound nbttagcompound = new NBTTagCompound();
                nbttagcompound.setByte(TAG_SLOT, (byte) i);
                this.stackResult[i].writeToNBT(nbttagcompound);
                nbttaglist.appendTag(nbttagcompound);
            }
        }

        compound.setTag(TAG_ITEMS, nbttaglist);

        if (this.hasCustomName())
        {
            compound.setString(TAG_CUSTOM_NAME, this.customName);
        }

        compound.setTag(TAG_INVENTORY, nbttaglist);
    }

    /**
     * Setter of the customName of the inventory.
     *
     * @param customName the name to set.
     */
    public void setCustomName(final String customName)
    {
        this.customName = customName;
    }

    @Override
    public boolean hasCustomName()
    {
        return true;
    }

    @NotNull
    @Override
    public ITextComponent getDisplayName()
    {
        return this.hasCustomName() ? new TextComponentString(this.getName()) : new TextComponentTranslation(this.getName());
    }

    /**
     * Get the name of this object. For citizens this returns their name.
     *
     * @return the name of the inventory.
     */
    @NotNull
    @Override
    public String getName()
    {
        return this.hasCustomName() ? this.customName : "field.inventory";
    }
}

 

 

 

The crashlog:

 

[17:21:31] [Client thread/FATAL]: Reported exception thrown!
net.minecraft.util.ReportedException: Updating screen events
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1803) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1117) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:405) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_112]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_112]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_112]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_112]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_112]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_112]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_112]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_112]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
at GradleStart.main(GradleStart.java:26) [start/:?]
Caused by: java.lang.NullPointerException
at net.minecraft.inventory.Container.slotClick(Container.java:256) ~[Container.class:?]
at net.minecraft.client.multiplayer.PlayerControllerMP.windowClick(PlayerControllerMP.java:594) ~[PlayerControllerMP.class:?]
at net.minecraft.client.gui.inventory.GuiContainer.handleMouseClick(GuiContainer.java:687) ~[GuiContainer.class:?]
at net.minecraft.client.gui.inventory.GuiContainer.mouseClicked(GuiContainer.java:429) ~[GuiContainer.class:?]
at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:611) ~[GuiScreen.class:?]
at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:576) ~[GuiScreen.class:?]
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1790) ~[Minecraft.class:?]
... 15 more
[17:21:31] [server thread/INFO] [FML]: Applying holder lookups
[17:21:31] [server thread/INFO] [FML]: Holder lookups applied
[17:21:31] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:600]: ---- Minecraft Crash Report ----
// This is a token for 1 free hug. Redeem at your nearest Mojangsta: [~~HUG~~]

Time: 12/11/16 5:21 PM
Description: Updating screen events

java.lang.NullPointerException: Updating screen events
at net.minecraft.inventory.Container.slotClick(Container.java:256)
at net.minecraft.client.multiplayer.PlayerControllerMP.windowClick(PlayerControllerMP.java:594)
at net.minecraft.client.gui.inventory.GuiContainer.handleMouseClick(GuiContainer.java:687)
at net.minecraft.client.gui.inventory.GuiContainer.mouseClicked(GuiContainer.java:429)
at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:611)
at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:576)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1790)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1117)
at net.minecraft.client.Minecraft.run(Minecraft.java:405)
at net.minecraft.client.main.Main.main(Main.java:118)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
at GradleStart.main(GradleStart.java:26)


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

-- Head --
Thread: Client thread
Stacktrace:
at net.minecraft.inventory.Container.slotClick(Container.java:256)
at net.minecraft.client.multiplayer.PlayerControllerMP.windowClick(PlayerControllerMP.java:594)
at net.minecraft.client.gui.inventory.GuiContainer.handleMouseClick(GuiContainer.java:687)
at net.minecraft.client.gui.inventory.GuiContainer.mouseClicked(GuiContainer.java:429)
at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:611)
at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:576)

-- Affected screen --
Details:
Screen name: com.minecolonies.coremod.inventory.GuiField

-- Affected level --
Details:
Level name: MpServer
All players: 1 total; [EntityPlayerSP['Player881'/226, l='MpServer', x=317.36, y=67.00, z=554.62]]
Chunk stats: MultiplayerChunkCache: 339, 339
Level seed: 0
Level generator: ID 00 - default, ver 1. Features enabled: false
Level generator options: 
Level spawn location: World: (405,64,482), Chunk: (at 5,4,2 in 25,30; contains blocks 400,0,480 to 415,255,495), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Level time: 10026 game time, 10026 day time
Level dimension: 0
Level storage version: 0x00000 - Unknown?
Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
Forced entities: 89 total; [EntityBat['Bat'/4096, l='MpServer', x=333.75, y=29.22, z=530.52], EntityBat['Bat'/4097, l='MpServer', x=333.73, y=39.69, z=511.63], EntityRabbit['Rabbit'/15, l='MpServer', x=247.68, y=64.00, z=474.05], EntityCreeper['Creeper'/2582, l='MpServer', x=256.18, y=49.00, z=570.52], EntityCreeper['Creeper'/2583, l='MpServer', x=257.50, y=49.00, z=569.50], EntityRabbit['Rabbit'/24, l='MpServer', x=256.75, y=64.00, z=490.18], EntityRabbit['Rabbit'/25, l='MpServer', x=264.13, y=64.00, z=498.85], EntityRabbit['Rabbit'/26, l='MpServer', x=266.45, y=64.00, z=491.62], EntityZombie['Zombie'/3611, l='MpServer', x=311.22, y=21.00, z=561.81], EntityRabbit['Rabbit'/27, l='MpServer', x=265.29, y=64.00, z=507.88], EntityRabbit['Rabbit'/28, l='MpServer', x=256.41, y=65.00, z=504.62], EntityRabbit['Rabbit'/29, l='MpServer', x=264.25, y=64.00, z=503.58], EntityRabbit['Rabbit'/30, l='MpServer', x=261.10, y=64.00, z=504.08], EntitySkeleton['Skeleton'/4639, l='MpServer', x=245.50, y=41.00, z=534.50], EntitySkeleton['Skeleton'/5922, l='MpServer', x=326.27, y=46.00, z=579.54], EntitySkeleton['Skeleton'/5923, l='MpServer', x=325.50, y=44.00, z=581.50], EntitySkeleton['Skeleton'/3620, l='MpServer', x=356.50, y=13.00, z=505.50], EntityCreeper['Creeper'/5924, l='MpServer', x=324.50, y=44.00, z=575.50], EntityCreeper['Creeper'/549, l='MpServer', x=385.50, y=29.00, z=529.50], EntitySkeleton['Skeleton'/3621, l='MpServer', x=354.74, y=13.00, z=501.53], EntityRabbit['Rabbit'/44, l='MpServer', x=295.50, y=68.00, z=524.68], EntityRabbit['Rabbit'/45, l='MpServer', x=291.91, y=66.00, z=531.42], EntityRabbit['Rabbit'/46, l='MpServer', x=289.81, y=64.00, z=557.66], EntityCreeper['Creeper'/4654, l='MpServer', x=303.50, y=15.00, z=495.50], EntityCreeper['Creeper'/4655, l='MpServer', x=305.50, y=15.00, z=494.50], EntityZombie['Zombie'/3379, l='MpServer', x=293.50, y=21.00, z=582.50], EntityRabbit['Rabbit'/52, l='MpServer', x=317.48, y=81.00, z=519.67], EntityRabbit['Rabbit'/53, l='MpServer', x=322.48, y=85.00, z=520.51], EntityRabbit['Rabbit'/54, l='MpServer', x=312.14, y=79.00, z=537.54], EntityRabbit['Rabbit'/55, l='MpServer', x=323.03, y=85.00, z=522.70], EntityZombieVillager['Zombie Villager'/3895, l='MpServer', x=345.50, y=30.00, z=527.50], EntityRabbit['Rabbit'/56, l='MpServer', x=312.28, y=65.00, z=559.92], EntityRabbit['Rabbit'/57, l='MpServer', x=299.80, y=65.00, z=551.76], EntitySkeleton['Skeleton'/3899, l='MpServer', x=368.50, y=24.00, z=571.50], EntitySkeleton['Skeleton'/828, l='MpServer', x=365.30, y=25.00, z=552.11], EntitySkeleton['Skeleton'/3900, l='MpServer', x=368.50, y=24.00, z=571.50], EntitySkeleton['Skeleton'/3901, l='MpServer', x=368.50, y=24.00, z=571.50], EntityRabbit['Rabbit'/62, l='MpServer', x=334.50, y=67.00, z=476.50], EntityRabbit['Rabbit'/63, l='MpServer', x=334.50, y=69.00, z=479.50], EntityZombie['Zombie'/2879, l='MpServer', x=276.22, y=17.00, z=569.44], EntityRabbit['Rabbit'/64, l='MpServer', x=326.83, y=69.00, z=495.51], EntityBat['Bat'/1611, l='MpServer', x=354.28, y=13.40, z=494.02], EntityRabbit['Rabbit'/75, l='MpServer', x=341.55, y=82.00, z=528.73], EntityRabbit['Rabbit'/76, l='MpServer', x=335.98, y=67.00, z=549.86], EntityRabbit['Rabbit'/77, l='MpServer', x=327.71, y=65.00, z=577.50], EntityRabbit['Rabbit'/78, l='MpServer', x=342.26, y=68.00, z=556.95], EntityCreeper['Creeper'/2897, l='MpServer', x=333.50, y=37.00, z=513.50], EntityBat['Bat'/4689, l='MpServer', x=294.33, y=23.10, z=576.72], EntitySkeleton['Skeleton'/5718, l='MpServer', x=364.50, y=40.00, z=502.50], EntityCreeper['Creeper'/1628, l='MpServer', x=375.50, y=43.00, z=514.50], EntityRabbit['Rabbit'/92, l='MpServer', x=344.12, y=73.00, z=536.52], EntityRabbit['Rabbit'/93, l='MpServer', x=331.96, y=67.00, z=561.49], EntityRabbit['Rabbit'/98, l='MpServer', x=345.03, y=82.00, z=527.47], EntityRabbit['Rabbit'/99, l='MpServer', x=360.48, y=74.00, z=527.60], EntityBat['Bat'/867, l='MpServer', x=304.53, y=22.75, z=570.21], EntitySkeleton['Skeleton'/3687, l='MpServer', x=362.50, y=26.00, z=576.50], EntityRabbit['Rabbit'/106, l='MpServer', x=370.60, y=71.00, z=539.57], EntityCreeper['Creeper'/4715, l='MpServer', x=306.50, y=39.00, z=571.50], EntityRabbit['Rabbit'/110, l='MpServer', x=373.70, y=68.00, z=552.50], EntitySpider['Spider'/4996, l='MpServer', x=372.01, y=23.00, z=560.50], EntitySkeleton['Skeleton'/5508, l='MpServer', x=244.50, y=41.00, z=541.50], EntitySpider['Spider'/4997, l='MpServer', x=362.70, y=30.00, z=552.15], EntitySkeleton['Skeleton'/5509, l='MpServer', x=245.50, y=41.00, z=540.50], EntityCreeper['Creeper'/3974, l='MpServer', x=340.50, y=12.00, z=508.50], EntitySpider['Spider'/4998, l='MpServer', x=369.91, y=23.00, z=560.50], EntityCreeper['Creeper'/1162, l='MpServer', x=350.50, y=43.00, z=514.50], EntityBat['Bat'/2195, l='MpServer', x=305.91, y=15.07, z=495.92], EntityBat['Bat'/4499, l='MpServer', x=313.77, y=28.89, z=566.49], EntityBat['Bat'/4501, l='MpServer', x=310.28, y=23.45, z=567.66], EntityCreeper['Creeper'/5269, l='MpServer', x=285.50, y=30.00, z=535.50], EntityCreeper['Creeper'/5270, l='MpServer', x=280.79, y=30.00, z=539.42], EntityCreeper['Creeper'/5558, l='MpServer', x=302.50, y=26.00, z=523.50], EntityZombie['Zombie'/4544, l='MpServer', x=367.50, y=25.00, z=551.50], EntityCreeper['Creeper'/4545, l='MpServer', x=366.06, y=25.00, z=551.30], EntityCreeper['Creeper'/4546, l='MpServer', x=365.30, y=25.00, z=551.38], EntitySkeleton['Skeleton'/3013, l='MpServer', x=293.50, y=22.00, z=585.50], EntitySkeleton['Skeleton'/5318, l='MpServer', x=396.17, y=35.00, z=529.50], EntityZombie['Zombie'/5830, l='MpServer', x=305.50, y=27.00, z=532.50], EntityCreeper['Creeper'/3529, l='MpServer', x=294.50, y=19.00, z=478.50], EntityZombie['Zombie'/3274, l='MpServer', x=265.50, y=26.00, z=541.50], EntityCreeper['Creeper'/2766, l='MpServer', x=390.50, y=29.00, z=529.50], EntitySkeleton['Skeleton'/4048, l='MpServer', x=313.50, y=26.00, z=566.50], EntityZombie['Zombie'/3798, l='MpServer', x=381.50, y=21.00, z=529.50], EntityBat['Bat'/5090, l='MpServer', x=314.45, y=18.52, z=538.75], EntityPlayerSP['Player881'/226, l='MpServer', x=317.36, y=67.00, z=554.62], EntityBat['Bat'/5358, l='MpServer', x=314.52, y=28.12, z=562.49], EntityBat['Bat'/5359, l='MpServer', x=303.45, y=37.00, z=572.96], EntityBat['Bat'/5360, l='MpServer', x=317.30, y=45.06, z=560.93], EntityBat['Bat'/3062, l='MpServer', x=337.21, y=14.34, z=514.43]]
Retry entities: 0 total; []
Server brand: fml,forge
Server type: Integrated singleplayer server
Stacktrace:
at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:451)
at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2772)
at net.minecraft.client.Minecraft.run(Minecraft.java:426)
at net.minecraft.client.main.Main.main(Main.java:118)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
at GradleStart.main(GradleStart.java:26)

-- System Details --
Details:
Minecraft Version: 1.11
Operating System: Linux (amd64) version 4.4.33-1-MANJARO
Java Version: 1.8.0_112, Oracle Corporation
Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 661286896 bytes (630 MB) / 1099956224 bytes (1049 MB) up to 1834483712 bytes (1749 MB)
JVM Flags: 0 total; 
IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94
FML: MCP 9.35 Powered by Forge 13.19.1.2188 4 mods loaded, 4 mods active
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
UCHIJAAAA	mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) 
UCHIJAAAA	FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.11-13.19.1.2188-PROJECT(minecolonies).jar) 
UCHIJAAAA	forge{13.19.1.2188} [Minecraft Forge] (forgeSrc-1.11-13.19.1.2188-PROJECT(minecolonies).jar) 
UCHIJAAAA	minecolonies{@VERSION@} [MineColonies] (minecolonies_main) 
Loaded coremods (and transformers): 
GL info: ' Vendor: 'Intel Open Source Technology Center' Version: '3.0 Mesa 13.0.2' Renderer: 'Mesa DRI Intel(R) Ivybridge Mobile '
Launched Version: 1.11
LWJGL: 2.9.4
OpenGL: Mesa DRI Intel(R) Ivybridge Mobile  GL version 3.0 Mesa 13.0.2, Intel Open Source Technology Center
GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.

Using VBOs: Yes
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Packs: 
Current Language: English (US)
Profiler Position: N/A (disabled)
CPU: 4x Intel(R) Core(TM) i7-3537U CPU @ 2.00GHz
[17:21:31] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:600]: #@!@# Game crashed! Crash report saved to: #@!@# /home/ray/IdeaProjects/minecolonies/run/./crash-reports/crash-2016-12-11_17.21.31-client.txt
[17:21:31] [Client thread/INFO] [FML]: Waiting for the server to terminate/save.
[17:21:31] [Client thread/INFO] [FML]: Server terminated.
Disconnected from the target VM, address: '127.0.0.1:45221', transport: 'socket'

 

 

 

Link to comment
Share on other sites

Don't use

IInventory

, use

IItemHandler

(or the default implementation:

ItemStackHandler

).

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

Instead of

Slot

, use

SlotItemHandler

.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

Do I have to take care of writeToNbt and readToNbt and of the itemStack or does the implementation does handle that already and I only have to define the size etc in the constructor?

 

You will need to call ItemStackHandler#serializeNBT() and ItemStackHandler#deserializeNBT() yourself.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Is there a way to set a custom name to the inventory in this case?

You will have to recreate that functionality your self just add the getName and hasCustomName and setName methods to your TE and implement them how you would normally in the Block class and GUI.

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

 

and to display it in a GUI?

 

player.displayGUIChest(inventoryField);

 

 

doesn't work anymore.

You should not have been using that in the first place. Create your on implementation of IGuiHandler and register it with NetworkRegistry. Then you call player.openGui(...)

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

I have a GUIHandler registered.

 

player.GUI wants "mod object" "modId" "world" and "x,y,z" what mod object, mod id and x,y,z do I have to enter there?

It wants either your modid, or your mods @Instance field for modObject. It wants a mod specific ID for your GUI/Container. Then it wants either the block coords or the player coords or the entity coords where this is opening from.

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

In my tileEntity I shall store it like this?

 

/**
     * Save data to NBT compound.
     * Writes the {@link #location} value.
     *
     * @param compound {@link net.minecraft.nbt.NBTTagCompound} to write data to.
     */
    public void writeToNBT(@NotNull final NBTTagCompound compound)
    {
        compound.setTag("inventory", inventory.serializeNBT());
    }

    /**
     * Save data to NBT compound.
     * Writes the {@link #location} value.
     *
     * @param compound {@link net.minecraft.nbt.NBTTagCompound} to write data to.
     */
    public void readFromNBT(@NotNull final NBTTagCompound compound)
    {
        inventory = new InventoryField();
        inventory.deserializeNBT(compound);
    }

Link to comment
Share on other sites

inventory.deserializeNBT((NBTTagCompound) compound.getTag("inventory"));

 

Also, I recommend naming your nbt tag with your mod ID.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I changed so much just to get the same error again:

 

[21:25:27] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:600]: ---- Minecraft Crash Report ----
// I feel sad now 

Time: 12/11/16 9:25 PM
Description: Updating screen events

java.lang.NullPointerException: Updating screen events
at net.minecraft.inventory.Container.slotClick(Container.java:256)
at net.minecraft.client.multiplayer.PlayerControllerMP.windowClick(PlayerControllerMP.java:594)
at net.minecraft.client.gui.inventory.GuiContainer.handleMouseClick(GuiContainer.java:687)
at net.minecraft.client.gui.inventory.GuiContainer.mouseClicked(GuiContainer.java:429)
at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:611)
at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:576)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1790)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1117)
at net.minecraft.client.Minecraft.run(Minecraft.java:405)
at net.minecraft.client.main.Main.main(Main.java:118)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
at GradleStart.main(GradleStart.java:26)


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

-- Head --
Thread: Client thread
Stacktrace:
at net.minecraft.inventory.Container.slotClick(Container.java:256)
at net.minecraft.client.multiplayer.PlayerControllerMP.windowClick(PlayerControllerMP.java:594)
at net.minecraft.client.gui.inventory.GuiContainer.handleMouseClick(GuiContainer.java:687)
at net.minecraft.client.gui.inventory.GuiContainer.mouseClicked(GuiContainer.java:429)
at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:611)
at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:576)

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.



×
×
  • Create New...

Important Information

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