Skip to content

Commit

Permalink
add legacy handling to picking up old chairs
Browse files Browse the repository at this point in the history
  • Loading branch information
kristianvld committed Dec 3, 2020
1 parent 2ea1125 commit 0f62e9d
Showing 1 changed file with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,6 @@ public static String getCouchGroupID(Entity trophy) {
return null;
}

public ArmorStand place(Player player, Block block, BlockFace face, EquipmentSlot hand) {
return place(player, block, face, hand, player.getEquipment().getItem(hand));
}

public ArmorStand place(Player player, Block block, BlockFace face, EquipmentSlot hand, ItemStack item) {
Vector offset;
boolean small;
Expand Down Expand Up @@ -277,8 +273,24 @@ public static boolean pickup(Player player, Entity entity) {
seat.remove();
}
BlockVector bv = getBlockVector(entity);
Block block = entity.getWorld().getBlockAt(bv.getBlockX(), bv.getBlockY(), bv.getBlockZ());
block.setType(Material.AIR);
if (bv != null) {
Block block = entity.getWorld().getBlockAt(bv.getBlockX(), bv.getBlockY(), bv.getBlockZ());
block.setType(Material.AIR);
} else {
// Old legacy handling, check nearby blocks up and down for slabs
Block slab = entity.getLocation().getBlock();
if (slab.getType() == SLAB_TYPE) {
slab.setType(Material.AIR);
}
slab = slab.getRelative(BlockFace.UP);
if (slab.getType() == SLAB_TYPE) {
slab.setType(Material.AIR);
}
slab = slab.getRelative(BlockFace.DOWN, 2);
if (slab.getType() == SLAB_TYPE) {
slab.setType(Material.AIR);
}
}
}
entity.remove();
return true;
Expand Down

0 comments on commit 0f62e9d

Please sign in to comment.