Jump to content

[1.10.2]NBTTagCompound uncaught exception upon exiting world?


Recommended Posts

Posted

Hello,

After making my tile entity use ItemStacks as a variable, it now freezes upon exiting the world, looping these two lines in the code, saying something about the writing to NBT is crashing the game.

[spoiler=Log Exerpt]

[18:46:11] [File IO Thread/INFO] [sTDERR]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at net.minecraft.nbt.NBTTagCompound.write(NBTTagCompound.java:29)
[18:46:11] [File IO Thread/INFO] [sTDERR]: [java.lang.ThreadGroup:uncaughtException:1052]: 	at net.minecraft.nbt.NBTTagCompound.writeEntry(NBTTagCompound.java:556)

 

 

Here's the TileEntity code:

[spoiler=TileEntityBonfire.class]

package com.t10a.crystalflask.tileentity;

import com.t10a.crystalflask.init.ModItems;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;

public class TileEntityBonfire extends TileEntity
{
    public ItemStack storedItem;
    //Variables telling the TileEntity what's currently contained.;

    //This tells the block how to handle adding items.
    public boolean addItem(ItemStack heldItem)
    {
        if(heldItem.getItem() == ModItems.estus_shard)
        {
            storedItem = new ItemStack(ModItems.estus_shard);
            markDirty();
            IBlockState state = worldObj.getBlockState(pos);
            worldObj.notifyBlockUpdate(pos, state, state, 3);
            return true;
        }
        else if(heldItem.getItem() == ModItems.estus_ash)
        {
            storedItem = new ItemStack(ModItems.estus_ash);
            markDirty();
            IBlockState state = worldObj.getBlockState(pos);
            worldObj.notifyBlockUpdate(pos, state, state, 3);
            return true;
        }
        else if(heldItem.getItem() == Items.BLAZE_ROD)
        {
            storedItem = new ItemStack(Items.BLAZE_ROD);
            markDirty();
            IBlockState state = worldObj.getBlockState(pos);
            worldObj.notifyBlockUpdate(pos, state, state, 3);
            return true;
        }
        return false;
    }
    //This tells the block how to handle removing items.
    public void removeItem()
    {
        if(storedItem.getItem() == (ModItems.estus_shard))
        {
            worldObj.spawnEntityInWorld(new EntityItem(worldObj, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, new ItemStack(ModItems.estus_shard)));
            storedItem.stackSize--;
            markDirty();
            IBlockState state = worldObj.getBlockState(pos);
            worldObj.notifyBlockUpdate(pos, state, state, 3);
        }
        else if(storedItem.getItem() == ModItems.estus_ash)
        {
            worldObj.spawnEntityInWorld(new EntityItem(worldObj, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, new ItemStack(ModItems.estus_ash)));
            storedItem.stackSize--;
            markDirty();
            IBlockState state = worldObj.getBlockState(pos);
            worldObj.notifyBlockUpdate(pos, state, state, 3);
        }
        else if(storedItem.getItem() == Items.BLAZE_ROD)
        {
            worldObj.spawnEntityInWorld(new EntityItem(worldObj, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, new ItemStack(Items.BLAZE_ROD)));
            storedItem.stackSize--;
            markDirty();
            IBlockState state = worldObj.getBlockState(pos);
            worldObj.notifyBlockUpdate(pos, state, state, 3);
        }
    }

    //Temporary crafting class. It'll be replaced by a dedicated crafting thing, so it's easier to add recipes, or other mods can add to it, in jolly modding cooperation \[T]/
    public void bonfireCraft(ItemStack heldItem)
    {
        //TODO: Delete this, and make a dedicated recipe handler, so it's easier to add recipes to. For both me and addon developers.
        if(heldItem.getItem() == Items.PRISMARINE_SHARD && storedItem.getItem() == Items.BLAZE_ROD)
        {
            worldObj.spawnEntityInWorld(new EntityItem(worldObj, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, new ItemStack(ModItems.estus_shard)));
            heldItem.stackSize--;
            storedItem.stackSize--;
        }
        else if(heldItem.getItem() == Items.SKULL && heldItem.getMetadata() == 1 && storedItem.getItem() == Items.BLAZE_ROD)
        {
            worldObj.spawnEntityInWorld(new EntityItem(worldObj, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, new ItemStack(ModItems.estus_ash)));
            heldItem.stackSize--;
            storedItem.stackSize--;
        }
    }

    //This is a big chunk of code that used  to be on the flask. This handles the restocking the uses, and upgrading of the flask when this is called by BlockBonfire.
    public void estusRestock(ItemStack heldItem)
    {
        if(heldItem.getItem() == ModItems.estus_flask)
        {
            NBTTagCompound nbt;

            if (heldItem.hasTagCompound())
            {
                nbt = heldItem.getTagCompound();
            }
            else
            {
                nbt = new NBTTagCompound();
            }
            if (nbt.hasKey("Uses"))
            {
                if(storedItem.getItem() == ModItems.estus_shard && nbt.getInteger("Max Uses") < 12)
                {
                    nbt.setInteger("Max Uses", nbt.getInteger("Max Uses") + 1);
                    storedItem.stackSize--;
                }
                else if(storedItem.getItem() == ModItems.estus_ash && nbt.getInteger("Potency") < 5)
                {
                    nbt.setInteger("Potency", nbt.getInteger("Potency") + 1);
                    storedItem.stackSize--;
                }
                nbt.setInteger("Uses", nbt.getInteger("Max Uses"));
            }
            else
            {
                nbt.setInteger("Uses", 1);
                nbt.setInteger("Max Uses", 1);
                nbt.setInteger("Potency", 1);
            }
            storedItem.setTagCompound(nbt);
        }
    }

    //This merely saves the variables defined earlier to NBT.
    @Override
    public NBTTagCompound writeToNBT(NBTTagCompound compound)
    {
        super.writeToNBT(compound);
        compound.setTag("ContainedItems", storedItem.writeToNBT(compound));

        return compound;
    }

    //Similar to above, but it loads from NBT instead.
    @Override
    public void readFromNBT(NBTTagCompound compound)
    {
        super.readFromNBT(compound);
        this.storedItem = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("ContainedItems"));
    }

    @Override
    public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt)
    {
        NBTTagCompound tag = pkt.getNbtCompound();
        readUpdateTag(tag);
    }

    @Override
    public SPacketUpdateTileEntity getUpdatePacket()
    {
        NBTTagCompound tag = new NBTTagCompound();
        this.writeUpdateTag(tag);
        return new SPacketUpdateTileEntity(pos, getBlockMetadata(), tag);
    }

    @Override
    public NBTTagCompound getUpdateTag()
    {
        NBTTagCompound tag = super.getUpdateTag();
        writeUpdateTag(tag);
        return tag;
    }

    public void writeUpdateTag(NBTTagCompound tag)
    {
        tag.setTag("ContainedItems", storedItem.writeToNBT(tag));
    }

    public void readUpdateTag(NBTTagCompound tag)
    {
        this.storedItem = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("ContainedItems"));
    }
}

 

If I'm asking a whole bunch of questions, please don't get angry. I'm trying to learn.

Posted

ItemStack#writeToNBT

returns its argument. In

TileEntityBonfire#writeToNBT

, you're passing the

NBTTagCompoud

argument to

ItemStack#writeToNBT

and then storing the return value (i.e. the argument) inside the argument. The NBT serialiser doesn't know how to deal with recursive references like this, so it throws an exception.

 

The solution to this is to call

ItemStack#writeToNBT

with a new

NBTTagCompound

or call

ItemStack#serializeNBT

(implements

INBTSerializable#serializeNBT

) which does this for you.

 

In future, post the whole stack trace instead of just a snippet of it.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

That fixed it. Thanks!

 

And yeah, I should have posted the whole log. Oops.

 

Side note: How would I set a ItemStack to null? My code, once something is placed in it, constantly spawns that item on a right click, and it's not clearing the item in there.

If I'm asking a whole bunch of questions, please don't get angry. I'm trying to learn.

Posted

Side note: How would I set a ItemStack to null? My code, once something is placed in it, constantly spawns that item on a right click, and it's not clearing the item in there.

 

When

storedItem.stackSize

reaches 0, set the

storedItem

field to

nill

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Okay, made it set the stack to null. Thing is, it crashed the game:

 

