Jump to content

Recommended Posts

Posted

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:

DyKdeCu.png

 

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;
}

}

 

Posted

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

Posted
  On 1/4/2017 at 9:18 PM, shadowfacts said:

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

Posted
  On 1/4/2017 at 9:21 PM, Tschipp said:

  Quote

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

Posted
  On 1/4/2017 at 9:14 PM, Animefan8888 said:

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 ] }
            }
        }
    ]
}

Posted
  On 1/4/2017 at 9:49 PM, Animefan8888 said:

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.

Posted

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.

Posted
  On 1/4/2017 at 9:58 PM, Jazzable said:

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.

Posted
  On 1/4/2017 at 10:01 PM, Animefan8888 said:

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...

Posted
  On 1/4/2017 at 10:05 PM, Tschipp said:

  Quote

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?

Posted

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.

 

  On 1/4/2017 at 10:15 PM, Tschipp said:

  Quote

  Quote

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello all. I'm currently grappling with the updateShape method in a custom class extending Block.  My code currently looks like this: The conditionals in CheckState are there to switch blockstate properties, which is working fine, as it functions correctly every time in getStateForPlacement.  The problem I'm running into is that when I update a state, the blocks seem to call CheckState with the position of the block which was changed updated last.  If I build a wall I can see the same change propagate across. My question thus is this: is updateShape sending its return to the neighbouring block?  Is each block not independently executing the updateShape method, thus inserting its own current position?  The first statement appears to be true, and the second false (each block is not independently executing the method). I have tried to fix this by saving the block's own position to a variable myPos at inception, and then feeding this in as CheckState(myPos) but this causes a worse outcome, where all blocks take the update of the first modified block, rather than just their neighbour.  This raises more questions than it answers, obviously: how is a different instance's variable propagating here?  I also tried changing it so that CheckState did not take a BlockPos, but had myPos built into the body - same problem. I have previously looked at neighbourUpdate and onNeighbourUpdate, but could not find a way to get this to work at all.  One post on here about updatePostPlacement and other methods has proven itself long superceded.  All other sources on the net seem to be out of date. Many thanks in advance for any help you might offer me, it's been several days now of trying to get this work and several weeks of generally trying to get round this roadblock.  - Sandermall
    • sorry, I might be stupid, but how do I open it? because the only options I have are too X out, copy it, which doesn't work and send crash report, which doesn't show it to me, also, sorry for taking so long.
    • Can you reproduce this with version 55.0.21? A whole lot of plant placement issues were just fixed in this PR.
    • Necro'ing that thread to ask if you found a solution ? I'm encountering the same crash on loading the world. I created the world in Creative to test my MP, went into survival to test combat, died, crashed on respawn and since then crash on loading the world. Deactivating Oculus isn't fixing it either, and I don't have Optifine (Twilight forest is incompatible)
  • Topics

×
×
  • Create New...

Important Information

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