Jump to content

Cutout Block Still Culling Adjacent Block Faces


Niroque

Recommended Posts

Hi there,

 

   My goal is to have this block look kind of like a lone fence post (minus attaching to adjacent blocks) where the object is cutout and the surfaces of the blocks around it are rendered.  I've tried duplicating a fence post but that became overly complicated and I got a bit lost.  Sadly this is what my block is doing so far (see attached).

 

   Using Eclipse and modding MC 1.12.2.  Here's my block class and definition:

package com.testmod.mod.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.BlockRenderLayer;

public class BlockBasic extends Block {
	public BlockBasic(String name, Material material) {
		super(material);
		setUnlocalizedName(name);
		setRegistryName(name);
	}
	
    public BlockRenderLayer getBlockLayer()
    {
        return BlockRenderLayer.TRANSLUCENT;
    }

    public boolean isFullCube(IBlockState state)
    {
        return false;
    }
    
    public boolean isOpaqueCube() {
    	return false;
    }
    
    public boolean isVisuallyOpaque() {
    	return false;
    }
}

 

package com.testmod.mod.init;

import com.testmod.mod.Reference;
import com.testmod.mod.blocks.BlockBasic;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

@Mod.EventBusSubscriber(modid=Reference.MODID)
public class ModBlocks {
	static Block firstBlock;
	static Block fenceDupe;
	
    public static void init() {
    	firstBlock = new BlockBasic("firstBlock", Material.WOOD);
	}
    
    public boolean isOpaqueCube(IBlockState state)
    {
        return false;
    }

    public boolean isFullCube(IBlockState state)
    {
        return false;
    }
	
	@SubscribeEvent
	public static void registerBlocks(RegistryEvent.Register<Block> event) {
		event.getRegistry().registerAll(firstBlock);
	}
	
	@SubscribeEvent
	public static void registerItemBlocks(RegistryEvent.Register<Item> event) {
		event.getRegistry().registerAll(new ItemBlock(firstBlock).setRegistryName(firstBlock.getRegistryName()));
	}
	
	@SubscribeEvent
	public static void registerRenders(ModelRegistryEvent event) {
		registerRender(Item.getItemFromBlock(firstBlock));
	}
	
	public static void registerRender(Item item) {
		ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation( item.getRegistryName(), "inventory"));
	}
}

 

I've added what I *think should be working, but no joy.  Anyone point me in the right direction?  BTW; new to Minecraft modding so forgive me if I've missed something obvious.

 

Thanks!

2019-01-09_18.53.00.png

Edited by Niroque
Link to comment
Share on other sites

I already have this to override, is there another way to override them that's more reliable?

 

    public BlockRenderLayer getBlockLayer()
    {
        return BlockRenderLayer.TRANSLUCENT;
    }
    
    public boolean isNormalCube(IBlockState state)
    {
        return false;
    }

    public boolean isFullCube(IBlockState state)
    {
        return false;
    }
    
    public boolean isOpaqueCube(IBlockState state) {
    	return false;
    }
    
    public boolean isVisuallyOpaque() {
    	return false;
    }

 

Link to comment
Share on other sites

No, those overrides should be sufficient.  What does your model JSON look like?

 

Also, you should be using CUTOUT_MIPPED for your block render layer (getBlockLayer()). TRANSLUCENT is for blocks like glass or ice.

Edited by desht
  • Like 1
Link to comment
Share on other sites

Here's my firstblock.json:
 

