Jump to content

is there a way, that the vanilla RedStoneWireBlock get´s the coloring from a png in a custom resourcelocation?


Drachenbauer

Recommended Posts

Hello

 

Is ther any way to write code, that changes, where the redstone wire get´s it´s coloring?

 

Maybe i put a gradient png-texture in another color (for sample yellow) into a custome mod resource location.

Can i tell the redstone wire to get it´s colors from there by writing a java-class?

Link to comment
Share on other sites

1 hour ago, Drachenbauer said:

Maybe i put a gradient png-texture in another color (for sample yellow) into a custome mod resource location.

I'm not sure if this will work, but it may be worth a try.

1 hour ago, Drachenbauer said:

Can i tell the redstone wire to get it´s colors from there by writing a java-class?

Probably but you may as well just use code and no image file to get the color. In BlockColors.register seems to be what you want. You can use that to change the color of the redstone there.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

RestoneWire's png is gray. It gets its color entirely from code.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

11 minutes ago, Drachenbauer said:

in some videos i saw, that with optifine, it´s possible to use a gradient png (16 pix x 1 pix) for this.

But Optifine for 1.15 is still not finished.

The progress-report page shows now 95% for more than a month.

Optifine probably does exactly what I said, but instead uses a file to determine the colors instead of raw code.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Now i have this:

    @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
    public static class RegistryEvents
    {
        public static IBlockColor blockColor;
        
        @SubscribeEvent
        public static void registerBlockColors(final ColorHandlerEvent.Block event)
        {
            event.getBlockColors().register(blockColor, Blocks.REDSTONE_WIRE);
        }
    }

in my main-class,

how do i now add the colors to it?

Link to comment
Share on other sites

Now i found this in the RedstoneBlock-class:

   @OnlyIn(Dist.CLIENT)
   public static int colorMultiplier(int p_176337_0_) {
      float f = (float)p_176337_0_ / 15.0F;
      float f1 = f * 0.6F + 0.4F;
      if (p_176337_0_ == 0) {
         f1 = 0.3F;
      }

      float f2 = f * f * 0.7F - 0.5F;
      float f3 = f * f * 0.6F - 0.7F;
      if (f2 < 0.0F) {
         f2 = 0.0F;
      }

      if (f3 < 0.0F) {
         f3 = 0.0F;
      }

      int i = MathHelper.clamp((int)(f1 * 255.0F), 0, 255);
      int j = MathHelper.clamp((int)(f2 * 255.0F), 0, 255);
      int k = MathHelper.clamp((int)(f3 * 255.0F), 0, 255);
      return -16777216 | i << 16 | j << 8 | k;
   }

 

how can i apply my own variant of this outside of the RedstoneBlock class?

 

If i know it, i think, i just have to change this

      int i = MathHelper.clamp((int)(f1 * 255.0F), 0, 255);
      int j = MathHelper.clamp((int)(f2 * 255.0F), 0, 255);
      int k = MathHelper.clamp((int)(f3 * 255.0F), 0, 255);
      

to this

      int i = MathHelper.clamp((int)(f1 * 255.0F), (f1 * 223.0F), 255);
      int j = MathHelper.clamp((int)(f2 * 255.0F), (f2 * 223.0F), 255);
      int k = MathHelper.clamp((int)(f3 * 255.0F), (f3 * 223.0F), 255);
      

to turn it into a warm yellow.

Edited by Drachenbauer
Link to comment
Share on other sites

Edit:

now i tried another type of calculation:

            int red;
            int green;
            
            if(power == 0)
            {
                red = 127 * 256 * 256;
                green = 111 * 256;
            }
            else
            {
                red = ((8 * power) + 128) * 256 * 256;
                green = ((7 * power) + 112) * 256;
            }
            
            return red + green;

in the colormultiplyer function in my class and noticed, my stuff is already applyed to the redstone.

 

I calculated the red and green channel of the color and put them together at the end.

This makes now a bright warm yellow for the highest redstone power level.

I have no "blue" value here, because at this yellow the blue channel is "0" for a bright yellow.

So i don´t need stuff about the blue channel here.

 

How do i now change the color of the redstone-particles (hovering over powered redstone stuff) to the same bright yellow?

It should be the case for every block-type, that emmits theese redstone-particles (redstone-wire, redstone-torch, redstone-ore activated lever, maybe there are some more things)

Edited by Drachenbauer
Link to comment
Share on other sites

3 hours ago, Drachenbauer said:

