Posted January 4, 20178 yr I'm trying to make a block that only renders it's side when it touches a block that is not air. This sort of works so far, the problem is that the block is only visible from the outside. Here is a screenshot to explain: The block is only visible through the grass, not if I stand inside or behind the block. I think, what I need to do is tell the game to render the insides of the block as well. How would I do that? Block Class: package tschipp.buildingblocks.blocks; import java.util.ArrayList; import java.util.List; import javax.annotation.Nullable; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.MapColor; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.IShearable; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import tschipp.buildingblocks.BBMod; public class BlockOvergrowth extends Block implements IShearable { public static final AxisAlignedBB boundingBox = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0625D, 0.0625D,0.0625D); public BlockOvergrowth() { super(Material.PLANTS, MapColor.GRASS); this.setCreativeTab(BBMod.buildingBlocks); this.setUnlocalizedName("overgrowth"); this.setSoundType(SoundType.PLANT); this.setHardness(0.1F); this.setResistance(1F); } @Override public boolean isShearable(ItemStack item, IBlockAccess world, BlockPos pos) { return true; } @Override @Deprecated public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return boundingBox; } @Nullable @Override public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) { return NULL_AABB; } @Override public boolean isReplaceable(IBlockAccess worldIn, BlockPos pos) { return true; } @Override public boolean isOpaqueCube(IBlockState state) { return false; } @Override public boolean isFullCube(IBlockState state) { return false; } @Override @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT; } @Override public boolean isCollidable() { return false; } @Deprecated @Override public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess world, BlockPos pos, EnumFacing side) { Block nextTo = world.getBlockState(pos.offset(side)).getBlock(); if(nextTo != Blocks.AIR) { return true; } return false; } @Override public List<ItemStack> onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) { List<ItemStack> drops = new ArrayList<ItemStack>(); drops.add(new ItemStack(BBBlocks.overgrowth)); return drops; } }
January 4, 20178 yr You need to edit your model and add planes for the inside. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
January 4, 20178 yr Show your model. You're probably only adding a quad for one side. Quads are only rendered from one side, from the opposite side they'll be invisible, so if you want your block to have the same texture on both sides, you'll need to quads. Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
January 4, 20178 yr Author Show your model. You're probably only adding a quad for one side. Quads are only rendered from one side, from the opposite side they'll be invisible, so if you want your block to have the same texture on both sides, you'll need to quads. I am using the cube_all model
January 4, 20178 yr Author Show your model. You're probably only adding a quad for one side. Quads are only rendered from one side, from the opposite side they'll be invisible, so if you want your block to have the same texture on both sides, you'll need to quads. I just realized I'm probably a idiot for using a block model that only has one element. I'll add some planes and get back to you. I am using the cube_all model
January 4, 20178 yr Author You need to edit your model and add planes for the inside. Alright, I made some progress: The sides now all get rendered, the problem is, they get rendered even when touching air. How do I need to alter my code / blockmodel? here is my model, I made it using MrCrayfish's model maker, because I have no idea how to model by hand: { "textures": { }, "elements": [ { "name": "Cube", "from": [ 0.0, 0.0, 0.0 ], "to": [ 0.0, 16.0, 16.0 ], "faces": { "north": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] }, "east": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 16.0 ] }, "south": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] }, "west": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 16.0 ] }, "up": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] }, "down": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] } } }, { "name": "Cube", "from": [ 0.0, 0.0, 0.0 ], "to": [ 16.0, 16.0, 0.0 ], "faces": { "north": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 16.0 ] }, "east": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] }, "south": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 16.0 ] }, "west": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] }, "up": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 0.0 ] }, "down": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 0.0 ] } } }, { "name": "Cube", "from": [ 16.0, 0.0, 0.0 ], "to": [ 16.0, 16.0, 16.0 ], "faces": { "north": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] }, "east": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 16.0 ] }, "south": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] }, "west": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 16.0 ] }, "up": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] }, "down": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] } } }, { "name": "Cube", "from": [ 0.0, 0.0, 16.0 ], "to": [ 16.0, 16.0, 16.0 ], "faces": { "north": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 16.0 ] }, "east": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] }, "south": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 16.0 ] }, "west": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] }, "up": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 0.0 ] }, "down": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 0.0 ] } } }, { "name": "Cube", "from": [ 0.0, 16.0, 0.0 ], "to": [ 16.0, 16.0, 16.0 ], "faces": { "north": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 0.0 ] }, "east": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 0.0 ] }, "south": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 0.0 ] }, "west": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 0.0 ] }, "up": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 16.0 ] }, "down": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 16.0 ] } } }, { "name": "Cube", "from": [ 0.0, 0.0, 0.0 ], "to": [ 16.0, 0.0, 16.0 ], "shade": false, "faces": { "north": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 0.0 ] }, "east": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 0.0 ] }, "south": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 0.0 ] }, "west": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 0.0 ] }, "up": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 16.0 ] }, "down": { "texture": "#all", "uv": [ 0.0, 0.0, 16.0, 16.0 ] } } } ] }
January 4, 20178 yr How did you do it before? VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
January 4, 20178 yr Author How did you do it before? I didn't change any of my code, just the block model. In the shouldSideBeRendered method I check if the side is touching air. If it is, I return false.
January 4, 20178 yr I think shouldSideBeRendered only works with cube_all models. Otherwise there'd be no way for the code to know which faces of which shapes count as each 'side'. You can definitely use blockstates to adapt the model depending on the blocks around it, as an alternative.
January 4, 20178 yr I think shouldSideBeRendered only works with cube_all models. Otherwise there'd be no way for the code to know which faces of which shapes count as each 'side'. You can definitely use blockstates to adapt the model depending on the blocks around it, as an alternative. There would be a way... "north": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] }, You specify the face in the model. But the BlockState part is definitely the correct way to go. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
January 4, 20178 yr Author There would be a way... "north": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] }, You specify the face in the model. But the BlockState part is definitely the correct way to go. What do you mean? I know Blockstates would probably be better but I find it a pain setting up the blockstates and all...
January 4, 20178 yr Author There would be a way... "north": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] }, You specify the face in the model. But the BlockState part is definitely the correct way to go. What do you mean? I know Blockstates would probably be better but I find it a pain setting up the blockstates and all... I think I found it! I just had to set a cullface for the elements! But now the planes of the block below and my block are z-fighting (I think that's the right word). How do I fix that?
January 4, 20178 yr You override getActualState in your Block class. This will return the default state with 6 values; boolean values. Each one will represent if there is a block that is not air. If there is a block that is not air it will add to the model using forges submodel system. Meaning you will use a forge style BlockState. You will also have to override getMetaFromState, getStateFromMeta, createBlockState. There would be a way... "north": { "texture": "#all", "uv": [ 0.0, 0.0, 0.0, 16.0 ] }, You specify the face in the model. But the BlockState part is definitely the correct way to go. What do you mean? I know Blockstates would probably be better but I find it a pain setting up the blockstates and all... I think I found it! I just had to set a cullface for the elements! But now the planes of the block below and my block are z-fighting (I think that's the right word). How do I fix that? You will have to make one face slightly closer to the middle of the block or slightly farther from the block. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.