1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

Updated saw mill block check

The saw mill will now only use the CS-CoreLib protection manager. Also Ive added a check to prevent people from duping planks using barrels.
This commit is contained in:
VoidAngel 2018-04-29 10:27:30 -07:00
parent dbdfa3cdb7
commit fc601bda6b

View File

@ -1887,10 +1887,24 @@ public class SlimefunSetup {
@Override
public boolean onInteract(Player p, MultiBlock mb, Block b) {
if (mb.isMultiBlock(SlimefunItem.getByID("SAW_MILL"))) {
if(CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true)) {
if(CSCoreLib.getLib().getProtectionManager().canBuild(p.getUniqueId(), b, true)) {
if (Slimefun.hasUnlocked(p, SlimefunItems.SAW_MILL, true)) {
if (b.getRelative(BlockFace.UP).getType() == Material.LOG) BlockBreaker.breakBlock(p, b.getRelative(BlockFace.UP), Arrays.asList(new ItemStack[] {new CustomItem(Material.WOOD, b.getRelative(BlockFace.UP).getData() % 4, 8)}), true);
else if (b.getRelative(BlockFace.UP).getType() == Material.LOG_2) BlockBreaker.breakBlock(p, b.getRelative(BlockFace.UP), Arrays.asList(new ItemStack[] {new CustomItem(Material.WOOD, (b.getRelative(BlockFace.UP).getData() % 2) + 4, 8)}), true);
if (b.getRelative(BlockFace.UP).getType() == Material.LOG) {
Block log = b.getRelative(BlockFace.UP);
if(!BlockStorage.hasBlockInfo(log)) {
log.getWorld().dropItemNaturally(log.getLocation(), new CustomItem(Material.WOOD, log.getData() % 4, 8));
log.getWorld().playEffect(log.getLocation(), Effect.STEP_SOUND, log.getType());
log.setType(Material.AIR);
}
}
else if (b.getRelative(BlockFace.UP).getType() == Material.LOG_2) {
Block log = b.getRelative(BlockFace.UP);
if(!BlockStorage.hasBlockInfo(log)) {
log.getWorld().dropItemNaturally(log.getLocation(), new CustomItem(Material.WOOD, (log.getData() % 2) + 4, 8));
log.getWorld().playEffect(log.getLocation(), Effect.STEP_SOUND, log.getType());
log.setType(Material.AIR);
}
}
}
}
return true;