I want to spawn some fire particles in my block's onBlockActivated method, when a variable in my tile entity is the right value (basically, you have to "activate" the block 3 times within a small window of time before the particles will spawn, and I'm saving the number of times and time elapsed in my tile entity). I have read about a million posts on this, and everything says that you should be able to spawn vanilla particles from the server. I swear I have seen examples of other mods doing this, too, but I can't get it to work. I know the code is running, because the println statement fires.
I also tried sending a packet, but it didn't work. I didn't include that code since I don't really think I should have to do that anyway. Please correct me if I'm wrong.
I also tried spawning the particles on the client, but even after grabbing a copy of my tile entity from the BlockPos parameter, I can't seem to access the variables (they don't change like they should).
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
EnumCampfireState campfireState = state.getValue(CAMPFIRE_STATE);
TileEntity tileEntity = world.getTileEntity(pos);
int stokeTime = ((PrimalTileEntityCampfire) tileEntity).tinderStokeTime;
int timesBlown = ((PrimalTileEntityCampfire) tileEntity).tinderTimesBlown;
if (world.isRemote) // client
{
// do stuff
}
else // server
{
if (heldItem == null && campfireState == EnumCampfireState.TINDER_STOKED)
{
if (stokeTime < 40)
{
((PrimalTileEntityCampfire) tileEntity).tinderStokeTime = 60;
((PrimalTileEntityCampfire) tileEntity).tinderTimesBlown += 1;
PrimalPacketHandler.INSTANCE.sendTo(new PrimalCampfirePacket(player, 0, pos), (EntityPlayerMP) player);
}
if (timesBlown > 3)
{
System.out.println("Spawning particle");
world.spawnParticle(EnumParticleTypes.FLAME, (double) pos.getX(), (double) pos.getY(), (double) pos.getZ(), 0.0D, 0.0D, 0.0D, new int[0]);
}
}
}
return true;
}