Skip to content

Commit

Permalink
Make sure campfire is lit
Browse files Browse the repository at this point in the history
  • Loading branch information
Sn0wStorm committed Aug 18, 2019
1 parent ee02426 commit 86f2cd7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/com/dre/brewery/BCauldron.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public BCauldron(Block block, BIngredients ingredients, int state) {

public void onUpdate() {
// Check if fire still alive
if (!Util.isChunkLoaded(block) || LegacyUtil.isFireForCauldron(block.getRelative(BlockFace.DOWN).getType())) {
if (!Util.isChunkLoaded(block) || LegacyUtil.isFireForCauldron(block.getRelative(BlockFace.DOWN))) {
// add a minute to cooking time
state++;
if (someRemoved) {
Expand Down
15 changes: 13 additions & 2 deletions src/com/dre/brewery/LegacyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,26 @@ public static boolean isSign(Material type) {
return type.name().endsWith("SIGN") || (!P.use1_13 && type == SIGN_POST);
}

public static boolean isFireForCauldron(Material type) {
return type != null && (type == Material.FIRE || type == CAMPFIRE || type == MAGMA_BLOCK || isLava(type));
public static boolean isFireForCauldron(Block block) {
Material type = block.getType();
return type != null && (type == Material.FIRE || type == MAGMA_BLOCK || litCampfire(block) || isLava(type));
}

// LAVA and STATIONARY_LAVA are merged as of 1.13
public static boolean isLava(Material type) {
return type == Material.LAVA || (!P.use1_13 && type == STATIONARY_LAVA);
}

public static boolean litCampfire(Block block) {
if (block.getType() == CAMPFIRE) {
BlockData data = block.getBlockData();
if (data instanceof org.bukkit.block.data.Lightable) {
return ((org.bukkit.block.data.Lightable) data).isLit();
}
}
return false;
}

public static boolean areStairsInverted(Block block) {
if (!P.use1_13) {
@SuppressWarnings("deprecation")
Expand Down
2 changes: 1 addition & 1 deletion src/com/dre/brewery/listeners/PlayerListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void onPlayerInteract(PlayerInteractEvent event) {

// Check if fire alive below cauldron when adding ingredients
Block down = clickedBlock.getRelative(BlockFace.DOWN);
if (LegacyUtil.isFireForCauldron(down.getType())) {
if (LegacyUtil.isFireForCauldron(down)) {

event.setCancelled(true);
boolean handSwap = false;
Expand Down

0 comments on commit 86f2cd7

Please sign in to comment.