Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • IBlockColor not changing color of block
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 1
NullDev

IBlockColor not changing color of block

By NullDev, February 19 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

NullDev    0

NullDev

NullDev    0

  • Tree Puncher
  • NullDev
  • Members
  • 0
  • 14 posts
Posted February 19

I register an IBlockColor like this:

Minecraft.getInstance().getBlockColors().register(new CakeColor(0xad6b15), block); //Cake color implements IBlockColor and its method

 

The getColor method is setup like this:

@Override
    public int getColor(BlockState p_getColor_1_, @Nullable IBlockDisplayReader p_getColor_2_, @Nullable BlockPos p_getColor_3_, int p_getColor_4_) {
        return color; // Returns the same color regardless of state
    }

Yet the color of my cake still uses the base texture when placed on the ground. I need the color to change.

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7688

diesieben07

diesieben07    7688

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7688
  • 56257 posts
Posted Saturday at 07:01 PM
22 hours ago, NullDev said:

I register an IBlockColor like this:


Minecraft.getInstance().getBlockColors().register(new CakeColor(0xad6b15), block); //Cake color implements IBlockColor and its method

 

That is incorrect. Use ColorHandlerEvent.Block.

 

22 hours ago, NullDev said:

Yet the color of my cake still uses the base texture when placed on the ground. I need the color to change.

Show your model JSON and texture.

  • Quote

Share this post


Link to post
Share on other sites

NullDev    0

NullDev

NullDev    0

  • Tree Puncher
  • NullDev
  • Members
  • 0
  • 14 posts
Posted Monday at 02:28 AM
On 2/20/2021 at 12:01 PM, diesieben07 said:

That is incorrect. Use ColorHandlerEvent.Block.

I am now registering the colors using that event, but nothing has changed. I even have the event logging to the console to check that it is working.

On 2/20/2021 at 12:01 PM, diesieben07 said:

Show your model JSON and texture.

Blockstate:

{
  "variants": {
    "bites=0": {
      "model": "tons_of_cakes:block/cake"
    },
    "bites=1": {
      "model": "tons_of_cakes:block/cake_slice1"
    },
    "bites=2": {
      "model": "tons_of_cakes:block/cake_slice2"
    },
    "bites=3": {
      "model": "tons_of_cakes:block/cake_slice3"
    },
    "bites=4": {
      "model": "tons_of_cakes:block/cake_slice4"
    },
    "bites=5": {
      "model": "tons_of_cakes:block/cake_slice5"
    },
    "bites=6": {
      "model": "tons_of_cakes:block/cake_slice6"
    }
  }
}

cake.json:

{
  "parent": "block/cake_slice1",
  "textures": {
    "down": "tons_of_cakes:blocks/cake_bottom",
    "up": "tons_of_cakes:blocks/cake_top",
    "north": "tons_of_cakes:blocks/cake_side",
    "south": "tons_of_cakes:blocks/cake_side",
    "east": "tons_of_cakes:blocks/cake_side",
    "west": "tons_of_cakes:blocks/cake_inside"
  }
}

cake_slice1:

{
  "parent": "block/cake_slice1",
  "textures": {
    "down": "tons_of_cakes:blocks/cake_bottom",
    "up": "tons_of_cakes:blocks/cake_top",
    "north": "tons_of_cakes:blocks/cake_side",
    "south": "tons_of_cakes:blocks/cake_side",
    "east": "tons_of_cakes:blocks/cake_side",
    "west": "tons_of_cakes:blocks/cake_inside"
  }
}

and the textures it is referencing are black and white versions of the vanilla textures, but it doesn't even show as black and white in game. It shows as the original vanilla texture.

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7688

diesieben07

diesieben07    7688

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7688
  • 56257 posts
Posted Monday at 07:15 AM
4 hours ago, NullDev said:

It shows as the original vanilla texture.

You set the vanilla cake_slice1 as your parent model and then do not override any of its textures (you specify six new textures instead, which go unused).

