Skip to content

Commit

Permalink
last fix TrapDoor
Browse files Browse the repository at this point in the history
  • Loading branch information
Pub4Game committed Jan 28, 2016
1 parent 1d053c1 commit 7a123ad
Showing 1 changed file with 23 additions and 29 deletions.
52 changes: 23 additions & 29 deletions src/main/java/cn/nukkit/block/Trapdoor.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public int getId() {
return TRAPDOOR;
}


@Override
public String getName() {
return "Wooden Trapdoor";
Expand Down Expand Up @@ -123,35 +122,30 @@ protected AxisAlignedBB recalculateBoundingBox() {

@Override
public boolean place(Item item, Block block, Block target, int face, double fx, double fy, double fz, Player player) {
if (target.isTransparent()) return false;
int faceBit = 0b00;
int upDownBit = 0b000;
if (fy > 0.5) upDownBit = 0b100;
switch (face) {
case Vector3.SIDE_NORTH:
faceBit = 0b11;
break;
case Vector3.SIDE_SOUTH:
faceBit = 0b10;
break;
case Vector3.SIDE_WEST:
faceBit = 0b01;
break;
case Vector3.SIDE_EAST:
faceBit = 0b00;
break;
//todo correct the faceBit according to player yaw when side is up or down
case Vector3.SIDE_UP:
upDownBit = 0b000;
break;
case Vector3.SIDE_DOWN:
upDownBit = 0b100;
break;
if((!target.isTransparent() || target.getId() == SLAB) && face != 0 && face != 1){
int faceBit = 0b00;
int upDownBit = 0b000;
if (fy > 0.5) upDownBit = 0b100;
switch (face) {
case Vector3.SIDE_NORTH:
faceBit = 0b11;
break;
case Vector3.SIDE_SOUTH:
faceBit = 0b10;
break;
case Vector3.SIDE_WEST:
faceBit = 0b01;
break;
case Vector3.SIDE_EAST:
faceBit = 0b00;
break;
}
this.meta |= upDownBit;
this.meta |= faceBit;
this.getLevel().setBlock(block, this, true, true);
return true;
}
this.meta |= upDownBit;
this.meta |= faceBit;
this.getLevel().setBlock(block, this, true, true);
return true;
return false;
}

@Override
Expand Down

0 comments on commit 7a123ad

Please sign in to comment.