Skip to content

Commit

Permalink
List piglin head (#2162)
Browse files Browse the repository at this point in the history
  • Loading branch information
PetteriM1 authored Jan 14, 2024
1 parent b5ee113 commit eb1e130
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
11 changes: 5 additions & 6 deletions src/main/java/cn/nukkit/block/BlockSkull.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,9 @@ public boolean place(Item item, Block block, Block target, BlockFace face, doubl
nbt.put(aTag.getName(), aTag);
}
}
BlockEntitySkull skull = (BlockEntitySkull) BlockEntity.createBlockEntity(BlockEntity.SKULL, getLevel().getChunk((int) block.x >> 4, (int) block.z >> 4), nbt);
if (skull == null) {
return false;
}

BlockEntitySkull blockEntity = (BlockEntitySkull) BlockEntity.createBlockEntity(BlockEntity.SKULL, this.getChunk(), nbt);
blockEntity.spawnToAll();

// TODO: 2016/2/3 SPAWN WITHER

Expand All @@ -103,7 +102,7 @@ public Item[] getDrops(Item item) {
int dropMeta = 0;
if (blockEntity != null) dropMeta = blockEntity.namedTag.getByte("SkullType");
return new Item[]{
new ItemSkull(dropMeta)
Item.get(Item.SKULL, dropMeta)
};
}

Expand All @@ -112,7 +111,7 @@ public Item toItem() {
BlockEntity blockEntity = getLevel().getBlockEntity(this);
int itemMeta = 0;
if (blockEntity != null) itemMeta = blockEntity.namedTag.getByte("SkullType");
return new ItemSkull(itemMeta);
return Item.get(Item.SKULL, itemMeta);
}

@Override
Expand Down
16 changes: 10 additions & 6 deletions src/main/java/cn/nukkit/item/ItemSkull.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
* Package cn.nukkit.item in project Nukkit.
*/
public class ItemSkull extends Item {

public static final int SKELETON_SKULL = 0;
public static final int WITHER_SKELETON_SKULL = 1;
public static final int ZOMBIE_HEAD = 2;
public static final int HEAD = 3;
public static final int CREEPER_HEAD = 4;
public static final int DRAGON_HEAD = 5;
public static final int PIGLIN_HEAD = 6;

public ItemSkull() {
this(0, 1);
Expand All @@ -29,17 +31,19 @@ public ItemSkull(Integer meta, int count) {

public static String getItemSkullName(int meta) {
switch (meta) {
case 1:
case WITHER_SKELETON_SKULL :
return "Wither Skeleton Skull";
case 2:
case ZOMBIE_HEAD:
return "Zombie Head";
case 3:
case HEAD:
return "Head";
case 4:
case CREEPER_HEAD:
return "Creeper Head";
case 5:
case DRAGON_HEAD:
return "Dragon Head";
case 0:
case PIGLIN_HEAD:
return "Piglin Head";
case SKELETON_SKULL:
default:
return "Skeleton Skull";
}
Expand Down

0 comments on commit eb1e130

Please sign in to comment.