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

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


Drachenbauer
 Share

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
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 register sounds that will be played at a specific location. For example: /playsound minecraft:ambient.cave block YageLyts ~ ~ ~15 This will play the sound ambient.cave at my position Z+15 and it works, the further I move the less I hear the sound. Now in my mod I register all my sounds using the sound event, but whenever I use that command, the sound is played no matter where I am on the map. It's like the sound is played as background. I've been trying to fix this for at least two hours but I can't find anything...   public class SoundRegistrator { public static final DeferredRegister<SoundEvent> REGISTRY = DeferredRegister.create(ForgeRegistries.SOUND_EVENTS, LoginMod.MOD_ID); public static final RegistryObject<SoundEvent> HOT_NOTIF = register("hot_notification"); public static final RegistryObject<SoundEvent> KEY_NOTIF = register("key_notifcation"); public static final RegistryObject<SoundEvent> MYST_LOOP = register("mystery_loop"); public static final RegistryObject<SoundEvent> NEWTREAS_NOTIF = register("newtreasure_notification"); public static final RegistryObject<SoundEvent> TREAS_FOUND = register("treasure_found"); public static final RegistryObject<SoundEvent> TREAS_FOUND_ANOTHER = register("treasure_foundby_anotherplayer"); private static RegistryObject<SoundEvent> register(String name) { return REGISTRY.register(name, () -> new SoundEvent(new ResourceLocation(LoginMod.MOD_ID, name))); } } public LoginMod() { FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::client); MinecraftForge.EVENT_BUS.register(this); PermissionAPI.registerNode("treasurehunt.setup", DefaultPermissionLevel.OP, "treasurehunt.setup"); SoundRegistrator.REGISTRY.register(FMLJavaModLoadingContext.get().getModEventBus()); } { "hot_notification": { "sounds": ["loginmod:hot_notification"] }, "key_notifcation": { "sounds": ["loginmod:key_notifcation"] }, "mystery_loop": { "sounds": [ { "name": "loginmod:mystery_loop", "stream": true } ] }, "newtreasure_notification": { "sounds": ["loginmod:newtreasure_notification"] }, "treasure_found": { "sounds": ["loginmod:treasure_found"] }, "treasure_foundby_anotherplayer": { "sounds": [ { "name": "loginmod:treasure_foundby_anotherplayer", "stream": true } ] } } Thank
    • You got hacked, didn't you?
    • wrong website 😐
    • https://myfemalefunda.com/الطاقة-الشمسية-في-المغرب/ https://kerbymethodconsulting.com/مشاريع-جديدة-ومبتكرة-2017-82582/ https://starsone.site/تحويل-الدولار-الى-الريال-العماني/ https://advocatesnairobi.com/سعر-عملة-حزم-اليوم/ https://starsone.site/يُعدُّ-البنك-المركزي-مؤسسة/
    • https://angosiam.com/ما-هي-حقوق-المرأة-في-تركيا/ https://myfemalefunda.com/مركز-دبي-للسلع-المتعددة/ https://sanakanwalfashion.com/اسعار-العقود-الاجلة-للداو-جونز/ https://kerbymethodconsulting.com/حساب-فاتورة-الكهرباء-الجزائر-2022-71662/ https://advocatesnairobi.com/كم-باقي-على-2030/
  • Topics

×
×
  • Create New...

Important Information

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