Jump to content

Recommended Posts

Posted

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

Posted

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?

Posted

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

Posted

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

Posted

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.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I tried do download the essential mod to my mod pack but i didnt work. I paly on 1.21 and it should work. I use neoforge for my modding. The weird things is my friend somehow added the mod to his modpack and many others that I somehow can´t. Is there anything i can do? 
    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
  • Topics

×
×
  • Create New...

Important Information

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