/usr/lib/jvm/java-8-openjdk/bin/java -Didea.launcher.port=7536 -Didea.launcher.bin.path=/usr/share/intellijidea-ce/bin -Dfile.encoding=UTF-8 -classpath /usr/lib/jvm/java-8-openjdk/jre/lib/charsets.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/cldrdata.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/dnsns.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/jaccess.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/localedata.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/nashorn.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/sunec.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/sunjce_provider.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/sunpkcs11.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/zipfs.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/jce.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/jsse.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/management-agent.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/resources.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/rt.jar:/drv/Data/Content/Minecraft/Mods/1.10.2/CrystalFlask/build/classes/production/CrystalFlask_main:/home/thomas/.gradle/caches/minecraft/deobfedDeps/compileDummy.jar:/home/thomas/.gradle/caches/minecraft/deobfedDeps/providedDummy.jar:/home/thomas/.gradle/caches/minecraft/net/minecraftforge/forge/1.10.2-12.18.1.2011/snapshot/20160518/forgeSrc-1.10.2-12.18.1.2011.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/com.google.code.findbugs/jsr305/3.0.1/f7be08ec23c21485b9b5a1cf1654c2ec8c58168d/jsr305-3.0.1.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/com.mojang/netty/1.6/4b75825a06139752bd800d9e29c5fd55b8b1b1e4/netty-1.6.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/oshi-project/oshi-core/1.1/9ddf7b048a8d701be231c0f4f95fd986198fd2d8/oshi-core-1.1.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/net.java.dev.jna/jna/3.4.0/803ff252fedbd395baffd43b37341dc4a150a554/jna-3.4.0.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/net.java.dev.jna/platform/3.4.0/e3f70017be8100d3d6923f50b3d2ee17714e9c13/platform-3.4.0.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/com.ibm.icu/icu4j-core-mojang/51.2/63d216a9311cca6be337c1e458e587f99d382b84/icu4j-core-mojang-51.2.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/net.sf.jopt-simple/jopt-simple/4.6/306816fb57cf94f108a43c95731b08934dcae15c/jopt-simple-4.6.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/io.netty/netty-all/4.0.23.Final/294104aaf1781d6a56a07d561e792c5d0c95f45/netty-all-4.0.23.Final.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/17.0/9c6ef172e8de35fd8d4d8783e4821e57cdef7445/guava-17.0.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-lang3/3.3.2/90a3822c38ec8c996e84c16a3477ef632cbc87a3/commons-lang3-3.3.2.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/commons-io/commons-io/2.4/b1b6ea3b7e4aa4f492509a4952029cd8e48019ad/commons-io-2.4.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/commons-codec/commons-codec/1.9/9ce04e34240f674bc72680f8b843b1457383161a/commons-codec-1.9.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/net.java.jutils/jutils/1.0.0/e12fe1fda814bd348c1579329c86943d2cd3c6a6/jutils-1.0.0.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/com.google.code.gson/gson/2.2.4/a60a5e993c98c864010053cb901b7eab25306568/gson-2.2.4.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/com.mojang/authlib/1.5.22/afaa8f6df976fcb5520e76ef1d5798c9e6b5c0b2/authlib-1.5.22.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/com.mojang/realms/1.9.5/efd57120f97df871cc725cf832f628d9d3f17eec/realms-1.9.5.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-compress/1.8.1/a698750c16740fd5b3871425f4cb3bbaa87f529d/commons-compress-1.8.1.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpclient/4.3.3/18f4247ff4572a074444572cee34647c43e7c9c7/httpclient-4.3.3.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/commons-logging/commons-logging/1.1.3/f6f66e966c70a83ffbdb6f17a0919eaf7c8aca7f/commons-logging-1.1.3.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpcore/4.3.2/31fbbff1ddbf98f3aa7377c94d33b0447c646b6e/httpcore-4.3.2.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/it.unimi.dsi/fastutil/7.0.12_mojang/ba787e741efdc425fc5d2ea654b57c15fba27efa/fastutil-7.0.12_mojang.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-api/2.0-beta9/1dd66e68cccd907880229f9e2de1314bd13ff785/log4j-api-2.0-beta9.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-core/2.0-beta9/678861ba1b2e1fccb594bb0ca03114bb05da9695/log4j-core-2.0-beta9.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/net.minecraft/launchwrapper/1.12/111e7bea9c968cdb3d06ef4632bf7ff0824d0f36/launchwrapper-1.12.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/jline/jline/2.13/2d9530d0a25daffaffda7c35037b046b627bb171/jline-2.13.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm-debug-all/5.0.3/f9e364ae2a66ce2a543012a4668856e84e5dab74/asm-debug-all-5.0.3.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/com.typesafe.akka/akka-actor_2.11/2.3.3/ed62e9fc709ca0f2ff1a3220daa8b70a2870078e/akka-actor_2.11-2.3.3.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/com.typesafe/config/1.2.1/f771f71fdae3df231bcd54d5ca2d57f0bf93f467/config-1.2.1.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-actors-migration_2.11/1.1.0/dfa8bc42b181d5b9f1a5dd147f8ae308b893eb6f/scala-actors-migration_2.11-1.1.0.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-compiler/2.11.1/56ea2e6c025e0821f28d73ca271218b8dd04926a/scala-compiler-2.11.1.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/org.scala-lang.plugins/scala-continuations-library_2.11/1.0.2/e517c53a7e9acd6b1668c5a35eccbaa3bab9aac/scala-continuations-library_2.11-1.0.2.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/org.scala-lang.plugins/scala-continuations-plugin_2.11.1/1.0.2/f361a3283452c57fa30c1ee69448995de23c60f7/scala-continuations-plugin_2.11.1-1.0.2.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-library/2.11.1/e11da23da3eabab9f4777b9220e60d44c1aab6a/scala-library-2.11.1.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/org.scala-lang.modules/scala-parser-combinators_2.11/1.0.1/f05d7345bf5a58924f2837c6c1f4d73a938e1ff0/scala-parser-combinators_2.11-1.0.1.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-reflect/2.11.1/6580347e61cc7f8e802941e7fde40fa83b8badeb/scala-reflect-2.11.1.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/org.scala-lang.modules/scala-swing_2.11/1.0.1/b1cdd92bd47b1e1837139c1c53020e86bb9112ae/scala-swing_2.11-1.0.1.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/org.scala-lang.modules/scala-xml_2.11/1.0.2/820fbca7e524b530fdadc594c39d49a21ea0337e/scala-xml_2.11-1.0.2.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/lzma/lzma/0.0.1/521616dc7487b42bef0e803bd2fa3faf668101d7/lzma-0.0.1.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/net.sf.trove4j/trove4j/3.0.3/42ccaf4761f0dfdfa805c9e340d99a755907e2dd/trove4j-3.0.3.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/com.paulscode/codecjorbis/20101023/c73b5636faf089d9f00e8732a829577de25237ee/codecjorbis-20101023.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/com.paulscode/codecwav/20101023/12f031cfe88fef5c1dd36c563c0a3a69bd7261da/codecwav-20101023.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/com.paulscode/libraryjavasound/20101123/5c5e304366f75f9eaa2e8cca546a1fb6109348b3/libraryjavasound-20101123.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/com.paulscode/librarylwjglopenal/20100824/73e80d0794c39665aec3f62eee88ca91676674ef/librarylwjglopenal-20100824.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/com.paulscode/soundsystem/20120107/419c05fe9be71f792b2d76cfc9b67f1ed0fec7f6/soundsystem-20120107.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/net.java.jinput/jinput/2.0.5/39c7796b469a600f72380316f6b1f11db6c2c7c4/jinput-2.0.5.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/org.lwjgl.lwjgl/lwjgl/2.9.4-nightly-20150209/697517568c68e78ae0b4544145af031c81082dfe/lwjgl-2.9.4-nightly-20150209.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/org.lwjgl.lwjgl/lwjgl_util/2.9.4-nightly-20150209/d51a7c040a721d13efdfbd34f8b257b2df882ad0/lwjgl_util-2.9.4-nightly-20150209.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/java3d/vecmath/1.5.2/79846ba34cbd89e2422d74d53752f993dcc2ccaf/vecmath-1.5.2.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/org.fusesource.jansi/jansi/1.11/655c643309c2f45a56a747fda70e3fadf57e9f11/jansi-1.11.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-actors/2.11.0/8ccfb6541de179bb1c4d45cf414acee069b7f78b/scala-actors-2.11.0.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/net.java.jinput/jinput-platform/2.0.5/7ff832a6eb9ab6a767f1ade2b548092d0fa64795/jinput-platform-2.0.5-natives-linux.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/net.java.jinput/jinput-platform/2.0.5/385ee093e01f587f30ee1c8a2ee7d408fd732e16/jinput-platform-2.0.5-natives-windows.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/net.java.jinput/jinput-platform/2.0.5/53f9c919f34d2ca9de8c51fc4e1e8282029a9232/jinput-platform-2.0.5-natives-osx.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/org.lwjgl.lwjgl/lwjgl-platform/2.9.4-nightly-20150209/b84d5102b9dbfabfeb5e43c7e2828d98a7fc80e0/lwjgl-platform-2.9.4-nightly-20150209-natives-windows.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/org.lwjgl.lwjgl/lwjgl-platform/2.9.4-nightly-20150209/931074f46c795d2f7b30ed6395df5715cfd7675b/lwjgl-platform-2.9.4-nightly-20150209-natives-linux.jar:/home/thomas/.gradle/caches/modules-2/files-2.1/org.lwjgl.lwjgl/lwjgl-platform/2.9.4-nightly-20150209/bcab850f8f487c3f4c4dbabde778bb82bd1a40ed/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar:/home/thomas/.gradle/caches/minecraft/net/minecraftforge/forge/1.10.2-12.18.1.2011/start:/usr/share/intellijidea-ce/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain GradleStart
[20:46:00] [main/INFO] [GradleStart]: Extra: []
[20:46:00] [main/INFO] [GradleStart]: Running with arguments: [--userProperties, {}, --assetsDir, /home/thomas/.gradle/caches/minecraft/assets, --assetIndex, 1.10, --accessToken{REDACTED}, --version, 1.10.2, --tweakClass, net.minecraftforge.fml.common.launcher.FMLTweaker, --tweakClass, net.minecraftforge.gradle.tweakers.CoremodTweaker]
[20:46:00] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
[20:46:00] [main/INFO] [LaunchWrapper]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
[20:46:00] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.CoremodTweaker
[20:46:00] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLTweaker
[20:46:00] [main/INFO] [FML]: Forge Mod Loader version 12.18.1.2011 for Minecraft 1.10.2 loading
[20:46:00] [main/INFO] [FML]: Java is OpenJDK 64-Bit Server VM, version 1.8.0_102, running on Linux:amd64:4.7.2-1-ARCH, installed at /usr/lib/jvm/java-8-openjdk/jre
[20:46:00] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation
[20:46:00] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.CoremodTweaker
[20:46:00] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.fml.relauncher.FMLCorePlugin
[20:46:00] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.classloading.FMLForgePlugin
[20:46:00] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[20:46:00] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
[20:46:00] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.AccessTransformerTweaker
[20:46:00] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[20:46:00] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[20:46:00] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
[20:46:00] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work!
[20:46:01] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing
[20:46:01] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
[20:46:01] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
[20:46:01] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.AccessTransformerTweaker
[20:46:01] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.TerminalTweaker
[20:46:01] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.TerminalTweaker
[20:46:01] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main}
[20:46:02] [Client thread/INFO]: Setting user: Player950
[20:46:04] [Client thread/WARN]: Skipping bad option: lastServer:
[20:46:04] [Client thread/INFO]: LWJGL Version: 2.9.4
ATTENTION: default value of option vblank_mode overridden by environment.
[20:46:04] [Client thread/INFO] [sTDOUT]: [net.minecraftforge.fml.client.SplashProgress:start:221]: ---- Minecraft Crash Report ----
// You should try our sister game, Minceraft!

Time: 30/08/16 8:46 PM
Description: Loading screen debug info

This is just a prompt for computer specs to be printed. THIS IS NOT A ERROR


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

