Skip to content

Commit

Permalink
Fills up cauldrons with snow.
Browse files Browse the repository at this point in the history
Fixes #82
  • Loading branch information
tastybento committed Sep 25, 2021
1 parent 47bead9 commit 354806c
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitTask;

import com.google.common.base.Enums;
import com.google.common.base.Optional;

import world.bentobox.bentobox.util.Util;
import world.bentobox.greenhouses.Greenhouses;
import world.bentobox.greenhouses.data.Greenhouse;
Expand Down Expand Up @@ -65,7 +68,8 @@ private boolean getAirBlocks(Greenhouse gh) {
if (Math.random() < addon.getSettings().getSnowDensity()
&& !b.isLiquid()
&& b.getRelative(BlockFace.UP).getType().equals(Material.AIR)) {
b.getRelative(BlockFace.UP).setType(Material.SNOW);
placeSnow(b);

createdSnow = true;
}
}
Expand All @@ -86,6 +90,15 @@ private boolean getAirBlocks(Greenhouse gh) {
return createdSnow;
}

private void placeSnow(Block b) {
Optional<Material> snowCauldron = Enums.getIfPresent(Material.class, "POWDER_SNOW_CAULDRON");
if (b.getType().equals(Material.CAULDRON) && snowCauldron.isPresent()) {
b.setType(snowCauldron.get());
} else {
b.getRelative(BlockFace.UP).setType(Material.SNOW);
}
}

/**
* TODO finish
* @param e block form event
Expand Down

0 comments on commit 354806c

Please sign in to comment.