Jump to content

Recommended Posts

Posted

So, I looked up a tutorial, and it said that to replace an entity with another one on spawn, I had to run an event handler. I programmed my event handler the way he did, and it didn't work. I then saw someone else's code and it worked for them but was different, so I tried that code. So far, neither works, and the second causes errors while the first just outright doesn't work. Can anyone help me figure out why?

 

Original Code:

package craftygirls.core.events;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import craftygirls.core.entity.EntityNeola;
import craftygirls.core.entity.NeolaTameable;
import net.minecraftforge.event.entity.living.LivingSpawnEvent;

public class CraftyEventHandling {

@SubscribeEvent
public void onEntityLivingSpawn(LivingSpawnEvent event) {
	if (!event.world.isRemote) {
		if (event.entityLiving instanceof EntityNeola) {
			EntityNeola oldNeola = (EntityNeola)event.entityLiving;

			if (oldNeola.getCanSpawnHere()) {
				NeolaTameable newNeola = new NeolaTameable(event.world);
				newNeola.setLocationAndAngles(oldNeola.posX, oldNeola.posY, oldNeola.posZ, oldNeola.rotationYaw, oldNeola.rotationPitch);
				event.world.spawnEntityInWorld(newNeola);
				oldNeola.setDead();
			}
		}
	}
}

}

 

Second Code (that errors):

package craftygirls.core.events;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import craftygirls.core.entity.EntityNeola;
import craftygirls.core.entity.NeolaTameable;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.living.LivingSpawnEvent;

public class CraftyEventHandling {

@SubscribeEvent
public void onEntityLivingSpawn(LivingSpawnEvent event) {
	if (!event.entity.worldObj.isRemote && event.entityLiving instanceof EntityNeola) {
			EntityNeola oldNeola = (EntityNeola)event.entity;
			World world = oldNeola.worldObj;
				NeolaTameable newNeola = new NeolaTameable(world);
				newNeola.setPosition(event.entity.posX, event.entity.posY, event.entity.posZ);
				event.world.spawnEntityInWorld(newNeola);
				oldNeola.setDead();
	}
}
}

Error with code:

[01:17:34] [Client thread/FATAL]: Unreported exception thrown!
java.lang.NullPointerException
at net.minecraft.client.network.NetHandlerPlayClient.handleSpawnMob(NetHandlerPlayClient.java:853) ~[NetHandlerPlayClient.class:?]
at net.minecraft.network.play.server.S0FPacketSpawnMob.processPacket(S0FPacketSpawnMob.java:129) ~[s0FPacketSpawnMob.class:?]
at net.minecraft.network.play.server.S0FPacketSpawnMob.processPacket(S0FPacketSpawnMob.java:222) ~[s0FPacketSpawnMob.class:?]
at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:232) ~[NetworkManager.class:?]
at net.minecraft.client.multiplayer.PlayerControllerMP.updateController(PlayerControllerMP.java:321) ~[PlayerControllerMP.class:?]
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1647) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:994) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:910) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:112) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_51]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_51]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_51]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_51]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) [launchwrapper-1.9.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.9.jar:?]
---- Minecraft Crash Report ----
// I'm sorry, Dave.

Time: 4/24/14 1:17 AM
Description: Unexpected error

java.lang.NullPointerException: Unexpected error
at net.minecraft.client.network.NetHandlerPlayClient.handleSpawnMob(NetHandlerPlayClient.java:853)
at net.minecraft.network.play.server.S0FPacketSpawnMob.processPacket(S0FPacketSpawnMob.java:129)
at net.minecraft.network.play.server.S0FPacketSpawnMob.processPacket(S0FPacketSpawnMob.java:222)
at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:232)
at net.minecraft.client.multiplayer.PlayerControllerMP.updateController(PlayerControllerMP.java:321)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1647)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:994)
at net.minecraft.client.Minecraft.run(Minecraft.java:910)
at net.minecraft.client.main.Main.main(Main.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)


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

-- Head --
Stacktrace:
at net.minecraft.client.network.NetHandlerPlayClient.handleSpawnMob(NetHandlerPlayClient.java:853)
at net.minecraft.network.play.server.S0FPacketSpawnMob.processPacket(S0FPacketSpawnMob.java:129)
at net.minecraft.network.play.server.S0FPacketSpawnMob.processPacket(S0FPacketSpawnMob.java:222)
at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:232)
at net.minecraft.client.multiplayer.PlayerControllerMP.updateController(PlayerControllerMP.java:321)