-- System Details --
Details:
Minecraft Version: 1.10.2
Operating System: Linux (amd64) version 4.7.2-1-ARCH
Java Version: 1.8.0_102, Oracle Corporation
Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 357181992 bytes (340 MB) / 577241088 bytes (550 MB) up to 1845493760 bytes (1760 MB)
JVM Flags: 0 total; 
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: 
Loaded coremods (and transformers): 
GL info: ' Vendor: 'X.Org' Version: '3.0 Mesa 12.0.1' Renderer: 'Gallium 0.4 on AMD HAWAII (DRM 2.45.0 / 4.7.2-1-ARCH, LLVM 3.8.1)'
[20:46:04] [Client thread/INFO] [FML]: MinecraftForge v12.18.1.2011 Initialized
[20:46:04] [Client thread/INFO] [FML]: Replaced 233 ore recipes
[20:46:05] [Client thread/INFO] [FML]: Found 0 mods from the command line. Injecting into mod discoverer
[20:46:05] [Client thread/INFO] [FML]: Searching /drv/Data/Content/Minecraft/Mods/1.10.2/CrystalFlask/mods for mods
[20:46:06] [Client thread/INFO] [FML]: Forge Mod Loader has identified 4 mods to load
[20:46:06] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, crystalflask] at CLIENT
[20:46:06] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, crystalflask] at SERVER
[20:46:06] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Crystal Flask
[20:46:06] [Client thread/INFO] [FML]: Processing ObjectHolder annotations
[20:46:06] [Client thread/INFO] [FML]: Found 423 ObjectHolder annotations
[20:46:06] [Client thread/INFO] [FML]: Identifying ItemStackHolder annotations
[20:46:06] [Client thread/INFO] [FML]: Found 0 ItemStackHolder annotations
[20:46:06] [Client thread/INFO] [FML]: Configured a dormant chunk cache size of 0
[20:46:06] [Forge Version Check/INFO] [ForgeVersionCheck]: [Forge] Starting version check at http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json
[20:46:06] [Client thread/INFO] [FML]: Applying holder lookups
[20:46:06] [Client thread/INFO] [FML]: Holder lookups applied
[20:46:06] [Client thread/INFO] [FML]: Injecting itemstacks
[20:46:06] [Client thread/INFO] [FML]: Itemstack injection complete
[20:46:07] [Forge Version Check/INFO] [ForgeVersionCheck]: [Forge] Found status: UP_TO_DATE Target: null
[20:46:07] [sound Library Loader/INFO]: Starting up SoundSystem...
[20:46:07] [Thread-7/INFO]: Initializing LWJGL OpenAL
[20:46:07] [Thread-7/INFO]: (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
[20:46:07] [Thread-7/INFO]: OpenAL initialized.
[20:46:08] [sound Library Loader/INFO]: Sound engine started
[20:46:08] [Client thread/INFO] [FML]: Max texture size: 16384
[20:46:08] [Client thread/INFO]: Created: 16x16 textures-atlas
[20:46:09] [Client thread/INFO] [FML]: Injecting itemstacks
[20:46:09] [Client thread/INFO] [FML]: Itemstack injection complete
[20:46:09] [Client thread/INFO] [FML]: Forge Mod Loader has successfully loaded 4 mods
[20:46:09] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Crystal Flask
[20:46:10] [Client thread/INFO]: SoundSystem shutting down...
[20:46:10] [Client thread/WARN]: Author: Paul Lamb, www.paulscode.com
[20:46:10] [sound Library Loader/INFO]: Starting up SoundSystem...
[20:46:10] [Thread-9/INFO]: Initializing LWJGL OpenAL
[20:46:10] [Thread-9/INFO]: (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
[20:46:10] [Thread-9/INFO]: OpenAL initialized.
[20:46:10] [sound Library Loader/INFO]: Sound engine started
[20:46:10] [Client thread/INFO] [FML]: Max texture size: 16384
[20:46:10] [Client thread/INFO]: Created: 1024x512 textures-atlas
[20:46:11] [Client thread/WARN]: Skipping bad option: lastServer:
[20:46:13] [Realms Notification Availability checker #1/INFO]: Could not authorize you against Realms server: Invalid session id
[20:46:28] [server thread/INFO]: Starting integrated minecraft server version 1.10.2
[20:46:28] [server thread/INFO]: Generating keypair
[20:46:28] [server thread/INFO] [FML]: Injecting existing block and item data into this server instance
[20:46:28] [server thread/INFO] [FML]: Applying holder lookups
[20:46:28] [server thread/INFO] [FML]: Holder lookups applied
[20:46:28] [server thread/INFO] [FML]: Loading dimension 0 (New World) (net.minecraft.server.integrated.IntegratedServer@7874650d)
[20:46:28] [server thread/INFO] [FML]: Loading dimension 1 (New World) (net.minecraft.server.integrated.IntegratedServer@7874650d)
[20:46:28] [server thread/INFO] [FML]: Loading dimension -1 (New World) (net.minecraft.server.integrated.IntegratedServer@7874650d)
[20:46:28] [server thread/INFO]: Preparing start region for level 0
[20:46:29] [server thread/INFO]: Preparing spawn area: 83%
[20:46:29] [server thread/INFO]: Changing view distance to 12, from 10
[20:46:30] [Netty Local Client IO #0/INFO] [FML]: Server protocol version 2
[20:46:30] [Netty Server IO #1/INFO] [FML]: Client protocol version 2
[20:46:30] [Netty Server IO #1/INFO] [FML]: Client attempting to join with 4 mods : [email protected],[email protected],[email protected],[email protected]
[20:46:30] [Netty Local Client IO #0/INFO] [FML]: [Netty Local Client IO #0] Client side modded connection established
[20:46:30] [server thread/INFO] [FML]: [server thread] Server side modded connection established
[20:46:30] [server thread/INFO]: Player950[local:E:bc843542] logged in with entity id 305 at (284.43848708926356, 65.0, 233.94999998807907)
[20:46:30] [server thread/INFO]: Player950 joined the game
[20:46:31] [server thread/INFO]: Saving and pausing game...
[20:46:31] [server thread/INFO]: Saving chunks for level 'New World'/Overworld
[20:46:31] [server thread/INFO]: Saving chunks for level 'New World'/Nether
[20:46:31] [server thread/INFO]: Saving chunks for level 'New World'/The End
[20:46:31] [pool-2-thread-1/WARN]: Couldn't look up profile properties for com.mojang.authlib.GameProfile@70675c4e[id=b8491575-8822-3c65-ac66-49751c8ac7b1,name=Player950,properties={},legacy=false]
com.mojang.authlib.exceptions.AuthenticationException: The client has sent too many requests within a certain amount of time
at com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService.makeRequest(YggdrasilAuthenticationService.java:65) ~[YggdrasilAuthenticationService.class:?]
at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillGameProfile(YggdrasilMinecraftSessionService.java:175) [YggdrasilMinecraftSessionService.class:?]
at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:59) [YggdrasilMinecraftSessionService$1.class:?]
at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:56) [YggdrasilMinecraftSessionService$1.class:?]
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache.get(LocalCache.java:3934) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4827) [guava-17.0.jar:?]
at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillProfileProperties(YggdrasilMinecraftSessionService.java:165) [YggdrasilMinecraftSessionService.class:?]
at net.minecraft.client.Minecraft.getProfileProperties(Minecraft.java:3060) [Minecraft.class:?]
at net.minecraft.client.resources.SkinManager$3.run(SkinManager.java:131) [skinManager$3.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_102]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_102]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_102]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_102]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_102]
[20:46:33] [server thread/FATAL]: Error executing task
java.util.concurrent.ExecutionException: java.lang.NullPointerException
at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_102]
at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_102]
at net.minecraft.util.Util.runTask(Util.java:26) [util.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:742) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536) [MinecraftServer.class:?]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_102]
Caused by: java.lang.NullPointerException
at com.t10a.crystalflask.tileentity.TileEntityBonfire.removeItem(TileEntityBonfire.java:50) ~[TileEntityBonfire.class:?]
at com.t10a.crystalflask.blocks.BlockBonfire.onBlockActivated(BlockBonfire.java:160) ~[blockBonfire.class:?]
at net.minecraft.server.management.PlayerInteractionManager.processRightClickBlock(PlayerInteractionManager.java:477) ~[PlayerInteractionManager.class:?]
at net.minecraft.network.NetHandlerPlayServer.processRightClickBlock(NetHandlerPlayServer.java:706) ~[NetHandlerPlayServer.class:?]
at net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock.processPacket(CPacketPlayerTryUseItemOnBlock.java:68) ~[CPacketPlayerTryUseItemOnBlock.class:?]
at net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock.processPacket(CPacketPlayerTryUseItemOnBlock.java:13) ~[CPacketPlayerTryUseItemOnBlock.class:?]
at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) ~[PacketThreadUtil$1.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_102]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_102]
at net.minecraft.util.Util.runTask(Util.java:25) ~[util.class:?]
... 5 more
[20:46:33] [server thread/ERROR]: Encountered an unexpected exception
net.minecraft.util.ReportedException: Exception ticking world
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:778) ~[MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687) ~[MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) ~[integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536) [MinecraftServer.class:?]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_102]
Caused by: java.lang.NullPointerException
at com.t10a.crystalflask.tileentity.TileEntityBonfire.writeUpdateTag(TileEntityBonfire.java:168) ~[TileEntityBonfire.class:?]
at com.t10a.crystalflask.tileentity.TileEntityBonfire.getUpdatePacket(TileEntityBonfire.java:154) ~[TileEntityBonfire.class:?]
at net.minecraft.server.management.PlayerChunkMapEntry.sendBlockEntity(PlayerChunkMapEntry.java:297) ~[PlayerChunkMapEntry.class:?]
at net.minecraft.server.management.PlayerChunkMapEntry.update(PlayerChunkMapEntry.java:259) ~[PlayerChunkMapEntry.class:?]
at net.minecraft.server.management.PlayerChunkMap.tick(PlayerChunkMap.java:134) ~[PlayerChunkMap.class:?]
at net.minecraft.world.WorldServer.tick(WorldServer.java:229) ~[WorldServer.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:772) ~[MinecraftServer.class:?]
... 4 more
[20:46:33] [server thread/ERROR]: This crash report has been saved to: /drv/Data/Content/Minecraft/Mods/1.10.2/CrystalFlask/./crash-reports/crash-2016-08-30_20.46.33-server.txt
[20:46:33] [server thread/INFO]: Stopping server
[20:46:33] [server thread/INFO]: Saving players
[20:46:33] [server thread/INFO]: Player950 lost connection: TextComponent{text='Server closed', siblings=[], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null}}
[20:46:33] [server thread/INFO]: Player950 left the game
[20:46:33] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:649]: ---- Minecraft Crash Report ----
// Would you like a cupcake?

Time: 30/08/16 8:46 PM
Description: Exception ticking world

java.lang.NullPointerException: Exception ticking world
at com.t10a.crystalflask.tileentity.TileEntityBonfire.writeUpdateTag(TileEntityBonfire.java:168)
at com.t10a.crystalflask.tileentity.TileEntityBonfire.getUpdatePacket(TileEntityBonfire.java:154)
at net.minecraft.server.management.PlayerChunkMapEntry.sendBlockEntity(PlayerChunkMapEntry.java:297)
at net.minecraft.server.management.PlayerChunkMapEntry.update(PlayerChunkMapEntry.java:259)
at net.minecraft.server.management.PlayerChunkMap.tick(PlayerChunkMap.java:134)
at net.minecraft.world.WorldServer.tick(WorldServer.java:229)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:772)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536)
at java.lang.Thread.run(Thread.java:745)


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

-- Head --
Thread: Client thread
Stacktrace:
at com.t10a.crystalflask.tileentity.TileEntityBonfire.writeUpdateTag(TileEntityBonfire.java:168)
at com.t10a.crystalflask.tileentity.TileEntityBonfire.getUpdatePacket(TileEntityBonfire.java:154)
at net.minecraft.server.management.PlayerChunkMapEntry.sendBlockEntity(PlayerChunkMapEntry.java:297)
at net.minecraft.server.management.PlayerChunkMapEntry.update(PlayerChunkMapEntry.java:259)
at net.minecraft.server.management.PlayerChunkMap.tick(PlayerChunkMap.java:134)
at net.minecraft.world.WorldServer.tick(WorldServer.java:229)

-- Affected level --
Details:
Level name: New World
All players: 1 total; [EntityPlayerMP['Player950'/305, l='New World', x=284.44, y=65.00, z=233.95]]
Chunk stats: ServerChunkCache: 626 Drop: 0
Level seed: -7867803231424391830
Level generator: ID 00 - default, ver 1. Features enabled: true
Level generator options: 
Level spawn location: World: (279,64,245), Chunk: (at 7,4,5 in 17,15; contains blocks 272,0,240 to 287,255,255), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Level time: 558 game time, 558 day time
Level dimension: 0
Level storage version: 0x04ABD - Anvil
Level weather: Rain time: 95785 (now: false), thunder time: 114240 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true
Stacktrace:
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:772)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536)
at java.lang.Thread.run(Thread.java:745)

