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

Particles [1.15]


modders2
 Share

Recommended Posts

How do I create a custom particle in 1.15?

I am using deferred registries - and I have this

public static DeferredRegister<ParticleType<?>> PARTICLE = new DeferredRegister<>(ForgeRegistries.PARTICLE_TYPES, Main.MOD_ID);
	
public static RegistryObject<ParticleType<?>> CARBON = PARTICLE.register("carbon", () -> new BasicParticleType(false));

However, I'm not sure what to do from here, if this is all I need or I need to add a directory to the actual texture file

Link to comment
Share on other sites

For particles there are 4 things:

  • Particle
  • ParticleType
  • IParticleData
  • IParticleFactory

Having BasicParticleType covers the ParticleType and IParticleData

Next you need a class that extends Particle (or TexturedParticle or SpriteTexturedParticle), in it you implement what you need (motion, texture, rendering).

 

You finally need a class (I nest it in my Particle class) that extends IParticleFactory, it'll have a makeParticle function (i think that is the name) that will take as a parameter your registered ParticleType and return an instance of the particle you created above.

 

For a simple particle BasicParticleType is fine, about 90% or more of vanilla particle use it. For more complex particles, you need a proper ParticleType and IParticleData, you can look at how vanilla does it in its redstone particle.

Link to comment
Share on other sites

38 minutes ago, Cyborgmas said:

For particles there are 4 things:

  • Particle
  • ParticleType
  • IParticleData
  • IParticleFactory

Having BasicParticleType covers the ParticleType and IParticleData

Next you need a class that extends Particle (or TexturedParticle or SpriteTexturedParticle), in it you implement what you need (motion, texture, rendering).

 

You finally need a class (I nest it in my Particle class) that extends IParticleFactory, it'll have a makeParticle function (i think that is the name) that will take as a parameter your registered ParticleType and return an instance of the particle you created above.

 

For a simple particle BasicParticleType is fine, about 90% or more of vanilla particle use it. For more complex particles, you need a proper ParticleType and IParticleData, you can look at how vanilla does it in its redstone particle.

Do you have an example I could look at maybe?

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

    • Hey Guys, i'm trying to create a Mod which adds an Entity for each Block which has a certain tag. For example for each ore in the "ores" tag. What would be the best to do something like that?
    • I am trying to spawn Fireball when player right clicks, I was following 1.12.2 tutorial but I am modding for 1.18.1. So I changed up code but it doesn't works This is my code:   package com.vamaka12.magiccraft.objects.tools; import net.minecraft.core.BlockPos; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.projectile.LargeFireball; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.Vec3; public class FireStaff extends Item { public FireStaff(Properties properties) { super(properties); } // @Override Gives error, It was in tutorial public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { ItemStack item = player.getItemInHand(hand); Vec3 aim = player.getLookAngle(); LargeFireball fireBall = new LargeFireball(level, player, 1, 1, 1); // gives error "Cannot resolve constructor", I don't know why fireBall.setPos(player.position().x + aim.x * 1.5D, player.position().y + aim.y * 1.5D, player.position().z + aim.z * 1.5D); // fireBall.accelerationX = aim.x * 0.1; fireBall.accelerationY = aim.y * 0.1; fireBall.accelerationZ = aim.z * 0.1; acceleration doesn't exists // level.spawnEntity doesn't exists item.setDamageValue(1); return InteractionResult.SUCCESS; } } Tutorial code: public class FireStaff extends ItemBase { public FireStaff(String name) { super(name); } @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { ItemStack item = playerIn.getHeldItem(handIn); Vec3d aim = playerIn.getLookVec(); EntityLargeFireBall fireball = new EntityLargeFirball(worldIn, playerIn, 1, 1 , 1); fireball.setPosition(playerIn.posX + aim.x * 1.5D, playerIn.posY + aim.y * 1.5D, playerIn.posZ + aim.z * 1.5D); fireBall.accelerationX = aim.x * 0.1; fireBall.accelerationY = aim.y * 0.1; fireBall.accelerationZ = aim.z * 0.1; worldIn.spawnEntity(fireball); item.damageItem(1, playerIn); return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, item); } } Somebody please help, I spended already 1 day
    • It is impossible to get this error with the latest 1.16.5 MDK.
    • I got the MDK directly from here didn't change a thing: https://files.minecraftforge.net/net/minecraftforge/forge/index_1.16.5.html
    • I got the MDK directly from here didn't change a thing: https://files.minecraftforge.net/net/minecraftforge/forge/index_1.16.5.html
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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