Posted April 24, 201411 yr So i tried to make a alloy smelter and when i only put something in the one slot it crashes ---- Minecraft Crash Report ---- // Why did you do that? Time: 4/23/14 8:49 PM Description: Ticking block entity java.lang.NullPointerException: Ticking block entity at com.professorvennie.tileEntity.TileEntityIronOxideAlloy.getresult(TileEntityIronOxideAlloy.java:271) at com.professorvennie.tileEntity.TileEntityIronOxideAlloy.canGrinde(TileEntityIronOxideAlloy.java:240) at com.professorvennie.tileEntity.TileEntityIronOxideAlloy.updateEntity(TileEntityIronOxideAlloy.java:207) at net.minecraft.world.World.updateEntities(World.java:2148) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:536) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:740) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:651) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:120) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:530) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:788) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at com.professorvennie.tileEntity.TileEntityIronOxideAlloy.getresult(TileEntityIronOxideAlloy.java:271) at com.professorvennie.tileEntity.TileEntityIronOxideAlloy.canGrinde(TileEntityIronOxideAlloy.java:240) at com.professorvennie.tileEntity.TileEntityIronOxideAlloy.updateEntity(TileEntityIronOxideAlloy.java:207) -- Block entity being ticked -- Details: Name: null // com.professorvennie.tileEntity.TileEntityIronOxideAlloy Block type: ID #191 (tile.ironOxideAlloyIdle // com.professorvennie.block.machines.ironOxideAlloy) Block data value: 4 / 0x4 / 0b0100 Block location: World: (1009,4,-137), Chunk: (at 1,0,7 in 63,-9; contains blocks 1008,0,-144 to 1023,255,-129), Region: (1,-1; contains chunks 32,-32 to 63,-1, blocks 512,0,-512 to 1023,255,-1) Actual block type: ID #192 (tile.ironOxideAlloyActive // com.professorvennie.block.machines.ironOxideAlloy) Actual block data value: 4 / 0x4 / 0b0100 Stacktrace: at net.minecraft.world.World.updateEntities(World.java:2148) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:536) -- Affected level -- Details: Level name: Copy of New World All players: 1 total; [EntityPlayerMP['Player463'/86, l='Copy of New World', x=1007.84, y=4.00, z=-136.43]] Chunk stats: ServerChunkCache: 625 Drop: 0 Level seed: 3993669303325543658 Level generator: ID 01 - flat, ver 0. Features enabled: true Level generator options: Level spawn location: World: (1010,4,-135), Chunk: (at 2,0,9 in 63,-9; contains blocks 1008,0,-144 to 1023,255,-129), Region: (1,-1; contains chunks 32,-32 to 63,-1, blocks 512,0,-512 to 1023,255,-1) Level time: 131410 game time, 73565 day time Level dimension: 0 Level storage version: 0x04ABD - Anvil Level weather: Rain time: 25227 (now: false), thunder time: 111332 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true Stacktrace: at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:740) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:651) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:120) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:530) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:788) -- System Details -- Details: Minecraft Version: 1.7.2 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.7.0_51, Oracle Corporation Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 850582768 bytes (811 MB) / 1056309248 bytes (1007 MB) up to 1056309248 bytes (1007 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 1852 (103712 bytes; 0 MB) allocated, 1566 (87696 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP v9.01-pre FML v7.2.129.1047 Minecraft Forge 10.12.0.1047 4 mods loaded, 4 mods active mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available FML{7.2.129.1047} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.0.1047.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Forge{10.12.0.1047} [Minecraft Forge] (forgeSrc-1.7.2-10.12.0.1047.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available ef{0.1.0} [Extra Food] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Profiler Position: N/A (disabled) Vec3 Pool Size: 246 (13776 bytes; 0 MB) allocated, 170 (9520 bytes; 0 MB) used Player Count: 1 / 8; [EntityPlayerMP['Player463'/86, l='Copy of New World', x=1007.84, y=4.00, z=-136.43]] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge' Here is my tileentity class package com.professorvennie.tileEntity; import java.util.Random; import com.professorvennie.block.EFBlock; import com.professorvennie.block.machines.ironOxideAlloy; import com.professorvennie.block.machines.ironOxideGrinder; import com.professorvennie.item.EFitem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.Constants; import net.minecraftforge.oredict.OreDictionary; public class TileEntityIronOxideAlloy extends TileEntity implements ISidedInventory{ private String localizedName; private Random rand = new Random(); private static final int[] slots_top = new int[]{0}; private static final int[] slots_bottom = new int[]{2, 1}; private static final int[] slots_sides = new int[]{1}; private ItemStack[] slots = new ItemStack[4]; public int GrindeSpeed = 80; public int power; public final int maxpower = 10000; public int currentItemBurnTime; public int cookTime; private int smeltItem; public int getsizeInventory(){ return this.slots.length; } @Override public ItemStack getStackInSlot(int var1) { return this.slots[var1]; } @Override public ItemStack decrStackSize(int var1, int var2) { if(this.slots[var1] != null){ ItemStack itemstack; if(this.slots[var1].stackSize <= var2){ itemstack = this.slots[var1]; this.slots[var1] = null; return itemstack; }else{ itemstack = this.slots[var1].splitStack(var2); if(this.slots[var1].stackSize == 0){ this.slots[var1] = null; } return itemstack; } } return null; } @Override public ItemStack getStackInSlotOnClosing(int var1) { if(this.slots[var1] != null){ ItemStack itemstack = this.slots[var1]; this.slots[var1] = null; return itemstack; } return null; } @Override public void setInventorySlotContents(int var1, ItemStack var2) { this.slots[var1]= var2; if(var2 != null && var2.stackSize > this.getInventoryStackLimit()){ var2.stackSize = this.getInventoryStackLimit(); } } @Override public String getInventoryName() { // TODO Auto-generated method stub return null; } @Override public boolean hasCustomInventoryName() { // TODO Auto-generated method stub return false; } @Override public int getInventoryStackLimit() { return 64; } public void readFromNBT(NBTTagCompound nbt){ super.readFromNBT(nbt); NBTTagList list = nbt.getTagList("items", Constants.NBT.TAG_COMPOUND); this.slots = new ItemStack[this.getsizeInventory()]; for(int i = 0; i < list.tagCount(); i ++){ NBTTagCompound compound = list.getCompoundTagAt(i); int j = compound.getByte("slot") & 0xff; if(j >= 0 && j < this.slots.length){ this.slots[j] = ItemStack.loadItemStackFromNBT(compound); } } this.power = (int)nbt.getShort("burntime"); this.cookTime = (int)nbt.getShort("cooktime"); this.currentItemBurnTime = (int)nbt.getShort("currentItemBurnTime"); if(nbt.hasKey("customname")){ this.localizedName = nbt.getString("customname"); } } public void writeToNBT(NBTTagCompound nbt){ super.writeToNBT(nbt); nbt.setShort("burntime", (short) this.power); nbt.setShort("cooktime", (short) this.cookTime); nbt.setShort("currentItemBurnTime", (short) this.currentItemBurnTime); NBTTagList list = new NBTTagList(); for(int i = 0; i < this.slots.length; i ++){ if(this.slots[i] != null){ NBTTagCompound compound = new NBTTagCompound(); compound.setByte("slot", (byte) i); this.slots[i].writeToNBT(compound); list.appendTag(compound); } } nbt.setTag("items", list); if(this.isInvNameLocalized()){ nbt.setString("customname", this.localizedName); } } @Override public boolean isUseableByPlayer(EntityPlayer var1) { return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : var1.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64D; } @Override public void openInventory() { // TODO Auto-generated method stub } @Override public void closeInventory() { // TODO Auto-generated method stub } public boolean hasPower(){ if(this.power> 0) return true; return false; } public boolean isGrinding(){ return this.cookTime > 0; } public void updateEntity(){ boolean flag = this.power > 0; boolean flag1 = false; if (hasPower() && isGrinding()){ this.power--; } if (!this.worldObj.isRemote){ if (this.power < this.maxpower && this.getItemPower(this.slots[1]) > 0){ this.power += getItemPower(this.slots[1]); flag1 = true; if (this.slots[1] != null){ this.slots[1].stackSize--; if (this.slots[1].stackSize == 0){ this.slots[1] = this.slots[1].getItem().getContainerItem(slots[1]); } } } if (this.hasPower() && this.canGrinde()) { this.cookTime++; if (this.cookTime == this.GrindeSpeed) { this.cookTime = 0; this.GrindItem(); flag1 = true; } } else { this.cookTime = 0; } if(flag != this.hasPower()){ flag1 = true; ironOxideAlloy.updateGrinderBlockState(this.power > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord); } } if(flag1){ this.markDirty(); } } private boolean canGrinde(){ if(this.slots[0] == null){ return false; }else{ ItemStack itemstack = getresult(this.slots[0], this.slots[3]); if(itemstack == null) return false; if(this.slots[2] == null) return true; if(!this.slots[2].isItemEqual(itemstack)) return false; int result = this.slots[2].stackSize + itemstack.stackSize; return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize()); } } public ItemStack getresult(ItemStack itemstack, ItemStack itemstack2) { // itemstack = getStackInSlot(0); // itemstack2 = getStackInSlot(3); // if(itemstack.getUnlocalizedName().equals(Items.iron_ingot.getUnlocalizedName())){ // if(itemstack2.getUnlocalizedName().equals(EFitem.saltingot.getUnlocalizedName())){ // return new ItemStack(EFitem.ironoxide); // } // else // if(itemstack.getUnlocalizedName().equals(EFitem.saltingot.getUnlocalizedName())){ // if(itemstack2.getUnlocalizedName().equals(Items.iron_ingot.getUnlocalizedName())){ // return new ItemStack(EFitem.ironoxide, 2); // } // } // else // return null; // } int i = itemstack.getItem().getIdFromItem(itemstack.getItem()); int j = itemstack2.getItem().getIdFromItem(itemstack2.getItem()); if (i == Items.iron_ingot.getIdFromItem(Items.iron_ingot) && j == EFitem.saltingot.getIdFromItem(EFitem.saltingot)) return new ItemStack(EFitem.ironoxide, 2); if (i == EFitem.saltingot.getIdFromItem(EFitem.saltingot) && j == Items.iron_ingot.getIdFromItem(Items.iron_ingot)) return new ItemStack(EFitem.ironoxide, 2); return null; } public void GrindItem(){ if(this.canGrinde()){ ItemStack itemstack = this.getresult(this.slots[0], this.slots[3]); if (this.slots[2] == null) { this.slots[2] = itemstack.copy(); } else if (this.slots[2].isItemEqual(itemstack)) { this.slots[2].stackSize += itemstack.stackSize; } this.slots[0].stackSize--; this.slots[3].stackSize--; if (this.slots[0].stackSize <= 0) { this.slots[0] = null; } } } public static int getItemPower(ItemStack itemstack){ if(itemstack == null){ return 0; }else{ int i = itemstack.getItem().getIdFromItem(itemstack.getItem()); if(i == EFitem.saltcyrstals.getIdFromItem(EFitem.saltcyrstals)) return 100; return 0; } } public static boolean isItemPower(ItemStack itemstack){ return getItemPower(itemstack) > 0; } @Override public boolean isItemValidForSlot(int var1, ItemStack var2) { return var1 == 2 ? false : (var1 == 1 ? isItemPower(var2) : true); } @Override public int[] getAccessibleSlotsFromSide(int var1) { return var1 == 0 ? slots_bottom : (var1 == 1 ? slots_top : slots_sides); } @Override public boolean canInsertItem(int var1, ItemStack var2, int var3) { return this.isItemValidForSlot(var1, var2); } @Override public boolean canExtractItem(int var1, ItemStack var2, int var3) { return var3 != 0 || var1 != 1 || var2.getItem() == Items.bucket; } public int getCookProgressScaled(int par1) { return this.cookTime * par1 / this.GrindeSpeed; } public int getPowerRemainingScaled(int par1){ return this.power * par1 / this.maxpower; } public boolean isInvNameLocalized() { return false; } public String getInvName() { return "container.IronOxideAlloy"; } public void setGuiDisplayName(String displayName) { } @Override public int getSizeInventory() { return 0; } public int getCurrentCharge() { return this.power; } public int getChargeCapcity() { return this.maxpower; } }
April 24, 201411 yr Adding some null checks in getResult should work. Creator of Jobo's ModLoader If I helped you could you please click the thank you button and applaud my karma.
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.