Skip to content

Commit

Permalink
PN-62 Fix #220 Stripping old full bark log conversion error
Browse files Browse the repository at this point in the history
  • Loading branch information
joserobjr committed May 10, 2020
1 parent 698b1ec commit 5f3b605
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
14 changes: 12 additions & 2 deletions src/main/java/cn/nukkit/block/BlockWood.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,27 @@ public boolean canBeActivated() {
}

protected int getStrippedId() {
int damage = getDamage();
if ((damage & 0b1100) == 0b1100) { // Only bark
return WOOD_BARK;
}

int[] strippedIds = new int[] {
STRIPPED_OAK_LOG,
STRIPPED_SPRUCE_LOG,
STRIPPED_BIRCH_LOG,
STRIPPED_JUNGLE_LOG
};
return strippedIds[getDamage() & 0x03];
return strippedIds[damage & 0x03];
}

protected int getStrippedDamage() {
return getDamage() >> 2;
int damage = getDamage();
if ((damage & 0b1100) == 0b1100) { // Only bark
return damage & 0x03 | 0x8;
}

return damage >> 2;
}

@Override
Expand Down
25 changes: 22 additions & 3 deletions src/main/java/cn/nukkit/block/BlockWood2.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import cn.nukkit.item.Item;
import cn.nukkit.item.ItemBlock;

import cn.nukkit.utils.BlockColor;

/**
Expand Down Expand Up @@ -40,14 +39,34 @@ public String getName() {

@Override
protected int getStrippedId() {
int typeId = getDamage() & 0x3;
int damage = getDamage();
if ((damage & 0b1100) == 0b1100) { // Only bark
return WOOD_BARK;
}

int typeId = damage & 0x3;
if (typeId == 0) {
return STRIPPED_ACACIA_LOG;
} else {
return STRIPPED_DARK_OAK_LOG;
}
}


@Override
protected int getStrippedDamage() {
int damage = getDamage();
if ((damage & 0b1100) == 0b1100) { // Only bark
int typeId = damage & 0x3;
if (typeId == 0) {
return 0x4 | 0x8;
} else {
return 0x5 | 0x8;
}
}

return super.getStrippedDamage();
}

@Override
public Item toItem() {
if ((getDamage() & 0b1100) == 0b1100) {
Expand Down

0 comments on commit 5f3b605

Please sign in to comment.