1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00

Merge pull request #2376 from Chlorophytus/master fixes #2360

Attempt to fix bug #2360
This commit is contained in:
TheBusyBiscuit 2020-10-01 20:28:51 +02:00 committed by GitHub
commit 7d5c34a8c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -32,6 +32,7 @@ import me.mrCookieSlime.Slimefun.api.BlockStorage;
* @author VoidAngel
* @author Poslovitch
* @author TheBusyBiscuit
* @author AccelShark
*
*/
public class BlockPhysicsListener implements Listener {
@ -54,21 +55,29 @@ public class BlockPhysicsListener implements Listener {
@EventHandler
public void onPistonExtend(BlockPistonExtendEvent e) {
for (Block b : e.getBlocks()) {
if (BlockStorage.hasBlockInfo(b) || (b.getRelative(e.getDirection()).getType() == Material.AIR && BlockStorage.hasBlockInfo(b.getRelative(e.getDirection())))) {
e.setCancelled(true);
return;
if (BlockStorage.hasBlockInfo(e.getBlock())) {
e.setCancelled(true);
}
else {
for (Block b : e.getBlocks()) {
if (BlockStorage.hasBlockInfo(b) || (b.getRelative(e.getDirection()).getType() == Material.AIR && BlockStorage.hasBlockInfo(b.getRelative(e.getDirection())))) {
e.setCancelled(true);
break;
}
}
}
}
@EventHandler
public void onPistonRetract(BlockPistonRetractEvent e) {
if (e.isSticky()) {
if (BlockStorage.hasBlockInfo(e.getBlock())) {
e.setCancelled(true);
}
else if (e.isSticky()) {
for (Block b : e.getBlocks()) {
if (BlockStorage.hasBlockInfo(b) || (b.getRelative(e.getDirection()).getType() == Material.AIR && BlockStorage.hasBlockInfo(b.getRelative(e.getDirection())))) {
e.setCancelled(true);
return;
break;
}
}
}