Jump to content

Recommended Posts

Posted (edited)

So I've been looking around for tutorials on custom particles and I can't find any up-to-date tutorials or anything on the forge doc. So far from what I can tell, spawning custom particles is different from vanilla since the spawnParticle method relies on the actual EnumParticleTypeClass. 

 

Basically, what I want to do is, when I place down a block, that block starts to slowly emit a purple particle effect. I already have the particle class, I just don't know how to get the block's position (which I think is impossible) or how to set the particles to start spawning from the block

 

ParticleManu.java:

  Reveal hidden contents

 

Edited by GooberGunter
Posted
  On 7/21/2017 at 6:00 PM, GooberGunter said:

Basically, what I want to do is, when I place down a block, that block starts to slowly emit a purple particle effect. I already have the particle class, I just don't know how to get the block's position (which I think is impossible) or how to set the particles to start spawning from the block

Expand  

See how BlockFurnace does this.

Custom particles are a thing that is not easily done afaik. You either need to add an enum constant to the EnumParticleType using EnumHelper and register your particle factory for the particleID you specify in your enum constant or you need to build your own particle system from the ground.

Posted (edited)

From the looks of it, the textureAtlasSprite class, which is what loads the texture for particles, has a built in forge method that allows for custom textures. if I'm looking at this right, it's promising.

  Reveal hidden contents

 

EDIT: It looks like I need a resource manager AND resource location. Sadly, I don't know how to do resource managers

Edited by GooberGunter
Posted

I've gotten as far as the resource manager, but I don't know how to set up the resource manager.

  Reveal hidden contents

 

Posted
  On 7/21/2017 at 8:28 PM, GooberGunter said:

I've gotten as far as the resource manager, but I don't know how to set up the resource manager.

Expand  

I'm not sure if you need to create your own IResourceManager for this(I don't really think you do, but I may be mistaken), but you can get a IResourceManager instance like so.

Minecraft.getMinecraft().getResourceManager();

 

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

I tried that and it gave me the following null exception:

  Reveal hidden contents

 

Posted

In the client proxy class:

  Reveal hidden contents

At the bottom

Posted

In the BlockManuCogBlockH class

  Reveal hidden contents

 

Posted
  On 7/21/2017 at 8:59 PM, GooberGunter said:

In the BlockManuCogBlockH class

Expand  

Then I believe that your particleTexture field is null when you access it in your constructor.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

TextureAtlasSprite has nothing to do with particles. It is simply a 'pointer' to a location of a specific image on a texture sheet(or if we disassemble the name - it is a sprite of a texture atlas(aka map)). Forge just allows custom loading of your sprites with those methods. By default there is only 1 texture map in the game - the blocks+items textures map.

Particles have that field avaliable mostly for block/item crack/break particles, as they need to know what texture to be rendered with. This field is null for other particle types and theirt textureIndex determines their location on their texture map(default vanilla particles.png file).

If you need a custom texture for your particles you can return 1 in your Particle::getFXLayer to use the blocks+items map as your texture and then call Particle::setParticleTexture with a TextureAtlasSprite object that would point to your custom texture on the blocks map. You will need to load that texture yourself using TextureStitchEvent and TextureMap::registerSprite.

  • Like 1
Posted (edited)
  On 7/22/2017 at 12:31 AM, V0idWa1k3r said:

TextureAtlasSprite object that would point to your custom texture on the blocks map. You will need to load that texture yourself using TextureStitchEvent and TextureMap::registerSprite.

Expand  

TextureMap::registerSprite returns you a TextureAtlasSprite object. This method must be called during TextureStitchEvent.Pre

Edited by V0idWa1k3r
Posted

That TextureAtlasSprite object that you recieve as a result of this method. 

There is no regular stitch event. TextureStitchEvent has 2 sub-events - pre(as the map is being setup) and post(after everything was loaded in).

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.