You also need to specify a tintindex of 0 for any face in your model that you want colored (look at the vanilla colorable models as examples).

 

  • Quote

Share this post


Link to post
Share on other sites

NullDev    0

NullDev

NullDev    0

  • Tree Puncher
  • NullDev
  • Members
  • 0
  • 14 posts
Posted Monday at 03:39 PM (edited)
8 hours ago, diesieben07 said:

You set the vanilla cake_slice1 as your parent model and then do not override any of its textures

How do I override textures?

Edited Monday at 03:40 PM by NullDev
  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7688

diesieben07

diesieben07    7688

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7688
  • 56257 posts
Posted Monday at 04:21 PM

Just like you did already, but you need to use the texture names that are actually used by the parent model, instead of specifying new ones.

  • Thanks 1
  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Skyriis
      [SOLVED][1.16.5] Adding a Button to KeyBindings

      By Skyriis · Posted 12 minutes ago

      That worked.   Here is my solution @SubscribeEvent public static void onOpenGui(final GuiScreenEvent.InitGuiEvent.Post event) { if (!(event.getGui() instanceof ControlsScreen)) return; final ControlsScreen controlsScreen = (ControlsScreen) event.getGui(); final KeyBindingList replacement = new KeyBindingListReplacement(controlsScreen, event.getGui().getMinecraft()); final KeyBindingList old = ObfuscationReflectionHelper.getPrivateValue(ControlsScreen.class, controlsScreen, "field_146494_r"); controlsScreen.getEventListeners().remove(old); ObfuscationReflectionHelper.setPrivateValue(ControlsScreen.class, controlsScreen, replacement, "field_146494_r"); try { Method addChildMethod = ObfuscationReflectionHelper.findMethod(Screen.class, "func_230481_d_", IGuiEventListener.class); addChildMethod.setAccessible(true); addChildMethod.invoke(controlsScreen, replacement); addChildMethod.setAccessible(false); } catch (IllegalAccessException | InvocationTargetException e) { e.printStackTrace(); } }  
    • DrCowiber
      Failed To Start Minecraft Server

      By DrCowiber · Posted 39 minutes ago

      im using this run.sh file, which contains: java -Xmx6G -Xms6G -jar minecraft_server.1.16.5.jar --nogui Edit: When I first posted about this I was using the serverRun.jar, which the first log file I posted is what the output was
    • Tez
      [1.15.2] Couln't not resolve dependency: net.minecraftforge:forge:1.15.2-31.2.0:userdev

      By Tez · Posted 59 minutes ago

      I'm new to mod coding so i've watch tutorial in youtube in setup workspace step i got this error , i've try many solutions to fix but it still not working try update gradle to 6.8.3 but still not working try update java and still not working too here's my stacktrace: Stacktrace
    • diesieben07
      Failed To Start Minecraft Server

      By diesieben07 · Posted 1 hour ago

      Please show how exactly you are starting the server.
    • DrCowiber
      Failed To Start Minecraft Server

      By DrCowiber · Posted 1 hour ago

      https://pastebin.com/TZJEsrTB
  • Topics

    • Skyriis
      8
      [SOLVED][1.16.5] Adding a Button to KeyBindings

      By Skyriis
      Started 22 hours ago

    • DrCowiber
      8
      Failed To Start Minecraft Server

      By DrCowiber
      Started 20 hours ago

    • Tez
      0
      [1.15.2] Couln't not resolve dependency: net.minecraftforge:forge:1.15.2-31.2.0:userdev

      By Tez
      Started 59 minutes ago

    • Mysterious minecrafter
      1
      game keeps crashing while initializings

      By Mysterious minecrafter
      Started 2 hours ago

    • lukeeeeee_1
      1
      I'm not managing to enter worlds

      By lukeeeeee_1
      Started 3 hours ago

  • Who's Online (See full list)

    • Iron1601
    • WindRunner7
    • redlynx
    • Skyriis
    • Uncreative
    • DrCowiber
    • Chryfi
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • IBlockColor not changing color of block
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community