Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.14.4] [SOLVED] world.addParticle() crashing with ParticleType
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 1
saxon564

[1.14.4] [SOLVED] world.addParticle() crashing with ParticleType

By saxon564, November 17 in Modder Support

  • intermediate
  • Reply to this topic
  • Start new topic

Recommended Posts

saxon564    20

saxon564

saxon564    20

  • Diamond Finder
  • saxon564
  • Forge Modder
  • 20
  • 485 posts
Posted November 17 (edited)

I am having an issue now where when I spawn my mob in, the game crashes when it starts trying to spawn particles around the entity. I have it set up where the user can specify the particles in the configs and it also allows them to use more than 1 particle. Because of this I have to use an array (protected static ParticleType<?>[] particleType;) to handle the particles. But when I fill the array and use it my editor is telling me I need to cast ParticleType to IParticleData, which cannot be done. How can I still use this array and also give the method the IParticleData it wants? 

 

This is my code trying spawning the particles.

My code setting the paticleType variable

My code building the array of particles.

Edited November 23 by saxon564
Marking Solved
  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6692

diesieben07

diesieben07    6692

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6692
  • 45730 posts
Posted November 17

Particles need more info than just the particle type (the sprinting particles for example need to know which block you are sprinting on). This is what IParticleData is used for. Have you looked at how vanilla Minecraft spawns particles?

  • Quote

Share this post


Link to post
Share on other sites

saxon564    20

saxon564

saxon564    20

  • Diamond Finder
  • saxon564
  • Forge Modder
  • 20
  • 485 posts
Posted November 17

I just looked into what you mentioned. Most calls use a field from ParticleTypes which I could do if the needed particle wasn't configurable or there was a way to get the ParticleTypes fields from the chosen particle in the configs. The other ones I saw was creating a new instance of ItemParticleData, BlockParticleData, or RedstoneParticleData, also I could use those if the particle I was handling needed one of them. But that is not the case. I am getting the particle from the ForgeRegistries which uses ParticleType. I have been digging around and am struggling to find a way to get from ParticleType to IParticleData and currently is is looking like I would have to re-register the particle which I know can't be the correct way to do it.

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6692

diesieben07

diesieben07    6692

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6692
  • 45730 posts
Posted November 17

You have to supply the correct particle data based on the particle type you want.

The ParticleType gives you the deserializer for it's matching IParticleData.

  • Quote

Share this post


Link to post
Share on other sites

saxon564    20

saxon564

saxon564    20

  • Diamond Finder
  • saxon564
  • Forge Modder
  • 20
  • 485 posts
Posted November 17

I've been trying to figure out how to work the deserializer to get IParticleData and for the life of me am having trouble figuring it out. Do you have any examples I can take a look at to help me with this? Or possibly know a mod with open source that does this that I can take a look at?

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6692

diesieben07

diesieben07    6692

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6692
  • 45730 posts
Posted November 17

Not that I know of, sorry. The idea of this deserializer is that you pass it a string and it gives you the proper particle data. It's used e.g. in the particle command. So you would have to have an additional string value in your configuration file so that users can supply this string to specify the particle data. You can see how this works here: https://minecraft.gamepedia.com/Commands/particle.

  • Quote

Share this post


Link to post
Share on other sites

desht    73

desht

desht    73

  • Creeper Killer
  • desht
  • Members
  • 73
  • 205 posts
Posted November 19 (edited)

There is in fact a such a mod now: https://github.com/TeamPneumatic/pnc-repressurized/tree/1.14

 

I will say first that the mod is in an extremely broken state right now (I only got it to compile a few days ago), but particles do actually work.  I added an air particle type which takes one float parameter controlling the particle's rendering alpha.  See the following:

 

  • Registering the particle types: https://github.com/TeamPneumatic/pnc-repressurized/blob/1.14/src/main/java/me/desht/pneumaticcraft/common/core/ModParticleTypes.java - note I register two particle types which use the same particle data (they only vary in their texture)
  • The particle data class: https://github.com/TeamPneumatic/pnc-repressurized/blob/1.14/src/main/java/me/desht/pneumaticcraft/client/particle/AirParticleData.java - this handles serialization/deserialization of the data the particle needs (in my case just a single float).  I need to move this to under common/ since both the client and server need to know about it, but when I added this I didn't fully understand it :P 
  • The particle itself: https://github.com/TeamPneumatic/pnc-repressurized/blob/1.14/src/main/java/me/desht/pneumaticcraft/client/particle/AirParticle.java - this handles the rendering and ticking of the actual particle instances in the client world.  Also includes a Factory inner class, which will be used to create particle instances from the particle type.
  • Registering the particle factories: https://github.com/TeamPneumatic/pnc-repressurized/blob/1.14/src/main/java/me/desht/pneumaticcraft/client/ClientSetup.java#L43-L47
  • And finally the particle JSON's: https://github.com/TeamPneumatic/pnc-repressurized/tree/1.14/src/main/resources/assets/pneumaticcraft/particles 

