remove door metadata
This commit is contained in:
parent
a4a488523b
commit
a1a15dcdf6
1 changed files with 6 additions and 92 deletions
|
@ -61,7 +61,7 @@ public class BlockDoor extends Block implements Rotatable
|
|||
|
||||
public boolean isPassable(IBlockAccess worldIn, BlockPos pos)
|
||||
{
|
||||
return isOpen(combineMetadata(worldIn, pos));
|
||||
return worldIn.getState(pos).getValue(OPEN);
|
||||
}
|
||||
|
||||
public boolean isFullCube()
|
||||
|
@ -82,17 +82,13 @@ public class BlockDoor extends Block implements Rotatable
|
|||
}
|
||||
|
||||
public void setBlockBoundsBasedOnState(IWorldAccess worldIn, BlockPos pos)
|
||||
{
|
||||
this.setBoundBasedOnMeta(combineMetadata(worldIn, pos));
|
||||
}
|
||||
|
||||
private void setBoundBasedOnMeta(int combinedMeta)
|
||||
{
|
||||
float f = 0.1875F;
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F);
|
||||
Facing enumfacing = getFacing(combinedMeta);
|
||||
boolean flag = isOpen(combinedMeta);
|
||||
boolean flag1 = isHingeLeft(combinedMeta);
|
||||
State state = worldIn.getState(pos);
|
||||
Facing enumfacing = state.getValue(FACING);
|
||||
boolean flag = state.getValue(OPEN);
|
||||
boolean flag1 = state.getValue(HINGE) == BlockDoor.EnumHingePosition.RIGHT;
|
||||
|
||||
if (flag)
|
||||
{
|
||||
|
@ -298,30 +294,6 @@ public class BlockDoor extends Block implements Rotatable
|
|||
return 1;
|
||||
}
|
||||
|
||||
private static int combineMetadata(IBlockAccess worldIn, BlockPos pos) {
|
||||
State state = worldIn.getState(pos);
|
||||
int meta = getMetadata(state);
|
||||
boolean top = isTop(meta);
|
||||
State down = worldIn.getState(pos.down());
|
||||
int dmeta = getMetadata(down);
|
||||
int m1 = top ? dmeta : meta;
|
||||
State up = worldIn.getState(pos.up());
|
||||
int umeta = getMetadata(up);
|
||||
int m2 = top ? meta : umeta;
|
||||
boolean right = (m2 & 1) != 0;
|
||||
boolean power = (m2 & 2) != 0;
|
||||
return removeHalfBit(m1) | (top ? 8 : 0) | (right ? 16 : 0) | (power ? 32 : 0);
|
||||
}
|
||||
|
||||
private static int getMetadata(State state) {
|
||||
if(!(state.getBlock() instanceof BlockDoor))
|
||||
return 0;
|
||||
else if(state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER)
|
||||
return 8 | (state.getValue(HINGE) == BlockDoor.EnumHingePosition.RIGHT ? 1 : 0) | (state.getValue(POWERED) ? 2 : 0);
|
||||
else
|
||||
return state.getValue(FACING).rotateY().getHorizontalIndex() | (state.getValue(OPEN) ? 4 : 0);
|
||||
}
|
||||
|
||||
public Item getItem(World worldIn, BlockPos pos)
|
||||
{
|
||||
return this.getItem();
|
||||
|
@ -342,34 +314,6 @@ public class BlockDoor extends Block implements Rotatable
|
|||
return BlockLayer.CUTOUT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
|
||||
* metadata, such as fence connections.
|
||||
*/
|
||||
public State getActualState(State state, IWorldAccess worldIn, BlockPos pos)
|
||||
{
|
||||
if (state.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER)
|
||||
{
|
||||
State iblockstate = worldIn.getState(pos.up());
|
||||
|
||||
if (iblockstate.getBlock() == this)
|
||||
{
|
||||
state = state.withProperty(HINGE, iblockstate.getValue(HINGE)).withProperty(POWERED, iblockstate.getValue(POWERED));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
State iblockstate1 = worldIn.getState(pos.down());
|
||||
|
||||
if (iblockstate1.getBlock() == this)
|
||||
{
|
||||
state = state.withProperty(FACING, iblockstate1.getValue(FACING)).withProperty(OPEN, iblockstate1.getValue(OPEN));
|
||||
}
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given metadata into a BlockState for this Block
|
||||
*/
|
||||
|
@ -378,39 +322,9 @@ public class BlockDoor extends Block implements Rotatable
|
|||
return (meta & 8) > 0 ? this.getState().withProperty(HALF, BlockDoor.EnumDoorHalf.UPPER).withProperty(HINGE, (meta & 1) > 0 ? BlockDoor.EnumHingePosition.RIGHT : BlockDoor.EnumHingePosition.LEFT).withProperty(POWERED, Boolean.valueOf((meta & 2) > 0)) : this.getState().withProperty(HALF, BlockDoor.EnumDoorHalf.LOWER).withProperty(FACING, Facing.getHorizontal(meta & 3).rotateYCCW()).withProperty(OPEN, Boolean.valueOf((meta & 4) > 0));
|
||||
}
|
||||
|
||||
protected static int removeHalfBit(int meta)
|
||||
{
|
||||
return meta & 7;
|
||||
}
|
||||
|
||||
public static boolean isOpen(IBlockAccess worldIn, BlockPos pos)
|
||||
{
|
||||
return isOpen(combineMetadata(worldIn, pos));
|
||||
}
|
||||
|
||||
public static Facing getFacing(IBlockAccess worldIn, BlockPos pos)
|
||||
{
|
||||
return getFacing(combineMetadata(worldIn, pos));
|
||||
}
|
||||
|
||||
public static Facing getFacing(int combinedMeta)
|
||||
{
|
||||
return Facing.getHorizontal(combinedMeta & 3).rotateYCCW();
|
||||
}
|
||||
|
||||
protected static boolean isOpen(int combinedMeta)
|
||||
{
|
||||
return (combinedMeta & 4) != 0;
|
||||
}
|
||||
|
||||
protected static boolean isTop(int meta)
|
||||
{
|
||||
return (meta & 8) != 0;
|
||||
}
|
||||
|
||||
protected static boolean isHingeLeft(int combinedMeta)
|
||||
{
|
||||
return (combinedMeta & 16) != 0;
|
||||
return worldIn.getState(pos).getValue(FACING);
|
||||
}
|
||||
|
||||
protected Property[] getProperties()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue