Jump to content

How can i make particles "glow" in exactly the given color?


Drachenbauer

Recommended Posts

I could not extend RedstoneParticle because it´s constructor is pivate.

So i copyed it´s whoole code and extend SpriteTexturedParticle, like the vanilla one does.

 

I made my constructor public, removed the random values from the color-calculations and changed the variant of getRenderType

 

How do i now override the vanilla RedstoneParticle with my variant?

 

Do i need to use registerFactory from ParticleManager ?

Do i need to create my own version of RedstoneParticleData to access my particle at the Bottom of that code and register it umder the original vanilla registryname?

Edited by Drachenbauer
Link to comment
Share on other sites

push

 

More questions in last post

 

Edit:

 

Now i added this:

        @SubscribeEvent
        public static void onParticleFactoryRegistration(ParticleFactoryRegisterEvent event)
        {
            Minecraft.getInstance().particles.registerFactory(ParticleTypes.DUST, YellowRedstoneParticle.Factory::new);
        }

To the registries-area in my main-class.

 

Now it shows bright yellow particles on all my redstone-components.

 

There are Redstone-Torches on the comperator and the repeater.

But in the vanilla-blocks, they don´t glow a bright, as the single redstone-torch.

So i decided to fit their look exactly to the single one.

Now i make particles appear on theese torches, just like the single redstone torches do.

And if minimum one torch on theese components is on, i made them emmit light, just like the single one does, too.

2020-04-05_17_59_31.png.9b3242d0ff923d328e122aa90092b649.png

This is how my comperators look now. (in the middle a single Redstone.-Torch as reference)

I like this new look.

Edited by Drachenbauer
Link to comment
Share on other sites

For the repeater i have got a little problem:

 

I can set the particle position by direction.

 

But using the BlockState DELAY for moving the particle position with the torch does not work.

 

My code for this:

package drachenbauer32.yellowredstonemod.blocks;

import java.util.Random;

import drachenbauer32.yellowredstonemod.util.Reference;
import net.minecraft.block.BlockState;
import net.minecraft.block.RepeaterBlock;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class YellowRepeaterBlock extends RepeaterBlock
{
    private double ParticleX_1;
    private double ParticleX_2;
    private double ParticleZ_1;
    private double ParticleZ_2;
    
    public YellowRepeaterBlock(Properties properties)
    {
        super(properties);
    }
    
    @Override
    public int getLightValue(BlockState state)
    {
        if(state.get(POWERED))
        {
            return 15;
        }
        else
        {
            return 0;
        }
    }
    
    private void setParticlePositions(BlockState state)
    {
        double delay = (double)state.get(DELAY) / 8;
        
        if (state.get(HORIZONTAL_FACING) == Direction.NORTH)
        {
            ParticleX_1 = 0.5;
            ParticleX_2 = 0.5;
            ParticleZ_1 = 0.8125;
            ParticleZ_2 = 0.6875 - delay;
        }
        else if (state.get(HORIZONTAL_FACING) == Direction.EAST)
        {
            ParticleX_1 = 0.1875;
            ParticleX_2 = 0.3125 + delay;
            ParticleZ_1 = 0.5;
            ParticleZ_2 = 0.5;
        }
        
        else if (state.get(HORIZONTAL_FACING) == Direction.SOUTH)
        {
            ParticleX_1 = 0.5;
            ParticleX_2 = 0.5;
            ParticleZ_1 = 0.1875;
            ParticleZ_2 = 0.3125 + delay;
        }
        else if (state.get(HORIZONTAL_FACING) == Direction.WEST)
        {
            ParticleX_1 = 0.8125;
            ParticleX_2 = 0.6875 - delay;
            ParticleZ_1 = 0.5;
            ParticleZ_2 = 0.5;
        }
    }
    
    @Override
    public void animateTick(BlockState state, World world, BlockPos pos, Random rand)
    {
        setParticlePositions(state);
        
        if (state.get(POWERED))
        {
            double d0 = (double)pos.getX() + ParticleX_1 + (rand.nextDouble() - 0.5D) * 0.2D;
            double d1 = (double)pos.getY() + 0.375 + (rand.nextDouble() - 0.5D) * 0.2D;
            double d2 = (double)pos.getZ() + ParticleZ_1 + (rand.nextDouble() - 0.5D) * 0.2D;
            world.addParticle(Reference.REDSTONE_DUST, d0, d1, d2, 0.0D, 0.0D, 0.0D);
            
            if (!(state.get(LOCKED)))
            {
                double d3 = (double)pos.getX() + ParticleX_2 + (rand.nextDouble() - 0.5D) * 0.2D;
                double d4 = (double)pos.getY() + 0.375 + (rand.nextDouble() - 0.5D) * 0.2D;
                double d5 = (double)pos.getZ() + ParticleZ_2 + (rand.nextDouble() - 0.5D) * 0.2D;
                world.addParticle(Reference.REDSTONE_DUST, d3, d4, d5, 0.0D, 0.0D, 0.0D);
            }
        }
    }
}

 

Edit:

Fixed:

I forgot a "(double)" in the division at the top of the setParticlePositions method.

So it gave an int, and that was "0"

Now you can see it in the code here.

 

Now it works.

Edited by Drachenbauer
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
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.