Jump to content

[SOLVED] [1.10.2] Rendering the inside of a block


Tschipp

Recommended Posts

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

}

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • The error code shows that i have outdated mods, but only coFH core crashes my game and it's not outdated + i double checked and its on the right version of forge. -- Head -- Thread: Render thread Stacktrace:     at cofh.core.client.PostEffect.m_6213_(PostEffect.java:80) ~[cofh_core-1.20.1-11.0.2.56.jar%23218!/:11.0.2] {re:mixin,re:classloading}     at cofh.core.client.PostBuffer.m_6213_(PostBuffer.java:96) ~[cofh_core-1.20.1-11.0.2.56.jar%23218!/:11.0.2] {re:classloading}     at net.minecraft.server.packs.resources.ResourceManagerReloadListener.m_10759_(ResourceManagerReloadListener.java:15) ~[client-1.20.1-20230612.114412-srg.jar%23267!/:?] {re:computing_frames,re:classloading,re:mixin}     at java.util.concurrent.CompletableFuture$UniRun.tryFire(CompletableFuture.java:787) ~[?:?] {}     at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482) ~[?:?] {}     at net.minecraft.server.packs.resources.SimpleReloadInstance.m_143940_(SimpleReloadInstance.java:69) ~[client-1.20.1-20230612.114412-srg.jar%23267!/:?] {re:classloading}     at net.minecraft.util.thread.BlockableEventLoop.m_6367_(BlockableEventLoop.java:198) ~[client-1.20.1-20230612.114412-srg.jar%23267!/:?] {re:mixin,pl:accesstransformer:B,xf:OptiFine:default,re:computing_frames,pl:accesstransformer:B,xf:OptiFine:default,re:classloading,pl:accesstransformer:B,xf:OptiFine:default}     at net.minecraft.util.thread.ReentrantBlockableEventLoop.m_6367_(ReentrantBlockableEventLoop.java:23) ~[client-1.20.1-20230612.114412-srg.jar%23267!/:?] {re:mixin,re:computing_frames,re:classloading}     at net.minecraft.util.thread.BlockableEventLoop.m_7245_(BlockableEventLoop.java:163) ~[client-1.20.1-20230612.114412-srg.jar%23267!/:?] {re:mixin,pl:accesstransformer:B,xf:OptiFine:default,re:computing_frames,pl:accesstransformer:B,xf:OptiFine:default,re:classloading,pl:accesstransformer:B,xf:OptiFine:default} -- Overlay render details -- Details:     Overlay name: net.minecraftforge.client.loading.ForgeLoadingOverlay Stacktrace:     at net.minecraft.client.renderer.GameRenderer.m_109093_(GameRenderer.java:1385) ~[client-1.20.1-20230612.114412-srg.jar%23267!/:?] {re:mixin,pl:accesstransformer:B,xf:OptiFine:default,re:classloading,pl:accesstransformer:B,xf:OptiFine:default,pl:mixin:APP:moonlight-common.mixins.json:GameRendererMixin,pl:mixin:APP:supplementaries-common.mixins.json:GameRendererMixin,pl:mixin:APP:mixins.cofhcore.json:GameRendererMixin,pl:mixin:APP:create.mixins.json:accessor.GameRendererAccessor,pl:mixin:APP:create.mixins.json:client.GameRendererMixin,pl:mixin:A}     at net.minecraft.client.Minecraft.m_91383_(Minecraft.java:1146) ~[client-1.20.1-20230612.114412-srg.jar%23267!/:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:A,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.m_91374_(Minecraft.java:718) ~[client-1.20.1-20230612.114412-srg.jar%23267!/:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:A,pl:runtimedistcleaner:A}     at net.minecraft.client.main.Main.main(Main.java:218) ~[1.20.1-forge-47.3.0.jar:?] {re:mixin,pl:runtimedistcleaner:A,re:classloading,pl:mixin:APP:flywheel.mixins.json:ClientMainMixin,pl:mixin:A,pl:runtimedistcleaner:A}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] {}     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}     at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] {}     at net.minecraftforge.fml.loading.targets.CommonLaunchHandler.runTarget(CommonLaunchHandler.java:111) ~[fmlloader-1.20.1-47.3.0.jar:?] {}     at net.minecraftforge.fml.loading.targets.CommonLaunchHandler.clientService(CommonLaunchHandler.java:99) ~[fmlloader-1.20.1-47.3.0.jar:?] {}     at net.minecraftforge.fml.loading.targets.CommonClientLaunchHandler.lambda$makeService$0(CommonClientLaunchHandler.java:25) ~[fmlloader-1.20.1-47.3.0.jar:?] {}     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:30) ~[modlauncher-10.0.9.jar:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) ~[modlauncher-10.0.9.jar:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) ~[modlauncher-10.0.9.jar:?] {}     at cpw.mods.modlauncher.Launcher.run(Launcher.java:108) ~[modlauncher-10.0.9.jar:?] {}     at cpw.mods.modlauncher.Launcher.main(Launcher.java:78) ~[modlauncher-10.0.9.jar:?] {}     at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) ~[modlauncher-10.0.9.jar:?] {}     at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) ~[modlauncher-10.0.9.jar:?] {}     at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:141) ~[bootstraplauncher-1.1.2.jar:?] {}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] {}     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}     at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] {}     at crystallauncher.MinecraftConstructor.run(MinecraftConstructor.java:29) ~[proxyserver.jar%2380!/:?] {}     at crystallauncher.MineClient.start(MineClient.java:201) ~[proxyserver.jar%2380!/:?] {}     at crystallauncher.MineClient.main(MineClient.java:42) ~[proxyserver.jar%2380!/:?] {}
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system
    • Need help with making shooting book, in this code i can summon fireball but it goes inside or oposite way can you help me? package net.LimboTeam.tropicmod.item.custom; import net.LimboTeam.tropicmod.item.ModCreativeModTab; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.projectile.LargeFireball; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import java.util.Random; public class FireballMagicBook extends Item { public FireballMagicBook(Properties properties) { super(new Item.Properties().tab(ModCreativeModTab.TropicModTab)); } @Override public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) { ItemStack itemStack = player.getItemInHand(hand); Random random = new Random(); Vec3 vec3 = player.getViewVector(1.0f); if (!level.isClientSide && hand == InteractionHand.MAIN_HAND){ double X = player.getX() - (player.getX() + vec3.x * 4.0); double Y = player.getY(0.5) - (0.5 + player.getY(0.5)); double Z = player.getZ() - (player.getZ() + vec3.z * 4.0); LargeFireball fireball = new LargeFireball(level, player, X , Y, Z,1); fireball.setPos(player.getX(), player.getY(), player.getZ()); level.addFreshEntity(fireball); level.playSound((Player)null, player.getX(), player.getY(), player.getZ(), SoundEvents.GHAST_SHOOT, SoundSource.NEUTRAL, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F)); if (!player.isCreative()) { itemStack.setDamageValue(itemStack.getDamageValue() + 1); } player.getCooldowns().addCooldown(this, 40 ); return new InteractionResultHolder<>(InteractionResult.SUCCESS, itemStack); } return new InteractionResultHolder<>(InteractionResult.FAIL, itemStack); } }  
  • Topics

×
×
  • Create New...

Important Information

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