Posted August 30, 20196 yr Hello, I need to create my own particle, so I've checked how Minecraft does it and maked same. But it now works as well, shows only "unknown particle" texture. Spoiler private void clientRegistries(final FMLClientSetupEvent event){ LOGGER.info("Client setup..."); WNBlockColors colors = new WNBlockColors(); Minecraft.getInstance().particles.registerFactory(Main.getParticleByID("wildnature:dungeon_heart"),DungeonHeartParticle.Factory::new); } RegistryEvents: @SubscribeEvent public static void registerParticles(final RegistryEvent.Register<ParticleType<?>> event){ LOGGER.info("Registering particles..."); event.getRegistry().register(ParticleRegistry.DUNGEON_HEART); } Particle Registry: public class ParticleRegistry { public static final BasicParticleType DUNGEON_HEART = register("wildnature:dungeon_heart", false); public static IParticleData DUNGEON_HEART_DATA; private static BasicParticleType register(String key, boolean alwaysShow) { System.out.println("Registering particle: " + key); return (BasicParticleType) Registry.<ParticleType<? extends IParticleData>>register(Registry.PARTICLE_TYPE, key, new BasicParticleType(alwaysShow)); } private static <T extends IParticleData> ParticleType<T> register(String key, IParticleData.IDeserializer<T> deserializer) { return Registry.register(Registry.PARTICLE_TYPE, key, new ParticleType<>(false, deserializer)); } } This is particle: @OnlyIn(Dist.CLIENT) public class DungeonHeartParticle extends SpriteTexturedParticle { private final double portalPosX; private final double portalPosY; private final double portalPosZ; public DungeonHeartParticle(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn) { super(worldIn, xCoordIn, yCoordIn, zCoordIn); this.motionX = xSpeedIn; this.motionY = ySpeedIn; this.motionZ = zSpeedIn; this.posX = xCoordIn; this.posY = yCoordIn; this.posZ = zCoordIn; this.portalPosX = this.posX; this.portalPosY = this.posY; this.portalPosZ = this.posZ; this.particleScale = 0.1F * (this.rand.nextFloat() * 0.2F + 0.5F); float f = this.rand.nextFloat() * 0.6F + 0.4F; this.particleRed = f * 0.9F; this.particleGreen = f * 0.3F; this.particleBlue = f; this.maxAge = (int)(Math.random() * 10.0D) + 40; } public IParticleRenderType getRenderType() { return IParticleRenderType.PARTICLE_SHEET_OPAQUE; } public void move(double x, double y, double z) { this.setBoundingBox(this.getBoundingBox().offset(x, y, z)); this.resetPositionToBB(); } public float getScale(float p_217561_1_) { float f = ((float)this.age + p_217561_1_) / (float)this.maxAge; f = 1.0F - f; f = f * f; f = 1.0F - f; return this.particleScale * f; } public int getBrightnessForRender(float partialTick) { int i = super.getBrightnessForRender(partialTick); float f = (float)this.age / (float)this.maxAge; f = f * f; f = f * f; int j = i & 255; int k = i >> 16 & 255; k = k + (int)(f * 15.0F * 16.0F); if (k > 240) { k = 240; } return j | k << 16; } public void tick() { this.prevPosX = this.posX; this.prevPosY = this.posY; this.prevPosZ = this.posZ; if (this.age++ >= this.maxAge) { this.setExpired(); } else { float f = (float)this.age / (float)this.maxAge; float f1 = -f + f * f * 2.0F; float f2 = 1.0F - f1; this.posX = this.portalPosX + this.motionX * (double)f2; this.posY = this.portalPosY + this.motionY * (double)f2 + (double)(1.0F - f); this.posZ = this.portalPosZ + this.motionZ * (double)f2; } } @Override protected float getMinU() { return 0f; } @Override protected float getMaxU() { return 1f; } @Override protected float getMinV() { return 0f; } @Override protected float getMaxV() { return 1f; } @OnlyIn(Dist.CLIENT) public static class Factory implements IParticleFactory<BasicParticleType> { private final IAnimatedSprite spriteSet; public Factory(IAnimatedSprite p_i50607_1_) { this.spriteSet = p_i50607_1_; } public Particle makeParticle(BasicParticleType typeIn, World worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) { DungeonHeartParticle portalparticle = new DungeonHeartParticle(worldIn, x, y, z, xSpeed, ySpeed, zSpeed); //portalparticle.selectSpriteRandomly(this.spriteSet); return portalparticle; } } } This in block: @OnlyIn(Dist.CLIENT) public void animateTick(BlockState stateIn, World worldIn, BlockPos pos, Random rand) { for(int i = 0; i < 3; ++i) { int j = rand.nextInt(2) * 2 - 1; int k = rand.nextInt(2) * 2 - 1; double d0 = (double)pos.getX() + 0.5D + 0.25D * (double)j; double d1 = (double)((float)pos.getY() + rand.nextFloat()); double d2 = (double)pos.getZ() + 0.5D + 0.25D * (double)k; double d3 = (double)(rand.nextFloat() * (float)j); double d4 = ((double)rand.nextFloat() - 0.5D) * 0.125D; double d5 = (double)(rand.nextFloat() * (float)k); worldIn.addParticle(ParticleRegistry.DUNGEON_HEART, d0, d1, d2, d3, d4, d5); } } Please, help!
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.