Skip to content

Commit

Permalink
Fix issue where shulkers on walls with shulkers above them could not …
Browse files Browse the repository at this point in the history
…be deposited into
  • Loading branch information
ChristopherHaws committed Oct 2, 2022
1 parent 578b12c commit a251e35
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void onBlockDamage(BlockDamageEvent event) {
event.setCancelled(true);

var aboveBlockID = clickedBlock.getRelative(BlockFace.UP).getType();
if (BlockUtilities.preventsChestOpen(clickedBlock.getType(), aboveBlockID)) {
if (!BlockUtilities.isOpenable(clickedBlock.getType(), aboveBlockID)) {
Chat.sendMessage(player, Level.Error, Messages.ChestLidBlocked);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void run() {
var type = this.getType(current);
if (MaterialUtilities.isChest(type)) {
var overType = this.getType(new Vector(current.getBlockX(), current.getBlockY() + 1, current.getBlockZ()));
if (!BlockUtilities.preventsChestOpen(type, overType)) {
if (BlockUtilities.isOpenable(type, overType)) {
chestLocations.add(this.makeLocation(current));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,17 @@ public static boolean isContainer(Block block) {
* @param aboveBlockID the block above the ctest
* @return whether the chest would not open
*/
public static boolean preventsChestOpen(Material container, Material aboveBlockID) {
public static boolean isOpenable(Material container, Material aboveBlockID) {
// This functions might make it into spigot at some point:
// https://hub.spigotmc.org/jira/browse/SPIGOT-5070
if (container == Material.BARREL) {
return false;
return true;
}

if (aboveBlockID == null) {
return false;
if (MaterialUtilities.isShulkerBox(container)) {
// Shulker boxes can face in more directions that UP. We should check the block
// based on the facing direction, but for now just return true to make this work.
return true;
}

return aboveBlockID.isOccluding();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,27 @@ public static boolean isChest(Material material) {
};
}

public static boolean isShulkerBox(Material material) {
return
material == Material.SHULKER_BOX ||
material == Material.BLACK_SHULKER_BOX ||
material == Material.GRAY_SHULKER_BOX ||
material == Material.LIGHT_GRAY_SHULKER_BOX ||
material == Material.WHITE_SHULKER_BOX ||
material == Material.BROWN_SHULKER_BOX ||
material == Material.RED_SHULKER_BOX ||
material == Material.ORANGE_SHULKER_BOX ||
material == Material.YELLOW_SHULKER_BOX ||
material == Material.LIME_SHULKER_BOX ||
material == Material.GREEN_SHULKER_BOX ||
material == Material.CYAN_SHULKER_BOX ||
material == Material.LIGHT_BLUE_SHULKER_BOX ||
material == Material.BLUE_SHULKER_BOX ||
material == Material.PINK_SHULKER_BOX ||
material == Material.MAGENTA_SHULKER_BOX ||
material == Material.PURPLE_SHULKER_BOX;
}

public static boolean isPassable(Material material) {
if (material == null) {
return false;
Expand Down

0 comments on commit a251e35

Please sign in to comment.