My mob is suppose to spawn the heart particles when right clicked with fish but it doesn't seem to spawn them. I tested to see if the code was working and it does it just doesnt spawn the particles.
code:
public boolean interact(EntityPlayer par1EntityPlayer)
Particles only spawn on the client side, and your code is running on the server side (i.e. when the world is not remote). That's fine, and actually how it should be done, but you need to notify the client about what it needs to do.
Vanilla entities do this with a one-two punch:
this.worldObj.setEntityState(this, someByteFlag);
// this sends a packet to the client-side version of the entity with they byte flag
@Override
@SideOnly(Side.CLIENT)
public void handleHealthUpdate(byte flag) {
if (flag == someByteFlag) { // whatever byte you sent, e.g. 4
this.playTameEffect(true);
} else {
super.handleHealthUpdate(flag);
}
}
Take a look at villagers, wolves, golems - all of these use this combination for informing the client of some change of state that needs a visual representation.
My mob is suppose to spawn the heart particles when right clicked with fish but it doesn't seem to spawn them. I tested to see if the code was working and it does it just doesnt spawn the particles.
code:
public boolean interact(EntityPlayer par1EntityPlayer)
{
ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
if (itemstack != null && itemstack.getItem() == Items.fish)
{
if (!par1EntityPlayer.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
if (itemstack.stackSize <= 0)
{
}
if (!this.worldObj.isRemote)
{
// this.setHealth(20);
((EntityPlayer) par1EntityPlayer).addChatComponentMessage(new ChatComponentTranslation("tile.feeding.quetz", new Object[0]));
this.playTameEffect(true);
return true;
}
}
return true;
}
Vanilla entities do this with a one-two punch: Take a look at villagers, wolves, golems - all of these use this combination for informing the client of some change of state that needs a visual representation.
nevermind i fixed it myself but thank you