Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hey folks,

I am triing to create a new type of air (toxic air), which means I need a block that will be semi transparent.

To do so I took a look at glass and how it does that.

I think that my solution lies in shouldSideBeRendered, but I feel like Im missing something.

I took the original method from the BlockBreakable class and removed some unnecessary checks, but its rendering as a full block.

The reason I dont extend BlockBreakable is because the method I want is hardcoded to work for glass.

 

package de.failender.shadowsrising.blocks;

import de.failender.shadowsrising.ShadowsRising;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class ToxicAir extends Block{

public ToxicAir() {
	super(Material.air);
	setCreativeTab(ShadowsRising.shadowTab);

}

public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
    {
        return null;
    }

    public boolean isOpaqueCube()
    {
        return false;
    }

    public boolean canCollideCheck(IBlockState state, boolean hitIfLiquid)
    {
        return false;
    }
    
    @Override
    public boolean isReplaceable(World worldIn, BlockPos pos) {
    	return true;
    }
    public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        Block block = iblockstate.getBlock();

            if (worldIn.getBlockState(pos.offset(side.getOpposite())) != iblockstate)
            {
                return true;
            }

            if (block == this)
            {
                return false;
            }
        

        return block == this ? false : super.shouldSideBeRendered(worldIn, pos, side);
    }
}

What is the problem that you are having?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author

Oh sorry I was rewriting my text and removed the problem.. retarded me. The block is not transparent. Its passable and all that but rendering like there is no transparency

The problem is in your json file.  Take a look at the json files for colored glass.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author

to be honest. im not sure whats the problem in there.

 

if i compare those jsons..

 

block models

 

 

{

    "parent": "block/cube_all",

    "textures": {

        "all": "shadowsrising:blocks/toxicair"

    }

}

 

 

 

 

 

{

    "parent": "block/cube_all",

    "textures": {

        "all": "blocks/glass_yellow"

    }

}

 

 

 

blockstates

 

 

{

    "variants": {

        "normal": { "model": "shadowsrising:toxicair"}

    }

}

 

 

 

 

 

{

    "variants": {

        "normal": { "model": "glass_yellow" }

    }

}

 

 

If you look in BlockStainedGlass you will find this

    @SideOnly(Side.CLIENT)
    public EnumWorldBlockLayer getBlockLayer()
    {
        return EnumWorldBlockLayer.TRANSLUCENT;
    }

while in Normal Glass TRANSLUCENT is instead CUTOUT.

Add this to your block class and it should fix the problem you are having.

Did you really need to know?

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.