Posted January 8, 201510 yr Hey everyone, I am trying to make particles spawn at a block, and have done it before in a mod I no longer have, but I can't seem to replicate it. My code is as follows: import java.util.Random; import com.descon.mod.DesconCreativeTabs; import com.descon.mod.Main; import com.descon.tileentity.TileEntityCampFire; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class CampfireProp extends BlockContainer{ public CampfireProp(Material material) { super(material); this.setCreativeTab(DesconCreativeTabs.tabGeneral); this.setLightLevel(0.7F); this.setHarvestLevel("axe", 1); this.setHardness(1F); this.setBlockBounds(0F, 0F, 0F, 1F, 0.125F, 1F); this.setBlockTextureName(Main.modID + ":" + "textures/blocks/campfire.png"); } public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_) { float f = (float)p_149734_2_ + 0.5F; float f1 = (float)p_149734_3_ + 0.2F + p_149734_5_.nextFloat() * 3.0F / 8.0F; float f2 = (float)p_149734_4_ + 0.5F; float f3 = 0.0F; float f4 = p_149734_5_.nextFloat() * 0.0F - 0.0F; p_149734_1_.spawnParticle("smoke", (double)(f - f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D); p_149734_1_.spawnParticle("flame", (double)(f - f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D); p_149734_1_.spawnParticle("smoke", (double)(f - f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D); p_149734_1_.spawnParticle("flame", (double)(f - f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D); p_149734_1_.spawnParticle("smoke", (double)(f - f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D); p_149734_1_.spawnParticle("flame", (double)(f - f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D); p_149734_1_.spawnParticle("smoke", (double)(f - f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D); p_149734_1_.spawnParticle("flame", (double)(f - f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D); } public int getRenderType() { return -1; } public boolean isOpaqueCube() { return false; } public boolean renderAsNormalBlock() { return false; } @Override public TileEntity createNewTileEntity(World var1, int var2) { return new TileEntityCampFire(); } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconRegister) { this.blockIcon = iconRegister.registerIcon(Main.modID + ":" + this.getUnlocalizedName().substring(5)); } } Do I need to reference it somewhere or add some extra code? Any help would be appreciated, -Whyneb
January 8, 201510 yr You could have a look at the redstone ore class, thats what i used for my ores: Former developer for DivineRPG, Pixelmon and now the maker of Essence of the Gods
January 8, 201510 yr Author Thanks for your reply, I just tried messing around with that, but found that it didn't help me - particles still aren't appearing
January 8, 201510 yr Try putting an @Override over your display tick method. See if you're overriding it Former developer for DivineRPG, Pixelmon and now the maker of Essence of the Gods
January 8, 201510 yr Author It had the green arrow next to it, indicating an Override, but I put one on top anyway - no difference. Thanks anyway though
January 8, 201510 yr Well you can have a look at my ore class to see if it will help! Former developer for DivineRPG, Pixelmon and now the maker of Essence of the Gods
January 8, 201510 yr Author As I am not fluent in Java, or particularly good at Modding (yet , your class file doesn't help me much (also because you seem to be doing something more complicated than I am). I did manage to dig up my old mod - the on the worked with block particles, and launch it with the latest forge, but it doesn't work any more. Is there a new way to do particle effects?
January 8, 201510 yr Not really... And there is nothing "special" to what my ores are doing really... Aha Former developer for DivineRPG, Pixelmon and now the maker of Essence of the Gods
January 8, 201510 yr Author I see... Hmm... If you were to make just a super basic block emit particle effects, how would you go about doing it?
January 8, 201510 yr well you can have a look at "EntityReddustFX.java" and do magic by c&p that, then add this into your block.java: @Override @SideOnly(Side.CLIENT) public void randomDisplayTick(World w, int x, int y, int z, Random rand) { renderParticle(w, x, y, z); } private void renderParticle(World w, int x, int y, int z) { Random random = w.rand; double d0 = 0.0625D; for(int l = 0; l < 6; ++l) { double d1 = (double)((float)x + random.nextFloat()); double d2 = (double)((float)y + random.nextFloat()); double d3 = (double)((float)z + random.nextFloat()); if(l == 0 && !w.getBlock(x, y + 1, z).isOpaqueCube()) d2 = (double)(y + 1) + d0; if(l == 1 && !w.getBlock(x, y - 1, z).isOpaqueCube()) d2 = (double)(y + 0) - d0; if(l == 2 && !w.getBlock(x, y, z + 1).isOpaqueCube()) d3 = (double)(z + 1) + d0; if(l == 3 && !w.getBlock(x, y, z - 1).isOpaqueCube()) d3 = (double)(z + 0) - d0; if(l == 4 && !w.getBlock(x + 1, y, z).isOpaqueCube()) d1 = (double)(x + 1) + d0; if(l == 5 && !w.getBlock(x - 1, y, z).isOpaqueCube()) d1 = (double)(x + 0) - d0; if(d1 < (double)x || d1 > (double)(x + 1) || d2 < 0.0D || d2 > (double)(y + 1) || d3 < (double)z || d3 > (double)(z + 1)) { OreParticleFX fx= new OreParticleFX(w, d1, d2, d3); FMLClientHandler.instance().getClient().effectRenderer.addEffect(fx); } } } And thats basically it Former developer for DivineRPG, Pixelmon and now the maker of Essence of the Gods
January 8, 201510 yr Author What would I replace "OreParticleFX" with? Do I have to create a new class and put a flame effect in there? How would I reference that? Sorry for the rapid-fire questions
January 8, 201510 yr If you want to use a vanilla particle, such as the flame: world.spawnParticle("flame", x, y, z, 0.0D, 0.0D, 0.0D); Former developer for DivineRPG, Pixelmon and now the maker of Essence of the Gods
January 8, 201510 yr Author So, this is what I have now: @Override @SideOnly(Side.CLIENT) public void randomDisplayTick(World w, int x, int y, int z, Random rand) { renderParticle(w, x, y, z, w); } private void renderParticle(World w, int x, int y, int z, World world) { Random random = w.rand; double d0 = 0.0625D; for(int l = 0; l < 6; ++l) { double d1 = (double)((float)x + random.nextFloat()); double d2 = (double)((float)y + random.nextFloat()); double d3 = (double)((float)z + random.nextFloat()); if(l == 0 && !w.getBlock(x, y + 1, z).isOpaqueCube()) d2 = (double)(y + 1) + d0; if(l == 1 && !w.getBlock(x, y - 1, z).isOpaqueCube()) d2 = (double)(y + 0) - d0; if(l == 2 && !w.getBlock(x, y, z + 1).isOpaqueCube()) d3 = (double)(z + 1) + d0; if(l == 3 && !w.getBlock(x, y, z - 1).isOpaqueCube()) d3 = (double)(z + 0) - d0; if(l == 4 && !w.getBlock(x + 1, y, z).isOpaqueCube()) d1 = (double)(x + 1) + d0; if(l == 5 && !w.getBlock(x - 1, y, z).isOpaqueCube()) d1 = (double)(x + 0) - d0; if(d1 < (double)x || d1 > (double)(x + 1) || d2 < 0.0D || d2 > (double)(y + 1) || d3 < (double)z || d3 > (double)(z + 1)) { world.spawnParticle("flame", x, y, z, 0.0D, 0.0D, 0.0D); } } } This doesn't work, and I know I've done something wrong, but I just can't crack it. Thanks for all of your help so far though - much appreciated
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.