For lots more useful info, also see https://gist.github.com/williewillus/353c872bcf1a6ace9921189f6100d09a#particles

 

Edited November 19 by desht
  • Quote

Share this post


Link to post
Share on other sites

saxon564    20

saxon564

saxon564    20

  • Diamond Finder
  • saxon564
  • Forge Modder
  • 20
  • 485 posts
Posted November 19
1 hour ago, desht said:

There is in fact a such a mod now: https://github.com/TeamPneumatic/pnc-repressurized/tree/1.14

 

I will say first that the mod is in an extremely broken state right now (I only got it to compile a few days ago), but particles do actually work.  I added an air particle type which takes one float parameter controlling the particle's rendering alpha.  See the following:

 

  • Registering the particle types: https://github.com/TeamPneumatic/pnc-repressurized/blob/1.14/src/main/java/me/desht/pneumaticcraft/common/core/ModParticleTypes.java - note I register two particle types which use the same particle data (they only vary in their texture)
  • The particle data class: https://github.com/TeamPneumatic/pnc-repressurized/blob/1.14/src/main/java/me/desht/pneumaticcraft/client/particle/AirParticleData.java - this handles serialization/deserialization of the data the particle needs (in my case just a single float).  I need to move this to under common/ since both the client and server need to know about it, but when I added this I didn't fully understand it :P 
  • The particle itself: https://github.com/TeamPneumatic/pnc-repressurized/blob/1.14/src/main/java/me/desht/pneumaticcraft/client/particle/AirParticle.java - this handles the rendering and ticking of the actual particle instances in the client world.  Also includes a Factory inner class, which will be used to create particle instances from the particle type.
  • Registering the particle factories: https://github.com/TeamPneumatic/pnc-repressurized/blob/1.14/src/main/java/me/desht/pneumaticcraft/client/ClientSetup.java#L43-L47
  • And finally the particle JSON's: https://github.com/TeamPneumatic/pnc-repressurized/tree/1.14/src/main/resources/assets/pneumaticcraft/particles 

For lots more useful info, also see https://gist.github.com/williewillus/353c872bcf1a6ace9921189f6100d09a#particles

 

Awesome! Sounds like you have a lot of good information in there! I will take a look at it when I have the opportunity tonight. Hopefully I can find what Im looking for and learn how to use it better for my application.

  • Quote

Share this post


Link to post
Share on other sites

saxon564    20

saxon564

saxon564    20

  • Diamond Finder
  • saxon564
  • Forge Modder
  • 20
  • 485 posts
Posted November 20

Unfortunately there wasn't much I could use from your code. Since I do not know exactly which particle I am using I cannot call ParticleTypes, which when you call

world.addParticle(AirParticleData.NORMAL, posX, posY, posZ, 0, 0, 0);

 it is equivalent to me calling 

world.addParticle(ParticleTypes.BUBBLE, posX, posY, posZ, 0, 0, 0);

as you already have the IParticleData setup. I have to setup the IParticleData on the fly, which I have figured out how to do, if only I could figure out how to get around the error