How do i now change the color of the redstone-particles (hovering over powered redstone stuff) to the same bright yellow?

I think the only way to do this is to override the ParticleType registry for RedstoneParticleData.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

18 minutes ago, Drachenbauer said:

How do i do this?

If it works like other registries you just need to register your own ParticleType with the same registry name as the Minecraft one. So something like "minecraft:redstone_particle_data"

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

If i normally register stuff, it get´s the mod-is at the front of the registry name.

How do i get "Minecraft" there?

 

I also noticed, the redstone wire block and the lever give a color value, where thay add the particles.

The other stuff uses a fixed value under RedstoneParticleData.

Edited by Drachenbauer
Link to comment
Share on other sites

3 minutes ago, Drachenbauer said:

If i normally register stuff, it get´s the mod-is at the front of the registry name.

How do i get "Minecraft" there?

.setRegistryName(modid, registryName)
or
setRegistryName("modid:registryName")

or

setRegistryName(new ResourceLocation(modid, registryName))

or

setRegistryName(new ResourceLocation(modid:registryName))

where modid is "minecraft"

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

I registered my own particletype on the same registryname as the original vanilla one.

 

I created my own variant of the RedstoneParticleData-class and changed the value in REDSTONE_DUST

But the redstone blocks still use the vanilla stuff instead of mine?

 

Edited by Drachenbauer
Link to comment
Share on other sites

6 minutes ago, Drachenbauer said:

But the redstone blocks still use the vanilla stuff instead of mine?

Show your code.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

This registers my particletype:

    public static final DeferredRegister<ParticleType<?>> PARTICLE_TYPES = new DeferredRegister<>(ForgeRegistries.PARTICLE_TYPES, "minecraft");
    
    public static final RegistryObject<ParticleType<YellowRedstoneParticles>> DUST = PARTICLE_TYPES.register("dust", () -> new ParticleType<YellowRedstoneParticles>(false, YellowRedstoneParticles.DESERIALIZER));

 

and the class for this is en exact copy of the vanilla RedstoneData class.

just with another name and the "REDSTONE_DUST" -field with a changed value

Link to comment
Share on other sites

2 minutes ago, Drachenbauer said:

This registers my particletype:

Interesting I guess particles don't really support being overriden. Which is not really friendly to you.

The only other way I see this as being possible is to override all of the redstone blocks and changing what particle they spawn.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Just now, Drachenbauer said:

Do you mean registering all of theese blocks the same way as i registered the particles?

with "linecraft" at the end of tho upper line and their original names in ther individual lines?

Yes and you will need to make a class for each of them that extends their current class and only overrides the methods that spawn the particles.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

I made such a class and registered it this way, but minecraft still uses the old one...

 

Now i think, if i register my own varialts of the blockitems in the old registrynames and attach them to the new blocks, maybe i can place the new blocks, but the ond ones still will be there in the world, if placed before using the mod......

Edited by Drachenbauer
Link to comment
Share on other sites

4 minutes ago, Drachenbauer said:

I made such a class and registered it this way, but minecraft still uses the old one...

 

Now i think, if i register my own varialts of the blockitems in the old registrynames and attach them to the new blocks, maybe i can place the new blocks, but the ond ones still will be there in the world, if placed before using the mod......

No if your override the registry it will be yours that are placed.

 

Also you won't need to register your own ItemBlocks.

Edited by Animefan8888

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

But i still see the old variant in the test world. the particles are still red.

 

edit:

I noticed, that i forgot the line in the main-class-constructor, that initializes the deferred registry for the blocks

 

Now i get this error:

Quote

java.lang.ClassCastException: drachenbauer32.yellowredstonemod.particles.YellowRedstoneParticles cannot be cast to net.minecraft.particles.RedstoneParticleData

 

if i now try to extend from RedstoneParticleData to create my own variant, i get a problem with the registry.

It says

Quote

The constructor ParticleType<YellowRedstoneParticles>(boolean, IParticleData.IDeserializer<RedstoneParticleData>) is undefined

As i had copyed and modifyed the class, the registration line was ok.

 

Now i placed a copy of the whoole deserializer-part from the original class into my one and replaced the name every where in this code.

Now it works.

 

Yellow redstone wire with yellow dust particles

Edited by Drachenbauer
Link to comment
Share on other sites

12 minutes ago, Drachenbauer said:

How can i make them all appear in the same bright yellow?

Since you have overriden the Blocks you can actually just use the RedstoneParticleData that's already there. The constructor parameters are RGBA 0.0-1.0

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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.