-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scaffolding no longer get broken when a torch is ontop (#12), gravity…
… blocks can not fall anymore when a torch is ontop
- Loading branch information
1 parent
0cf2f4d
commit d59567a
Showing
4 changed files
with
77 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/java/dev/array21/harotorch/events/BlockFadeEventListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package dev.array21.harotorch.events; | ||
|
||
import org.bukkit.Location; | ||
import org.bukkit.Material; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.block.BlockFadeEvent; | ||
|
||
public class BlockFadeEventListener implements Listener { | ||
|
||
@EventHandler | ||
public void onBlockFadeEvent(BlockFadeEvent event) { | ||
//We wont break a scaffolding block when a torch is ontop of it | ||
if(event.getBlock().getType() == Material.SCAFFOLDING) { | ||
Location l = event.getBlock().getLocation(); | ||
if(!Common.checkSurroundings(l)) { | ||
event.setCancelled(true); | ||
} | ||
} | ||
} | ||
} |
46 changes: 24 additions & 22 deletions
46
src/main/java/dev/array21/harotorch/events/BlockPhysicsEventListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package dev.array21.harotorch.events; | ||
|
||
import org.bukkit.Location; | ||
|
||
import dev.array21.harotorch.torch.TorchHandler; | ||
|
||
public class Common { | ||
|
||
/** | ||
* Check if a Location has any torches surrounding it | ||
* @param loc | ||
* @return Returns true if it does not, false if it does. | ||
*/ | ||
public static boolean checkSurroundings(Location loc) { | ||
Location loc_y_plus_1 = new Location(loc.getWorld(), loc.getX(), loc.getY() + 1, loc.getZ()); | ||
Location loc_x_plus_1 = new Location(loc.getWorld(), loc.getX() +1, loc.getY(), loc.getZ()); | ||
Location loc_x_minus_1 = new Location(loc.getWorld(), loc.getX() -1, loc.getY(), loc.getZ()); | ||
Location loc_z_plus_1 = new Location(loc.getWorld(), loc.getX(), loc.getY(), loc.getZ() +1); | ||
Location loc_z_minus_1 = new Location(loc.getWorld(), loc.getX(), loc.getY(), loc.getZ() -1); | ||
|
||
if(TorchHandler.isTorch(loc_y_plus_1) | ||
|| TorchHandler.isTorch(loc_x_plus_1) | ||
|| TorchHandler.isTorch(loc_x_minus_1) | ||
|| TorchHandler.isTorch(loc_z_plus_1) | ||
|| TorchHandler.isTorch(loc_z_minus_1)) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} |