Jump to content

Sireous

Members
  • Posts

    24
  • Joined

  • Last visited

Posts posted by Sireous

  1. Hi,

    I need to accesses byPath field of net.minecraft.client.renderer.texture.TextureManager. As I found out I need to use accesstransformer.cfg file and make the field public via it. In this file field names of class look like f_<numbers>. And I was unable to figure out, how to get those. It seems like it is connected to something called mappings (thing left after Minecraft decompile process). How can I get such a name for a field of a class?

  2. Hi

    I have recently developed Minecraft mod, that exports world portions, which then are imported with my Blender addon into Blender scene. The idea was to be able to export modded minecraft worlds. Currently it proved to work nicely. But there are 2 majior drawbacks:
    1) It does not export paintings, armor stands and item frames.
    2) It does not export blocks, that use custom renderers (like chisel and bits mod blocks)

    My approach is that I ask minecraft renderers (BlockRenderDispatcher, BlockEntityRenderDispatcher) to render what they see at some block position into my custom VertexConsumer classes.

    Seems like I am missing some other types of renderes.

    How paintings, armor stands and item frames render themselves? Can I somehow access renderers, that are introduced by other mods?

  3. After game is loaded or resource-packs are reloaded debug console fill with some info, ending with:

    [20:16:17] [Render thread/INFO] [minecraft/TextureAtlas]: Created: 4096x2048x4 minecraft:textures/atlas/blocks.png-atlas
    [20:16:17] [Render thread/INFO] [minecraft/TextureAtlas]: Created: 512x256x4 minecraft:textures/atlas/signs.png-atlas
    [20:16:17] [Render thread/INFO] [minecraft/TextureAtlas]: Created: 1024x1024x4 minecraft:textures/atlas/banner_patterns.png-atlas
    [20:16:17] [Render thread/INFO] [minecraft/TextureAtlas]: Created: 1024x1024x4 minecraft:textures/atlas/shield_patterns.png-atlas
    [20:16:17] [Render thread/INFO] [minecraft/TextureAtlas]: Created: 512x512x4 minecraft:textures/atlas/chest.png-atlas
    [20:16:17] [Render thread/INFO] [minecraft/TextureAtlas]: Created: 1024x512x4 minecraft:textures/atlas/beds.png-atlas
    [20:16:17] [Render thread/INFO] [minecraft/TextureAtlas]: Created: 1024x512x4 minecraft:textures/atlas/shulker_boxes.png-atlas
    [20:16:23] [Render thread/INFO] [minecraft/TextureAtlas]: Created: 1024x1024x0 minecraft:textures/atlas/particles.png-atlas
    [20:16:23] [Render thread/INFO] [minecraft/TextureAtlas]: Created: 1024x1024x0 minecraft:textures/atlas/paintings.png-atlas
    [20:16:23] [Render thread/INFO] [minecraft/TextureAtlas]: Created: 256x256x0 minecraft:textures/atlas/mob_effects.png-atlas

    I wonder, if there is any event fired after that load or reload happenes?

  4. 29 minutes ago, warjort said:

    No, that is the color when it is drawn on a map item.

     

    If you want the custom color of a block, look at the BlockColors class e.g.

    BlockColors.getColor(BlockState, Level, BlockPos)

    The instance the game uses is a private field in the Minecraft class, so you will need to use an access transformer.

    https://forge.gemwire.uk/wiki/Access_Transformers

    Thanks!

    By the way, getColor returns int. How it is converted to RGB or something of that kind?

  5. 14 hours ago, MFMods said:

    what do you need?

    Well, to make things clear. You might know that things like BlockEntityRenderer are used by Minecraft to render things into our monitor. But lets say I have asked such renderers to render some portion of the world into my own buffer => I got Minecraft geometry as it is rendered right now in my screen. I also dumped current texture atlases as .png (basic ones, because I can't yet figure out how to get full list of atlases in code). So I got geometry, I got textures. But:

    14 hours ago, MFMods said:

    those green stuff are usually gray (in png files)

    I need to know color for each block to setup Blender materials, so it will look exactly, like in my world. Because right now all grass/water/leaves are in greyscale. So, I want to know that:

    14 hours ago, MFMods said:

    then, the developer tells the game how to recolor these parts of the model.

  6. Most Biomes in Minecraft have unique grass/foliage/water color. It can be accessed via methods .getFoliageColor(), .getGrassColor() and .getWaterColor() of the Biome class. That means, technically, that game has an awairness of whenever block is grass/foliage and fluid is water. Am I able to gain such awairness too? Considering that I have access to instance of ServerLevel class and BlockPosition, where I want to check these conditions.

  7. Well, the scenario... It's quite complicated. You can view the whole source code here:

    https://github.com/Dreadoom/RenderCube

    I am interested in this piece of code:

    // Min and max coordinates over each axes
    int region_min_x = Math.min(position1.getX(), position2.getX());
    int region_max_x = Math.max(position1.getX(), position2.getX());
    int region_min_y = Math.min(position1.getY(), position2.getY());
    int region_max_y = Math.max(position1.getY(), position2.getY());
    int region_min_z = Math.min(position1.getZ(), position2.getZ());
    int region_max_z = Math.max(position1.getZ(), position2.getZ());
    
    // Loop over coordinates
    for(int x = region_min_x; x <= region_max_x; x++){
    	for(int y = region_min_y; y <= region_max_y; y++){
    		for(int z = region_min_z; z <= region_max_z; z++){
    			// Current block position
                BlockPos position = new BlockPos(x, y, z);
    
    			// Process block
    			boolean success = RenderCubeUtils.renderBlock( source, jsonWriter, position, new BlockPos(
                                            position.getX() - region_min_x,
                                            position.getY() - region_min_y,
                                            position.getZ() - region_min_z));
    
    			// We finish with success only if RenderCubeUtils.RenderBlock(...) returned true
    			if(!success){
    				// Finish with failure
    				return -1;
               	}
    		}
    	}
    }

    I want it to look something like this:

    // Min and max coordinates over each axes
    int region_min_x = Math.min(position1.getX(), position2.getX());
    int region_max_x = Math.max(position1.getX(), position2.getX());
    int region_min_y = Math.min(position1.getY(), position2.getY());
    int region_max_y = Math.max(position1.getY(), position2.getY());
    int region_min_z = Math.min(position1.getZ(), position2.getZ());
    int region_max_z = Math.max(position1.getZ(), position2.getZ());
    
    // Loop over coordinates
    for(int x = region_min_x; x <= region_max_x; x++){
    	for(int y = region_min_y; y <= region_max_y; y++){
    		for(int z = region_min_z; z <= region_max_z; z++){
    			// Current block position
                BlockPos position = new BlockPos(x, y, z);
                                                       
                if(x == region_min_x){
                	makeInvisible(position.mutable().setWithOffset(position, Direction.WEST)));
                }
                // Same for other 5 vars
    
    			// Process block
    			boolean success = RenderCubeUtils.renderBlock( source, jsonWriter, position, new BlockPos(
                                            position.getX() - region_min_x,
                                            position.getY() - region_min_y,
                                            position.getZ() - region_min_z));
                                                       
                if(x == region_min_x){
                	makeVisible(position.mutable().setWithOffset(position, Direction.WEST)));
                }
                // Same for other 5 vars
    
    			// We finish with success only if RenderCubeUtils.RenderBlock(...) returned true
    			if(!success){
    				// Finish with failure
    				return -1;
               	}
    		}
    	}
    }

     

  8. Let's say I have those 2 variables:

    ServerLevel level = source.getLevel();
    
    BlockState block = level.getBlockState(levelPosition);

    I want to make block near one I got (in any direction) temporarily invisible, perform some actions with block I have and then make invisible one visible again. How can I do this?

  9. When I try to get quads for beds/chests/fluids via this code

    // Get level, where command is executed
    ServerLevel level = source.getLevel();
    
    // Get BlockState at position
    BlockState block = level.getBlockState(levelPosition);
    
    // We do not want to render air
    if (!block.isAir()) {
    	// Is used to get IBakedModel
    	BlockRenderDispatcher blockRenderer = Minecraft.getInstance().getBlockRenderer();
    
    	// Is used in getQuads(...)
    	Random rand = new Random();
    
    	// Rendered block
        RenderedBlock renderedBlock = new RenderedBlock(regionPosition.getX(),
                                                        regionPosition.getY(),
                                                        regionPosition.getZ());
    
        // Block extra model data
        IModelData data = blockRenderer.getBlockModel(block).getModelData(level, levelPosition, block, EmptyModelData.INSTANCE);
    
        // Get model quads
        List<BakedQuad> quads = blockRenderer.getBlockModel(block).getQuads(block, null, rand, data);
    
       	// List of all possible directions
        ArrayList<Direction> directions = RenderCubeUtils.getAllPossibleDirections();
    
        // Through all directions
        for (Direction direction : directions) {
        	// Get model quads, corresponding to this direction
            List<BakedQuad> quadsTemp = blockRenderer.getBlockModel(block).getQuads(block, direction, rand, data);
    
            // Join lists of quads
            quads = Stream.concat(quads.stream(), quadsTemp.stream()).toList();
    	}
    }

    I get empty 'quads' list. Why is this happening? How can I fix this?

  10. Hi there,

    Is there a way I can get texture atlases ResourceLocation in Minecraft 1.18.2 forge? Or something like it, because on startup game log has these lines:

    [15:15:23] [Render thread/INFO] [minecraft/TextureAtlas]: Created: 4096x2048x4 minecraft:textures/atlas/blocks.png-atlas
    [15:15:23] [Render thread/INFO] [minecraft/TextureAtlas]: Created: 512x256x4 minecraft:textures/atlas/signs.png-atlas
    [15:15:23] [Render thread/INFO] [minecraft/TextureAtlas]: Created: 1024x1024x4 minecraft:textures/atlas/banner_patterns.png-atlas
    [15:15:23] [Render thread/INFO] [minecraft/TextureAtlas]: Created: 1024x1024x4 minecraft:textures/atlas/shield_patterns.png-atlas
    [15:15:23] [Render thread/INFO] [minecraft/TextureAtlas]: Created: 512x512x4 minecraft:textures/atlas/chest.png-atlas
    [15:15:23] [Render thread/INFO] [minecraft/TextureAtlas]: Created: 1024x512x4 minecraft:textures/atlas/beds.png-atlas
    [15:15:23] [Render thread/INFO] [minecraft/TextureAtlas]: Created: 1024x512x4 minecraft:textures/atlas/shulker_boxes.png-atlas
    [15:15:30] [Render thread/INFO] [minecraft/TextureAtlas]: Created: 1024x1024x0 minecraft:textures/atlas/particles.png-atlas
    [15:15:30] [Render thread/INFO] [minecraft/TextureAtlas]: Created: 1024x1024x0 minecraft:textures/atlas/paintings.png-atlas
    [15:15:30] [Render thread/INFO] [minecraft/TextureAtlas]: Created: 256x256x0 minecraft:textures/atlas/mob_effects.png-atlas

    This means somewhere there is ResourceLocation that holds these files. I can get, for example, minecraft:textures/atlas/blocks.png-atlas via this code

    TextureManager textureManager = Minecraft.getInstance().getTextureManager();
    TextureAtlas textureAtlas = (TextureAtlas) textureManager.getTexture(new ResourceLocation("textures/atlas/blocks.png"));

    but what if, for example, some mod has added new atlas? I want to get whole list of those, via something like this

    Collection<ResourceLocation> resourceLocations = Minecraft.getInstance().getResourceManager().listResources(
                        "textures/atlas",
                        res -> res.chars().noneMatch(i -> Character.isLetter(i) && Character.isUpperCase(i)));

    but this approach sadly is not working.

  11. Hi there,

    Let's say, I've got a BakedModel via this code

    BlockRenderDispatcher blockRenderer = Minecraft.getInstance().getBlockRenderer();
    BakedModel blockModel = blockRenderer.getBlockModel(block);

    where block is an instance of BlockState. Then I do

    List<BakedQuad> quads = blockModel.getQuads(...);

    to get all BakedQuads of this model.

    While I iterate over them, I want to get a texture file (eg. .txt or .jpg) witch each of this quads use. Is that possible, and, if so, how can I do that?

    P. S. I see, that BakedQuad has a TextureAtlasSprite inside, witch I can get, but I don't know if that is what I need, and how to get texture file from it.

×
×
  • Create New...

Important Information

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