From de582168e66120927236be90b3efcd83752b8b38 Mon Sep 17 00:00:00 2001 From: Astoria Date: Mon, 10 Apr 2023 15:15:15 -0500 Subject: [PATCH] Better chip fall off detection --- .../api/AbstractWireTileSided.java | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/brokenmoon/afloydwiremod/api/AbstractWireTileSided.java b/src/main/java/net/brokenmoon/afloydwiremod/api/AbstractWireTileSided.java index 759f552..8060336 100644 --- a/src/main/java/net/brokenmoon/afloydwiremod/api/AbstractWireTileSided.java +++ b/src/main/java/net/brokenmoon/afloydwiremod/api/AbstractWireTileSided.java @@ -73,7 +73,40 @@ public abstract class AbstractWireTileSided extends AbstractWireTile{ @Override public void onNeighborBlockChange(World world, int i, int j, int k, int l) { - this.dropTileIfCantStay(world, i, j, k); + if (this.dropTileIfCantStay(world, i, j, k)) { + int i1 = world.getBlockMetadata(i, j, k); + boolean flag = true; + switch(i1){ + case 0: + if(world.isBlockNormalCube(i, j + 1, k)) + flag = false; + break; + case 1: + if(world.isBlockNormalCube(i - 1, j, k)) + flag = false; + break; + case 2: + if(world.isBlockNormalCube(i + 1, j, k)) + flag = false; + break; + case 3: + if(world.isBlockNormalCube(i, j, k - 1)) + flag = false; + break; + case 4: + if(world.isBlockNormalCube(i, j, k + 1)) + flag = false; + break; + case 5: + if(this.canPlaceOnTop(world, i, j - 1, k)) + flag = false; + break; + } + if (flag) { + this.dropBlockAsItem(world, i, j, k, world.getBlockMetadata(i, j, k)); + world.setBlockWithNotify(i, j, k, 0); + } + } } private boolean dropTileIfCantStay(World world, int i, int j, int k) {