Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Making a Block Spawn Void Particles (Or Any Particle)


BungeeTheCookie
 Share

Recommended Posts

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

Link to comment
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.

Link to comment
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.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

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

Link to comment
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.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

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

Link to comment
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!

Link to comment
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.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

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

Link to comment
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?

Link to comment
Share on other sites

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
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.

 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • The version you are using is no longer supported on this forum. Please update to a modern version of Minecraft to receive support. Currently supported versions are 1.18.1/1.18.2 (Latest) and 1.16.5 (LTS).
    • 21.05 10:58:51 [Multicraft] Starting server! 21.05 10:58:51 [Multicraft] Loaded config for "Forge 1.18.2" 21.05 10:58:54 [Multicraft] Adding template "apexupdater" and options "always,install,temp" from config 21.05 10:58:54 [Multicraft] Running setup... 21.05 10:58:55 [Setup/"Apex Updater" initialize] Running Apex Updater... 21.05 10:58:55 [Setup/"Apex Updater" initialize] Selected JAR = forge_1.18.2 21.05 10:58:55 [Multicraft] Done, returned Ok 21.05 10:58:55 [Multicraft] Setup done, restarting 21.05 10:58:55 [Multicraft] Server stopped 21.05 10:58:58 [Multicraft] Loading server properties 21.05 10:58:58 [Multicraft] Starting server! 21.05 10:58:58 [Multicraft] Loaded config for "Forge 1.18.2" 21.05 10:59:02 [Multicraft] Updating eula.txt file 21.05 10:59:02 [Server] INFO WARNING: Published ports are discarded when using host network mode 21.05 10:59:02 [Server] INFO 129b57832ff2b3c5dd1e6699415c45bbeec9485191111984027a045d09d3ddfd 21.05 10:59:05 [Server] INFO [Log4jPatcher] [INFO] Transforming org/apache/logging/log4j/core/pattern/MessagePatternConverter 21.05 10:59:05 [Server] INFO [Log4jPatcher] [WARN] Unable to find noLookups:Z field in org/apache/logging/log4j/core/pattern/MessagePatternConverter 21.05 10:59:05 [Server] INFO [Log4jPatcher] [INFO] Transforming org/apache/logging/log4j/core/lookup/JndiLookup 21.05 10:59:05 [Server] INFO 2022-05-21 10:59:05,552 main WARN Advanced terminal features are not available in this environment 21.05 10:59:05 [Server] main/INFO [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher running: args [--launchTarget, forgeserver, --fml.forgeVersion, 40.1.20, --fml.mcVersion, 1.18.2, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20220404.173914, nogui] 21.05 10:59:05 [Server] main/INFO [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher 9.1.3+9.1.3+main.9b69c82a starting: java version 17.0.1 by Red Hat, Inc. 21.05 10:59:05 [Server] main/INFO [op.OptiFineTransformationService/]: OptiFineTransformationService.onLoad 21.05 10:59:05 [Server] main/INFO [op.OptiFineTransformationService/]: OptiFine ZIP file URL: union:/mods/OptiFine_1.18.2_HD_U_H7.jar%2338!/ 21.05 10:59:05 [Server] main/INFO [op.OptiFineTransformationService/]: OptiFine ZIP file: /mods/OptiFine_1.18.2_HD_U_H7.jar 21.05 10:59:05 [Server] main/INFO [op.OptiFineTransformer/]: Target.PRE_CLASS is available 21.05 10:59:05 [Server] main/INFO [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.5 Source=union:/jar/libraries/org/spongepowered/mixin/0.8.5/mixin-0.8.5.jar%2314!/ Service=ModLauncher Env=SERVER 21.05 10:59:05 [Server] main/INFO [op.OptiFineTransformationService/]: OptiFineTransformationService.initialize 21.05 10:59:06 [Server] main/ERROR [ne.mi.fm.lo.ModSorter/LOADING]: Missing mandatory dependencies: minecraft, minecraft, caelus 21.05 10:59:07 [Server] main/INFO [op.OptiFineTransformationService/]: OptiFineTransformationService.transformers 21.05 10:59:07 [Server] main/INFO [op.OptiFineTransformer/]: Targets: 350 21.05 10:59:07 [Server] main/INFO [op.OptiFineTransformationService/]: additionalClassesLocator: [optifine., net.optifine.] 21.05 10:59:07 [Server] INFO Exception in thread "main" java.lang.IllegalArgumentException: V3.0.0: Version string does not start with a number 21.05 10:59:07 [Server] INFO at java.base/java.lang.module.ModuleDescriptor$Version.<init>(ModuleDescriptor.java:1005) 21.05 10:59:07 [Server] INFO at java.base/java.lang.module.ModuleDescriptor$Version.parse(ModuleDescriptor.java:1090) 21.05 10:59:07 [Server] INFO at java.base/java.lang.module.ModuleDescriptor$Builder.version(ModuleDescriptor.java:2062) 21.05 10:59:07 [Server] INFO at MC-BOOTSTRAP/fmlloader@1.18.2-40.1.20/net.minecraftforge.fml.loading.moddiscovery.ModJarMetadata.descriptor(ModJarMetadata.java:72) 21.05 10:59:07 [Server] INFO at cpw.mods.securejarhandler@1.0.3/cpw.mods.jarhandling.impl.Jar.computeDescriptor(Jar.java:47) 21.05 10:59:07 [Server] INFO at cpw.mods.securejarhandler@1.0.3/cpw.mods.cl.JarModuleFinder$JarModuleReference.<init>(JarModuleFinder.java:50) 21.05 10:59:07 [Server] INFO at cpw.mods.securejarhandler@1.0.3/cpw.mods.cl.JarModuleFinder.lambda$new$0(JarModuleFinder.java:28) 21.05 10:59:07 [Server] INFO at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) 21.05 10:59:07 [Server] INFO at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) 21.05 10:59:07 [Server] INFO at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) 21.05 10:59:07 [Server] INFO at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) 21.05 10:59:07 [Server] INFO at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) 21.05 10:59:07 [Server] INFO at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) 21.05 10:59:07 [Server] INFO at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) 21.05 10:59:07 [Server] INFO at cpw.mods.securejarhandler@1.0.3/cpw.mods.cl.JarModuleFinder.<init>(JarModuleFinder.java:29) 21.05 10:59:07 [Server] INFO at cpw.mods.securejarhandler@1.0.3/cpw.mods.cl.JarModuleFinder.of(JarModuleFinder.java:43) 21.05 10:59:07 [Server] INFO at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.ModuleLayerHandler.buildLayer(ModuleLayerHandler.java:70) 21.05 10:59:07 [Server] INFO at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.TransformationServicesHandler.buildTransformingClassLoader(TransformationServicesHandler.java:60) 21.05 10:59:07 [Server] INFO at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.Launcher.run(Launcher.java:104) 21.05 10:59:07 [Server] INFO at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.Launcher.main(Launcher.java:77) 21.05 10:59:07 [Server] INFO at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) 21.05 10:59:07 [Server] INFO at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) 21.05 10:59:07 [Server] INFO at cpw.mods.bootstraplauncher@1.0.0/cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:149) 21.05 10:59:09 [Multicraft] Server shut down (starting) 21.05 10:59:09 [Multicraft] Restarting crashed server in 300 seconds 21.05 10:59:09 [Multicraft] Server stopped  
    • EntityEvent.Size exists specifically for this purpose. You don't need to set the dimensions field using reflection. Your use of reflection will also crash outside of the development environment (you must use SRG names). Also not that you should put the Field instance in a static final field, this allows the JVM to more aggressively optimize it.
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.