Skip to content

Commit 505ed59

Browse files
committed
part 1 of bestiary
1 parent f4ee17d commit 505ed59

58 files changed

Lines changed: 1670 additions & 206 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

commons/src/main/java/net/swofty/commons/StringUtility.java

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
66
import net.minestom.server.instance.block.Block;
77
import net.minestom.server.item.Material;
8+
import net.swofty.commons.statistics.ItemStatistic;
89

910
import java.math.RoundingMode;
1011
import java.text.DecimalFormat;
@@ -275,4 +276,91 @@ public static String ntify(int i) {
275276
};
276277
};
277278
}
279+
280+
public static String getFormatedStatistic(ItemStatistic statistic) {
281+
return statistic.getDisplayColor() + statistic.getSymbol() + " " + statistic.getDisplayName();
282+
}
283+
284+
/*
285+
public static List<String> centerLines(List<String> lines) {
286+
int maxLength = lines.stream()
287+
.map(StringUtility::stripColor)
288+
.mapToInt(String::length)
289+
.max()
290+
.orElse(0);
291+
292+
List<String> centered = new ArrayList<>();
293+
for (String line : lines) {
294+
String stripped = stripColor(line);
295+
int padding = Math.max(0, (maxLength - stripped.length()) / 2);
296+
centered.add(" ".repeat(padding) + line);
297+
}
298+
299+
return centered;
300+
}
301+
*/
302+
303+
//TODO fix this stupid centering
304+
public static List<String> centerLines(List<String> lines) {
305+
int CHAT_WIDTH_PIXELS = 320;
306+
int SPACE_WIDTH = 4; // Minecraft space width
307+
List<String> centered = new ArrayList<>();
308+
309+
for (String line : lines) {
310+
if (line.isEmpty()) {
311+
centered.add(line);
312+
continue;
313+
}
314+
315+
boolean bold = false;
316+
int pixelWidth = 0;
317+
int formatCodeCount = 0;
318+
319+
// Calculate visible width and count format codes
320+
for (int i = 0; i < line.length(); i++) {
321+
char c = line.charAt(i);
322+
if (c == '§' && i + 1 < line.length()) {
323+
char code = line.charAt(i + 1);
324+
if (code == 'l') bold = true;
325+
else if (code == 'r') bold = false;
326+
formatCodeCount += 2;
327+
i++; // Skip format code
328+
continue;
329+
}
330+
pixelWidth += getCharWidth(c, bold) + 1; // +1 for character spacing
331+
}
332+
333+
// Subtract the last character's spacing
334+
if (pixelWidth > 0) pixelWidth--;
335+
336+
// Calculate padding
337+
int padding = (CHAT_WIDTH_PIXELS - pixelWidth) / 2;
338+
int spaces = Math.max(0, padding / SPACE_WIDTH);
339+
340+
// Add extra space if needed (Minecraft rendering quirk)
341+
if (padding % SPACE_WIDTH >= 2) {
342+
spaces++;
343+
}
344+
System.out.printf("Line (%.3f px): %s\n", (float)pixelWidth, line.replace("§", "&"));
345+
346+
centered.add(" ".repeat(spaces) + line);
347+
}
348+
349+
return centered;
350+
}
351+
352+
private static int getCharWidth(char c, boolean bold) {
353+
// Special case for certain characters
354+
if (c == '➡') return 6; // Arrow character
355+
if (c == '✯') return 7; // Star character
356+
357+
return switch (c) {
358+
case ' ', 'I', '[', ']', 't' -> 4;
359+
case '!', '.', ',', ':', ';', 'i', '|' -> 2;
360+
case '\'', '`', 'l' -> 3;
361+
case '*', 'f', 'k', '<', '>' -> 5;
362+
case '§' -> 0;
363+
default -> bold ? 6 : 5;
364+
};
365+
}
278366
}

configuration/collections/mining.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ collections:
302302
- type: XP
303303
data:
304304
xp: 4
305+
- type: CUSTOM_AWARD
306+
data:
307+
customAward: LOOTING_DISCOUNT
305308
- amount: 500
306309
rewards:
307310
- type: XP

configuration/items/vanillaItems.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5094,6 +5094,8 @@ items:
50945094
result:
50955095
type: DIAMOND_SWORD
50965096
amount: 1
5097+
- id: STANDARD_ITEM
5098+
standard_item_type: SWORD
50975099
default_statistics:
50985100
damage: 35.0
50995101
- id: GOLDEN_SWORD
@@ -5120,6 +5122,8 @@ items:
51205122
result:
51215123
type: GOLDEN_SWORD
51225124
amount: 1
5125+
- id: STANDARD_ITEM
5126+
standard_item_type: SWORD
51235127
default_statistics:
51245128
damage: 20.0
51255129
- id: IRON_SWORD
@@ -5146,6 +5150,8 @@ items:
51465150
result:
51475151
type: IRON_SWORD
51485152
amount: 1
5153+
- id: STANDARD_ITEM
5154+
standard_item_type: SWORD
51495155
default_statistics:
51505156
damage: 30.0
51515157
- id: STONE_SWORD
@@ -5172,6 +5178,8 @@ items:
51725178
result:
51735179
type: STONE_SWORD
51745180
amount: 1
5181+
- id: STANDARD_ITEM
5182+
standard_item_type: SWORD
51755183
default_statistics:
51765184
damage: 25.0
51775185
- id: WOODEN_SWORD
@@ -5198,6 +5206,8 @@ items:
51985206
result:
51995207
type: WOODEN_SWORD
52005208
amount: 1
5209+
- id: STANDARD_ITEM
5210+
standard_item_type: SWORD
52015211
default_statistics:
52025212
damage: 20.0
52035213
- id: BREWING_STAND

type.generic/src/main/java/net/swofty/types/generic/SkyBlockGenericLoader.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,12 @@ public void initialize(MinecraftServer server) {
219219
/**
220220
* Register entities
221221
*/
222-
typeLoader.getMobs().forEach(mob -> {
223-
MobRegistry.registerExtraMob(mob.getEntityType(), mob.getClazz());
224-
});
222+
loopThroughPackage("net.swofty.types.generic.entity.mob.mobs", SkyBlockMob.class)
223+
.forEach(mob -> MobRegistry.registerExtraMob(mob.getClass()));
224+
225225
MathUtility.delay(() -> SkyBlockMob.runRegionPopulators(MinecraftServer.getSchedulerManager()), 50);
226226

227+
227228
/**
228229
* Handle server attributes
229230
*/

type.generic/src/main/java/net/swofty/types/generic/SkyBlockTypeLoader.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ public interface SkyBlockTypeLoader {
3131
List<SkyBlockEventClass> getTraditionalEvents();
3232
List<SkyBlockEventClass> getCustomEvents();
3333

34-
List<MobRegistry> getMobs();
35-
3634
List<SkyBlockNPC> getNPCs();
3735

3836
List<SkyBlockVillagerNPC> getVillagerNPCs();

0 commit comments

Comments
 (0)