Block fixes

This commit is contained in:
WayofTime 2016-03-18 13:16:38 -04:00
parent 252a4559f0
commit 10c6829482
31 changed files with 638 additions and 561 deletions

View file

@ -1,18 +1,22 @@
package WayofTime.bloodmagic.block;
import WayofTime.bloodmagic.BloodMagic;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import WayofTime.bloodmagic.BloodMagic;
public abstract class BlockRoutingNode extends BlockContainer
{
protected static final AxisAlignedBB AABB = new AxisAlignedBB(0.378F, 0.378F, 0.378F, 0.625F, 0.625F, 0.625F);
public static final PropertyBool UP = PropertyBool.create("up");
public static final PropertyBool DOWN = PropertyBool.create("down");
public static final PropertyBool NORTH = PropertyBool.create("north");
@ -29,25 +33,23 @@ public abstract class BlockRoutingNode extends BlockContainer
setResistance(5.0F);
setHarvestLevel("pickaxe", 2);
setBlockBounds(0.378F, 0.378F, 0.378F, 0.625F, 0.625F, 0.625F);
this.setDefaultState(this.blockState.getBaseState().withProperty(DOWN, false).withProperty(UP, false).withProperty(NORTH, false).withProperty(EAST, false).withProperty(SOUTH, false).withProperty(WEST, false));
}
@Override
public boolean isOpaqueCube()
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
{
return AABB;
}
@Override
public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos)
{
return false;
}
@Override
public boolean canRenderInLayer(EnumWorldBlockLayer layer)
{
return layer == EnumWorldBlockLayer.CUTOUT_MIPPED || layer == EnumWorldBlockLayer.TRANSLUCENT;
}
@Override
public boolean isFullCube()
public boolean isFullCube(IBlockState state)
{
return false;
}
@ -58,6 +60,18 @@ public abstract class BlockRoutingNode extends BlockContainer
return false;
}
@Override
public EnumBlockRenderType getRenderType(IBlockState state)
{
return EnumBlockRenderType.MODEL;
}
@Override
public boolean canRenderInLayer(BlockRenderLayer layer)
{
return layer == BlockRenderLayer.CUTOUT_MIPPED || layer == BlockRenderLayer.TRANSLUCENT;
}
@Override
public IBlockState getStateFromMeta(int meta)
{
@ -76,24 +90,18 @@ public abstract class BlockRoutingNode extends BlockContainer
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
{
return state.withProperty(UP, this.shouldConnect(worldIn, pos.up())).withProperty(DOWN, this.shouldConnect(worldIn, pos.down())).withProperty(NORTH, this.shouldConnect(worldIn, pos.north())).withProperty(EAST, this.shouldConnect(worldIn, pos.east())).withProperty(SOUTH, this.shouldConnect(worldIn, pos.south())).withProperty(WEST, this.shouldConnect(worldIn, pos.west()));
return state.withProperty(UP, this.shouldConnect(state, worldIn, pos.up())).withProperty(DOWN, this.shouldConnect(state, worldIn, pos.down())).withProperty(NORTH, this.shouldConnect(state, worldIn, pos.north())).withProperty(EAST, this.shouldConnect(state, worldIn, pos.east())).withProperty(SOUTH, this.shouldConnect(state, worldIn, pos.south())).withProperty(WEST, this.shouldConnect(state, worldIn, pos.west()));
}
@Override
protected BlockState createBlockState()
protected BlockStateContainer createBlockState()
{
return new BlockState(this, UP, DOWN, NORTH, EAST, WEST, SOUTH);
return new BlockStateContainer(this, UP, DOWN, NORTH, EAST, WEST, SOUTH);
}
public boolean shouldConnect(IBlockAccess world, BlockPos pos)
public boolean shouldConnect(IBlockState state, IBlockAccess world, BlockPos pos)
{
Block block = world.getBlockState(pos).getBlock();
return block.isFullBlock() && block.isFullCube();
}
@Override
public int getRenderType()
{
return 3;
return block.isFullBlock(state) && block.isFullCube(state);
}
}