Jump to content

[1.7.10] Ticking Block Entity


Angelofdeath324

Recommended Posts

This is my first mod so don't assume I know anything! I am doing this to practice the java I learned off a free online tutorial.  I am trying to add another type of generator to Extra Utilities that runs off enchanted items but when I place it down i get this crash:

 

[19:18:05] [server thread/ERROR]: Encountered an unexpected exception

net.minecraft.util.ReportedException: Ticking block entity

at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:642) ~[MinecraftServer.class:?]

at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:547) ~[MinecraftServer.class:?]

at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:111) ~[bsx.class:?]

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:427) [MinecraftServer.class:?]

at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685) [?:?]

Caused by: java.lang.NullPointerException

at tileentity.TileEntityEnchantGenerator.getFuelBurn(TileEntityEnchantGenerator.java:42) ~[TileEntityEnchantGenerator.class:?]

at com.rwtema.extrautils.tileentity.generators.TileEntityGeneratorFurnace.burnItem(TileEntityGeneratorFurnace.java:52) ~[TileEntityGeneratorFurnace.class:?]

at com.rwtema.extrautils.tileentity.generators.TileEntityGeneratorFurnace.processInput(TileEntityGeneratorFurnace.java:39) ~[TileEntityGeneratorFurnace.class:?]

at com.rwtema.extrautils.tileentity.generators.TileEntityGenerator.func_145845_h(TileEntityGenerator.java:214) ~[TileEntityGenerator.class:?]

at net.minecraft.world.World.func_72939_s(World.java:1939) ~[ahb.class:?]

at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:489) ~[mt.class:?]

at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:636) ~[MinecraftServer.class:?]

... 4 more

 

 

Heres the code I wrote:

 

package tileentity;

 

import com.rwtema.extrautils.tileentity.generators.TileEntityGeneratorFurnace;

import net.minecraft.enchantment.EnchantmentHelper;

import net.minecraft.item.ItemStack;

import net.minecraft.nbt.NBTTagCompound;

 

public class TileEntityEnchantGenerator extends TileEntityGeneratorFurnace {

double curLevel;

public TileEntityEnchantGenerator() {

super();

this.curLevel=0;

}

 

public int getTotalEnchantmentLevel(ItemStack fuel){

if(fuel.isItemEnchanted()){

int sum =0;

for (int i = 0; i < 255 ;i++){

int l = EnchantmentHelper.getEnchantmentLevel(i, fuel);

sum = sum + l;

}

return sum;

}

else return 0;

}

@Override

 

public int transferLimit() {

 

    return 2000;

 

}

 

@Override

 

public void readFromNBT(final NBTTagCompound nbt) {

 

    super.readFromNBT(nbt);

 

    this.curLevel = nbt.getDouble("curLevel");

 

}

@Override

public double getFuelBurn(final ItemStack item){

if (item.isItemEnchanted()){

if (item.isItemStackDamageable()){

return item.getMaxDamage();

}

}

return 0.0;

}

@Override

public double getGenLevelForStack(final ItemStack item){

return 5*Math.pow(getTotalEnchantmentLevel(item),2);

}

 

@Override

 

public void writeToNBT(final NBTTagCompound nbt) {

 

    super.writeToNBT(nbt);

 

    nbt.setDouble("curLevel", this.curLevel);

 

}

 

@Override

 

public double genLevel() {

 

    return this.curLevel;

 

}

@Override

 

public void adjustGenLevel(final ItemStack item) {

 

    this.curLevel = this.getGenLevelForStack(item);

 

}

}

 

Can you please tell me where I went wrong? If you need me to paste any other classes just tell me and I will.

 

Link to comment
Share on other sites

1.7.10 is no longer supported by Forge.

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

 

1.12 -> 1.13 primer by williewillus.

 

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

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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