- 5,018
- 47
- 783
Господа, ставлю значит блокстейт, сетаю ему нулевую коллизию. Блок проходим со всех сторон, но данная вот конкретная нормалль почему то остается непроходимой. Как ето понимать? Никакого дергания причем, свидетельствующего о том, что какой то обычный рассинхрон. Проверка на клиент есть. Просто одна нормалль по какой то причине твердая!
Блок имеет тайл, если это важно, хотя я не понял как он тут и причем.
Блок имеет тайл, если это важно, хотя я не понял как он тут и причем.
Java:
public class BigHermodoor extends BlockBase {
private static AxisAlignedBB[] SIDE_AABB = new AxisAlignedBB[] {
new AxisAlignedBB(0D, 0D, 0.6D, 1D, 1D, 1D),
new AxisAlignedBB(0D, 0D, 0D, 1D, 1D, 0.4D),
new AxisAlignedBB(0D, 0D, 0D, 0.4D, 1D, 1D),
new AxisAlignedBB(0.6D, 0D, 0D, 1D, 1D, 1D)
};
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
public BigHermodoor(Material materialIn, String name, float hardness, float resistanse, SoundType soundtype) {
super(materialIn, name);
setSoundType(SoundType.WOOD);
setDefaultState(blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
}
@Override
public boolean isFullCube(IBlockState state) {
return false;
}
public void onBlockAdded(World world, BlockPos pos, IBlockState state)
{
if (!world.isRemote)
{
if(state.getValue(FACING) == EnumFacing.EAST) {
if(world.isAirBlock(pos.north()) && world.isAirBlock(pos.up()) && world.isAirBlock(pos.north().up())) {
world.setBlockState(pos.north(), RegBlocks.fantom_block3.getDefaultState().withProperty(FACING, EnumFacing.EAST));
world.setBlockState(pos.up(), RegBlocks.fantom_block3.getDefaultState().withProperty(FACING, EnumFacing.EAST));
world.setBlockState(pos.north().up(), RegBlocks.fantom_block3.getDefaultState().withProperty(FACING, EnumFacing.EAST));
}
}
if(state.getValue(FACING) == EnumFacing.WEST) {
if(world.isAirBlock(pos.south()) && world.isAirBlock(pos.up()) && world.isAirBlock(pos.south().up())) {
world.setBlockState(pos.south(), RegBlocks.fantom_block3.getDefaultState().withProperty(FACING, EnumFacing.WEST));
world.setBlockState(pos.up(), RegBlocks.fantom_block3.getDefaultState().withProperty(FACING, EnumFacing.WEST));
world.setBlockState(pos.south().up(), RegBlocks.fantom_block3.getDefaultState().withProperty(FACING, EnumFacing.WEST));
}
}
if(state.getValue(FACING) == EnumFacing.SOUTH) {
if(world.isAirBlock(pos.east()) && world.isAirBlock(pos.up()) && world.isAirBlock(pos.east().up())) {
world.setBlockState(pos.east(), RegBlocks.fantom_block3.getDefaultState().withProperty(FACING, EnumFacing.SOUTH));
world.setBlockState(pos.up(), RegBlocks.fantom_block3.getDefaultState().withProperty(FACING, EnumFacing.SOUTH));
world.setBlockState(pos.east().up(), RegBlocks.fantom_block3.getDefaultState().withProperty(FACING, EnumFacing.SOUTH));
}
}
if(state.getValue(FACING) == EnumFacing.NORTH) {
if(world.isAirBlock(pos.west()) && world.isAirBlock(pos.up()) && world.isAirBlock(pos.west().up())) {
world.setBlockState(pos.west(), RegBlocks.fantom_block3.getDefaultState().withProperty(FACING, EnumFacing.NORTH));
world.setBlockState(pos.up(), RegBlocks.fantom_block3.getDefaultState().withProperty(FACING, EnumFacing.NORTH));
world.setBlockState(pos.west().up(), RegBlocks.fantom_block3.getDefaultState().withProperty(FACING, EnumFacing.NORTH));
}
}
}
}
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
}
@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
{
return NULL_AABB;
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
{
World w = (World)source;
if(w.isRemote) {
TileEntity te = source.getTileEntity(pos);
if(te instanceof TileEntityBigHermoDoor) {
if(((TileEntityBigHermoDoor)te).asm != null) {
if(((TileEntityBigHermoDoor)te).asm.currentState().equals("closed")) {
if(w.isRemote) {
switch (state.getValue(FACING))
{
case SOUTH:
return this.SIDE_AABB[2];
case NORTH:
default:
return this.SIDE_AABB[3];
case WEST:
return this.SIDE_AABB[1];
case EAST:
return this.SIDE_AABB[0];
}
}
}
else if(((TileEntityBigHermoDoor)te).asm.currentState().equals("open")) {
if(w.isRemote) {
switch (state.getValue(FACING))
{
case SOUTH:
return this.SIDE_AABB[0];
case NORTH:
default:
return this.SIDE_AABB[1];
case WEST:
return this.SIDE_AABB[2];
case EAST:
return this.SIDE_AABB[3];
}
}
}
}
}
}
return this.SIDE_AABB[3];
}
@Override
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Nonnull
@Override
public ExtendedBlockState createBlockState() {
return new ExtendedBlockState(this, new IProperty[]{ FACING, Properties.StaticProperty }, new IUnlistedProperty[]{ Properties.AnimationProperty });
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
TileEntity te = world.getTileEntity(pos);
if(te instanceof TileEntityBigHermoDoor) {
if(((TileEntityBigHermoDoor)te).asm != null) {
if(((TileEntityBigHermoDoor)te).asm.currentState().equals("open")) {
if(!world.isRemote) {
if(state.getValue(FACING) == EnumFacing.EAST) {
if(world.getBlockState(pos.north()).getBlock() == RegBlocks.fantom_block3 && world.getBlockState(pos.north().up()).getBlock() == RegBlocks.fantom_block3) {
world.setBlockState(pos.north(), Blocks.AIR.getDefaultState());
world.setBlockState(pos.north().up(), Blocks.AIR.getDefaultState());
}
}
}
}
if(((TileEntityBigHermoDoor)te).asm.currentState().equals("closed")) {
if(!world.isRemote) {
if(state.getValue(FACING) == EnumFacing.EAST) {
if(world.isAirBlock(pos.north()) && world.isAirBlock(pos.north().up())) {
world.setBlockState(pos.north(), RegBlocks.fantom_block3.getDefaultState().withProperty(FACING, EnumFacing.EAST));
world.setBlockState(pos.north().up(), RegBlocks.fantom_block3.getDefaultState().withProperty(FACING, EnumFacing.EAST));
}
}
}
}
if(world.isRemote) {
if(te instanceof TileEntityBigHermoDoor) {
((TileEntityBigHermoDoor)te).click();
}
}
}
}return true;
}
@Override
public TileEntity createNewTileEntity(@Nonnull World worldIn, int meta) {
return new TileEntityBigHermoDoor();
}
@Override
public IBlockState getActualState(@Nonnull IBlockState state, IBlockAccess world, BlockPos pos) {
return state.withProperty(Properties.StaticProperty, true);
}
@Override
public IBlockState getStateFromMeta(int meta) {
EnumFacing facing = EnumFacing.getHorizontal(meta);
return getDefaultState().withProperty(FACING, facing);
}
@Override
public int getMetaFromState(IBlockState state) {
return state.getValue(FACING).getHorizontalIndex();
}
@Override
public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facingIn, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
EnumFacing facing = (placer == null) ? EnumFacing.NORTH : EnumFacing.fromAngle(placer.rotationYaw);
return getDefaultState().withProperty(FACING, facing);
}
/*
@Override
public EnumBlockRenderType getRenderType(IBlockState state) {
return EnumBlockRenderType.ENTITYBLOCK_ANIMATED;
}
*/
}