• 0

    posted a message on [SOLVED] Block with Overlay turns black when at certain distance/angle?

    Also, the only reason the stone texture underneath was showing instead of just a solid white or black color, was because when I created the texture I just took the default lapis ore texture and erased all the stone parts and grayscaled it. Then when I saved it, even though it was 100% transparent, it still saved the color values of the erased pixels, and so I was just overlaying an entire texture over the stone block texture.

    Posted in: Modification Development
  • 0

    posted a message on I want to randomize textures for a few blocks so that they're unique to that save.

    As the title says, I am trying to make blocks whose textures are randomly generated when a new world is created. Right now I have a couple blocks with two textures: a base texture, and an ore "overlay" texture.





    When a world is created I want the game to randomly choose from an array, or folder, of textures, and apply it to those blocks permanently for that world.

    From what I understand, if you want multiple textures for a block, you usually put variants in the blockstate json file. Unfortunately I have no idea how to randomize that at world generation with json, without creating a buttload of preset textures before hand.


    If I could just do something like this It would make it way easier:


    public static Texture[] baseTextures = new Texture{Texture1.png, Texture2.png...., Texture20.png, etc...};
    public static Texture[] oreTextures = new Texture{oreTexture1.png, oreTexture2.png...., oreTexture50.png, etc...};
    
    Random r1 = new Random.nextInt(baseTextures.length);
    Random r2 = new Random.nextInt(oreTextures.length);
    
    myBlock.setBaseTexture(baseTextures[r1]);
    myBlock.setOreTexture(oreTextures[r2]);







    (obviously pseudo code, but you get the idea)


    Any Ideas on where to start?

    Posted in: Modification Development
  • 0

    posted a message on [SOLVED] Block with Overlay turns black when at certain distance/angle?

    Finally worked out what was wrong!


    I created a class for my block:


    public class RNG_Ore extends Block{
    	
    	public RNG_Ore(Properties properties){
    		super(properties);
    		//super(name, material);
    		properties.sound(SoundType.STONE);
    		properties.hardnessAndResistance(2.0f, 1.0f);
    		properties.lightValue(0);
    	}
    
    	
    	//@Override
    	public boolean isOpaqueCube(BlockState state){
    		return false;
    	}
    	
    	public boolean isSolid(BlockState state){
    		return true;
    	}
    	
    	public BlockRenderLayer getRenderLayer() {
    	      return BlockRenderLayer.CUTOUT;
    	   }
    }


    The BlockRenderLayer function is the most important bit


    Then when I register the block I create a new RNG_Ore, rather than a Block

    BlockList.rng_ore01 = [b]new RNG_Ore[/b](Block.Properties.create(Material.WOOD).hardnessAndResistance(2.0f, 1.0f).lightValue(0).variableOpacity().sound(SoundType.STONE)).setRegistryName(location("rng_ore01"))
    Posted in: Modification Development
  • 0

    posted a message on [SOLVED] Block with Overlay turns black when at certain distance/angle?

    I wanted to make a block texture that had a second overlayed texture, that i could change the color of later on. I based my json file for the block model off of the grass_block.json, because it is one of the few blocks that does this (changing the grass color depending on the biome).


    It more or less works as intended, but when I look at the block from more than 6 or 7 blocks away, some sides of the block turn almost black. The side that turns black depends on the angle I am looking at it from.





    I've messed with the light value of the block, I have tried tampering with the tintindexes and cullface parameters,as well as tried "parent": "block/block" instead of "parent": "block/cube_all"


    Here is my json file:




    {   "parent": "block/cube_all",
        "textures": {
        	"particle": "block/stone",
            "all": "block/stone",
            "overlay": "mod01:block/rng_ore_overlay02"
        },
        "elements": [
            {   "from": [ 0, 0, 0 ],
                "to": [ 16, 16, 16 ],
                "faces": {
                    "down":  { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "cullface": "down"},
                    "up":    { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "cullface": "up"},
                    "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "cullface": "north"},
                    "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "cullface": "south"},
                    "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "cullface": "west"},
                    "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "cullface": "east"}
                }
            },
            {   "from": [ 0, 0, 0 ],
                "to": [ 16, 16, 16 ],
                "faces": {
                    "down":  { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "down" },
                    "up":    { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "up" },
                    "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "north" },
                    "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "south" },
                    "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "west" },
                    "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "east" }
                }
            }
        ]
    }











    Any Ideas as to what's going on would be appreciated :)

    Posted in: Modification Development
  • To post a comment, please or register a new account.