Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit d97089c

Browse files
committed
Reattempt porting 1.21.1
1 parent 3cfbbbf commit d97089c

File tree

138 files changed

+1306
-1056
lines changed

Some content is hidden

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

138 files changed

+1306
-1056
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
// see https://fabricmc.net/develop/ for new versions
3-
id 'fabric-loom' version '1.7-SNAPSHOT' apply false
3+
id 'fabric-loom' version '1.9.+' apply false
44
// see https://projects.neoforged.net/neoforged/moddevgradle for new versions
55
id 'net.neoforged.moddev' version '0.1.110' apply false
66
}

common/src/main/java/dev/ultreon/devices/ClientModEvents.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public CompletableFuture<Void> reload(@NotNull PreparableReloadListener.Preparat
8888

8989
return CompletableFuture.runAsync(() -> {
9090
if (!ApplicationManager.getAllApplications().isEmpty()) {
91-
ApplicationManager.getAllApplications().forEach(AppInfo::reload);
91+
ApplicationManager.getAllApplications().forEach(appInfo -> appInfo.reload(resourceManager));
9292
generateIconAtlas(resourceManager); // FIXME: Broken resource reloading, can't find image resource while definitely exists.
9393
}
9494

common/src/main/java/dev/ultreon/devices/Devices.java

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package dev.ultreon.devices;
22

33
import com.google.common.base.Suppliers;
4-
import com.google.common.collect.ImmutableList;
54
import com.google.gson.*;
65
import com.mojang.serialization.Lifecycle;
76
import dev.ultreon.devices.api.ApplicationManager;
@@ -12,8 +11,8 @@
1211
import dev.ultreon.devices.api.utils.OnlineRequest;
1312
import dev.ultreon.devices.block.PrinterBlock;
1413
import dev.ultreon.devices.core.ComputerScreen;
15-
import dev.ultreon.devices.core.client.ClientNotification;
16-
import dev.ultreon.devices.core.client.debug.ClientAppDebug;
14+
import dev.ultreon.devices.client.ClientNotification;
15+
import dev.ultreon.devices.client.debug.ClientAppDebug;
1716
import dev.ultreon.devices.core.io.task.*;
1817
import dev.ultreon.devices.core.network.task.TaskConnect;
1918
import dev.ultreon.devices.core.network.task.TaskGetDevices;
@@ -52,13 +51,15 @@
5251
import dev.ultreon.mods.xinexlib.event.system.EventSystem;
5352
import dev.ultreon.mods.xinexlib.platform.XinexPlatform;
5453
import dev.ultreon.mods.xinexlib.registrar.RegistrarManager;
54+
import net.minecraft.client.Minecraft;
5555
import net.minecraft.core.BlockPos;
5656
import net.minecraft.core.MappedRegistry;
5757
import net.minecraft.nbt.CompoundTag;
5858
import net.minecraft.resources.ResourceKey;
5959
import net.minecraft.resources.ResourceLocation;
6060
import net.minecraft.server.MinecraftServer;
6161
import net.minecraft.server.level.ServerPlayer;
62+
import net.minecraft.server.packs.resources.ResourceManager;
6263
import net.minecraft.world.InteractionHand;
6364
import net.minecraft.world.InteractionResult;
6465
import net.minecraft.world.entity.player.Player;
@@ -68,7 +69,6 @@
6869
import net.minecraft.world.level.Level;
6970
import net.minecraft.world.level.block.Block;
7071
import org.jetbrains.annotations.ApiStatus;
71-
import org.jetbrains.annotations.NotNull;
7272
import org.jetbrains.annotations.Nullable;
7373
import org.slf4j.Logger;
7474
import org.slf4j.LoggerFactory;
@@ -93,7 +93,6 @@ public abstract class Devices {
9393
private static final Pattern DEV_PREVIEW_PATTERN = Pattern.compile("\\d+\\.\\d+\\.\\d+-dev\\d+");
9494
private static final boolean IS_DEV_PREVIEW = DEV_PREVIEW_PATTERN.matcher(Reference.VERSION).matches();
9595
private static final String GITWEB_REGISTER_URL = "https://ultreon.gitlab.io/gitweb/site_register.json";
96-
public static final String VULNERABILITIES_URL = "https://jab125.com/gitweb/vulnerabilities.php";
9796
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
9897
private static final SiteRegisterStack SITE_REGISTER_STACK = new SiteRegisterStack();
9998

@@ -206,7 +205,6 @@ private void registerApplications() {
206205
TaskManager.registerTask(TaskSendAction::new);
207206
TaskManager.registerTask(TaskSetupFileBrowser::new);
208207
TaskManager.registerTask(TaskGetFiles::new);
209-
TaskManager.registerTask(TaskListDirectory::new);
210208
TaskManager.registerTask(TaskGetMainDrive::new);
211209

212210
// App Store
@@ -303,23 +301,15 @@ public Application registerApplication(ResourceLocation identifier, ApplicationS
303301
apps.add(theAppWeGot);
304302

305303
AppInfo info = new AppInfo(identifier, SystemApp.class.isAssignableFrom(theAppWeGot.getClass()));
306-
info.reload();
304+
ResourceManager resourceManager = Minecraft.getInstance().getResourceManager();
305+
307306
theAppWeGot.setInfo(info);
308307

309308
application.set(theAppWeGot);
310309
});
311310
return application.get();
312311
}
313312

314-
@NotNull
315-
private static AppInfo generateAppInfo(ResourceLocation identifier, Class<? extends Application> clazz) {
316-
LOGGER.debug("Generating app info for {}", identifier.toString());
317-
318-
AppInfo info = new AppInfo(identifier, SystemApp.class.isAssignableFrom(clazz));
319-
info.reload();
320-
return info;
321-
}
322-
323313
protected abstract Map<String, IPrint.Renderer> getRegisteredRenders();
324314

325315
protected abstract void setRegisteredRenders(Map<String, IPrint.Renderer> map);
@@ -419,21 +409,7 @@ private static void setupSiteRegistrations() {
419409
}
420410

421411
private static void checkForVulnerabilities() {
422-
OnlineRequest.getInstance().make(VULNERABILITIES_URL, ((success, response) -> {
423-
if (!success) {
424-
LOGGER.error("Could not access vulnerabilities!");
425-
vulnerabilities = ImmutableList.of();
426-
return;
427-
}
428412

429-
JsonArray array = JsonParser.parseString(new String(response)).getAsJsonArray();
430-
vulnerabilities = Vulnerability.parseArray(array);
431-
vulnerabilities.forEach(vul -> {
432-
String s = vul.toPrettyString();
433-
s.lines().toList().forEach(line -> LOGGER.debug("[VulChecker] {}", line));
434-
LOGGER.debug("[VulChecker]");
435-
});
436-
}));
437413
}
438414

439415
private static CompletableFuture<Void> setupSiteRegistration(String url) {
@@ -512,8 +488,12 @@ enum Type {
512488
return future;
513489
}
514490

491+
/**
492+
* @deprecated Use {@link #res(String)} instead!
493+
*/
494+
@Deprecated
515495
public static ResourceLocation id(String id) {
516-
return ResourceLocation.fromNamespaceAndPath(MOD_ID, id);
496+
return res(id);
517497
}
518498

519499
private static class ProtectedArrayList<T> extends ArrayList<T> {
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package dev.ultreon.devices;
22

3-
import dev.ultreon.devices.object.AppInfo;
4-
53
public interface DevicesModPlatform {
64
String getVersion();
75

8-
void updateIcon(AppInfo info, int iconU, int iconV);
96
}

common/src/main/java/dev/ultreon/devices/Resources.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ private Resources() {
88
}
99

1010

11-
public static final ResourceLocation ENDER_MAIL_ICONS = Devices.id("textures/gui/ender_mail.png");
12-
public static final ResourceLocation ENDER_MAIL_BACKGROUND = Devices.id("textures/gui/ender_mail_background.png");
11+
public static final ResourceLocation ENDER_MAIL_ICONS = Devices.res("textures/gui/ender_mail.png");
12+
public static final ResourceLocation ENDER_MAIL_BACKGROUND = Devices.res("textures/gui/ender_mail_background.png");
1313
}

common/src/main/java/dev/ultreon/devices/api/ApplicationManager.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,8 @@ public static List<AppInfo> getAllApplications() {
8080
public static AppInfo getApplication(ResourceLocation appId) {
8181
return APP_INFO.get(appId);
8282
}
83+
84+
public static AppInfo getApplicationForExtension(String upperCase) {
85+
return APP_INFO.values().stream().filter(info -> info.getExtensions().contains(upperCase)).findFirst().orElse(null);
86+
}
8387
}

common/src/main/java/dev/ultreon/devices/api/app/Alphabet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package dev.ultreon.devices.api.app;
22

33
import com.mojang.blaze3d.systems.RenderSystem;
4-
import com.mojang.blaze3d.vertex.PoseStack;
4+
import dev.ultreon.devices.Devices;
55
import net.minecraft.client.Minecraft;
66
import net.minecraft.client.gui.GuiGraphics;
77
import net.minecraft.resources.ResourceLocation;
@@ -14,7 +14,7 @@
1414
public enum Alphabet implements IIcon {
1515
EXCLAMATION_MARK, QUOTATION_MARK, NUMBER_SIGN, DOLLAR_SIGN, PERCENT_SIGN, AMPERSAND, APOSTROPHE, LEFT_PARENTHESIS, RIGHT_PARENTHESIS, ASTERISK, PLUS_SIGN, COMMA, HYPHEN_MINUS, FULL_STOP, SLASH, ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, COLON, SEMI_COLON, LESS_THAN, EQUALS, MORE_THAN, QUESTION_MARK, COMMERCIAL_AT, UPPERCASE_A, UPPERCASE_B, UPPERCASE_C, UPPERCASE_D, UPPERCASE_E, UPPERCASE_F, UPPERCASE_G, UPPERCASE_H, UPPERCASE_I, UPPERCASE_J, UPPERCASE_K, UPPERCASE_L, UPPERCASE_M, UPPERCASE_N, UPPERCASE_O, UPPERCASE_P, UPPERCASE_Q, UPPERCASE_R, UPPERCASE_S, UPPERCASE_T, UPPERCASE_U, UPPERCASE_V, UPPERCASE_W, UPPERCASE_X, UPPERCASE_Y, UPPERCASE_Z, LEFT_SQUARE_BRACKET, SLASH_REVERSE, RIGHT_SQUARE_BRACKET, CARET, UNDERSCORE, GRAVE_ACCENT, LEFT_CURLY_BRACKET, VERTICAL_LINE, RIGHT_CURLY_BRACKET, TILDE;
1616

17-
private static final ResourceLocation ALPHABET_ASSET = new ResourceLocation("devices:textures/gui/alphabet.png");
17+
private static final ResourceLocation ALPHABET_ASSET = Devices.res("textures/gui/alphabet.png");
1818

1919
private static final int ICON_SIZE = 10;
2020
private static final int GRID_SIZE = 20;

common/src/main/java/dev/ultreon/devices/api/app/Icons.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package dev.ultreon.devices.api.app;
22

33

4+
import dev.ultreon.devices.Devices;
45
import net.minecraft.resources.ResourceLocation;
56

67
/**
@@ -9,7 +10,7 @@
910
public enum Icons implements IIcon {
1011
ARROW_RIGHT, ARROW_DOWN, ARROW_UP, ARROW_LEFT, CHECK, CROSS, PLUS, IMPORT, EXPORT, NEW_FILE, NEW_FOLDER, LOAD, COPY, CUT, CLIPBOARD, SAVE, TRASH, RENAME, EDIT, SEARCH, RELOAD, CHEESE, CHEVRON_RIGHT, CHEVRON_DOWN, CHEVRON_UP, CHEVRON_LEFT, MAIL, BELL, LOCK, UNLOCK, KEY, WIFI_HIGH, WIFI_MED, WIFI_LOW, WIFI_NONE, PLAY, STOP, PAUSE, PREVIOUS, NEXT, INFO, WARNING, ERROR, VOLUME_ON, VOLUME_OFF, STAR_OFF, STAR_HALF, STAR_ON, CHAT, EJECT, CLOCK, SHOPPING_CART, SHOPPING_CART_ADD, SHOPPING_CART_REMOVE, USER, USER_ADD, USER_REMOVE, COMMUNITY, SHARE, CONTACTS, COMPUTER, PRINTER, GAME_CONTROLLER, CAMERA, HEADPHONES, TELEVISION, SMART_PHONE, USB, INTERNAL_DRIVE, EXTERNAL_DRIVE, NETWORK_DRIVE, DATABASE, CD, BATTERY_FULL, BATTERY_HALF, BATTERY_LOW, BATTERY_EMPTY, POWER_ON, POWER_OFF, EARTH, PICTURE, SHOP, HOME, THUMBS_UP_OFF, THUMBS_UP_ON, THUMBS_DOWN_OFF, THUMBS_DOWN_ON, BOOKMARK_OFF, BOOKMARK_ON, UNDO, REDO, WRENCH, HAMMER, FORBIDDEN, MUSIC, EYE_DROPPER, DOTS_VERTICAL, DOTS_HORIZONTAL, EXPAND, SHRINK, SORT, FONT, ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT, ALIGN_JUSTIFY, COIN, CASH, VERIFIED, BOOK_CLOSED, BOOK_OPEN, VIDEO_ROLL, VIDEO_CAMERA, LIGHT_BULB_OFF, LIGHT_BULB_ON, LOCATION, SEND, LOGIN, LOGOUT, HELP, HEART_OFF, HEART_ON, MAP, BRIGHTNESS, GIFT_RED, GIFT_CYAN, GIFT_GREEN, GIFT_BLUE, CREDIT_CARD, PIN, VISIBILITY_OFF, VISIBILITY_ON, HOURGLASS, OFFLINE, LIVE, ONLINE, CONNECTING, MICROPHONE, MICROPHONE_MUTE, HEADPHONES_MUTE, ZOOM_IN, ZOOM_OUT, FILE, FOLDER, SAVE_AS, FLASHED_WARNING, WARNING_GRAY;
1112

12-
private static final ResourceLocation ICON_ASSET = new ResourceLocation("devices:textures/gui/icons.png");
13+
private static final ResourceLocation ICON_ASSET = Devices.res("textures/gui/icons.png");
1314

1415
private static final int ICON_SIZE = 10;
1516
private static final int GRID_SIZE = 20;

common/src/main/java/dev/ultreon/devices/api/app/Notification.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package dev.ultreon.devices.api.app;
22

33
import dev.ultreon.devices.api.task.Task;
4-
import dev.ultreon.devices.core.client.ClientNotification;
4+
import dev.ultreon.devices.client.ClientNotification;
55
import dev.ultreon.devices.network.PacketHandler;
66
import dev.ultreon.devices.network.task.NotificationPacket;
77
import net.minecraft.nbt.CompoundTag;

common/src/main/java/dev/ultreon/devices/api/app/System.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,5 @@ default void launchApp(AppInfo info, FileInfo path, Consumer<LauncherResponse> c
8686
Collection<AppInfo> getInstalledApplications();
8787

8888
void openDialog(Dialog message);
89+
8990
}

0 commit comments

Comments
 (0)