forked from MLG-Fortress/AutomaticInventory
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBlockUtilities.java
More file actions
47 lines (39 loc) · 1.19 KB
/
Copy pathBlockUtilities.java
File metadata and controls
47 lines (39 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package dev.chaws.automaticinventory.utilities;
import org.bukkit.Material;
import org.bukkit.block.Barrel;
import org.bukkit.block.Block;
import org.bukkit.block.Chest;
import org.bukkit.block.ShulkerBox;
public class BlockUtilities {
public static boolean isContainer(Block block) {
if (block.getState() instanceof Chest) {
return true;
}
if (block.getState() instanceof ShulkerBox) {
return true;
}
if (block.getState() instanceof Barrel) {
return true;
}
return false;
}
/**
* Function to check if a chest would open based only on its block above
*
* @param aboveBlock the block above the ctest
* @return whether the chest would not open
*/
public static boolean isOpenable(Material container, Material aboveBlock) {
// This functions might make it into spigot at some point:
// https://hub.spigotmc.org/jira/browse/SPIGOT-5070
if (container == Material.BARREL) {
return true;
}
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 !aboveBlock.isOccluding();
}
}