Jump to content

Recommended Posts

Posted

 @SubscribeEvent//오른쪽 클릭했을때 이벤트
public void onEntityRightClicked(EntityInteractEvent e)
{
	 EntityCow dead;
	 if (e.target instanceof EntityPig)
	 {
		 EntityPig pig = (EntityPig) e.target;
		 double x = pig.posX;
		 double y = pig.posY;
		 double z = pig.posZ;
		 dead = new EntityCow(e.target.worldObj);
		 dead.copyLocationAndAnglesFrom(pig);
		// dead.setPosition(x,y,z);
		 System.out.println(dead.getCommandSenderName() + dead.posX + ","+ dead.posY + "," + dead.posZ);
		 pig.setDead();
	 }
}

why not working my code..?

pig delete working. buy, not create cow entity..

Posted

Please learn more Java.

 

Making "new Cow" != "spawn Cow". You need to call World#spawnEntityInWorld.

 

Clean up useless code, learn to code properly.

1.7.10 is no longer supported by forge, you are on your own.

Posted

What Ernio was so nicely trying to explain is that creating the new instance of EntityCow simply constructs the data for the cow in memory, but doesn't actually add it to the world to participate in the game. To do that, you need to spawn the cow in the world, and furthermore make sure the position is correct.

 

Note also that you must spawn the cow on the server side, otherwise it creates sort of a "ghost" entity that will look right briefly but then do weird stuff.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Please learn more Java.

 

Making "new Cow" != "spawn Cow". You need to call World#spawnEntityInWorld.

 

Clean up useless code, learn to code properly.

 

thanks bro.

Posted

What Ernio was so nicely trying to explain is that creating the new instance of EntityCow simply constructs the data for the cow in memory, but doesn't actually add it to the world to participate in the game. To do that, you need to spawn the cow in the world, and furthermore make sure the position is correct.

 

Note also that you must spawn the cow on the server side, otherwise it creates sort of a "ghost" entity that will look right briefly but then do weird stuff.

 

Oh! Good Answer. This was perfectly understood. Thanks bro.

 

solve as next:

                //param is Server World.

EntityZombie zombie = new EntityZombie( MinecraftServer.getServer().getEntityWorld());

//First server

MinecraftServer.getServer().getEntityWorld().spawnEntityInWorld(zombie);

                //Last Client Create.

e.entityPlayer.getEntityWorld().spawnEntityInWorld(zombie);

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.