Jump to content

Recommended Posts

Posted

Decided to mess around making mods recently for some friends of mine. I created a custom class for food, and everything in it and everywhere else looks fine, but whenever I go to test it I get an error. It happens at the exact moment when a player finishes eating a food item. I'm at a loss here, so I though I'd give asking the community a shot.

 

---- Minecraft Crash Report ----

// Don't be sad, have a hug! <3

 

Time: 9/2/15 10:56 AM

Description: Ticking player

 

java.lang.NullPointerException: Ticking player

at com.yahoo.copysage123.galickgun.items.ItemFoodGalickGun.onFoodEaten(ItemFoodGalickGun.java:32)

at com.yahoo.copysage123.galickgun.items.ItemFoodGalickGun.onEaten(ItemFoodGalickGun.java:43)

at net.minecraft.item.ItemStack.onFoodEaten(ItemStack.java:169)

at net.minecraft.entity.player.EntityPlayer.onItemUseFinish(EntityPlayer.java:470)

at net.minecraft.entity.player.EntityPlayerMP.onItemUseFinish(EntityPlayerMP.java:970)

at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:281)

at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:330)

at net.minecraft.network.NetHandlerPlayServer.processPlayer(NetHandlerPlayServer.java:329)

at net.minecraft.network.play.client.C03PacketPlayer.processPacket(C03PacketPlayer.java:37)

at net.minecraft.network.play.client.C03PacketPlayer.processPacket(C03PacketPlayer.java:111)

at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241)

at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182)

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726)

at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)

at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)

at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)

 

 

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

---------------------------------------------------------------------------------------

 

-- Head --

Stacktrace:

at com.yahoo.copysage123.galickgun.items.ItemFoodGalickGun.onFoodEaten(ItemFoodGalickGun.java:32)

at com.yahoo.copysage123.galickgun.items.ItemFoodGalickGun.onEaten(ItemFoodGalickGun.java:43)

at net.minecraft.item.ItemStack.onFoodEaten(ItemStack.java:169)

at net.minecraft.entity.player.EntityPlayer.onItemUseFinish(EntityPlayer.java:470)

at net.minecraft.entity.player.EntityPlayerMP.onItemUseFinish(EntityPlayerMP.java:970)

at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:281)

 

-- Player being ticked --

Details:

Entity Type: null (net.minecraft.entity.player.EntityPlayerMP)

Entity ID: 325

Entity Name: Player670

Entity's Exact location: -224.12, 77.00, 221.73

Entity's Block location: World: (-225,77,221), Chunk: (at 15,4,13 in -15,13; contains blocks -240,0,208 to -225,255,223), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)

Entity's Momentum: 0.00, -0.08, 0.00

Stacktrace:

at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:330)

at net.minecraft.network.NetHandlerPlayServer.processPlayer(NetHandlerPlayServer.java:329)

at net.minecraft.network.play.client.C03PacketPlayer.processPacket(C03PacketPlayer.java:37)

at net.minecraft.network.play.client.C03PacketPlayer.processPacket(C03PacketPlayer.java:111)

at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241)

 

-- Ticking connection --

Details:

Connection: net.minecraft.network.NetworkManager@498e8d96

Stacktrace:

at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182)

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726)

at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)

at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)

at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)

 

-- System Details --

Details:

Minecraft Version: 1.7.10

Operating System: Windows 7 (amd64) version 6.1

Java Version: 1.8.0_60, Oracle Corporation

Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation

Memory: 137296808 bytes (130 MB) / 490209280 bytes (467 MB) up to 917504000 bytes (875 MB)

JVM Flags: 0 total;

AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used

IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94

FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1448 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.05} [Minecraft Coder Pack] (minecraft.jar)

UCHIJAAAA FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1448-1.7.10.jar)

UCHIJAAAA Forge{10.13.4.1448} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1448-1.7.10.jar)

UCHIJAAAA galickgun{1.12} [Galick Gun] (bin)

GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.

Profiler Position: N/A (disabled)

Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used

Player Count: 1 / 8; [EntityPlayerMP['Player670'/325, l='New World', x=-224.12, y=77.00, z=221.73]]

Type: Integrated Server (map_client.txt)

Is Modded: Definitely; Client brand changed to 'fml,forge'

Posted

package com.yahoo.copysage123.galickgun.items;

 

import com.yahoo.copysage123.galickgun.Reference;

 

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.ItemFood;

import net.minecraft.item.ItemStack;

import net.minecraft.potion.PotionEffect;

import net.minecraft.world.World;

 

public class ItemFoodGalickGun extends ItemFood {

private PotionEffect[] effects;

//constructor w/ potion effects

//Potion effect example (to be added in item creation, in ModItems:

//.addPotionEffect(new PotionEffect(Potion.regeneration.id, 200, 4), 0.5)

public ItemFoodGalickGun(String name, int healAmount, float saturationModifier, boolean wolvesFavorite, PotionEffect... effects) {

    super(healAmount, saturationModifier, wolvesFavorite);

    this.setUnlocalizedName(name);

    this.setTextureName(Reference.MODID + ":" + name);

    this.effects = effects;

}

//constructor w/o potion effects

public ItemFoodGalickGun(String name, int healAmount, float saturationModifier, boolean wolvesFavorite) {

    super(healAmount, saturationModifier, wolvesFavorite);

    this.setUnlocalizedName(name);

    this.setTextureName(Reference.MODID + ":" + name);

}

 

@Override

public void onFoodEaten(ItemStack stack, World world, EntityPlayer player) {

super.onFoodEaten(stack, world, player);

for (int i = 0; i < effects.length; i ++) {

        if (!world.isRemote && effects != null && effects.getPotionID() > 0)

            player.addPotionEffect(new PotionEffect(this.effects.getPotionID(), this.effects.getDuration(), this.effects.getAmplifier(), this.effects.getIsAmbient()));

    }

}

 

}

Posted

Turns out I was being dumb haha. I put an if statement around the for loop that focused on potion effects, making sure to check that the effects array was filled, and that fixed it. I'll leave this here then for anyone else who might have a similar dumb moment.

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.