-- System Details --
Details:
Minecraft Version: 1.10.2
Operating System: Linux (amd64) version 4.7.2-1-ARCH
Java Version: 1.8.0_102, Oracle Corporation
Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 416124224 bytes (396 MB) / 987758592 bytes (942 MB) up to 1845493760 bytes (1760 MB)
JVM Flags: 0 total; 
IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95
FML: MCP 9.32 Powered by Forge 12.18.1.2011 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.10.2-12.18.1.2011.jar) 
UCHIJAAAA	Forge{12.18.1.2011} [Minecraft Forge] (forgeSrc-1.10.2-12.18.1.2011.jar) 
UCHIJAAAA	crystalflask{1.10.2-BETA} [Crystal Flask] (CrystalFlask_main) 
Loaded coremods (and transformers): 
GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.
Profiler Position: N/A (disabled)
Player Count: 1 / 8; [EntityPlayerMP['Player950'/305, l='New World', x=284.44, y=65.00, z=233.95]]
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to 'fml,forge'
[20:46:33] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:649]: #@!@# Game crashed! Crash report saved to: #@!@# ./crash-reports/crash-2016-08-30_20.46.33-server.txt
[20:46:33] [Client thread/INFO] [FML]: Waiting for the server to terminate/save.
[20:46:33] [server thread/INFO]: Stopping singleplayer server as player logged out
[20:46:33] [server thread/INFO]: Saving worlds
[20:46:33] [server thread/INFO]: Saving chunks for level 'New World'/Overworld
[20:46:33] [server thread/ERROR] [FML]: A TileEntity type com.t10a.crystalflask.tileentity.TileEntityBonfire has throw an exception trying to write state. It will not persist. Report this to the mod author
java.lang.NullPointerException
at com.t10a.crystalflask.tileentity.TileEntityBonfire.writeToNBT(TileEntityBonfire.java:130) ~[TileEntityBonfire.class:?]
at net.minecraft.world.chunk.storage.AnvilChunkLoader.writeChunkToNBT(AnvilChunkLoader.java:409) [AnvilChunkLoader.class:?]
at net.minecraft.world.chunk.storage.AnvilChunkLoader.saveChunk(AnvilChunkLoader.java:182) [AnvilChunkLoader.class:?]
at net.minecraft.world.gen.ChunkProviderServer.saveChunkData(ChunkProviderServer.java:208) [ChunkProviderServer.class:?]
at net.minecraft.world.gen.ChunkProviderServer.saveChunks(ChunkProviderServer.java:236) [ChunkProviderServer.class:?]
at net.minecraft.world.WorldServer.saveAllChunks(WorldServer.java:1061) [WorldServer.class:?]
at net.minecraft.server.MinecraftServer.saveAllWorlds(MinecraftServer.java:414) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.saveAllWorlds(IntegratedServer.java:238) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.stopServer(MinecraftServer.java:455) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.stopServer(IntegratedServer.java:369) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:589) [MinecraftServer.class:?]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_102]
[20:46:33] [server thread/INFO]: Saving chunks for level 'New World'/Nether
[20:46:33] [server thread/INFO]: Saving chunks for level 'New World'/The End
[20:46:33] [server thread/INFO] [FML]: Unloading dimension 0
[20:46:33] [server thread/INFO] [FML]: Unloading dimension -1
[20:46:33] [server thread/INFO] [FML]: Unloading dimension 1
[20:46:34] [server thread/INFO] [FML]: Applying holder lookups
[20:46:34] [server thread/INFO] [FML]: Holder lookups applied
[20:46:34] [server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STOPPING and forced into state SERVER_STOPPED. Errors may have been discarded.
[20:46:34] [Client thread/INFO] [FML]: Server terminated.
AL lib: (EE) alc_cleanup: 1 device not closed

Process finished with exit code 255

 

(maybe I shouldn't have explicitly told it to register the item as null. I'm just not sure how to clear it.)

 

Here's the TileEntityBonfire class:

 

package com.t10a.crystalflask.tileentity;

import com.t10a.crystalflask.init.ModItems;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;

public class TileEntityBonfire extends TileEntity
{
    public ItemStack storedItem;
    //Variables telling the TileEntity what's currently contained.;

    //This tells the block how to handle adding items.
    public boolean addItem(ItemStack heldItem)
    {
        if(heldItem.getItem() == ModItems.estus_shard)
        {
            storedItem = new ItemStack(ModItems.estus_shard);
            markDirty();
            IBlockState state = worldObj.getBlockState(pos);
            worldObj.notifyBlockUpdate(pos, state, state, 3);
            return true;
        }
        else if(heldItem.getItem() == ModItems.estus_ash)
        {
            storedItem = new ItemStack(ModItems.estus_ash);
            markDirty();
            IBlockState state = worldObj.getBlockState(pos);
            worldObj.notifyBlockUpdate(pos, state, state, 3);
            return true;
        }
        else if(heldItem.getItem() == Items.BLAZE_ROD)
        {
            storedItem = new ItemStack(Items.BLAZE_ROD);
            markDirty();
            IBlockState state = worldObj.getBlockState(pos);
            worldObj.notifyBlockUpdate(pos, state, state, 3);
            return true;
        }
        return false;
    }
    //This tells the block how to handle removing items.
    public void removeItem()
    {
        if(storedItem.getItem() == ModItems.estus_ash)
        {
            worldObj.spawnEntityInWorld(new EntityItem(worldObj, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, new ItemStack(ModItems.estus_ash)));
        }
        else if(storedItem.getItem() == ModItems.estus_shard)
        {
            worldObj.spawnEntityInWorld(new EntityItem(worldObj, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, new ItemStack(ModItems.estus_shard)));
        }
        else if(storedItem.getItem() == Items.BLAZE_ROD)
        {
            worldObj.spawnEntityInWorld(new EntityItem(worldObj, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, new ItemStack(Items.BLAZE_ROD)));
        }
        storedItem = null;
        markDirty();
        IBlockState state = worldObj.getBlockState(pos);
        worldObj.notifyBlockUpdate(pos, state, state, 3);
    }

    //Temporary crafting class. It'll be replaced by a dedicated crafting thing, so it's easier to add recipes, or other mods can add to it, in jolly modding cooperation \[T]/
    public void bonfireCraft(ItemStack heldItem)
    {
        //TODO: Delete this, and make a dedicated recipe handler, so it's easier to add recipes to. For both me and addon developers.
        if(heldItem.getItem() == Items.PRISMARINE_SHARD && storedItem.getItem() == Items.BLAZE_ROD)
        {
            worldObj.spawnEntityInWorld(new EntityItem(worldObj, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, new ItemStack(ModItems.estus_shard)));
            heldItem.stackSize--;
            storedItem.stackSize--;
        }
        else if(heldItem.getItem() == Items.SKULL && heldItem.getMetadata() == 1 && storedItem.getItem() == Items.BLAZE_ROD)
        {
            worldObj.spawnEntityInWorld(new EntityItem(worldObj, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, new ItemStack(ModItems.estus_ash)));
            heldItem.stackSize--;
            storedItem.stackSize--;
        }
    }

    //This is a big chunk of code that used  to be on the flask. This handles the restocking the uses, and upgrading of the flask when this is called by BlockBonfire.
    public void estusRestock(ItemStack heldItem)
    {
        if(heldItem.getItem() == ModItems.estus_flask)
        {
            NBTTagCompound nbt;

            if (heldItem.hasTagCompound())
            {
                nbt = heldItem.getTagCompound();
            }
            else
            {
                nbt = new NBTTagCompound();
            }
            if (nbt.hasKey("Uses"))
            {
                if(storedItem.getItem() == ModItems.estus_shard && nbt.getInteger("Max Uses") < 12)
                {
                    nbt.setInteger("Max Uses", nbt.getInteger("Max Uses") + 1);
                    storedItem.stackSize--;
                }
                else if(storedItem.getItem() == ModItems.estus_ash && nbt.getInteger("Potency") < 5)
                {
                    nbt.setInteger("Potency", nbt.getInteger("Potency") + 1);
                    storedItem.stackSize--;
                }
                nbt.setInteger("Uses", nbt.getInteger("Max Uses"));
            }
            else
            {
                nbt.setInteger("Uses", 1);
                nbt.setInteger("Max Uses", 1);
                nbt.setInteger("Potency", 1);
            }
            storedItem.setTagCompound(nbt);
        }
    }

    //This merely saves the variables defined earlier to NBT.
    @Override
    public NBTTagCompound writeToNBT(NBTTagCompound compound)
    {
        super.writeToNBT(compound);
        compound.setTag("ContainedItems", storedItem.serializeNBT());

        return compound;
    }

    //Similar to above, but it loads from NBT instead.
    @Override
    public void readFromNBT(NBTTagCompound compound)
    {
        super.readFromNBT(compound);
        this.storedItem = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("ContainedItems"));
    }

    @Override
    public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt)
    {
        NBTTagCompound tag = pkt.getNbtCompound();
        readUpdateTag(tag);
    }

    @Override
    public SPacketUpdateTileEntity getUpdatePacket()
    {
        NBTTagCompound tag = new NBTTagCompound();
        this.writeUpdateTag(tag);
        return new SPacketUpdateTileEntity(pos, getBlockMetadata(), tag);
    }

    @Override
    public NBTTagCompound getUpdateTag()
    {
        NBTTagCompound tag = super.getUpdateTag();
        writeUpdateTag(tag);
        return tag;
    }

    public void writeUpdateTag(NBTTagCompound tag)
    {
        tag.setTag("ContainedItems", storedItem.writeToNBT(tag));
    }

    public void readUpdateTag(NBTTagCompound tag)
    {
        this.storedItem = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("ContainedItems"));
    }
}

 

If I'm asking a whole bunch of questions, please don't get angry. I'm trying to learn.

Posted

You never account for

storedItem

being

null

. You need to check that it's not

null

before you call a method or access a field on it.

 

Consider using an

IItemHandler

inventory to store the item, this will handle a lot of the item storage logic for you. If needed, you can extend

ItemStackHandler

(the standard

IItemHandler

implementation), override

ItemStackHandler#insertItem

to check if the

ItemStack

's

Item

is valid before calling the super method (preventing invalid items from being inserted) and override

ItemStackHandler#getStackLimit

to limit the number of items that can be stored in each slot.

 

Use the

INBTSerializable

methods implemented by

ItemStackHandler

to read from/write to NBT.

 

If you want to allow automated inventory access later (by things like Hoppers and Item Conduits), you can expose the

IItemHandler

as a Capability.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Will I need to create a new class to use ItemStackHandler? I can't extend both TileEntity & ItemStackHandler into my tile entity class.

If I'm asking a whole bunch of questions, please don't get angry. I'm trying to learn.

Posted

Will I need to create a new class to use ItemStackHandler? I can't extend both TileEntity & ItemStackHandler into my tile entity class.

You could create a field of ItemStackHandler.

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.

Posted

Okay, got that all in a field.

How would I use it in the Block class to say, insert an item on right click? I can't shove it in onBlockActivated like how I did it before, as insertItem can't be called from it.

 

side question: What does simulating the insertion of an item do? And what would it be useful for?

If I'm asking a whole bunch of questions, please don't get angry. I'm trying to learn.

Posted

Okay, got that all in a field.

How would I use it in the Block class to say, insert an item on right click? I can't shove it in onBlockActivated like how I did it before, as insertItem can't be called from it.

 

side question: What does simulating the insertion of an item do? And what would it be useful for?

It would allow you to check what stack was returned there with out taking any action and you should be able to call it from the field (assuming it is not private or protected and is initialized. If it is private or protected create a getter method for it).

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.

Posted

Okay then. How would I initialise the StackHandler in the onBlockActivated? As in, I have the tileEntity defined as

TileEntityBonfire bonfire = (TileEntityBonfire) tileEntity;

, where tileEntity is initialised as

TileEntity tileEntity = worldIn.getTileEntity(pos);

?

I've got the stackHandler defined as

ItemStackHandler stackHandler = (TileEntityBonfire.StackHandler) stackHandler;

already.

If I'm asking a whole bunch of questions, please don't get angry. I'm trying to learn.

Posted

Okay then. How would I initialise the StackHandler in the onBlockActivated? As in, I have the tileEntity defined as

TileEntityBonfire bonfire = (TileEntityBonfire) tileEntity;

, where tileEntity is initialised as

TileEntity tileEntity = worldIn.getTileEntity(pos);

?

I've got the stackHandler defined as

ItemStackHandler stackHandler = (TileEntityBonfire.StackHandler) stackHandler;

already.

 

You shouldn't need to cast the

IItemHandler

here, you should store it as its actual type in a private field. If you make it visible to other classes (through a getter method), it should only be as

