Jump to content

Simple way to add particle effect to a custom block? (I know Java but not mods)


Recommended Posts

Posted

<storytime>For a basic modding class, I decided to do a simple little set of ruby blocks. One of those is an enchanted ruby block, that looks just like a normal ruby block EXCEPT (the plan is, anyways) it had the smoke particles that come off of nether portals and ender eyes. Unfortunately, I can't find any information on how to do that and lately I've been stuck trying to get .spawnParticle to work on a block.

 

I've tryed a lot of crap and I honestly don't remember what, but this is my current code, copied mainly from the code for ender eyes (Possibly doesn't work because my block isn't an item/entity?)

 

import java.util.Random;

 

import net.minecraft.block.material.Material;

import net.minecraft.client.Minecraft;

import net.minecraft.client.particle.EntityFX;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.item.Item;

import net.minecraft.world.World;

 

import com.grady.gradymod.BaseBlock.BaseBlock;

 

import cpw.mods.fml.common.registry.GameRegistry;

 

public class EnchantedRubyBlock extends BaseBlock {

    protected static Random itemRand = new Random();

public EnchantedRubyBlock(Material material) {

super(material);

setHardness(10);

setBlockName("EnchantedRubyBlock");

setCreativeTab(CreativeTabs.tabBlock);

setLightLevel(0.1F);

setBlockTextureName(GradyMod.MODID + ":" + "EnchantedRubyBlock");

 

// EntityFX candleFlame = new EntityFX(World world, 10, 10, 10);

// Minecraft.getMinecraft().effectRenderer.addEffect(candleFlame);

}

public void onTick(World par1World, int par2, int par3, int par4, Random par5Random) {

 

            double d0 = (double)((float)par2 + (5.0F + itemRand.nextFloat() * 6.0F) / 16.0F);

            double d1 = (double)((float)par3 + 0.8125F);

            double d2 = (double)((float)par4 + (5.0F + itemRand.nextFloat() * 6.0F) / 16.0F);

            double d3 = 0.0D;

            double d4 = 0.0D;

            double d5 = 0.0D;

            par1World.spawnParticle("smoke", d0, d1, d2, d3, d4, d5);

}

}

 

This doesn't work, but also doesn't give any errors and therefore vaults itself to the top of the line of possible leads. Any other ideas? One liners? Wierd hacks or tricks? If you could post them here please, that would be great.

 

Posted

Hi

 

I think you need randomDisplayTick() and  (perhaps - not sure-) this.setTickRandomly(true);

 

Try looking at BlockTorch for clues.

 

Just a general tip - whenever you're overriding a method from a base class (in this case Block), it's a good idea to put @Override before the method.  That will help pick up several confusing errors.

 

-TGG

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.