saxon564 Posted May 2, 2014 Posted May 2, 2014 I am trying to change some mobs to "another" mob and i keep getting a ghost mob and the new one. I have used this code before and did not have this problem so i cannot figure this out. here is the code im using: private int loc = 0; public void onLivingUpdate() { super.onLivingUpdate(); if (loc == 0) { loc += 1; if (Loader.isModLoaded("mochickens")) { System.out.println("Creeper Chicken Mob: X=" + this.posX + " Y=" + this.posY + " Z=" + this.posZ + " attempting to change"); try { EntityLiving newEntity = (EntityLiving) EntityCreeperChicken.class .getDeclaredConstructor(new Class[] { World.class }) .newInstance(new Object[] { this.worldObj }); if (this.isChild()) { ((EntityAgeable) newEntity).setGrowingAge(this .getGrowingAge()); } newEntity.setLocationAndAngles(this.posX, this.posY + 0.5D, this.posZ, this.rotationPitch, this.rotationYaw); if (this.isTamed()) { ((EntityCreeperChicken) newEntity).setTamed(true); ((EntityTameable) newEntity).setOwner(this .getOwnerName()); } this.worldObj.spawnEntityInWorld(newEntity); this.setDead(); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchMethodException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } Could any possibly point out why this is happening? Quote
saxon564 Posted May 2, 2014 Author Posted May 2, 2014 ok, thank you. I should have thought of that. its works right now. Working Code: private int loc = 0; public void onLivingUpdate() { super.onLivingUpdate(); if ((loc == 0) && (!this.worldObj.isRemote)) { loc += 1; if (Loader.isModLoaded("mochickens")) { System.out.println("Creeper Chicken Mob: X=" + this.posX + " Y=" + this.posY + " Z=" + this.posZ + " attempting to change"); try { EntityLiving newEntity = (EntityLiving) EntityCreeperChicken.class .getDeclaredConstructor(new Class[] { World.class }) .newInstance(new Object[] { this.worldObj }); if (this.isChild()) { ((EntityAgeable) newEntity).setGrowingAge(this .getGrowingAge()); } newEntity.setLocationAndAngles(this.posX, this.posY + 0.5D, this.posZ, this.rotationPitch, this.rotationYaw); if (this.isTamed()) { ((EntityCreeperChicken) newEntity).setTamed(true); ((EntityTameable) newEntity).setOwner(this .getOwnerName()); } this.worldObj.spawnEntityInWorld(newEntity); this.setDead(); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchMethodException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } Quote
Recommended Posts
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.