IItemHandler

.

 

As for how you store the item from

Block#onBlockActivated

, there are two options:

  • The
    Block

    uses a getter method to get the

    IItemHandler

    from the

    TileEntity

    and the

    Block

    handles storing the item

  • The
    Block

    tells the

    TileEntity

    that it was right clicked (by calling a method) and the

    TileEntity

    handles storing the item

 

 

 

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Hmm... I'll go for the second one.

Actually, I got a crash here when I placed it in the world. Here's the log:

[spoiler=Crash Log]

OpenJDK 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
[16:25:15] [main/INFO] [GradleStart]: Extra: []
[16:25:15] [main/INFO] [GradleStart]: Running with arguments: [--userProperties, {}, --assetsDir, /home/thomas/.gradle/caches/minecraft/assets, --assetIndex, 1.10, --accessToken{REDACTED}, --version, 1.10.2, --tweakClass, net.minecraftforge.fml.common.launcher.FMLTweaker, --tweakClass, net.minecraftforge.gradle.tweakers.CoremodTweaker]
[16:25:15] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
[16:25:15] [main/INFO] [LaunchWrapper]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
[16:25:15] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.CoremodTweaker
[16:25:15] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLTweaker
[16:25:15] [main/INFO] [FML]: Forge Mod Loader version 12.18.1.2011 for Minecraft 1.10.2 loading
[16:25:15] [main/INFO] [FML]: Java is OpenJDK 64-Bit Server VM, version 1.8.0_102, running on Linux:amd64:4.7.2-1-ARCH, installed at /usr/lib/jvm/java-8-openjdk/jre
[16:25:15] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation
[16:25:15] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.CoremodTweaker
[16:25:15] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.fml.relauncher.FMLCorePlugin
[16:25:15] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.classloading.FMLForgePlugin
[16:25:15] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[16:25:15] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
[16:25:15] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.AccessTransformerTweaker
[16:25:15] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[16:25:15] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[16:25:15] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
[16:25:15] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work!
[16:25:16] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing
[16:25:16] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
[16:25:16] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
[16:25:16] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.AccessTransformerTweaker
[16:25:16] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.TerminalTweaker
[16:25:16] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.TerminalTweaker
[16:25:16] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main}
[16:25:17] [Client thread/INFO]: Setting user: Player948
[16:25:19] [Client thread/INFO]: LWJGL Version: 2.9.4
ATTENTION: default value of option vblank_mode overridden by environment.
[16:25:19] [Client thread/INFO] [FML]: Could not load splash.properties, will create a default one
[16:25:19] [Client thread/INFO] [sTDOUT]: [net.minecraftforge.fml.client.SplashProgress:start:221]: ---- Minecraft Crash Report ----
// You're mean.

Time: 2/09/16 4:25 PM
Description: Loading screen debug info

This is just a prompt for computer specs to be printed. THIS IS NOT A ERROR


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

-- System Details --
Details:
Minecraft Version: 1.10.2
Operating System: Linux (amd64) version 4.7.2-1-ARCH
Java Version: 1.8.0_102, Oracle Corporation
Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 661000712 bytes (630 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: 
Loaded coremods (and transformers): 
GL info: ' Vendor: 'X.Org' Version: '3.0 Mesa 12.0.1' Renderer: 'Gallium 0.4 on AMD HAWAII (DRM 2.45.0 / 4.7.2-1-ARCH, LLVM 3.8.1)'
[16:25:19] [Client thread/INFO] [FML]: MinecraftForge v12.18.1.2011 Initialized
[16:25:19] [Client thread/INFO] [FML]: Replaced 233 ore recipes
[16:25:20] [Client thread/INFO] [FML]: Found 0 mods from the command line. Injecting into mod discoverer
[16:25:20] [Client thread/INFO] [FML]: Searching /drv/Data/Content/Minecraft/Mods/1.10.2/CrystalFlask/run/mods for mods
[16:25:20] [Client thread/INFO] [FML]: Forge Mod Loader has identified 4 mods to load
[16:25:20] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, crystalflask] at CLIENT
[16:25:20] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, crystalflask] at SERVER
[16:25:21] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Crystal Flask
[16:25:21] [Client thread/INFO] [FML]: Processing ObjectHolder annotations
[16:25:21] [Client thread/INFO] [FML]: Found 423 ObjectHolder annotations
[16:25:21] [Client thread/INFO] [FML]: Identifying ItemStackHolder annotations
[16:25:21] [Client thread/INFO] [FML]: Found 0 ItemStackHolder annotations
[16:25:21] [Client thread/INFO] [FML]: Configured a dormant chunk cache size of 0
[16:25:21] [Forge Version Check/INFO] [ForgeVersionCheck]: [Forge] Starting version check at http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json
[16:25:21] [Client thread/INFO] [FML]: Applying holder lookups
[16:25:21] [Client thread/INFO] [FML]: Holder lookups applied
[16:25:21] [Client thread/INFO] [FML]: Injecting itemstacks
[16:25:21] [Client thread/INFO] [FML]: Itemstack injection complete
[16:25:21] [sound Library Loader/INFO]: Starting up SoundSystem...
[16:25:21] [Forge Version Check/INFO] [ForgeVersionCheck]: [Forge] Found status: UP_TO_DATE Target: null
[16:25:22] [Thread-6/INFO]: Initializing LWJGL OpenAL
[16:25:22] [Thread-6/INFO]: (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
[16:25:22] [Thread-6/INFO]: OpenAL initialized.
[16:25:22] [sound Library Loader/INFO]: Sound engine started
[16:25:23] [Client thread/INFO] [FML]: Max texture size: 16384
[16:25:23] [Client thread/INFO]: Created: 16x16 textures-atlas
[16:25:24] [Client thread/INFO] [FML]: Injecting itemstacks
[16:25:24] [Client thread/INFO] [FML]: Itemstack injection complete
[16:25:24] [Client thread/INFO] [FML]: Forge Mod Loader has successfully loaded 4 mods
[16:25:24] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Crystal Flask
[16:25:24] [Client thread/INFO]: SoundSystem shutting down...
[16:25:24] [Client thread/WARN]: Author: Paul Lamb, www.paulscode.com
[16:25:24] [sound Library Loader/INFO]: Starting up SoundSystem...
[16:25:24] [Thread-8/INFO]: Initializing LWJGL OpenAL
[16:25:24] [Thread-8/INFO]: (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
[16:25:24] [Thread-8/INFO]: OpenAL initialized.
[16:25:25] [sound Library Loader/INFO]: Sound engine started
[16:25:25] [Client thread/INFO] [FML]: Max texture size: 16384
[16:25:25] [Client thread/INFO]: Created: 1024x512 textures-atlas
[16:25:27] [Realms Notification Availability checker #1/INFO]: Could not authorize you against Realms server: Invalid session id
[16:25:33] [server thread/INFO]: Starting integrated minecraft server version 1.10.2
[16:25:33] [server thread/INFO]: Generating keypair
[16:25:33] [server thread/INFO] [FML]: Injecting existing block and item data into this server instance
[16:25:33] [server thread/INFO] [FML]: Applying holder lookups
[16:25:33] [server thread/INFO] [FML]: Holder lookups applied
[16:25:33] [server thread/INFO] [FML]: Loading dimension 0 (New World) (net.minecraft.server.integrated.IntegratedServer@3795c8c6)
[16:25:33] [server thread/WARN]: Unable to find spawn biome
[16:25:35] [server thread/INFO] [FML]: Loading dimension 1 (New World) (net.minecraft.server.integrated.IntegratedServer@3795c8c6)
[16:25:35] [server thread/INFO] [FML]: Loading dimension -1 (New World) (net.minecraft.server.integrated.IntegratedServer@3795c8c6)
[16:25:35] [server thread/INFO]: Preparing start region for level 0
[16:25:36] [server thread/INFO]: Preparing spawn area: 15%
[16:25:37] [server thread/INFO]: Preparing spawn area: 31%
[16:25:38] [server thread/INFO]: Preparing spawn area: 48%
[16:25:39] [server thread/INFO]: Preparing spawn area: 64%
[16:25:40] [server thread/INFO]: Preparing spawn area: 85%
[16:25:41] [server thread/INFO]: Changing view distance to 12, from 10
[16:25:42] [Netty Local Client IO #0/INFO] [FML]: Server protocol version 2
[16:25:42] [Netty Server IO #1/INFO] [FML]: Client protocol version 2
[16:25:42] [Netty Server IO #1/INFO] [FML]: Client attempting to join with 4 mods : [email protected],[email protected],[email protected],[email protected]
[16:25:42] [Netty Local Client IO #0/INFO] [FML]: [Netty Local Client IO #0] Client side modded connection established
[16:25:42] [server thread/INFO] [FML]: [server thread] Server side modded connection established
[16:25:42] [server thread/INFO]: Player948[local:E:2ffd9c11] logged in with entity id 1156 at (-493.5, 68.0, -812.5)
[16:25:42] [server thread/INFO]: Player948 joined the game
[16:25:43] [pool-2-thread-1/WARN]: Couldn't look up profile properties for com.mojang.authlib.GameProfile@6b9c0e72[id=2dd1d9e7-57ae-36c4-8b90-c235b1bdb90f,name=Player948,properties={},legacy=false]
com.mojang.authlib.exceptions.AuthenticationException: The client has sent too many requests within a certain amount of time
at com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService.makeRequest(YggdrasilAuthenticationService.java:65) ~[YggdrasilAuthenticationService.class:?]
at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillGameProfile(YggdrasilMinecraftSessionService.java:175) [YggdrasilMinecraftSessionService.class:?]
at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:59) [YggdrasilMinecraftSessionService$1.class:?]
at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:56) [YggdrasilMinecraftSessionService$1.class:?]
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache.get(LocalCache.java:3934) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4827) [guava-17.0.jar:?]
at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillProfileProperties(YggdrasilMinecraftSessionService.java:165) [YggdrasilMinecraftSessionService.class:?]
at net.minecraft.client.Minecraft.getProfileProperties(Minecraft.java:3060) [Minecraft.class:?]
at net.minecraft.client.resources.SkinManager$3.run(SkinManager.java:131) [skinManager$3.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_102]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_102]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_102]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_102]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_102]
[16:25:44] [server thread/INFO]: Player948 has just earned the achievement [Taking Inventory]
[16:25:44] [Client thread/INFO]: [CHAT] Player948 has just earned the achievement [Taking Inventory]
[16:25:49] [server thread/ERROR]: Encountered an unexpected exception
net.minecraft.util.ReportedException: Exception ticking world
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:778) ~[MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687) ~[MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) ~[integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536) [MinecraftServer.class:?]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_102]
Caused by: java.lang.NullPointerException
at com.t10a.crystalflask.tileentity.TileEntityBonfire.writeUpdateTag(TileEntityBonfire.java:206) ~[TileEntityBonfire.class:?]
at com.t10a.crystalflask.tileentity.TileEntityBonfire.getUpdatePacket(TileEntityBonfire.java:192) ~[TileEntityBonfire.class:?]
at net.minecraft.server.management.PlayerChunkMapEntry.sendBlockEntity(PlayerChunkMapEntry.java:297) ~[PlayerChunkMapEntry.class:?]
at net.minecraft.server.management.PlayerChunkMapEntry.update(PlayerChunkMapEntry.java:259) ~[PlayerChunkMapEntry.class:?]
at net.minecraft.server.management.PlayerChunkMap.tick(PlayerChunkMap.java:134) ~[PlayerChunkMap.class:?]
at net.minecraft.world.WorldServer.tick(WorldServer.java:229) ~[WorldServer.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:772) ~[MinecraftServer.class:?]
... 4 more
[16:25:49] [server thread/ERROR]: This crash report has been saved to: /drv/Data/Content/Minecraft/Mods/1.10.2/CrystalFlask/run/./crash-reports/crash-2016-09-02_16.25.49-server.txt
[16:25:49] [server thread/INFO]: Stopping server
[16:25:49] [server thread/INFO]: Saving players
[16:25:49] [server thread/INFO]: Player948 lost connection: TextComponent{text='Server closed', siblings=[], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null}}
[16:25:49] [server thread/INFO]: Player948 left the game
[16:25:49] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:649]: ---- Minecraft Crash Report ----
// This doesn't make any sense!