-- Affected level --
Details:
Level name: MpServer
All players: 1 total; [EntityClientPlayerMP['Player763'/170, l='MpServer', x=-176.53, y=87.23, z=362.89]]
Chunk stats: MultiplayerChunkCache: 314, 314
Level seed: 0
Level generator: ID 00 - default, ver 1. Features enabled: false
Level generator options: 
Level spawn location: World: (8,64,256), Chunk: (at 8,4,0 in 0,16; contains blocks 0,0,256 to 15,255,271), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Level time: 6049 game time, 6049 day time
Level dimension: 0
Level storage version: 0x00000 - Unknown?
Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
Forced entities: 75 total; [EntityChicken['Chicken'/0, l='MpServer', x=-191.50, y=67.00, z=384.50], EntityChicken['Chicken'/1, l='MpServer', x=-190.47, y=81.00, z=409.44], EntityChicken['Chicken'/2, l='MpServer', x=-185.61, y=78.00, z=398.56], EntityChicken['Chicken'/3, l='MpServer', x=-185.19, y=76.00, z=422.56], EntityChicken['Chicken'/4, l='MpServer', x=-186.59, y=76.00, z=422.59], EntitySkeleton['Skeleton'/5, l='MpServer', x=-180.50, y=62.00, z=443.50], EntitySkeleton['Skeleton'/6, l='MpServer', x=-187.69, y=60.00, z=443.50], EntityBat['Bat'/1368, l='MpServer', x=-240.63, y=35.46, z=398.08], EntityZombie['Zombie'/7, l='MpServer', x=-181.50, y=62.00, z=445.50], EntityBat['Bat'/1364, l='MpServer', x=-253.63, y=35.10, z=402.75], EntitySkeleton['Skeleton'/14, l='MpServer', x=-164.47, y=64.00, z=373.16], EntitySkeleton['Skeleton'/15, l='MpServer', x=-160.50, y=63.00, z=374.50], EntityCreeper['Creeper'/21, l='MpServer', x=-149.50, y=58.00, z=431.50], EntityZombie['Zombie'/20, l='MpServer', x=-151.84, y=64.00, z=374.38], EntitySpider['Spider'/23, l='MpServer', x=-140.22, y=24.00, z=427.09], EntityChicken['Chicken'/22, l='MpServer', x=-159.47, y=70.00, z=422.53], EntitySkeleton['Skeleton'/25, l='MpServer', x=-138.50, y=24.00, z=432.50], EntityChicken['Chicken'/24, l='MpServer', x=-123.63, y=71.00, z=432.47], EntityChicken['Chicken'/27, l='MpServer', x=-141.58, y=78.00, z=440.06], EntitySpider['Spider'/26, l='MpServer', x=-136.50, y=24.00, z=436.50], EntitySpider['Spider'/29, l='MpServer', x=-117.50, y=42.00, z=384.50], EntityChicken['Chicken'/28, l='MpServer', x=-129.53, y=71.00, z=437.47], EntitySkeleton['Skeleton'/30, l='MpServer', x=-125.94, y=13.00, z=410.47], EntityCreeper['Creeper'/1609, l='MpServer', x=-253.50, y=30.00, z=423.50], EntityCreeper['Creeper'/32, l='MpServer', x=-115.69, y=19.00, z=411.34], EntityCreeper['Creeper'/33, l='MpServer', x=-124.41, y=14.00, z=411.00], EntityZombie['Zombie'/38, l='MpServer', x=-106.34, y=33.00, z=335.41], EntityCreeper['Creeper'/39, l='MpServer', x=-124.66, y=29.00, z=341.95], EntitySheep['Sheep'/37, l='MpServer', x=-102.88, y=67.00, z=312.28], EntityBat['Bat'/784, l='MpServer', x=-113.66, y=32.10, z=350.75], EntitySkeleton['Skeleton'/42, l='MpServer', x=-103.50, y=35.00, z=364.50], EntitySkeleton['Skeleton'/43, l='MpServer', x=-107.50, y=35.00, z=364.50], EntitySheep['Sheep'/41, l='MpServer', x=-101.34, y=66.00, z=322.59], EntityZombie['Zombie'/46, l='MpServer', x=-109.50, y=36.00, z=388.50], EntityZombie['Zombie'/47, l='MpServer', x=-105.50, y=32.00, z=384.50], EntityZombie['Zombie'/44, l='MpServer', x=-106.50, y=32.00, z=383.50], EntityChicken['Chicken'/50, l='MpServer', x=-105.56, y=86.00, z=428.66], EntityChicken['Chicken'/49, l='MpServer', x=-107.47, y=86.00, z=431.47], EntityBat['Bat'/773, l='MpServer', x=-245.53, y=46.00, z=426.75], EntityZombie['Zombie'/48, l='MpServer', x=-107.50, y=32.00, z=385.50], EntityZombie['Zombie'/1853, l='MpServer', x=-118.50, y=21.00, z=312.50], EntityCreeper['Creeper'/1855, l='MpServer', x=-115.53, y=24.00, z=320.34], EntityBat['Bat'/883, l='MpServer', x=-117.00, y=24.00, z=333.55], EntityZombie['Zombie'/1854, l='MpServer', x=-120.50, y=21.00, z=310.50], EntitySkeleton['Skeleton'/1029, l='MpServer', x=-137.97, y=12.00, z=414.59], EntityBat['Bat'/871, l='MpServer', x=-245.46, y=32.00, z=435.40], EntityBat['Bat'/872, l='MpServer', x=-244.02, y=35.00, z=444.80], EntityCreeper['Creeper'/1591, l='MpServer', x=-162.53, y=69.28, z=337.91], EntityZombie['Zombie'/851, l='MpServer', x=-114.50, y=42.00, z=385.50], EntityBat['Bat'/2303, l='MpServer', x=-247.15, y=16.84, z=303.65], EntityZombie['Zombie'/850, l='MpServer', x=-114.50, y=42.00, z=387.50], EntityBat['Bat'/2300, l='MpServer', x=-225.60, y=23.51, z=309.68], EntityZombie['Zombie'/849, l='MpServer', x=-119.50, y=42.00, z=384.50], EntityZombie['Zombie'/852, l='MpServer', x=-116.50, y=42.00, z=382.50], EntitySpider['Spider'/2281, l='MpServer', x=-157.87, y=63.00, z=380.07], EntityZombie['Zombie'/2032, l='MpServer', x=-102.50, y=19.00, z=417.50], EntityCreeper['Creeper'/2034, l='MpServer', x=-104.25, y=18.00, z=413.50], EntityBat['Bat'/2305, l='MpServer', x=-235.63, y=18.65, z=291.13], EntityChicken['Chicken'/186, l='MpServer', x=-223.84, y=77.00, z=412.41], EntityChicken['Chicken'/187, l='MpServer', x=-223.53, y=76.00, z=407.97], EntityChicken['Chicken'/184, l='MpServer', x=-222.50, y=80.00, z=378.50], EntityChicken['Chicken'/185, l='MpServer', x=-222.50, y=80.00, z=378.50], EntityChicken['Chicken'/190, l='MpServer', x=-202.44, y=62.52, z=376.56], EntityChicken['Chicken'/191, l='MpServer', x=-192.50, y=66.00, z=383.50], EntityChicken['Chicken'/188, l='MpServer', x=-222.50, y=81.00, z=412.50], EntityChicken['Chicken'/189, l='MpServer', x=-222.50, y=81.00, z=412.50], EntityChicken['Chicken'/178, l='MpServer', x=-225.91, y=81.00, z=375.56], EntityCreeper['Creeper'/2365, l='MpServer', x=-247.50, y=44.00, z=422.50], EntityChicken['Chicken'/183, l='MpServer', x=-220.50, y=80.00, z=378.50], EntityCreeper['Creeper'/2366, l='MpServer', x=-243.50, y=44.00, z=424.50], EntitySkeleton['Skeleton'/1433, l='MpServer', x=-125.31, y=29.00, z=343.60], EntitySkeleton['Skeleton'/193, l='MpServer', x=-192.50, y=39.00, z=425.50], EntityChicken['Chicken'/192, l='MpServer', x=-193.50, y=70.00, z=382.50], EntityClientPlayerMP['Player763'/170, l='MpServer', x=-176.53, y=87.23, z=362.89], EntityBat['Bat'/1456, l='MpServer', x=-243.75, y=26.98, z=410.41]]
Retry entities: 0 total; []
Server brand: fml,forge
Server type: Integrated singleplayer server
Stacktrace:
at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:412)
at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2521)
at net.minecraft.client.Minecraft.run(Minecraft.java:939)
at net.minecraft.client.main.Main.main(Main.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

-- 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(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 745461440 bytes (710 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 9299 (520744 bytes; 0 MB) allocated, 2 (112 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95
FML: MCP v9.01-pre FML v7.2.156.1060 Minecraft Forge 10.12.1.1060 7 mods loaded, 7 mods active
mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
FML{7.2.156.1060} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.1.1060.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Forge{10.12.1.1060} [Minecraft Forge] (forgeSrc-1.7.2-10.12.1.1060.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
sureencore{V1.0} [sureen Core] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
craftygirls{Alpha v0.6} [The Crafty Girls Core Mod] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
gemsmod{Alpha v0.1} [Gems Mod] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
youtubers{Alpha v0.1} [Youtubers Mod] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Launched Version: 1.6
LWJGL: 2.9.0
OpenGL: GeForce GT 635/PCIe/SSE2 GL version 4.3.0, NVIDIA Corporation
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Packs: []
Current Language: English (US)
Profiler Position: N/A (disabled)
Vec3 Pool Size: 1787 (100072 bytes; 0 MB) allocated, 22 (1232 bytes; 0 MB) used
Anisotropic Filtering: Off (1)
#@!@# Game crashed! Crash report saved to: #@!@# C:\Users\Sureen Ink\Desktop\Minecraft Mods\forge-1.7.2-1060\eclipse\.\crash-reports\crash-2014-04-24_01.17.34-client.txt
AL lib: (EE) alc_cleanup: 1 device not closed

Posted

Well, I can't seem to spawn in tameable entities via the regular code because it's hard coded in. Someone said the only way to do that is to learn ASM and I can't find anything on that (nor do I even know what it means...which makes it hard to look for). So, I found a tutorial on how to spawn in entities the game won't normally let you spawn in. What this does is make it so that whenever an entity that I want to be tameable is spawned it, it spawns in the tameable version on top of the non-tameable version, then removes the non-tameable version.

Posted

I would say the "original code" stuff is a lot better.

 

if (oldNeola.getCanSpawnHere())

Did you override that method in EntityNeola ?

What is the parent class of EntityNeola and NeolaTameable ?

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



×
×
  • Create New...

Important Information

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