Skip to content

Commit ff39f80

Browse files
fix: add default drop
Took 25 minutes
1 parent e69621c commit ff39f80

2 files changed

Lines changed: 24 additions & 12 deletions

File tree

type.generic/src/main/java/net/swofty/types/generic/event/actions/player/region/ActionRegionBlockPlace.java

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
import net.swofty.types.generic.event.SkyBlockEventClass;
99
import net.swofty.types.generic.user.SkyBlockPlayer;
1010
import net.swofty.types.generic.event.SkyBlockEvent;
11+
import net.swofty.types.generic.utility.MathUtility;
1112

1213
public class ActionRegionBlockPlace implements SkyBlockEventClass {
14+
private static final int ISLAND_SIZE = 161;
1315

1416
@SkyBlockEvent(node = EventNodes.PLAYER, requireDataLoaded = false)
1517
public void run(PlayerBlockPlaceEvent event) {
@@ -19,20 +21,24 @@ public void run(PlayerBlockPlaceEvent event) {
1921
return;
2022
}
2123

22-
if (SkyBlockConst.getTypeLoader().getType() == ServerType.ISLAND) {
23-
Integer islandSizePlus = (int) Math.floor((double) 161/2);
24-
Integer islandSizeMinus = -islandSizePlus;
25-
Point position = event.getBlockPosition();
26-
Integer x = position.blockX();
27-
Integer z = position.blockZ();
28-
29-
if (x > islandSizePlus || x < islandSizeMinus || z > islandSizePlus || z < islandSizeMinus) {
30-
event.setCancelled(true);
31-
player.sendMessage("§cYou can't build any further in this direction!");
32-
}
24+
if (!SkyBlockConst.isIslandServer()) event.setCancelled(true);
25+
26+
int islandSizePlus = (int) Math.floor((double) ISLAND_SIZE/2);
27+
int islandSizeMinus = -islandSizePlus;
28+
Point position = event.getBlockPosition();
29+
int x = position.blockX();
30+
int z = position.blockZ();
31+
32+
if (x > islandSizePlus || x < islandSizeMinus || z > islandSizePlus || z < islandSizeMinus) {
33+
event.setCancelled(true);
34+
player.sendMessage("§cYou can't build any further in this direction!");
3335
return;
3436
}
35-
event.setCancelled(true);
37+
38+
// Solve weird placement block issues
39+
MathUtility.delay(() -> {
40+
//player.getChunk().sendChunk(player);
41+
}, 5);
3642
}
3743
}
3844

type.generic/src/main/java/net/swofty/types/generic/item/components/CustomDropComponent.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ public static List<SkyBlockItem> simulateDrop(SkyBlockItem brokenItem, SkyBlockP
6060
}
6161
}
6262

63+
// No rules matched - return default drop (1 of the original material)
64+
ItemType originalType = brokenItem.getAttributeHandler().getPotentialType();
65+
if (originalType != null) {
66+
drops.add(new SkyBlockItem(originalType, 1));
67+
}
68+
6369
return drops;
6470
}
6571

0 commit comments

Comments
 (0)