Time: 2/09/16 4:25 PM
Description: Exception ticking world

java.lang.NullPointerException: Exception ticking world
at com.t10a.crystalflask.tileentity.TileEntityBonfire.writeUpdateTag(TileEntityBonfire.java:206)
at com.t10a.crystalflask.tileentity.TileEntityBonfire.getUpdatePacket(TileEntityBonfire.java:192)
at net.minecraft.server.management.PlayerChunkMapEntry.sendBlockEntity(PlayerChunkMapEntry.java:297)
at net.minecraft.server.management.PlayerChunkMapEntry.update(PlayerChunkMapEntry.java:259)
at net.minecraft.server.management.PlayerChunkMap.tick(PlayerChunkMap.java:134)
at net.minecraft.world.WorldServer.tick(WorldServer.java:229)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:772)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536)
at java.lang.Thread.run(Thread.java:745)


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

-- Head --
Thread: Client thread
Stacktrace:
at com.t10a.crystalflask.tileentity.TileEntityBonfire.writeUpdateTag(TileEntityBonfire.java:206)
at com.t10a.crystalflask.tileentity.TileEntityBonfire.getUpdatePacket(TileEntityBonfire.java:192)
at net.minecraft.server.management.PlayerChunkMapEntry.sendBlockEntity(PlayerChunkMapEntry.java:297)
at net.minecraft.server.management.PlayerChunkMapEntry.update(PlayerChunkMapEntry.java:259)
at net.minecraft.server.management.PlayerChunkMap.tick(PlayerChunkMap.java:134)
at net.minecraft.world.WorldServer.tick(WorldServer.java:229)

-- Affected level --
Details:
Level name: New World
All players: 1 total; [EntityPlayerMP['Player948'/1156, l='New World', x=-493.81, y=68.00, z=-811.77]]
Chunk stats: ServerChunkCache: 893 Drop: 0
Level seed: -5966445043629997792
Level generator: ID 00 - default, ver 1. Features enabled: true
Level generator options: 
Level spawn location: World: (-486,64,-804), Chunk: (at 10,4,12 in -31,-51; contains blocks -496,0,-816 to -481,255,-801), Region: (-1,-2; contains chunks -32,-64 to -1,-33, blocks -512,0,-1024 to -1,255,-513)
Level time: 156 game time, 156 day time
Level dimension: 0
Level storage version: 0x04ABD - Anvil
Level weather: Rain time: 120201 (now: false), thunder time: 51286 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true
Stacktrace:
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:772)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536)
at java.lang.Thread.run(Thread.java:745)

-- System Details --
Details:
Minecraft Version: 1.10.2
Operating System: Linux (amd64) version 4.7.2-1-ARCH
Java Version: 1.8.0_102, Oracle Corporation
Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 679137520 bytes (647 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95
FML: MCP 9.32 Powered by Forge 12.18.1.2011 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.10.2-12.18.1.2011.jar) 
UCHIJAAAA	Forge{12.18.1.2011} [Minecraft Forge] (forgeSrc-1.10.2-12.18.1.2011.jar) 
UCHIJAAAA	crystalflask{1.10.2-BETA} [Crystal Flask] (bin) 
Loaded coremods (and transformers): 
GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.
Profiler Position: N/A (disabled)
Player Count: 1 / 8; [EntityPlayerMP['Player948'/1156, l='New World', x=-493.81, y=68.00, z=-811.77]]
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to 'fml,forge'
[16:25:49] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:649]: #@!@# Game crashed! Crash report saved to: #@!@# ./crash-reports/crash-2016-09-02_16.25.49-server.txt
[16:25:49] [Client thread/INFO] [FML]: Waiting for the server to terminate/save.
[16:25:49] [server thread/INFO]: Stopping singleplayer server as player logged out
[16:25:49] [server thread/INFO]: Saving worlds
[16:25:49] [server thread/INFO]: Saving chunks for level 'New World'/Overworld
[16:25:49] [server thread/ERROR] [FML]: A TileEntity type com.t10a.crystalflask.tileentity.TileEntityBonfire has throw an exception trying to write state. It will not persist. Report this to the mod author
java.lang.NullPointerException
at com.t10a.crystalflask.tileentity.TileEntityBonfire.writeToNBT(TileEntityBonfire.java:168) ~[TileEntityBonfire.class:?]
at net.minecraft.world.chunk.storage.AnvilChunkLoader.writeChunkToNBT(AnvilChunkLoader.java:409) [AnvilChunkLoader.class:?]
at net.minecraft.world.chunk.storage.AnvilChunkLoader.saveChunk(AnvilChunkLoader.java:182) [AnvilChunkLoader.class:?]
at net.minecraft.world.gen.ChunkProviderServer.saveChunkData(ChunkProviderServer.java:208) [ChunkProviderServer.class:?]
at net.minecraft.world.gen.ChunkProviderServer.saveChunks(ChunkProviderServer.java:236) [ChunkProviderServer.class:?]
at net.minecraft.world.WorldServer.saveAllChunks(WorldServer.java:1061) [WorldServer.class:?]
at net.minecraft.server.MinecraftServer.saveAllWorlds(MinecraftServer.java:414) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.saveAllWorlds(IntegratedServer.java:238) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.stopServer(MinecraftServer.java:455) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.stopServer(IntegratedServer.java:369) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:589) [MinecraftServer.class:?]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_102]
[16:25:49] [server thread/INFO]: Saving chunks for level 'New World'/Nether
[16:25:49] [server thread/INFO]: Saving chunks for level 'New World'/The End
[16:25:49] [server thread/INFO] [FML]: Unloading dimension 0
[16:25:49] [server thread/INFO] [FML]: Unloading dimension -1
[16:25:49] [server thread/INFO] [FML]: Unloading dimension 1
[16:25:49] [server thread/INFO] [FML]: Applying holder lookups
[16:25:49] [server thread/INFO] [FML]: Holder lookups applied
[16:25:49] [server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STOPPING and forced into state SERVER_STOPPED. Errors may have been discarded.
[16:25:49] [Client thread/INFO] [FML]: Server terminated.
AL lib: (EE) alc_cleanup: 1 device not closed

 

 

And here's the TileEntity class(where the error occurs)

[spoiler=TileEntityBonfire.class]

package com.t10a.crystalflask.tileentity;

import com.t10a.crystalflask.init.ModItems;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.items.ItemStackHandler;

public class TileEntityBonfire extends TileEntity
{
    public ItemStack storedItem;

    public class StackHandler extends ItemStackHandler
    {
        @Override
        public ItemStack insertItem(int slot, ItemStack stack, boolean simulate)
        {
            if(stack == null || stack.stackSize == 0)
            {
            	return null;
            }
            else return super.insertItem(0, stack, false);
             
        }

        @Override
        public ItemStack extractItem(int slot, int amount, boolean simulate)
        {
            return super.extractItem(0, amount, false);
        }

        @Override
        protected int getStackLimit(int slot, ItemStack stack) {
            return 1;
        }

        @Override
        public NBTTagCompound serializeNBT() {
            return super.serializeNBT();
        }

        @Override
        public void deserializeNBT(NBTTagCompound nbt) {
            super.deserializeNBT(nbt);
        }
    }

    //Variables telling the TileEntity what's currently contained.;
    //BELOW IS COMMENTED OUT, MAINLY FOR CHECKING OUT THE NEW ITEMSTACKHANDLER
    //This tells the block how to handle adding items.
    /*
    public boolean addItem(ItemStack heldItem)
    {
        if(heldItem.getItem() == ModItems.estus_shard)
        {
            storedItem = new ItemStack(ModItems.estus_shard);
            markDirty();
            IBlockState state = worldObj.getBlockState(pos);
            worldObj.notifyBlockUpdate(pos, state, state, 3);
            return true;
        }
        else if(heldItem.getItem() == ModItems.estus_ash)
        {
            storedItem = new ItemStack(ModItems.estus_ash);
            markDirty();
            IBlockState state = worldObj.getBlockState(pos);
            worldObj.notifyBlockUpdate(pos, state, state, 3);
            return true;
        }
        else if(heldItem.getItem() == Items.BLAZE_ROD)
        {
            storedItem = new ItemStack(Items.BLAZE_ROD);
            markDirty();
            IBlockState state = worldObj.getBlockState(pos);
            worldObj.notifyBlockUpdate(pos, state, state, 3);
            return true;
        }
        return false;
    }
    //This tells the block how to handle removing items.
    public void removeItem()
    {
        if(storedItem.getItem() == ModItems.estus_ash)
        {
            worldObj.spawnEntityInWorld(new EntityItem(worldObj, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, new ItemStack(ModItems.estus_ash)));
        }
        else if(storedItem.getItem() == ModItems.estus_shard)
        {
            worldObj.spawnEntityInWorld(new EntityItem(worldObj, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, new ItemStack(ModItems.estus_shard)));
        }
        else if(storedItem.getItem() == Items.BLAZE_ROD)
        {
            worldObj.spawnEntityInWorld(new EntityItem(worldObj, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, new ItemStack(Items.BLAZE_ROD)));
        }
        storedItem = null;
        markDirty();
        IBlockState state = worldObj.getBlockState(pos);
        worldObj.notifyBlockUpdate(pos, state, state, 3);
    }
    */
    //Temporary crafting class. It'll be replaced by a dedicated crafting thing, so it's easier to add recipes, or other mods can add to it, in jolly modding cooperation \[T]/
    public void bonfireCraft(ItemStack heldItem)
    {
        //TODO: Delete this, and make a dedicated recipe handler, so it's easier to add recipes to. For both me and addon developers.
        if(heldItem.getItem() == Items.PRISMARINE_SHARD && storedItem.getItem() == Items.BLAZE_ROD)
        {
            worldObj.spawnEntityInWorld(new EntityItem(worldObj, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, new ItemStack(ModItems.estus_shard)));
            heldItem.stackSize--;
            storedItem.stackSize--;
        }
        else if(heldItem.getItem() == Items.SKULL && heldItem.getMetadata() == 1 && storedItem.getItem() == Items.BLAZE_ROD)
        {
            worldObj.spawnEntityInWorld(new EntityItem(worldObj, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, new ItemStack(ModItems.estus_ash)));
            heldItem.stackSize--;
            storedItem.stackSize--;
        }
    }


    //This is a big chunk of code that used  to be on the flask. This handles the restocking the uses, and upgrading of the flask when this is called by BlockBonfire.
    public void estusRestock(ItemStack heldItem)
    {
        if(heldItem.getItem() == ModItems.estus_flask)
        {
            NBTTagCompound nbt;

            if (heldItem.hasTagCompound())
            {
                nbt = heldItem.getTagCompound();
            }
            else
            {
                nbt = new NBTTagCompound();
            }
            if (nbt.hasKey("Uses"))
            {
                if(storedItem.getItem() == ModItems.estus_shard && nbt.getInteger("Max Uses") < 12)
                {
                    nbt.setInteger("Max Uses", nbt.getInteger("Max Uses") + 1);
                    storedItem.stackSize--;
                }
                else if(storedItem.getItem() == ModItems.estus_ash && nbt.getInteger("Potency") < 5)
                {
                    nbt.setInteger("Potency", nbt.getInteger("Potency") + 1);
                    storedItem.stackSize--;
                }
                nbt.setInteger("Uses", nbt.getInteger("Max Uses"));
            }
            else
            {
                nbt.setInteger("Uses", 1);
                nbt.setInteger("Max Uses", 1);
                nbt.setInteger("Potency", 1);
            }
            storedItem.setTagCompound(nbt);
        }
    }

    //This merely saves the variables defined earlier to NBT.
    @Override
    public NBTTagCompound writeToNBT(NBTTagCompound compound)
    {
        super.writeToNBT(compound);
        compound.setTag("ContainedItems", storedItem.serializeNBT());

        return compound;
    }

    //Similar to above, but it loads from NBT instead.
    @Override
    public void readFromNBT(NBTTagCompound compound)
    {
        super.readFromNBT(compound);
        this.storedItem = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("ContainedItems"));
    }

    @Override
    public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt)
    {
        NBTTagCompound tag = pkt.getNbtCompound();
        readUpdateTag(tag);
    }

    @Override
    public SPacketUpdateTileEntity getUpdatePacket()
    {
        NBTTagCompound tag = new NBTTagCompound();
        this.writeUpdateTag(tag);
        return new SPacketUpdateTileEntity(pos, getBlockMetadata(), tag);
    }

    @Override
    public NBTTagCompound getUpdateTag()
    {
        NBTTagCompound tag = super.getUpdateTag();
        writeUpdateTag(tag);
        return tag;
    }

    public void writeUpdateTag(NBTTagCompound tag)
    {
        tag.setTag("ContainedItems", storedItem.writeToNBT(tag));
    }

    public void readUpdateTag(NBTTagCompound tag)
    {
        this.storedItem = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("ContainedItems"));
    }
}

 

