package mcjty.deepresonance.blocks.debug;
import mcjty.deepresonance.DeepResonance;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.BlockRenderLayer;
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.client.model.ModelLoader;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List;
import java.util.Random;
public class DebugBlock extends Block {
public static final int STATUS_RED = 0;
public static final int STATUS_BLUE = 1;
public static final int STATUS_YELLOW = 2;
public static PropertyInteger STATUS = PropertyInteger.create("status", 0, 2);
public DebugBlock() {
super(Material.GLASS);
setUnlocalizedName(DeepResonance.MODID + "_debug_block");
setRegistryName("debug_block");
GameRegistry.register(this);
GameRegistry.register(new ItemBlock(this), getRegistryName());
}
@SideOnly(Side.CLIENT)
public void initModel() {
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(this), 0, new ModelResourceLocation(getRegistryName(), "inventory"));
}
@Override
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public boolean isFullBlock(IBlockState state) {
return false;
}
@Override
public boolean isFullCube(IBlockState state) {
return false;
}
@SideOnly(Side.CLIENT)
@Override
public BlockRenderLayer getBlockLayer() {
return BlockRenderLayer.TRANSLUCENT;
}
@Override
public boolean isBlockNormalCube(IBlockState state) {
return false;
}
@Override
public int quantityDropped(Random random) {
return 0;
}
@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) {
return null;
}
@Override
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, Entity entityIn) {
}
@SideOnly(Side.CLIENT)
@Override
public boolean shouldSideBeRendered(IBlockState state, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
Block block = state.getBlock();
IBlockState state2 = blockAccess.getBlockState(pos.offset(side));
Block block2 = state2.getBlock();
if (block.getMetaFromState(state) != block2.getMetaFromState(state2)) {
return true;
}
if (block == this) {
return false;
}
return block != this && super.shouldSideBeRendered(state, blockAccess, pos, side);
}
@Override
public IBlockState getStateFromMeta(int meta) {
return getDefaultState().withProperty(STATUS, meta);
}
@Override
public int getMetaFromState(IBlockState state) {
return state.getValue(STATUS);
}
@Override
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, STATUS);
}
}