Is there a way to dynamically update block textures after initialization?

SSBlur

I would like to update a specific block in the world's texture without replacing the block or registering multiple blocks. I am using Forge version 1.7.2, recommended version.

Universal Electricity

What you can do is have multiple textures in your textures directory, and register them all in your registerBlockIcons(IIconRegister register) method. Example:

package com.example.examplemod;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class BlockMultiTextureDemo extends Block {

//Save state to NBT at the world save time.
private int state = 0;

private final int DONE = 0;
private final int WORKING = 1;
private final int NOPOWER = 2;
private final int MACHINEBROKE = 3;


@SideOnly(Side.CLIENT)
public static IIcon doneIcon;
@SideOnly(Side.CLIENT)
public static IIcon workIcon;
@SideOnly(Side.CLIENT)
public static IIcon nopowerIcon;
@SideOnly(Side.CLIENT)
public static IIcon brokeIcon;
@SideOnly(Side.CLIENT)
public static IIcon topIcon;

protected BlockMultiTextureDemo(Material material) {
    super(material);
}

@Override
public void registerBlockIcons(IIconRegister register) {
    super.registerBlockIcons(register);
    doneIcon = register.registerIcon("MODID:" + getUnlocalizedName()
            + "_DONE");
    workIcon = register.registerIcon("MODID:" + getUnlocalizedName()
            + "_WORKING");
    nopowerIcon = register.registerIcon("MODID:" + getUnlocalizedName()
            + "_NOPOWER");
    brokeIcon = register.registerIcon("MODID:" + getUnlocalizedName()
            + "_BROKE");
    topIcon = register.registerIcon("MODID:" + getUnlocalizedName()
            + "_TOP");

}

@Override
protected String getTextureName() {
    return super.getTextureName();
}

@Override
public IIcon getIcon(int side, int meta) {
    switch (meta) {
    case DONE:
        return doneIcon;
    case WORKING:
        return workIcon;
    case NOPOWER:
        return nopowerIcon;
    case MACHINEBROKE:
        return brokeIcon;
    default:
        return topIcon;
    }
  }
}

Hope this is what you are looking for!

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Is there a way to dynamically update block textures after initialization?

From Dev

jQuery plugin - update settings after initialization

From Dev

update redux reducers after store initialization

From Dev

Update scope value after dynamically update textbox

From Dev

Three js, block textures are blured

From Dev

R is there a way to dynamically update a function as you are building it

From Dev

Block textures and block names not loading minecraft forge

From Dev

AngularJS Is there a way to dynamically register a directive after boostrap

From Dev

How to update UILabel text in custom class after initialization (Swift 3)

From Dev

Reusing static initialization block

From Dev

Reusing static initialization block

From Dev

Is there a way to merge textures in Unity in a shader?

From Dev

Textures broken after importing to Unity

From Dev

Minecraft Forge 1.8 - Loading Block Textures

From Dev

Best way to update html after promise result

From Dev

Tastypie: Is there a way to invalidate Cache after resource Update?

From Dev

How to update CollectionView's numberOfItemsInSection after block finishes executing

From Dev

How to update CollectionView's numberOfItemsInSection after block finishes executing

From Java

What is the currently correct way to dynamically update plots in Jupyter/iPython?

From Dev

Fastest way to dynamically update the style of millions of DOM elements

From Dev

Is there a way to dynamically update a list of allowed origins in Web API CORS

From Dev

Better way to dynamically update tile data on Commodore 64

From Dev

Is there any way to dynamically update data index without restarting EmbeddedSolrServer in solrj?

From Dev

Do code inside a synchronized block but after wait() runs in synchronized way?

From Dev

Best way to duplicate block of html after copying it with yat command

From Dev

What is the proper way to animate block resizing after its content changed

From Dev

initialization block vs constructor vs variable initialization

From Dev

initialization block vs constructor vs variable initialization

From Dev

jQuery DataTable - Enable/disable column filtering on hide/show after initialization dynamically

Related Related

  1. 1

    Is there a way to dynamically update block textures after initialization?

  2. 2

    jQuery plugin - update settings after initialization

  3. 3

    update redux reducers after store initialization

  4. 4

    Update scope value after dynamically update textbox

  5. 5

    Three js, block textures are blured

  6. 6

    R is there a way to dynamically update a function as you are building it

  7. 7

    Block textures and block names not loading minecraft forge

  8. 8

    AngularJS Is there a way to dynamically register a directive after boostrap

  9. 9

    How to update UILabel text in custom class after initialization (Swift 3)

  10. 10

    Reusing static initialization block

  11. 11

    Reusing static initialization block

  12. 12

    Is there a way to merge textures in Unity in a shader?

  13. 13

    Textures broken after importing to Unity

  14. 14

    Minecraft Forge 1.8 - Loading Block Textures

  15. 15

    Best way to update html after promise result

  16. 16

    Tastypie: Is there a way to invalidate Cache after resource Update?

  17. 17

    How to update CollectionView's numberOfItemsInSection after block finishes executing

  18. 18

    How to update CollectionView's numberOfItemsInSection after block finishes executing

  19. 19

    What is the currently correct way to dynamically update plots in Jupyter/iPython?

  20. 20

    Fastest way to dynamically update the style of millions of DOM elements

  21. 21

    Is there a way to dynamically update a list of allowed origins in Web API CORS

  22. 22

    Better way to dynamically update tile data on Commodore 64

  23. 23

    Is there any way to dynamically update data index without restarting EmbeddedSolrServer in solrj?

  24. 24

    Do code inside a synchronized block but after wait() runs in synchronized way?

  25. 25

    Best way to duplicate block of html after copying it with yat command

  26. 26

    What is the proper way to animate block resizing after its content changed

  27. 27

    initialization block vs constructor vs variable initialization

  28. 28

    initialization block vs constructor vs variable initialization

  29. 29

    jQuery DataTable - Enable/disable column filtering on hide/show after initialization dynamically

HotTag

Archive