If I'm asking a whole bunch of questions, please don't get angry. I'm trying to learn.

Posted

You never create an instance of your

StackHandler

class and thus you never use it. It should probably be a

static

inner class, it shouldn't need to access the

TileEntityBonfire

.

 

There's no reason to override a method if all you do in the override is call the super method.

 

Your

StackHandler#insertItem

method breaks the contract of

IItemHandler

, i.e. that passing

true

as the

simulate

argument doesn't affect the contents of the inventory.

ItemStackHandler#insertItem

already checks for

stack

being

null

and

stack.stackSize

being 0, there's no reason to do this in your override.

 

Your

writeUpdateTag

method still doesn't account for

storedItem

being

null

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Ok, (I think) I fixed the StackHandler by initialising it as

TileEntityBonfire.StackHandler stackHandler = (StackHandler) new TileEntityBonfire.StackHandler();

. I also got rid of the override, and fixed up the

simulate

boolean, by returning

simulate

in both of the supers. How would I handle writeUpdateTag being null?

If I'm asking a whole bunch of questions, please don't get angry. I'm trying to learn.

Posted

Ok, (I think) I fixed the StackHandler by initialising it as

TileEntityBonfire.StackHandler stackHandler = (StackHandler) new TileEntityBonfire.StackHandler();

. I also got rid of the override, and fixed up the

simulate

boolean, by returning

simulate

in both of the supers. How would I handle writeUpdateTag being null?

if (storedItem != null) //Write Item to NBT.

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.

Posted

Got that. It doesn't crash the game now when I load the world OR place a new block down. Thing is, I can't exactly extract an item from stack 0, while I could definitely insert a stack. Not sure where I goofed, as I'm telling the game if

heldItem == null

(as in the empty hand), it'll run

stackHandler.extractItem(0, 1, false);

.

 

Here's the code for the block:

[spoiler=Newer BlockBonfire.class]

package com.t10a.crystalflask.blocks;

import com.t10a.crystalflask.Reference;
import com.t10a.crystalflask.init.ModItems;
import com.t10a.crystalflask.tileentity.TileEntityBonfire;
import com.t10a.crystalflask.tileentity.TileEntityBonfire.StackHandler;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemStackHandler;

import java.util.List;
import java.util.Random;

public class BlockBonfire extends Block
{
    //private static final AxisAlignedBB BOUNDING_BOX = new AxisAlignedBB(x1, y1, z1, x2, y2, z2);
    //This sets the hitbox for this block,
    private static final AxisAlignedBB BOUNDING_BOX = new AxisAlignedBB(0.0625 * 3, 0, 0.0625 * 4, 0.0625 * 12, 0.0625 * 15, 0.0625 * 12);

    public BlockBonfire(String name, CreativeTabs tabs)
    {
        super(Material.ROCK);
        //It's a good idea to put the modid into the block's unlocalised name, to prevent conflicts in the en_US.lang.
        setUnlocalizedName(Reference.MOD_ID + "." + name);
        setRegistryName(Reference.MOD_ID, name);
        setCreativeTab(tabs);
        this.setLightLevel(5.0F);
    }

    /*
    * The following are obvious. isFullCube checks if this is a full cube (it isn't), isOpaqueCube checks if this cube is opaque (it isn't a cube, so no),
    * getBlockLayer returns this block is solid, getBoundingBox tells the game the hitbox we defined earlier(?), and addCollisionBoxToList registers the hitbox(?).
    */
    @Override
    public boolean isFullCube(IBlockState state) {
        return false;
    }

    @Override
    public boolean isOpaqueCube(IBlockState state) {
        return false;
    }

    @Override
    public BlockRenderLayer getBlockLayer() {
        return BlockRenderLayer.SOLID;
    }

    @Override
    public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
        return BOUNDING_BOX;
    }

    @Override
    public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, Entity entityIn) {
        super.addCollisionBoxToList(pos, entityBox, collidingBoxes, BOUNDING_BOX);
    }

    //WIP. Pretty much is responsible for the particle effects this block emits.
    //TODO: Make this emit special particles based on what item is contained.
    @SideOnly(Side.CLIENT)
    public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand)
    {
        double d0 = (double)pos.getX() + 0.5D;
        double d1 = (double)pos.getY() + rand.nextDouble() * 6.0D / 16.0D;
        double d2 = (double)pos.getZ() + 0.5D;
        double d3 = rand.nextDouble() * 0.6D - 0.3D;

        if (rand.nextDouble() < 0.3D)
        {
            worldIn.playSound((double)pos.getX() + 0.5D, (double)pos.getY(), (double)pos.getZ() + 0.5D, SoundEvents.BLOCK_FIRE_AMBIENT, SoundCategory.BLOCKS, 1.0F, 1.0F, false);
        }

        worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1 + d3, d2, 0.0D, 0.0D, 0.0D, 0);
        worldIn.spawnParticle(EnumParticleTypes.FLAME, d0, d1 + d3, d2, 0.0D, 0.0D, 0.0D, 0);
        /*
        if(worldIn.isRemote)
        {
            TileEntity tileEntity = worldIn.getTileEntity(pos);
            if (tileEntity instanceof TileEntityBonfire)
            {
                TileEntityBonfire bonfire = (TileEntityBonfire) tileEntity;
                if(bonfire.stack.getItem() == ModItems.estus_shard)
                {
                    worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1 + d3, d2, 0.0D, 0.0D, 0.0D, 0);
                    worldIn.spawnParticle(EnumParticleTypes.CRIT, d0, d1 + d3, d2, 0.0D, 0.0D, 0.0D, 0);
                    worldIn.spawnParticle(EnumParticleTypes.FLAME, d0, d1 + d3, d2, 0.0D, 0.0D, 0.0D, 0);
                }
                else if(bonfire.stack.getItem() == ModItems.estus_ash)
                {
                    worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d0, d1 + d3, d2, 0.0D, 0.0D, 0.0D, 0);
                    worldIn.spawnParticle(EnumParticleTypes.FLAME, d0, d1 + d3, d2, 0.0D, 0.0D, 0.0D, 0);
                }
                else if(bonfire.stack.getItem() == Items.BLAZE_ROD)
                {
                    worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1 + d3, d2, 0.0D, 0.0D, 0.0D, 0);
                    worldIn.spawnParticle(EnumParticleTypes.FLAME, d0, d1 + d3, d2, 0.0D, 0.0D, 0.0D, 0);
                    if(rand.nextDouble() > 0.3D)
                    {
                        worldIn.spawnParticle(EnumParticleTypes.LAVA, d0, d1 + d3, d2, 0.0D, 0.0D, 0.0D, 0);
                    }
                }
                else
                {
                    worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1 + d3, d2, 0.0D, 0.0D, 0.0D, 0);
                    worldIn.spawnParticle(EnumParticleTypes.FLAME, d0, d1 + d3, d2, 0.0D, 0.0D, 0.0D, 0);
                }
            }
        }
        */
    }
    //This pretty much tells the TileEntity class what to do based on what's right-clicking it.
    @Override
    public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
        if(!worldIn.isRemote)
        {
            TileEntity tileEntity = worldIn.getTileEntity(pos);
            if(tileEntity instanceof TileEntityBonfire)
            {
                TileEntityBonfire bonfire = (TileEntityBonfire) tileEntity;
                TileEntityBonfire.StackHandler stackHandler = (StackHandler) new TileEntityBonfire.StackHandler();
                if(heldItem != null)
                {
                    if (heldItem.getItem() == ModItems.estus_shard || heldItem.getItem() == ModItems.estus_ash || heldItem.getItem() == Items.BLAZE_ROD)
                    {
                        stackHandler.insertItem(0, heldItem, false);
                        heldItem.stackSize--;
                        return true;
                    }
                    else if (heldItem.getItem() == ModItems.estus_flask)
                    {
                        bonfire.estusRestock(heldItem);
                        return true;
                    }
                    else if(heldItem.getItem() == Items.PRISMARINE_SHARD || (heldItem.getItem() == Items.SKULL && heldItem.getMetadata() == 1))
                    {
                        bonfire.bonfireCraft(heldItem);
                        return true;
                    }
                }
                stackHandler.extractItem(0, 1, false);
                return true;
            }
        }
        return false;
    }

    //Tells the game this has a TileEntity
    @Override
    public boolean hasTileEntity(IBlockState state) {
        return true;
    }

    //Tells the game what tile entity to create when placed
    @Override
    public TileEntity createTileEntity(World world, IBlockState state) {
        return new TileEntityBonfire();
    }
}

 

Also, how would I check what's in Slot 0, so I can do things with the item? And would I be able to simply 'delete' the item in stack 0?

If I'm asking a whole bunch of questions, please don't get angry. I'm trying to learn.

Posted

Got that. It doesn't crash the game now when I load the world OR place a new block down. Thing is, I can't exactly extract an item from stack 0, while I could definitely insert a stack. Not sure where I goofed, as I'm telling the game if

heldItem == null

(as in the empty hand), it'll run

stackHandler.extractItem(0, 1, false);

.

 

Here's the code for the block:

[spoiler=Newer BlockBonfire.class]

package com.t10a.crystalflask.blocks;

import com.t10a.crystalflask.Reference;
import com.t10a.crystalflask.init.ModItems;
import com.t10a.crystalflask.tileentity.TileEntityBonfire;
import com.t10a.crystalflask.tileentity.TileEntityBonfire.StackHandler;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemStackHandler;

import java.util.List;
import java.util.Random;

