Posted July 25, 20169 yr I want to spawn particles based on a given item stack ( EnumParticleTypes.ITEM_CRACK / EnumParticleTypes.BLOCK_CRACK ), trouble is, particles are client sided and the places in the code where I want the effects are all server sided. I created a method to spawn them so I didn't have to type out the code over and over, but that doesn't help the fact that it's the wrong side. I'm aware of DataParameter s, although since I need a given ItemStack and they only take booleans, ints, floats etc. (right?), I don't think they will be much use. Here's the method so far, please help improve upon it @SideOnly(Side.CLIENT) public void spawnEatParticles(ItemStack stack) { if(stack.getItem() instanceof ItemBlock) { Block block = ((ItemBlock)stack.getItem()).getBlock(); for(int i = 0; i < 20; i++) { this.worldObj.spawnParticle(EnumParticleTypes.BLOCK_CRACK, this.headPosition.getX() + (double)this.rand.nextFloat() - (this.getPosition().getX() - this.posX) - 0.5, this.headPosition.getY() + (double)this.rand.nextFloat() - (this.getPosition().getY() - this.posY), this.headPosition.getZ() + (double)this.rand.nextFloat() - (this.getPosition().getZ() - this.posZ) - 0.5, (this.rand.nextInt(6) - 3) / 5, 0.1, (this.rand.nextInt(6) - 3) / 5, new int[] {Block.getIdFromBlock(block)}); } } else { for(int i = 0; i < 20; i++) { this.worldObj.spawnParticle(EnumParticleTypes.ITEM_CRACK, this.headPosition.getX() + (double)this.rand.nextFloat() - (this.getPosition().getX() - this.posX) - 0.5, this.headPosition.getY() + (double)this.rand.nextFloat() - (this.getPosition().getY() - this.posY), this.headPosition.getZ() + (double)this.rand.nextFloat() - (this.getPosition().getZ() - this.posZ) - 0.5, (this.rand.nextInt(6) - 3) / 5, 0.1, (this.rand.nextInt(6) - 3) / 5, new int[] {Item.getIdFromItem(stack.getItem()), stack.getMetadata()}); } } } IGN: matte006 Played Minecraft since summer 2011. Modding is my life now. Please check out my mod https://minecraft.curseforge.com/projects/gadgets-n-goodies-mod?gameCategorySlug=mc-mods&projectID=230028
July 25, 20169 yr If you want code running on the server to trigger something on the client (or vice versa), you need to send a packet. In this case, vanilla already has a method to do this for you: WorldServer#spawnParticle . Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
July 25, 20169 yr Author In this case, vanilla already has a method to do this for you: WorldServer#spawnParticle . Yay, it works now! Thanks a lot! IGN: matte006 Played Minecraft since summer 2011. Modding is my life now. Please check out my mod https://minecraft.curseforge.com/projects/gadgets-n-goodies-mod?gameCategorySlug=mc-mods&projectID=230028
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.