Jump to content

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


Recommended Posts

Posted

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?

Posted
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.

Posted

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.

Posted

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.

Posted
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.

Posted

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?

Posted (edited)

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
Posted (edited)

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
Posted
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.

Posted
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.

Posted (edited)

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
Posted
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.

Posted (edited)

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
Posted

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

Posted
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.

Posted
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.

Posted (edited)

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
Posted (edited)
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.

Posted (edited)

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
Posted (edited)

The particles have slightly different colorshades: some are darker and some are a bit reddish or greenish...

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

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

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • https://mclo.gs/46Xf7Sq thanks
    • That seems to have fixed it, thank you!
    • I am having some issues starting an RLCraft server on a minimal install of Debian 12. I have Java installed and I'm able to start the vanilla Minecraft server jar no problem and people can join and play without any issues, as soon as I try to create a new directory with the Forge jar the initial install with the INSTALLER jar works when I use the java command with the --installServer flag, but as soon as I try to start the server using the forge jar that is NOT labelled with installer I get the following error: A problem occurred running the Server launcher.java.lang.reflect.InvocationTargetException         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)         at java.base/java.lang.reflect.Method.invoke(Method.java:569)         at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.run(ServerLaunchWrapper.java:70)         at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.main(ServerLaunchWrapper.java:34) Caused by: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')         at net.minecraft.launchwrapper.Launch.<init>(Launch.java:34)         at net.minecraft.launchwrapper.Launch.main(Launch.java:28)         ... 6 more   I have tried using newer versions of Java directly from Oracle as well. Has anybody been successful in starting and running a RLCraft server from the terminal on a Linux machine? I cannot figure out why it doesn't want to work but the vanilla jar works without issue. Thank you in advance!
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.