Making a Block Spawn Void Particles (Or Any Particle)

Recommended Posts

Hello people of Forge! How do you make it so when you place a block, it spawns void particles, or any particle. Thanks!

Share on other sites

Take a look at the torch code.

Share on other sites

```public class TileEntityRunecraftFire extends BlockContainer {

public TileEntityRunecraftFire(int id) {
super(id, Material.fire);
this.setCreativeTab(Main.tabRuneCraft);
}

@Override
public TileEntity createNewTileEntity(World world) {
return new TileEntityRunecraftFireEntity();
}

@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random random){

if (random.nextInt(24) == 0)
{
world.playSound((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), "fire.fire", 1.0F + random.nextFloat(), random.nextFloat() * 0.7F + 0.3F, false);
}

float f1 = (float)x + 0.6F;
float f2 = (float)y + 0.1F;
float f3 = (float)z + 0.6F;
float f4 = random.nextFloat() * 0.3F -0.3F;
float f5 = random.nextFloat() * 0.3F -0.3F;
float f6 = (float)y + 0.2F;
float f7 = (float)y + 0.3F;
float f8 = (float)y + 0.4F;
float f9 = (float)y + 0.5F;
float f10 = (float)y + 0.6F;
float f11 = (float)x + 0.6F;
float f12 = (float)z + 0.6F;

world.spawnParticle("flame", (double)(f1+f4), (double)f2, (double)(f3+f5), 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)(f1+f4), (double)f6, (double)(f3+f5), 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)(f1+f4), (double)f7, (double)(f3+f5), 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)(f1+f4), (double)f8, (double)(f3+f5), 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)(f1+f4), (double)f9, (double)(f3+f5), 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)(f1+f4), (double)f10, (double)(f3+f5), 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)(f11+f4), (double)f6, (double)(f12+f5), 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)(f11+f4), (double)f7, (double)(f12+f5), 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)(f11+f4), (double)f8, (double)(f12+f5), 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)(f11+f4), (double)f9, (double)(f12+f5), 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)(f11+f4), (double)f10, (double)(f12+f5), 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)(f11+f4), (double)f2, (double)(f12+f5), 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)(f1+f4), (double)f6, (double)(f12+f5), 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)(f1+f4), (double)f7, (double)(f12+f5), 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)(f1+f4), (double)f8, (double)(f12+f5), 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)(f1+f4), (double)f9, (double)(f12+f5), 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)(f1+f4), (double)f10, (double)(f12+f5), 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)(f1+f4), (double)f2, (double)(f12+f5), 0.0D, 0.0D, 0.0D);

}

@Override
public int getRenderType() {
return -1;
}

@Override
public boolean isOpaqueCube() {
return false;
}

public boolean renderAsNormalBlock() {
return false;
}

public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
par1World.setBlock(par2, par3, par4, FireMaking.ITEM_ASHES_ID);
}

public void registerIcons(IconRegister icon) {
this.blockIcon = icon.registerIcon("runecraft:textures/blocks/Fire");
}
}
```

Old fire code that spawned fire particles, I don't know if it still works for 1.7.2 but you can try.

I'm always happy to help others!

Java is not my main programming language but I have alot experience in PHP/HTML/JS/CSS3/C#/SQL

Share on other sites

Ok, so here are a few bugs.

One, I do not want it to replace the block with a flame particle, I want it to spawn void particles around it that disappear over time.

Two, whenever Minecraft is minimized, it spams Open GL Error @post render 1286: invalid framebuffer operation.

Three, It doesn't display the block anymore, just the Flame particle effect, while I want the void particle effect.

Four, in the inventory, it doesn't show the block, just a bunch of blackness.

Share on other sites

Ok, I realized that @stjnhero's was just not working out for me. I am updating Forge because after I deleted stjnhero's code, it is still spamming the open GL Error. Anyone else know how to make void particles?

Bump

Share on other sites

Particles.

Are a b*tch if you want them to look like something that Minecraft doesn't have.  Fortunately for you, the void particle exists and is what you want.