The method deserialize(ParticleType<capture#5-of ?>, StringReader) in the type IParticleData.IDeserializer<capture#5-of ?>
is not applicable for the arguments (ParticleType<capture#6-of ?>, StringReader)

 

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6692

diesieben07

diesieben07    6692

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6692
  • 45730 posts
Posted November 20

Show your code.

  • Quote

Share this post


Link to post
Share on other sites

saxon564    20

saxon564

saxon564    20

  • Diamond Finder
  • saxon564
  • Forge Modder
  • 20
  • 485 posts
Posted November 20

Sorry, was late and forgot about that.

Here is the current code

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6692

diesieben07

diesieben07    6692

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6692
  • 45730 posts
Posted November 20

You'll have to use a helper method which takes a ParticleType<T> and then do the deserialization there. You can't do it with a ParticleType<*>.

  • Like 1
  • Quote

Share this post


Link to post
Share on other sites

saxon564    20

saxon564

saxon564    20

  • Diamond Finder
  • saxon564
  • Forge Modder
  • 20
  • 485 posts
Posted November 23

I have gotten it working now. I finally found the code in the ParticleArgument class that handles this and was able to implement it. I had build some code similar, but didn't have all the parts to it.

I had:

private static deserializeParticle(StringReader reader, ParticleType<T extends IParticleData> type) {

But what it needed to be was:

private static <T extends IParticleData> T deserializeParticle(StringReader reader, ParticleType<T> type) throws CommandSyntaxException {

 

Thank you for your patience with my diesieben! You are always a great help!

  • Quote

Share this post


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

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • TomPlayzs
      [ solved ] - HUD images (exp bar, health, hunger, etc.) glitching out.

      By TomPlayzs · Posted 28 minutes ago

      I have this problem too! How do i fix it?
    • Oliviafrostpaw
      [1.14.4] Injecting into Existing Loot Tables, Blocks

      By Oliviafrostpaw · Posted 39 minutes ago

      Making it easier for showing the code, please see GitHub repository that I ideally should have set up to begin with so that I would have known when exactly all of this broke Github Link
    • DragonITA
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By DragonITA · Posted 1 hour ago

      i think whoever's bugging me in the HorseEntity Class is, here: private static final String[] HORSE_TEXTURES = new String[]{"textures/entity/horse/horse_white.png", "textures/entity/horse/horse_creamy.png", "textures/entity/horse/horse_chestnut.png", "textures/entity/horse/horse_brown.png", "textures/entity/horse/horse_black.png", "textures/entity/horse/horse_gray.png", "textures/entity/horse/horse_darkbrown.png"};  
    • DragonITA
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By DragonITA · Posted 1 hour ago

      package net.batonfack.fantasymod.client.models; import net.minecraft.client.renderer.entity.model.EntityModel; import net.minecraft.client.renderer.entity.model.RendererModel; import net.minecraft.client.renderer.model.ModelBox; import net.minecraft.entity.LivingEntity; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) public class ModelUnicornWitoutAbstracHorse<T extends LivingEntity> extends EntityModel<T> { protected final RendererModel field_217127_a; protected final RendererModel field_217128_b; private final RendererModel CornGroup; private final RendererModel Corn1; private final RendererModel Corn2; private final RendererModel Corn3; public ModelUnicornWitoutAbstracHorse(float p_i51065_1_) { this.field_217127_a = null; this.field_217128_b = null; this.textureWidth = 128; this.textureHeight = 64; CornGroup = new RendererModel(this); CornGroup.setRotationPoint(0.0F, 0.0F, 0.0F); Corn1 = new RendererModel(this, 64, 0); Corn1.setRotationPoint(1.5F, -5.0F, -15.0F); this.Corn1.setRotationPoint(0.5409F, 0.0F, 0.0F); CornGroup.addChild(Corn1); Corn1.cubeList.add(new ModelBox(Corn1, 52, 57, -3.0F, -3.0F, -4.0F, 3, 4, 3, 0.0F, true)); Corn2 = new RendererModel(this, 64, 28); Corn2.setRotationPoint(1.5F, -5.0F, -15.0F); this.Corn2.setRotationPoint(0.5409F, 0.0F, 0.0F); CornGroup.addChild(Corn2); Corn2.cubeList.add(new ModelBox(Corn2, 0, 0, -2.4F, -5.3F, -3.6F, 2, 3, 2, 0.0F, true)); Corn3 = new RendererModel(this, 96, 32); Corn3.setRotationPoint(1.5F, -5.0F, -15.0F); this.Corn3.setRotationPoint(0.5409F, 0.0F, 0.0F); CornGroup.addChild(Corn3); Corn3.cubeList.add(new ModelBox(Corn3, 0, 0, -1.8F, -8.1F, -3.2F, 1, 3, 1, 0.0F, true)); } protected void func_199047_a(RendererModel p_199047_1_) { RendererModel renderermodel = new RendererModel(this, 19, 16); renderermodel.addBox(0.55F, -13.0F, 4.0F, 2, 3, 1, -0.001F); RendererModel renderermodel1 = new RendererModel(this, 19, 16); renderermodel1.addBox(-2.55F, -13.0F, 4.0F, 2, 3, 1, -0.001F); p_199047_1_.addChild(renderermodel); p_199047_1_.addChild(renderermodel1); } }  
    • DragonITA
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By DragonITA · Posted 1 hour ago

      package net.batonfack.fantasymod.entities; import net.batonfack.fantasymod.init.FantasyModEntities; import net.minecraft.entity.EntityType; import net.minecraft.entity.passive.horse.HorseEntity; import net.minecraft.world.World; public class UnicornEntity extends HorseEntity { @SuppressWarnings("unchecked") public UnicornEntity(EntityType<? extends HorseEntity> type, World worldIn) { super((EntityType<? extends HorseEntity>) FantasyModEntities.UNICORN_ENTITY, worldIn); } }  
  • Topics

    • WinneonSword
      2
      [ solved ] - HUD images (exp bar, health, hunger, etc.) glitching out.

      By WinneonSword
      Started August 31, 2013

    • Oliviafrostpaw
      8
      [1.14.4] Injecting into Existing Loot Tables, Blocks

      By Oliviafrostpaw
      Started December 8

    • DragonITA
      40
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By DragonITA
      Started Monday at 10:06 AM

    • DarkZapato
      2
      Optifine 1.14.4 U HD F4 crash froge

      By DarkZapato
      Started Thursday at 04:09 PM

    • troyvs
      0
      [1.12.2]help me to attach capability to player

      By troyvs
      Started 1 hour ago

  • Who's Online (See full list)

    • Ayonix
    • yanny
    • Juice_lmao
    • DragonITA
    • TolgacanM
    • Choonster
    • Misterboy64
    • Yanny7
    • ricoc90
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.14.4] [SOLVED] world.addParticle() crashing with ParticleType
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community