{
    "__comment": "Model generated using MrCrayfish's Model Creator (https://mrcrayfish.com/tools?id=mc)",
    "textures": {
        "0": "tm:blocks/firstblock",
        "1": "tm:blocks/firstblock"
    },
    "display": {
        "head": {
            "rotation": [ 0, 180, 0 ],
            "translation": [ 0, 0, 0 ],
            "scale": [ 1, 1, 1 ]
        },
        "firstperson_righthand": {
            "rotation": [ 0, 315, 0 ],
            "translation": [ 0, 2.5, 0 ],
            "scale": [ 0.4, 0.4, 0.4 ]
        },
        "thirdperson_lefthand": {
            "rotation": [ 75, 45, 0 ],
            "translation": [ 0, 2.5, 0 ],
            "scale": [ 0.375, 0.375, 0.375 ]
        },
        "firstperson_lefthand": {
            "rotation": [ 0, 0, 45 ],
            "translation": [ 0, 2.5, 0 ],
            "scale": [ 0.4, 0.4, 0.4 ]
        },
        "gui": {
            "rotation": [ 30, 45, 0 ],
            "translation": [ 0, 0, 0 ],
            "scale": [ 0.625, 0.625, 0.625 ]
        },
        "ground": {
            "rotation": [ 0, 0, 0 ],
            "translation": [ 0, 3, 0 ],
            "scale": [ 0.25, 0.25, 0.25 ]
        },
        "fixed": {
            "rotation": [ 0, 180, 0 ],
            "translation": [ 0, 0, 0 ],
            "scale": [ 1, 1, 1 ]
        },
        "thirdperson_righthand": {
            "rotation": [ 75, 315, 0 ],
            "translation": [ 0, 2.5, 0 ],
            "scale": [ 0.375, 0.375, 0.375 ]
        }
    },
    "elements": [
        {
            "name": "Cube",
            "from": [ 2, 1, 4 ], 
            "to": [ 4, 10, 6 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 0, 0, 2, 9 ] },
                "east": { "texture": "#0", "uv": [ 0, 0, 2, 9 ] },
                "south": { "texture": "#0", "uv": [ 0, 0, 2, 9 ] },
                "west": { "texture": "#0", "uv": [ 0, 0, 2, 9 ] },
                "down": { "texture": "#0", "uv": [ 0, 0, 2, 2 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 11, 1, 4 ], 
            "to": [ 13, 10, 6 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 1, 7, 3, 16 ] },
                "east": { "texture": "#0", "uv": [ 9, 7, 11, 16 ] },
                "south": { "texture": "#0", "uv": [ 5, 0, 7, 9 ] },
                "west": { "texture": "#0", "uv": [ 0, 7, 2, 16 ] },
                "down": { "texture": "#0", "uv": [ 0, 0, 2, 2 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 11, 1, 14 ], 
            "to": [ 13, 10, 16 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 8, 5, 10, 14 ] },
                "east": { "texture": "#0", "uv": [ 0, 3, 2, 12 ] },
                "south": { "texture": "#0", "uv": [ 4, 4, 6, 13 ] },
                "west": { "texture": "#0", "uv": [ 13, 0, 15, 9 ] },
                "down": { "texture": "#0", "uv": [ 0, 0, 2, 2 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 2, 1, 14 ], 
            "to": [ 4, 10, 16 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 4, 7, 6, 16 ] },
                "east": { "texture": "#0", "uv": [ 13, 3, 15, 12 ] },
                "south": { "texture": "#0", "uv": [ 8, 5, 10, 14 ] },
                "west": { "texture": "#0", "uv": [ 9, 0, 11, 9 ] },
                "down": { "texture": "#0", "uv": [ 0, 0, 2, 2 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 2, 9, 4 ], 
            "to": [ 13, 10, 16 ], 
            "faces": {
                "north": { "texture": "#1", "uv": [ 0, 0, 11, 1 ] },
                "east": { "texture": "#1", "uv": [ 0, 0, 12, 1 ] },
                "south": { "texture": "#1", "uv": [ 0, 0, 11, 1 ] },
                "west": { "texture": "#1", "uv": [ 0, 0, 12, 1 ] },
                "up": { "texture": "#1", "uv": [ 0, 0, 11, 12 ] },
                "down": { "texture": "#1", "uv": [ 0, 0, 11, 12 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 2, 9, 5 ], 
            "to": [ 4, 21, 7 ], 
            "rotation": { "origin": [ 8.0, 8.0, 5.0 ], "axis": "x", "angle": -22.5 },
            "faces": {
                "north": { "texture": "#0", "uv": [ 1, 0, 3, 12 ] },
                "east": { "texture": "#0", "uv": [ 0, 4, 2, 16 ] },
                "south": { "texture": "#0", "uv": [ 9, 4, 11, 16 ] },
                "west": { "texture": "#0", "uv": [ 5, 4, 7, 16 ] },
                "up": { "texture": "#0", "uv": [ 1, 2, 3, 4 ] },
                "down": { "texture": "#0", "uv": [ 0, 0, 2, 2 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 11, 9, 5 ], 
            "to": [ 13, 21, 7 ], 
            "rotation": { "origin": [ 8.0, 8.0, 5.0 ], "axis": "x", "angle": -22.5 },
            "faces": {
                "north": { "texture": "#0", "uv": [ 0, 0, 2, 12 ] },
                "east": { "texture": "#0", "uv": [ 5, 4, 7, 16 ] },
                "south": { "texture": "#0", "uv": [ 0, 0, 2, 12 ] },
                "west": { "texture": "#0", "uv": [ 0, 0, 2, 12 ] },
                "up": { "texture": "#0", "uv": [ 0, 0, 2, 2 ] },
                "down": { "texture": "#0", "uv": [ 0, 0, 2, 2 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 4, 12, 6 ], 
            "to": [ 11, 13, 7 ], 
            "rotation": { "origin": [ 8.0, 8.0, 8.0 ], "axis": "x", "angle": -22.5 },
            "faces": {
                "north": { "texture": "#1", "uv": [ 0, 0, 7, 1 ] },
                "east": { "texture": "#1", "uv": [ 0, 0, 1, 1 ] },
                "south": { "texture": "#1", "uv": [ 0, 0, 7, 1 ] },
                "west": { "texture": "#1", "uv": [ 0, 0, 1, 1 ] },
                "up": { "texture": "#1", "uv": [ 0, 0, 7, 1 ] },
                "down": { "texture": "#1", "uv": [ 0, 0, 7, 1 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 4, 20, 6 ], 
            "to": [ 11, 21, 7 ], 
            "rotation": { "origin": [ 8.0, 8.0, 8.0 ], "axis": "x", "angle": -22.5 },
            "faces": {
                "north": { "texture": "#1", "uv": [ 0, 0, 7, 1 ] },
                "east": { "texture": "#1", "uv": [ 0, 0, 1, 1 ] },
                "south": { "texture": "#1", "uv": [ 0, 0, 7, 1 ] },
                "west": { "texture": "#1", "uv": [ 0, 0, 1, 1 ] },
                "up": { "texture": "#1", "uv": [ 0, 0, 7, 1 ] },
                "down": { "texture": "#1", "uv": [ 0, 0, 7, 1 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 9, 11, 6 ], 
            "to": [ 10, 20, 7 ], 
            "rotation": { "origin": [ 8.0, 8.0, 5.0 ], "axis": "x", "angle": -22.5 },
            "faces": {
                "north": { "texture": "#0", "uv": [ 10, 7, 11, 16 ] },
                "east": { "texture": "#0", "uv": [ 5, 4, 6, 13 ] },
                "south": { "texture": "#0", "uv": [ 14, 4, 15, 13 ] },
                "west": { "texture": "#0", "uv": [ 5, 4, 6, 13 ] },
                "up": { "texture": "#0", "uv": [ 2, 7, 3, 8 ] },
                "down": { "texture": "#0", "uv": [ 0, 0, 1, 1 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 7, 11, 6 ], 
            "to": [ 8, 20, 7 ], 
            "rotation": { "origin": [ 8.0, 8.0, 5.0 ], "axis": "x", "angle": -22.5 },
            "faces": {
                "north": { "texture": "#0", "uv": [ 2, 7, 3, 16 ] },
                "east": { "texture": "#0", "uv": [ 0, 0, 1, 9 ] },
                "south": { "texture": "#0", "uv": [ 6, 6, 7, 15 ] },
                "west": { "texture": "#0", "uv": [ 0, 0, 1, 9 ] },
                "up": { "texture": "#0", "uv": [ 2, 7, 3, 8 ] },
                "down": { "texture": "#0", "uv": [ 0, 0, 1, 1 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 5, 11, 6 ], 
            "to": [ 6, 20, 7 ], 
            "rotation": { "origin": [ 8.0, 8.0, 5.0 ], "axis": "x", "angle": -22.5 },
            "faces": {
                "north": { "texture": "#0", "uv": [ 0, 3, 1, 12 ] },
                "east": { "texture": "#0", "uv": [ 1, 3, 2, 12 ] },
                "south": { "texture": "#0", "uv": [ 0, 6, 1, 15 ] },
                "west": { "texture": "#0", "uv": [ 2, 7, 3, 16 ] },
                "up": { "texture": "#0", "uv": [ 2, 7, 3, 8 ] },
                "down": { "texture": "#0", "uv": [ 0, 0, 1, 1 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 2, 3, 6 ], 
            "to": [ 3, 4, 14 ], 
            "faces": {
                "east": { "texture": "#1", "uv": [ 0, 0, 8, 1 ] },
                "west": { "texture": "#1", "uv": [ 0, 0, 8, 1 ] },
                "up": { "texture": "#0", "uv": [ 0, 0, 1, 8 ] },
                "down": { "texture": "#0", "uv": [ 0, 0, 1, 8 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 12, 3, 6 ], 
            "to": [ 13, 4, 14 ], 
            "faces": {
                "east": { "texture": "#1", "uv": [ 0, 0, 8, 1 ] },
                "west": { "texture": "#1", "uv": [ 0, 0, 8, 1 ] },
                "up": { "texture": "#0", "uv": [ 0, 0, 1, 8 ] },
                "down": { "texture": "#0", "uv": [ 0, 0, 1, 8 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 3, 3, 9 ], 
            "to": [ 12, 4, 11 ], 
            "faces": {
                "north": { "texture": "#1", "uv": [ 0, 0, 9, 1 ] },
                "south": { "texture": "#1", "uv": [ 0, 0, 9, 1 ] },
                "up": { "texture": "#1", "uv": [ 0, 0, 9, 2 ] },
                "down": { "texture": "#1", "uv": [ 0, 0, 9, 2 ] }
            }
        }
    ]
}

 

Link to comment
Share on other sites

After weeding out chaff leftover from debugging...

For anyone running into this, if you use:

public class YourBlockClass extends Block {

    public BlockRenderLayer getBlockLayer()
    {
        return BlockRenderLayer.CUTOUT_MIPPED;
    }

...
}

You also need to include:

    public boolean isOpaqueCube(IBlockState state) {
    	return false;
    }

 

In the end though, (for my block purposes anyhow) I was able to omit the usage of BlockRenderLayer getBlockLayer() and now only use isOpaqueCube(IBlockState state) in my block class.  The reason it wasn't working before is because I didn't include the passed variable "IBlockState state" in my early debugging (see my initial post).  I was having a hard time finding a working example since it took a while for me to find a way to see minecraft source code that wasn't obfuscated (mc modding newb).  Hope this helps someone!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...

Important Information

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