public class BlockBonfire extends Block
{
    //private static final AxisAlignedBB BOUNDING_BOX = new AxisAlignedBB(x1, y1, z1, x2, y2, z2);
    //This sets the hitbox for this block,
    private static final AxisAlignedBB BOUNDING_BOX = new AxisAlignedBB(0.0625 * 3, 0, 0.0625 * 4, 0.0625 * 12, 0.0625 * 15, 0.0625 * 12);

    public BlockBonfire(String name, CreativeTabs tabs)
    {
        super(Material.ROCK);
        //It's a good idea to put the modid into the block's unlocalised name, to prevent conflicts in the en_US.lang.
        setUnlocalizedName(Reference.MOD_ID + "." + name);
        setRegistryName(Reference.MOD_ID, name);
        setCreativeTab(tabs);
        this.setLightLevel(5.0F);
    }

    /*
    * The following are obvious. isFullCube checks if this is a full cube (it isn't), isOpaqueCube checks if this cube is opaque (it isn't a cube, so no),
    * getBlockLayer returns this block is solid, getBoundingBox tells the game the hitbox we defined earlier(?), and addCollisionBoxToList registers the hitbox(?).
    */
    @Override
    public boolean isFullCube(IBlockState state) {
        return false;
    }

    @Override
    public boolean isOpaqueCube(IBlockState state) {
        return false;
    }

    @Override
    public BlockRenderLayer getBlockLayer() {
        return BlockRenderLayer.SOLID;
    }

    @Override
    public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
        return BOUNDING_BOX;
    }

    @Override
    public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, Entity entityIn) {
        super.addCollisionBoxToList(pos, entityBox, collidingBoxes, BOUNDING_BOX);
    }

    //WIP. Pretty much is responsible for the particle effects this block emits.
    //TODO: Make this emit special particles based on what item is contained.
    @SideOnly(Side.CLIENT)
    public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand)
    {
        double d0 = (double)pos.getX() + 0.5D;
        double d1 = (double)pos.getY() + rand.nextDouble() * 6.0D / 16.0D;
        double d2 = (double)pos.getZ() + 0.5D;
        double d3 = rand.nextDouble() * 0.6D - 0.3D;

        if (rand.nextDouble() < 0.3D)
        {
            worldIn.playSound((double)pos.getX() + 0.5D, (double)pos.getY(), (double)pos.getZ() + 0.5D, SoundEvents.BLOCK_FIRE_AMBIENT, SoundCategory.BLOCKS, 1.0F, 1.0F, false);
        }

        worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1 + d3, d2, 0.0D, 0.0D, 0.0D, 0);
        worldIn.spawnParticle(EnumParticleTypes.FLAME, d0, d1 + d3, d2, 0.0D, 0.0D, 0.0D, 0);
        /*
        if(worldIn.isRemote)
        {
            TileEntity tileEntity = worldIn.getTileEntity(pos);
            if (tileEntity instanceof TileEntityBonfire)
            {
                TileEntityBonfire bonfire = (TileEntityBonfire) tileEntity;
                if(bonfire.stack.getItem() == ModItems.estus_shard)
                {
                    worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1 + d3, d2, 0.0D, 0.0D, 0.0D, 0);
                    worldIn.spawnParticle(EnumParticleTypes.CRIT, d0, d1 + d3, d2, 0.0D, 0.0D, 0.0D, 0);
                    worldIn.spawnParticle(EnumParticleTypes.FLAME, d0, d1 + d3, d2, 0.0D, 0.0D, 0.0D, 0);
                }
                else if(bonfire.stack.getItem() == ModItems.estus_ash)
                {
                    worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d0, d1 + d3, d2, 0.0D, 0.0D, 0.0D, 0);
                    worldIn.spawnParticle(EnumParticleTypes.FLAME, d0, d1 + d3, d2, 0.0D, 0.0D, 0.0D, 0);
                }
                else if(bonfire.stack.getItem() == Items.BLAZE_ROD)
                {
                    worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1 + d3, d2, 0.0D, 0.0D, 0.0D, 0);
                    worldIn.spawnParticle(EnumParticleTypes.FLAME, d0, d1 + d3, d2, 0.0D, 0.0D, 0.0D, 0);
                    if(rand.nextDouble() > 0.3D)
                    {
                        worldIn.spawnParticle(EnumParticleTypes.LAVA, d0, d1 + d3, d2, 0.0D, 0.0D, 0.0D, 0);
                    }
                }
                else
                {
                    worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1 + d3, d2, 0.0D, 0.0D, 0.0D, 0);
                    worldIn.spawnParticle(EnumParticleTypes.FLAME, d0, d1 + d3, d2, 0.0D, 0.0D, 0.0D, 0);
                }
            }
        }
        */
    }
    //This pretty much tells the TileEntity class what to do based on what's right-clicking it.
    @Override
    public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
        if(!worldIn.isRemote)
        {
            TileEntity tileEntity = worldIn.getTileEntity(pos);
            if(tileEntity instanceof TileEntityBonfire)
            {
                TileEntityBonfire bonfire = (TileEntityBonfire) tileEntity;
                TileEntityBonfire.StackHandler stackHandler = (StackHandler) new TileEntityBonfire.StackHandler();
                if(heldItem != null)
                {
                    if (heldItem.getItem() == ModItems.estus_shard || heldItem.getItem() == ModItems.estus_ash || heldItem.getItem() == Items.BLAZE_ROD)
                    {
                        stackHandler.insertItem(0, heldItem, false);
                        heldItem.stackSize--;
                        return true;
                    }
                    else if (heldItem.getItem() == ModItems.estus_flask)
                    {
                        bonfire.estusRestock(heldItem);
                        return true;
                    }
                    else if(heldItem.getItem() == Items.PRISMARINE_SHARD || (heldItem.getItem() == Items.SKULL && heldItem.getMetadata() == 1))
                    {
                        bonfire.bonfireCraft(heldItem);
                        return true;
                    }
                }
                stackHandler.extractItem(0, 1, false);
                return true;
            }
        }
        return false;
    }

    //Tells the game this has a TileEntity
    @Override
    public boolean hasTileEntity(IBlockState state) {
        return true;
    }

    //Tells the game what tile entity to create when placed
    @Override
    public TileEntity createTileEntity(World world, IBlockState state) {
        return new TileEntityBonfire();
    }
}

 

Also, how would I check what's in Slot 0, so I can do things with the item? And would I be able to simply 'delete' the item in stack 0?

You are reinitializing your StackHandler every time you right click it, so obviously it will not contain an Item. Also you do not need an ItemStack field in your TileEntity as you are using an IItemHandler, an IItemHandler more specifically an ItemStackHandler only has access to its ItemStacks and there by uses them. I'm going  to ask you how much Java do you know?

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.

Posted

I followed the Codecademy tutorial, so I know basics. Minecraft modding is also my first foray into serious programming outside of Bash scripts & high school Visual Basic programs a year or two ago. (please don't ban me for this D:)

This is also my first-ish attempt at extending my modding skills beyond simply "adding custom tools to the game", and yes, I did watch MrCrayFish's tutorials (though before that, I watched Pahimar's tutorials)

If I'm asking a whole bunch of questions, please don't get angry. I'm trying to learn.

Posted

I followed the Codecademy tutorial, so I know basics. Minecraft modding is also my first foray into serious programming outside of Bash scripts & high school Visual Basic programs a year or two ago. (please don't ban me for this D:)

This is also my first-ish attempt at extending my modding skills beyond simply "adding custom tools to the game".

What I would recommend is understanding how an Object Oriented Programming language works, before stepping into the world of modding, because things like re-initializing a field like that will obviously reset all of the data inside of it. Also understand the difference between initializing and creating. Because there is  a big difference. And this is not a forum where you go to learn Java or any other programming language. So you should go refresh/learn Java before continuing.

Java tutorial link

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.

Posted

Okay then. When I finish that up, I'll simply start a new post. Thanks for the link.

If any admin wants to lock this, feel free to do so.

If I'm asking a whole bunch of questions, please don't get angry. I'm trying to learn.

Posted

Ok, (I think) I fixed the StackHandler by initialising it as

TileEntityBonfire.StackHandler stackHandler = (StackHandler) new TileEntityBonfire.StackHandler();

.

 

There's no reason to cast an object as you create it.

 

Either refer to the inner class by its full name (

TileEntityBonfire.StackHandler

) or its own name (

StackHandler

), try to be consistent.

 

As Animefan8888 said, you must have a solid understanding of Java and OO programming in general before you make a mod.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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

    • Reach Out To Rapid Digital: What sapp Info: +1 41 4 80 7 14 85 Email INFO: rap iddi gita lrecov ery @ exe cs. com Hello, my name is Jayson, and I’m 35 years old from the United Kingdom. My family and I recently endured an incredibly challenging experience that I wouldn’t wish on anyone. We became victims of a cryptocurrency investment fraud scheme that saw us lose a staggering $807,000 in USDT and Bitcoins. The fraudsters had created a convincing facade, and we were lured into investing, only to discover later that the platform was a complete scam. We were left devastated, not just financially, but emotionally, as we had trusted these people and believed in the legitimacy of the investment. After the initial shock wore off, we desperately searched for ways to recover the lost funds. It seemed like an impossible task, and we felt as though there was no hope. That’s when, by sheer luck, we stumbled across a post about Rapid Digital Recovery, a cryptocurrency and funds recovery organization with a proven track record in cybersecurity and fraud recovery. We decided to reach out to them, and from the first interaction, we were impressed with their professionalism and transparency. They explained the recovery process in detail and reassured us that they had the skills and expertise to track down the perpetrators and recover our funds. This gave us a renewed sense of hope, something we hadn’t felt in months. What truly stood out during our experience with Rapid Digital Recovery was their dedication to the recovery process. The team went above and beyond, using sophisticated tracking tools and cyber forensics to gather critical information. Within a matter of weeks, they had successfully located the funds and traced the scam back to the fraudsters responsible. They worked with the authorities to ensure the criminals were held accountable for their actions. To our relief, the team at Rapid Digital Recovery was able to recover every single penny we had lost. The funds were returned in full, and the sense of closure we felt was invaluable. We couldn’t have imagined such a positive outcome in the early stages of our recovery journey, and we are deeply grateful for the work they did. If you ever find yourself in a similar situation, I highly recommend contacting Rapid Digital Recovery. Their expertise, transparency, and dedication to their clients make them the go-to choice for anyone seeking to recover lost cryptocurrency or funds. They truly gave us back our financial future.  
    • This is my first time modding anything, so maybe just skill issue. I'm using Forge 54.0.12 and Temurin 21.0.5+11-LTS I wanted to create a custom keybind and to check whether it works I'd like to send a chat message. I tried using Minecraft.getInstance().player.sendSystemMessage(Component.literal("test")); but IntelliJ couldnt resolve sendSystemMessage(...). Since I saw people using it in earlier versions, I tried the same thing with 1.20.6(- 50.1.0), where it works fine, now I can't figure out if this is intentional and whether there are other options for sending chat messages. On that note, is there more documentation than https://docs.minecraftforge.net/en/1.21.x/? It seems very incomplete compared to something like the Oracle Java docs
    • Hi, i'm having this error and I wanna fix it. we try: -Reload drivers -Eliminate .minecraft -Eliminate Java -Restart launcher -Verify if minecraft is using gpu -Mods  in .minecraft is empty -Install the latest and recomended version of forge idk what i have to do, help me pls. the lastest log is: https://mclo.gs/WAMao8x  
    • Read the FAQ, Rule #2. (https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/)  
  • Topics

×
×
  • Create New...

Important Information

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