I forget what class Minecraft uses where it figures out what string matches what particle (FX[something something]?) but you can find it by just tracing through existing code (hover over a function and you'll get the Javadoc, click the green dot in the upper left corner or the name of the function to jump to that point in the code).  It's only four jumps through a couple of vanilla classes (start with world.spawnParticle).

Once you find the name you're looking for (I know that redstone is "reddust" for instance) you can just use that instead of "flame" when calling spawnParticle.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

DO NOT PM ME WITH PROBLEMS. No help will be given.

Share on other sites

Minecraft's particles are terribly hardcoded. The particle name you are looking for is "depthsuspend".

Share on other sites

Minecraft's particles are terribly hardcoded. The particle name you are looking for is "depthsuspend".

Yes, yes they are.

And adding new types is a right pain, because if you don't change the texture right and change it back everything just falls apart.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

DO NOT PM ME WITH PROBLEMS. No help will be given.

Share on other sites

Minecraft's particles are terribly hardcoded. The particle name you are looking for is "depthsuspend".

Yes, yes they are.

And adding new types is a right pain, because if you don't change the texture right and change it back everything just falls apart.

Ok, I will test this out. Thanks for your help!

Share on other sites

If you do move to your own particles, you'll want this:

```public class ParticleUtils
{
static Map<String, ResourceLocation> boundTextures = new HashMap();

public static void bindTexture(String texture)
{
ResourceLocation rl = null;
if (boundTextures.containsKey(texture))
rl = (ResourceLocation)boundTextures.get(texture);
else {
rl = new ResourceLocation("MODID", texture);
}
Minecraft.getMinecraft().renderEngine.bindTexture(rl);
}

public static ResourceLocation getParticleTexture()
{
try
{
return (ResourceLocation)ReflectionHelper.getPrivateValue(EffectRenderer.class, null, new String[] { "particleTextures", "b", "field_110737_b" }); } catch (Exception e) {
}
return null;
}
}```

That will let you switch textures without buggering anything.  Call the first function to change to your texture (the code there just caches the resource location so it doesn't have to make new file references all the time) and then call the second function when you're done rendering your particles to reset the texture back to Minecraft's vanilla particle sheet.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

DO NOT PM ME WITH PROBLEMS. No help will be given.

Share on other sites

If you do move to your own particles, you'll want this:

```public class ParticleUtils
{
static Map<String, ResourceLocation> boundTextures = new HashMap();

public static void bindTexture(String texture)
{
ResourceLocation rl = null;
if (boundTextures.containsKey(texture))
rl = (ResourceLocation)boundTextures.get(texture);
else {
rl = new ResourceLocation("MODID", texture);
}
Minecraft.getMinecraft().renderEngine.bindTexture(rl);
}

public static ResourceLocation getParticleTexture()
{
try
{
return (ResourceLocation)ReflectionHelper.getPrivateValue(EffectRenderer.class, null, new String[] { "particleTextures", "b", "field_110737_b" }); } catch (Exception e) {
}
return null;
}
}```

That will let you switch textures without buggering anything.  Call the first function to change to your texture (the code there just caches the resource location so it doesn't have to make new file references all the time) and then call the second function when you're done rendering your particles to reset the texture back to Minecraft's vanilla particle sheet.

Thank you very much! In order to make this to work, would i have to just have a class extend Particle and call these two methods?

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.

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

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

×

• Posts

• Also remove   wthit quark biggerspongeabsorptionradius
• You could use the BlockTags.MINEABLE_WITH_AXE tag.
• The game wont start and keeps crashing everytime I hit play "The game crashed whilst rendering overlay Error: java.lang.IllegalAccessError: failed to access class com.mojang.blaze3d.platform.GlStateManager\$TextureState from class net.coderbot.iris.gl.IrisRenderSystem\$DSAARB (com.mojang.blaze3d.platform.GlStateManager\$TextureState is in module minecraft@1.18.2 of loader 'TRANSFORMER' @724b939e; net.coderbot.iris.gl.IrisRenderSystem\$DSAARB is in module oculus@1.6.4 of loader 'TRANSFORMER' @724b939e)" How do I get it to stop? Log error here: https://pastebin.com/byv1dR54
• In case anyone happens on this with the same issue, I was able to overcome it. After re-reading @Paint_Ninja's last post numerous time, it finally dawned on me that he was referring wholly to the forge installer, which has nothing to do with the packaged modpack installer. As such, I downloaded the new copy of the forge installer and copied it to my linux host, then opened a second ssh session and prepared a cp command to move the new (correct) installer over to the install directory where I was installing the modpack. After the modpack installer had just about finished retrieving files, I overwrote the installer.jar file with the correct one in a seperate ssh session. The modpack (packaged) installer then used that jar to install forge with the included files, and the install finished as I would have expected. Thanks all!

• Who's Online (See full list)

×

• Activity

×
• Create New...