diff --git a/build.gradle b/build.gradle index 7047e018b..ce01c7afa 100644 --- a/build.gradle +++ b/build.gradle @@ -1,98 +1,192 @@ -plugins { - id "architectury-plugin" version "3.4-SNAPSHOT" - id "dev.architectury.loom" version "0.12.0-SNAPSHOT" apply false - id "io.github.pacifistmc.forgix" version "1.2.2" - id "org.jetbrains.kotlin.jvm" version "1.7.10" - // id 'org.jetbrains.kotlin.jvm' version '1.7.1' -} -repositories { - gradlePluginPortal() +buildscript { + repositories { + // These repositories are only for Gradle plugins, put any other repositories in the repository block further below + maven { + name "SpongePowered" + url 'https://repo.spongepowered.org/repository/maven-public/' + } + mavenCentral() + } + dependencies { + classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT' + } } -architectury { - minecraft = rootProject.minecraft_version +plugins { + id 'net.minecraftforge.gradle' version '5.1.+' + id 'org.parchmentmc.librarian.forgegradle' version '1.+' } -version = "${mod_version}" -Object getIngame_version() { - return "${mod_version}" +apply plugin: 'org.spongepowered.mixin' + +group = 'com.ultreon.mods' +version = '0.5.0-bp.116' + +java { + archivesBaseName = 'devices-mod' + toolchain.languageVersion = JavaLanguageVersion.of(8) } -forgix { - group = "com.ultreon.mods" - mergedJarName = "devices-${version}.jar" - outputDir = "build/libs/merged" +minecraft { + // The mappings can be changed at any time and must be in the following format. + // Channel: Version: + // official MCVersion Official field/method names from Mojang mapping files + // parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official + // + // You must be aware of the Mojang license when using the 'official' or 'parchment' mappings. + // See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md + // + // Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge + // Additional setup is needed to use their mappings: https://github.com/ParchmentMC/Parchment/wiki/Getting-Started + // + // Use non-default mappings at your own risk. They may not always work. + // Simply re-run your setup task after changing the mappings to update your workspace. + mappings channel: 'official', version: '1.16.5' + + accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') + + // Default run configurations. + // These can be tweaked, removed, or duplicated as needed. + runs { + client { + workingDirectory project.file('run') + + // Recommended logging data for a user-dev environment + // The markers can be added/remove as needed separated by commas. + // "SCAN": For mods scan. + // "REGISTRIES": For firing of registry events. + // "REGISTRYDUMP": For getting the contents of all registries. + property 'forge.logging.markers', 'REGISTRIES' + + + // Recommended logging level for the console + // You can set various levels here. + // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels + property 'forge.logging.console.level', 'debug' + + // Comma-separated list of namespaces to load game-tests from. Empty = all namespaces. + property 'forge.enabledGameTestNamespaces', 'device-mod' + + mods { + devicemod { + source sourceSets.main + } + } + } - forge { - projectName = "merge-forge" - jarLocation = "build/libs/devices-${version}.jar" - // additionalRelocate("com.ultreon.devices", "forge.com.ultreon.devices") + server { + workingDirectory project.file('run') - // mixin "devices-common.mixins.json" - // mixin "devices.mixins.json" - } + property 'forge.logging.markers', 'REGISTRIES' - fabric { - projectName = "merge-fabric" - jarLocation = "build/libs/devices-${version}.jar" - // additionalRelocate("com.ultreon.devices", "fabric.com.ultreon.devices") - } -} + property 'forge.logging.console.level', 'debug' -println "forgix.outputDir = $forgix.outputDir" + property 'forge.enabledGameTestNamespaces', 'device-mod' -subprojects { - apply plugin: "dev.architectury.loom" + mods { + devicemod { + source sourceSets.main + } + } + } - loom { - silentMojangMappingsLicense() - } + // This run config launches GameTestServer and runs all registered game-tests, then exits. + // By default, the server will crash when no game-tests are provided. + // The game-test system is also enabled by default for other run configs under the /test command. + gameTestServer { + workingDirectory project.file('run') - dependencies { - minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" - // The following line declares the mojmap mappings, you may use other mappings as well - mappings loom.layered() { - officialMojangMappings() - parchment("org.parchmentmc.data:parchment-1.18.2:2022.06.26@zip") + property 'forge.logging.markers', 'REGISTRIES' + + property 'forge.logging.console.level', 'debug' + + property 'forge.enabledGameTestNamespaces', 'device-mod' + + mods { + devicemod { + source sourceSets.main + } + } } -// layered - // The following line declares the yarn mappings you may select this one as well. - // mappings "net.fabricmc:yarn:@YARN_MAPPINGS@:v2" - } -} + data { + workingDirectory project.file('run') -allprojects { - apply plugin: "java" - apply plugin: "architectury-plugin" - apply plugin: "maven-publish" + property 'forge.logging.markers', 'REGISTRIES' - archivesBaseName = rootProject.archives_base_name - version = rootProject.version - group = rootProject.maven_group + property 'forge.logging.console.level', 'debug' - repositories { - // Add repositories to retrieve artifacts from in here. - // You should only use this when depending on other mods because - // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. - // See https://docs.gradle.org/current/userguide/declaring_repositories.html - // for more information about repositories. - maven { url = "https://maven.parchmentmc.org" } - - flatDir { - dir "${rootProject.projectDir}/libs" + // Specify the mod-id for data generation, where to output the resulting resource, and where to look for existing resources. + args '--mod', 'devices', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') + + mods { + devicemod { + source sourceSets.main + } + } } } +} - tasks.withType(JavaCompile) { - options.encoding = "UTF-8" - options.release = 17 - } +mixin { + add sourceSets.main, "device-mod.refmap.json" - java { - withSourcesJar() + config "device-mod.mixins.json" +} + +// Include resources generated by data generators. +sourceSets.main.resources { srcDir 'src/generated/resources' } + +repositories { + // Put repositories for dependencies here + // ForgeGradle automatically adds the Forge maven and Maven Central for you + + // If you have mod jar dependencies in ./libs, you can declare them as a repository like so: + // flatDir { + // dir 'libs' + // } +} + +dependencies { + // Specify the version of Minecraft to use. If this is any group other than 'net.minecraft' it is assumed + // that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied. + // The user-dev artifact is a special name and will get all sorts of transformations applied to it. + minecraft 'net.minecraftforge:forge:1.16.5-36.2.42' + + implementation "org.jetbrains:annotations:24.0.1" + + // Real mod deobf dependency examples - these get remapped to your current mappings + // compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency + // runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency + // implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency + + // Examples using mod jars from ./libs + // implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}") + + // For more info... + // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html + // http://www.gradle.org/docs/current/userguide/dependency_management.html + + annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' +} + +// Example for how to get properties into the manifest for reading at runtime. +jar { + manifest { + attributes([ + "Specification-Title" : "devices", + "Specification-Vendor" : "Ultreon Team", + "Specification-Version" : "1", // We are version 1 of ourselves + "Implementation-Title" : project.name, + "Implementation-Version" : project.jar.archiveVersion, + "Implementation-Vendor" : "Ultreon Team", + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") + ]) } } -mergeJars.mustRunAfter build -//build.dependsOn mergeJars \ No newline at end of file +jar.finalizedBy('reobfJar') + +tasks.withType(JavaCompile).configureEach { + options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation +} diff --git a/common/src/main/java/com/ultreon/devices/ClientModEvents.java b/common/src/main/java/com/ultreon/devices/ClientModEvents.java index cbcacd0fc..c3ee20e21 100644 --- a/common/src/main/java/com/ultreon/devices/ClientModEvents.java +++ b/common/src/main/java/com/ultreon/devices/ClientModEvents.java @@ -1,25 +1,25 @@ package com.ultreon.devices; import com.ultreon.devices.block.entity.renderer.*; -import com.mojang.blaze3d.platform.NativeImage; +import net.minecraft.client.renderer.texture.NativeImage; import com.ultreon.devices.api.ApplicationManager; import com.ultreon.devices.core.Laptop; import com.ultreon.devices.init.DeviceBlockEntities; import com.ultreon.devices.init.DeviceBlocks; import com.ultreon.devices.object.AppInfo; import dev.architectury.injectables.annotations.ExpectPlatform; -import dev.architectury.registry.client.rendering.BlockEntityRendererRegistry; +import dev.architectury.registry.client.rendering.TileEntityRendererRegistry; import dev.architectury.registry.client.rendering.RenderTypeRegistry; import dev.architectury.registry.registries.Registries; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.texture.DynamicTexture; -import net.minecraft.core.Registry; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.packs.resources.PreparableReloadListener; -import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.util.Registry; +import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.PreparableReloadListener; +import net.minecraft.resources.IResourceManager; import net.minecraft.util.profiling.ProfilerFiller; -import net.minecraft.world.level.block.Block; +import net.minecraft.block.Block; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.Marker; @@ -70,7 +70,7 @@ public static void clientSetup() { public static class ReloaderListener implements PreparableReloadListener { @NotNull @Override - public CompletableFuture reload(@NotNull PreparableReloadListener.PreparationBarrier preparationBarrier, @NotNull ResourceManager resourceManager, @NotNull ProfilerFiller preparationsProfiler, @NotNull ProfilerFiller reloadProfiler, @NotNull Executor backgroundExecutor, @NotNull Executor gameExecutor) { + public CompletableFuture reload(@NotNull PreparableReloadListener.PreparationBarrier preparationBarrier, @NotNull IResourceManager resourceManager, @NotNull ProfilerFiller preparationsProfiler, @NotNull ProfilerFiller reloadProfiler, @NotNull Executor backgroundExecutor, @NotNull Executor gameExecutor) { LOGGER.debug("Reloading resources from the Device Mod."); return CompletableFuture.runAsync(() -> { @@ -206,11 +206,11 @@ public static void setRenderLayer(Block block, RenderType type) { public static void registerRenderers() { LOGGER.info("Registering renderers."); - BlockEntityRendererRegistry.register(DeviceBlockEntities.LAPTOP.get(), LaptopRenderer::new); - BlockEntityRendererRegistry.register(DeviceBlockEntities.PRINTER.get(), PrinterRenderer::new); - BlockEntityRendererRegistry.register(DeviceBlockEntities.PAPER.get(), PaperRenderer::new); - BlockEntityRendererRegistry.register(DeviceBlockEntities.ROUTER.get(), RouterRenderer::new); - BlockEntityRendererRegistry.register(DeviceBlockEntities.SEAT.get(), OfficeChairRenderer::new); + TileEntityRendererRegistry.register(DeviceBlockEntities.LAPTOP.get(), LaptopRenderer::new); + TileEntityRendererRegistry.register(DeviceBlockEntities.PRINTER.get(), PrinterRenderer::new); + TileEntityRendererRegistry.register(DeviceBlockEntities.PAPER.get(), PaperRenderer::new); + TileEntityRendererRegistry.register(DeviceBlockEntities.ROUTER.get(), RouterRenderer::new); + TileEntityRendererRegistry.register(DeviceBlockEntities.SEAT.get(), OfficeChairRenderer::new); } public static void registerLayerDefinitions() { diff --git a/common/src/main/java/com/ultreon/devices/DeviceConfig.java b/common/src/main/java/com/ultreon/devices/DeviceConfig.java index f5034e437..4f9a4af72 100644 --- a/common/src/main/java/com/ultreon/devices/DeviceConfig.java +++ b/common/src/main/java/com/ultreon/devices/DeviceConfig.java @@ -2,8 +2,8 @@ import dev.architectury.injectables.annotations.ExpectPlatform; import dev.architectury.platform.Platform; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.INBT; import net.minecraftforge.common.ForgeConfigSpec; public class DeviceConfig { @@ -54,20 +54,20 @@ public class DeviceConfig { .define(CATEGORY_PIXEL_PAINTER + ".renderPrintedIn3d", false); DEBUG_BUTTON = builder.comment("Display a button to access a worldless laptop") - .define(CATEGORY_DEBUG + ".debugButton", Platform.isDevelopmentEnvironment()); + .define(CATEGORY_DEBUG + ".debugButton", Platform.isDevelopmentOnlyIn()); CONFIG = builder.build(); } // TODO *** Add read/write of synchronization tags of the config file if needed *** - public static void readSyncTag(CompoundTag tag) { - if (tag.contains("pingRate", Tag.TAG_INT)) PING_RATE.set(tag.getInt("pingRate")); - if (tag.contains("signalRange", Tag.TAG_INT)) SIGNAL_RANGE.set(tag.getInt("signalRange")); + public static void readSyncTag(CompoundNBT tag) { + if (tag.contains("pingRate", Constants.NBT.TAG_INT)) PING_RATE.set(tag.getInt("pingRate")); + if (tag.contains("signalRange", Constants.NBT.TAG_INT)) SIGNAL_RANGE.set(tag.getInt("signalRange")); } - public static CompoundTag writeSyncTag() { - CompoundTag tag = new CompoundTag(); + public static CompoundNBT writeSyncTag() { + CompoundNBT tag = new CompoundNBT(); tag.putInt("pingRate", PING_RATE.get()); tag.putInt("signalRange", SIGNAL_RANGE.get()); return tag; diff --git a/common/src/main/java/com/ultreon/devices/DeviceTab.java b/common/src/main/java/com/ultreon/devices/DeviceTab.java index 4166991b7..3000da2e7 100644 --- a/common/src/main/java/com/ultreon/devices/DeviceTab.java +++ b/common/src/main/java/com/ultreon/devices/DeviceTab.java @@ -1,11 +1,11 @@ package com.ultreon.devices; import com.ultreon.devices.init.DeviceItems; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.ItemStack; +import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemStack; import org.jetbrains.annotations.NotNull; -public class DeviceTab extends CreativeModeTab { +public class DeviceTab extends ItemGroup { public DeviceTab(String label) { super(0, "A"); throw new AssertionError(); diff --git a/common/src/main/java/com/ultreon/devices/Devices.java b/common/src/main/java/com/ultreon/devices/Devices.java index 73b6632e8..3fafd48cc 100644 --- a/common/src/main/java/com/ultreon/devices/Devices.java +++ b/common/src/main/java/com/ultreon/devices/Devices.java @@ -52,15 +52,15 @@ import dev.architectury.platform.Platform; import dev.architectury.registry.CreativeTabRegistry; import dev.architectury.registry.registries.Registries; -import dev.architectury.utils.Env; -import dev.architectury.utils.EnvExecutor; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.DistExecutor; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.ResourceLocation; import net.minecraft.server.MinecraftServer; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -import net.minecraft.world.level.Level; +import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.world.World; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; @@ -80,7 +80,7 @@ public class Devices { public static final String MOD_ID = "devices"; - public static final CreativeModeTab TAB_DEVICE = CreativeTabRegistry.create(id("devices_tab_device"), () -> new ItemStack(DeviceItems.RED_LAPTOP.get())); + public static final ItemGroup GROUP_DEVICE = CreativeTabRegistry.create(id("devices_tab_device"), () -> new ItemStack(DeviceItems.RED_LAPTOP.get())); public static final Supplier REGISTRIES = Suppliers.memoize(() -> Registries.get(MOD_ID)); public static final List SITE_REGISTRATIONS = new ProtectedArrayList<>(); public static final Logger LOGGER = LoggerFactory.getLogger("Devices Mod"); @@ -106,16 +106,16 @@ public static void init() { registerApplications(); - EnvExecutor.runInEnv(Env.CLIENT, () -> () -> { + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> { ClientAppDebug.register(); ClientModEvents.clientSetup(); //todo }); - EnvExecutor.runInEnv(Env.CLIENT, () -> Devices::setupSiteRegistrations); + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> Devices::setupSiteRegistrations); setupEvents(); - EnvExecutor.runInEnv(Env.CLIENT, () -> Devices::setupClientEvents); //todo + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> Devices::setupClientEvents); //todo if (!ArchitecturyTarget.getCurrentTarget().equals("forge")) { loadComplete(); } @@ -227,7 +227,7 @@ public static void init() { // } public static void preInit() { - if (DEVELOPER_MODE && Platform.isDevelopmentEnvironment()) { + if (DEVELOPER_MODE && Platform.isDevelopmentOnlyIn()) { throw new LaunchException(); } @@ -319,7 +319,7 @@ private static void registerApplications() { TaskManager.registerTask(TaskNotificationTest::new); } - EnvExecutor.runInEnv(Env.CLIENT, () -> () -> PrintingManager.registerPrint(new ResourceLocation(Reference.MOD_ID, "picture"), PixelPainterApp.PicturePrint.class)); + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> PrintingManager.registerPrint(new ResourceLocation(Reference.MOD_ID, "picture"), PixelPainterApp.PicturePrint.class)); } @ExpectPlatform @@ -349,7 +349,7 @@ public static Application registerApplication(ResourceLocation identifier, Suppl } AtomicReference application = new AtomicReference<>(null); - EnvExecutor.runInEnv(Env.CLIENT, () -> () -> { + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> { List apps = getAPPLICATIONS(); /*ObfuscationReflectionHelper.getPrivateValue(Laptop.class, null, "APPLICATIONS");*/ assert apps != null; apps.add(appl); @@ -407,10 +407,10 @@ public static boolean registerPrint(ResourceLocation identifier, Class () -> { + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> { ClientNotification notification = ClientNotification.loadFromTag(tag); notification.push(); }); @@ -461,7 +461,7 @@ private static void setupEvents() { LifecycleEvent.SERVER_STARTING.register((instance -> server = instance)); LifecycleEvent.SERVER_STOPPED.register(instance -> server = null); InteractionEvent.RIGHT_CLICK_BLOCK.register(((player, hand, pos, face) -> { - Level level = player.getLevel(); + World level = player.getLevel(); if (!player.getItemInHand(hand).isEmpty() && player.getItemInHand(hand).getItem() == Items.PAPER) { if (level.getBlockState(pos).getBlock() instanceof PrinterBlock) { return EventResult.interruptTrue(); diff --git a/common/src/main/java/com/ultreon/devices/Resources.java b/common/src/main/java/com/ultreon/devices/Resources.java index 8c10643fa..d2e878567 100644 --- a/common/src/main/java/com/ultreon/devices/Resources.java +++ b/common/src/main/java/com/ultreon/devices/Resources.java @@ -1,6 +1,6 @@ package com.ultreon.devices; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.ResourceLocation; public final class Resources { private Resources() { diff --git a/common/src/main/java/com/ultreon/devices/api/ApplicationManager.java b/common/src/main/java/com/ultreon/devices/api/ApplicationManager.java index 6e983e41b..51fd24eb2 100644 --- a/common/src/main/java/com/ultreon/devices/api/ApplicationManager.java +++ b/common/src/main/java/com/ultreon/devices/api/ApplicationManager.java @@ -3,7 +3,7 @@ import com.ultreon.devices.Devices; import com.ultreon.devices.api.app.Application; import com.ultreon.devices.object.AppInfo; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.ResourceLocation; import org.slf4j.Marker; import org.slf4j.MarkerFactory; diff --git a/common/src/main/java/com/ultreon/devices/api/WorldSavedData.java b/common/src/main/java/com/ultreon/devices/api/WorldSavedData.java index fd77eaf99..6a0f1d3aa 100644 --- a/common/src/main/java/com/ultreon/devices/api/WorldSavedData.java +++ b/common/src/main/java/com/ultreon/devices/api/WorldSavedData.java @@ -1,9 +1,9 @@ package com.ultreon.devices.api; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.CompoundNBT; public interface WorldSavedData { - void save(CompoundTag tag); + void save(CompoundNBT tag); - void load(CompoundTag tag); + void load(CompoundNBT tag); } diff --git a/common/src/main/java/com/ultreon/devices/api/app/Alphabet.java b/common/src/main/java/com/ultreon/devices/api/app/Alphabet.java index 5cfcf0850..dababa31e 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/Alphabet.java +++ b/common/src/main/java/com/ultreon/devices/api/app/Alphabet.java @@ -1,9 +1,9 @@ package com.ultreon.devices.api.app; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.Minecraft; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.ResourceLocation; import java.awt.*; @@ -69,12 +69,12 @@ public int getOrdinal() { return ordinal(); } - public void draw(PoseStack pose, Minecraft mc, int x, int y, int color) { + public void draw(MatrixStack pose, Minecraft mc, int x, int y, int color) { Color temp = new Color(color); float[] hsb = Color.RGBtoHSB(temp.getRed(), temp.getGreen(), temp.getBlue(), null); Color iconColor = new Color(Color.HSBtoRGB(hsb[0], hsb[1], 1f)); - RenderSystem.setShaderColor(iconColor.getRed() / 255f, iconColor.getGreen() / 255f, iconColor.getBlue() / 255f, 1f); + RenderSystem.blendColor(iconColor.getRed() / 255f, iconColor.getGreen() / 255f, iconColor.getBlue() / 255f, 1f); this.draw(pose, mc, x, y); - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.blendColor(1f, 1f, 1f, 1f); } } diff --git a/common/src/main/java/com/ultreon/devices/api/app/Application.java b/common/src/main/java/com/ultreon/devices/api/app/Application.java index f9ce4aec3..ddb9d971e 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/Application.java +++ b/common/src/main/java/com/ultreon/devices/api/app/Application.java @@ -1,7 +1,7 @@ package com.ultreon.devices.api.app; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.Devices; import com.ultreon.devices.api.io.File; import com.ultreon.devices.core.Laptop; @@ -12,8 +12,8 @@ import com.ultreon.devices.util.DataHandler; import com.ultreon.devices.util.GLHelper; import net.minecraft.client.Minecraft; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; import org.jetbrains.annotations.Nullable; import java.util.Objects; @@ -109,7 +109,7 @@ public final void restoreDefaultLayout() { * your application window. */ @Override - public abstract void init(@Nullable CompoundTag intent); + public abstract void init(@Nullable CompoundNBT intent); @Override public void onTick() { @@ -132,7 +132,7 @@ public void onTick() { * @param partialTicks the render partial ticks. */ @Override - public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean active, float partialTicks) { + public void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean active, float partialTicks) { // GL11.glEnable(GL11.GL_SCISSOR_TEST); GLHelper.pushScissor(x, y, width, height); @@ -149,7 +149,7 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in currentLayout.renderOverlay(pose, laptop, mc, mouseX, mouseY, active); - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.blendColor(1f, 1f, 1f, 1f); // TODO Port this to 1.18.2 if possible // Lighting.turnOff(); @@ -274,12 +274,12 @@ public void onClose() { /** * Called when you first load up your application. Allows you to read any * stored data you have saved. Only called if you have saved data. This - * method is called after {{@link Wrappable#init(CompoundTag)} so you can update any + * method is called after {{@link Wrappable#init(CompoundNBT)} so you can update any * Components with this data. * * @param tag the tag compound where you saved data is */ - public abstract void load(CompoundTag tag); + public abstract void load(CompoundNBT tag); /** * Allows you to save data from your application. This is only called if @@ -288,7 +288,7 @@ public void onClose() { * * @param tag the tag compound to save your data to */ - public abstract void save(CompoundTag tag); + public abstract void save(CompoundNBT tag); /** * Sets the defaults layout width. It should be noted that the width must be diff --git a/common/src/main/java/com/ultreon/devices/api/app/Component.java b/common/src/main/java/com/ultreon/devices/api/app/Component.java index 5bf511c8b..5c9f8ed78 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/Component.java +++ b/common/src/main/java/com/ultreon/devices/api/app/Component.java @@ -1,13 +1,13 @@ package com.ultreon.devices.api.app; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.core.Laptop; import com.ultreon.devices.programs.system.object.ColorScheme; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiComponent; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.client.gui.AbstractGui; +import net.minecraft.util.ResourceLocation; -public abstract class Component extends GuiComponent { +public abstract class Component extends AbstractGui { /** * The default components textures */ @@ -99,7 +99,7 @@ protected void handleTick() { * @param windowActive if the window is active (at front) * @param partialTicks percentage passed in-between two ticks */ - protected void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + protected void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { } /** @@ -113,7 +113,7 @@ protected void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, * @param mouseY the current y position of the mouse * @param windowActive if the window is active (at front) */ - protected void renderOverlay(PoseStack pose, Laptop laptop, Minecraft mc, int mouseX, int mouseY, boolean windowActive) { + protected void renderOverlay(MatrixStack pose, Laptop laptop, Minecraft mc, int mouseX, int mouseY, boolean windowActive) { } /** @@ -248,11 +248,11 @@ protected ColorScheme getColorScheme() { return Laptop.getSystem().getSettings().getColorScheme(); } - public void drawVerticalLine(PoseStack pose, int x, int y1, int y2, int rgb) { + public void drawVerticalLine(MatrixStack pose, int x, int y1, int y2, int rgb) { fill(pose, x, y1, x + 1, y2, rgb); } - public void drawHorizontalLine(PoseStack pose, int x1, int x2, int y, int rgb) { + public void drawHorizontalLine(MatrixStack pose, int x1, int x2, int y, int rgb) { fill(pose, x1, y, x2, y + 1, rgb); } } diff --git a/common/src/main/java/com/ultreon/devices/api/app/Dialog.java b/common/src/main/java/com/ultreon/devices/api/app/Dialog.java index 7433ddc21..0fd3ed6f0 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/Dialog.java +++ b/common/src/main/java/com/ultreon/devices/api/app/Dialog.java @@ -1,6 +1,6 @@ package com.ultreon.devices.api.app; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.app.component.Button; import com.ultreon.devices.api.app.component.ItemList; import com.ultreon.devices.api.app.component.Text; @@ -21,14 +21,14 @@ import com.ultreon.devices.programs.system.component.FileBrowser; import com.ultreon.devices.programs.system.object.ColorScheme; import com.ultreon.devices.util.GLHelper; -import net.minecraft.ChatFormatting; +import net.minecraft.util.text.TextFormatting; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiComponent; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.nbt.Tag; +import net.minecraft.client.gui.IngameGui; +import net.minecraft.client.gui.AbstractGui; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.ListNBT; +import net.minecraft.nbt.INBT; import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull; @@ -66,7 +66,7 @@ protected final void setLayout(Layout layout) { } @Override - public void init(@Nullable CompoundTag intent) { + public void init(@Nullable CompoundNBT intent) { this.defaultLayout.clear(); this.setLayout(defaultLayout); } @@ -80,7 +80,7 @@ public void onTick() { } @Override - public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean active, float partialTicks) { + public void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean active, float partialTicks) { GLHelper.pushScissor(x, y, width, height); customLayout.render(pose, laptop, mc, x, y, mouseX, mouseY, active, partialTicks); GLHelper.popScissor(); @@ -200,7 +200,7 @@ public Message(String messageText) { } @Override - public void init(@Nullable CompoundTag intent) { + public void init(@Nullable CompoundNBT intent) { super.init(intent); int textHeight = Minecraft.getInstance().font.wordWrapHeight(messageText, getWidth() - 10); @@ -208,7 +208,7 @@ public void init(@Nullable CompoundTag intent) { super.init(intent); - defaultLayout.setBackground((pose, gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> Gui.fill(pose, x, y, x + width, y + height, Color.LIGHT_GRAY.getRGB())); + defaultLayout.setBackground((pose, gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> IngameGui.fill(pose, x, y, x + width, y + height, Color.LIGHT_GRAY.getRGB())); Text message = new Text(messageText, 5, 5, getWidth() - 10); this.addComponent(message); @@ -256,7 +256,7 @@ public Confirmation(String messageText) { } @Override - public void init(@Nullable CompoundTag intent) { + public void init(@Nullable CompoundNBT intent) { super.init(intent); int lines = Minecraft.getInstance().font.wordWrapHeight(messageText, getWidth() - 10); @@ -264,7 +264,7 @@ public void init(@Nullable CompoundTag intent) { super.init(intent); - defaultLayout.setBackground((pose, gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> Gui.fill(pose, x, y, x + width, y + height, Color.LIGHT_GRAY.getRGB())); + defaultLayout.setBackground((pose, gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> IngameGui.fill(pose, x, y, x + width, y + height, Color.LIGHT_GRAY.getRGB())); Text message = new Text(messageText, 5, 5, getWidth() - 10); this.addComponent(message); @@ -355,7 +355,7 @@ public Input(String messageText) { } @Override - public void init(@Nullable CompoundTag intent) { + public void init(@Nullable CompoundNBT intent) { super.init(intent); int offset = 0; @@ -368,7 +368,7 @@ public void init(@Nullable CompoundTag intent) { super.init(intent); - defaultLayout.setBackground((pose, gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> Gui.fill(pose, x, y, x + width, y + height, Color.LIGHT_GRAY.getRGB())); + defaultLayout.setBackground((pose, gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> IngameGui.fill(pose, x, y, x + width, y + height, Color.LIGHT_GRAY.getRGB())); if (messageText != null) { Text message = new Text(messageText, 5, 5, getWidth() - 10); @@ -483,7 +483,7 @@ public OpenFile(Application app) { } @Override - public void init(@Nullable CompoundTag intent) { + public void init(@Nullable CompoundNBT intent) { super.init(intent); main = new Layout(211, 126); @@ -585,7 +585,7 @@ public void setFilter(Application app) { @SuppressWarnings({"FieldCanBeLocal", "unused"}) public static class SaveFile extends Dialog { private final Application app; - private final CompoundTag data; + private final CompoundNBT data; public ResponseHandler responseHandler; private String name; private String positiveText = "Save"; @@ -599,7 +599,7 @@ public static class SaveFile extends Dialog { private String path = FileSystem.DIR_HOME; - public SaveFile(Application app, CompoundTag data) { + public SaveFile(Application app, CompoundNBT data) { this.app = app; this.data = data; this.setTitle("Save File"); @@ -613,7 +613,7 @@ public SaveFile(Application app, File file) { } @Override - public void init(@Nullable CompoundTag intent) { + public void init(@Nullable CompoundNBT intent) { super.init(intent); main = new Layout(211, 145); @@ -762,7 +762,7 @@ public Print(IPrint print) { } @Override - public void init(@Nullable CompoundTag intent) { + public void init(@Nullable CompoundNBT intent) { super.init(intent); layoutMain = new Layout(150, 132); @@ -784,9 +784,9 @@ public void init(@Nullable CompoundTag intent) { itemListPrinters = new ItemList<>(5, 18, 140, 5); itemListPrinters.setListItemRenderer(new ListItemRenderer<>(16) { @Override - public void render(PoseStack pose, NetworkDevice networkDevice, GuiComponent gui, Minecraft mc, int x, int y, int width, int height, boolean selected) { + public void render(MatrixStack pose, NetworkDevice networkDevice, AbstractGui gui, Minecraft mc, int x, int y, int width, int height, boolean selected) { ColorScheme colorScheme = Laptop.getSystem().getSettings().getColorScheme(); - Gui.fill(pose, x, y, x + width, y + height, selected ? colorScheme.getItemHighlightColor() : colorScheme.getItemBackgroundColor()); + IngameGui.fill(pose, x, y, x + width, y + height, selected ? colorScheme.getItemHighlightColor() : colorScheme.getItemBackgroundColor()); Icons.PRINTER.draw(pose, mc, x + 3, y + 3); RenderUtil.drawStringClipped(pose, networkDevice.getName(), x + 18, y + 4, 118, Laptop.getSystem().getSettings().getColorScheme().getTextColor(), true); } @@ -867,7 +867,7 @@ private void getPrinters(ItemList itemList) { task.setCallback((tag, success) -> { if (success) { assert tag != null; - ListTag list = tag.getList("network_devices", Tag.TAG_COMPOUND); + ListNBT list = tag.getList("network_devices", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < list.size(); i++) { itemList.addItem(NetworkDevice.fromTag(list.getCompound(i))); } @@ -894,21 +894,21 @@ private Info(NetworkDevice entry) { } @Override - public void init(@Nullable CompoundTag intent) { + public void init(@Nullable CompoundNBT intent) { super.init(intent); layoutMain = new Layout(120, 70); - labelName = new com.ultreon.devices.api.app.component.Label(ChatFormatting.GOLD.toString() + ChatFormatting.BOLD + entry.getName(), 5, 5); + labelName = new com.ultreon.devices.api.app.component.Label(TextFormatting.GOLD.toString() + TextFormatting.BOLD + entry.getName(), 5, 5); layoutMain.addComponent(labelName); - labelPaper = new com.ultreon.devices.api.app.component.Label(ChatFormatting.DARK_GRAY + "Paper: " + ChatFormatting.RESET + 0, 5, 18); //TODO fix paper count + labelPaper = new com.ultreon.devices.api.app.component.Label(TextFormatting.DARK_GRAY + "Paper: " + TextFormatting.RESET + 0, 5, 18); //TODO fix paper count labelPaper.setAlignment(Component.ALIGN_LEFT); labelPaper.setShadow(false); layoutMain.addComponent(labelPaper); assert entry.getPos() != null; - String position = ChatFormatting.DARK_GRAY + "X: " + ChatFormatting.RESET + entry.getPos().getX() + " " + ChatFormatting.DARK_GRAY + "Y: " + ChatFormatting.RESET + entry.getPos().getY() + " " + ChatFormatting.DARK_GRAY + "Z: " + ChatFormatting.RESET + entry.getPos().getZ(); + String position = TextFormatting.DARK_GRAY + "X: " + TextFormatting.RESET + entry.getPos().getX() + " " + TextFormatting.DARK_GRAY + "Y: " + TextFormatting.RESET + entry.getPos().getY() + " " + TextFormatting.DARK_GRAY + "Z: " + TextFormatting.RESET + entry.getPos().getZ(); labelPosition = new com.ultreon.devices.api.app.component.Label(position, 5, 30); labelPosition.setShadow(false); layoutMain.addComponent(labelPosition); diff --git a/common/src/main/java/com/ultreon/devices/api/app/IIcon.java b/common/src/main/java/com/ultreon/devices/api/app/IIcon.java index 62d4dd585..16037e17b 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/IIcon.java +++ b/common/src/main/java/com/ultreon/devices/api/app/IIcon.java @@ -1,10 +1,10 @@ package com.ultreon.devices.api.app; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiComponent; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.client.gui.AbstractGui; +import net.minecraft.util.ResourceLocation; public interface IIcon { ResourceLocation getIconAsset(); @@ -35,15 +35,15 @@ public interface IIcon { int getOrdinal(); - default void draw(PoseStack pose, Minecraft mc, int x, int y) { - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); - RenderSystem.setShaderTexture(0, getIconAsset()); + default void draw(MatrixStack pose, Minecraft mc, int x, int y) { + RenderSystem.blendColor(1f, 1f, 1f, 1f); + mc.textureManager.bind(getIconAsset()); int size = getIconSize(); int assetWidth = getGridWidth() * size; // java.lang.System.out.println("assetWidth = " + assetWidth); int assetHeight = getGridHeight() * size; // java.lang.System.out.println("assetHeight = " + assetHeight); // GuiComponent.blit(pose, x + contentX, y + iconY, iconWidth, iconHeight, iconU, iconV, iconWidth, iconHeight, iconSourceWidth, iconSourceHeight); - GuiComponent.blit(pose, x, y, size, size, getU(), getV(), size, size, assetWidth, assetHeight); + AbstractGui.blit(pose, x, y, size, size, getU(), getV(), size, size, assetWidth, assetHeight); } } diff --git a/common/src/main/java/com/ultreon/devices/api/app/Icons.java b/common/src/main/java/com/ultreon/devices/api/app/Icons.java index 36d4a1a7d..a1315c125 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/Icons.java +++ b/common/src/main/java/com/ultreon/devices/api/app/Icons.java @@ -1,7 +1,7 @@ package com.ultreon.devices.api.app; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.ResourceLocation; /** * @author MrCrayfish diff --git a/common/src/main/java/com/ultreon/devices/api/app/Layout.java b/common/src/main/java/com/ultreon/devices/api/app/Layout.java index d1537814b..862de4950 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/Layout.java +++ b/common/src/main/java/com/ultreon/devices/api/app/Layout.java @@ -1,14 +1,14 @@ package com.ultreon.devices.api.app; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.app.listener.InitListener; import com.ultreon.devices.core.Laptop; import com.ultreon.devices.core.Wrappable; import com.ultreon.devices.util.GLHelper; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiComponent; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.client.gui.AbstractGui; +import net.minecraft.nbt.CompoundNBT; import java.awt.*; import java.util.ArrayList; @@ -21,7 +21,7 @@ * in your application to switch interfaces during runtime. *

* Use {@link Application#setCurrentLayout(Layout)} - * inside of {@link Wrappable#init(CompoundTag)} + * inside of {@link Wrappable#init(CompoundNBT)} * to set the current layout for your application. *

* Check out the example applications to get a better understand of @@ -164,7 +164,7 @@ public void handleTick() { * @param y the starting y rendering position (top most) */ @Override - public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + public void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { if (!this.visible) return; @@ -172,7 +172,7 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in background.render(pose, laptop, mc, x, y, width, height, mouseX, mouseY, windowActive); } - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.blendColor(1f, 1f, 1f, 1f); for (var c : new ArrayList<>(components)) { RenderSystem.disableDepthTest(); GLHelper.pushScissor(x, y, width, height); @@ -182,7 +182,7 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in } @Override - public void renderOverlay(PoseStack pose, Laptop laptop, Minecraft mc, int mouseX, int mouseY, boolean windowActive) { + public void renderOverlay(MatrixStack pose, Laptop laptop, Minecraft mc, int mouseX, int mouseY, boolean windowActive) { if (!visible) return; @@ -371,7 +371,7 @@ public interface Background { * @param width the width of the layout * @param height the height of the layout */ - void render(PoseStack pose, GuiComponent gui, Minecraft mc, int x, int y, int width, int height, int mouseX, int mouseY, boolean windowActive); + void render(MatrixStack pose, AbstractGui gui, Minecraft mc, int x, int y, int width, int height, int mouseX, int mouseY, boolean windowActive); } public static class Context extends Layout { @@ -382,7 +382,7 @@ public Context(int width, int height) { } @Override - public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + public void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { super.render(pose, laptop, mc, x, y, mouseX, mouseY, windowActive, partialTicks); if (borderVisible) { drawHorizontalLine(pose, x, x + width - 1, y, Color.DARK_GRAY.getRGB()); diff --git a/common/src/main/java/com/ultreon/devices/api/app/Notification.java b/common/src/main/java/com/ultreon/devices/api/app/Notification.java index 4d11380fd..36ddb8deb 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/Notification.java +++ b/common/src/main/java/com/ultreon/devices/api/app/Notification.java @@ -4,8 +4,8 @@ import com.ultreon.devices.core.client.ClientNotification; import com.ultreon.devices.network.PacketHandler; import com.ultreon.devices.network.task.NotificationPacket; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.server.level.ServerPlayer; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.entity.player.ServerPlayerEntity; import org.apache.commons.lang3.StringUtils; /** @@ -53,15 +53,15 @@ public Notification(IIcon icon, String title, String subTitle) { * * @return the notification tag */ - public CompoundTag toTag() { - CompoundTag tag = new CompoundTag(); + public CompoundNBT toTag() { + CompoundNBT tag = new CompoundNBT(); tag.putString("title", title); if (!StringUtils.isEmpty(subTitle)) { tag.putString("subTitle", subTitle); } - CompoundTag tagIcon = new CompoundTag(); + CompoundNBT tagIcon = new CompoundNBT(); tagIcon.putInt("ordinal", icon.getOrdinal()); tagIcon.putString("className", icon.getClass().getName()); @@ -75,7 +75,7 @@ public CompoundTag toTag() { * * @param player the target player */ - public void pushTo(ServerPlayer player) { + public void pushTo(ServerPlayerEntity player) { PacketHandler.sendToClient(new NotificationPacket(this), player); } } diff --git a/common/src/main/java/com/ultreon/devices/api/app/ScrollableLayout.java b/common/src/main/java/com/ultreon/devices/api/app/ScrollableLayout.java index 3c7b309a0..c7bb5069f 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/ScrollableLayout.java +++ b/common/src/main/java/com/ultreon/devices/api/app/ScrollableLayout.java @@ -1,12 +1,12 @@ package com.ultreon.devices.api.app; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.app.component.Text; import com.ultreon.devices.core.Laptop; import com.ultreon.devices.util.GLHelper; import com.ultreon.devices.util.GuiHelper; import net.minecraft.client.Minecraft; -import net.minecraft.util.Mth; +import net.minecraft.util.math.MathHelper; import java.awt.*; @@ -41,7 +41,7 @@ public ScrollableLayout(int left, int top, int width, int height, int visibleHei } @Override - public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + public void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { if (!visible) return; @@ -51,7 +51,7 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in } @Override - public void renderOverlay(PoseStack pose, Laptop laptop, Minecraft mc, int mouseX, int mouseY, boolean windowActive) { + public void renderOverlay(MatrixStack pose, Laptop laptop, Minecraft mc, int mouseX, int mouseY, boolean windowActive) { if (!visible) return; @@ -60,7 +60,7 @@ public void renderOverlay(PoseStack pose, Laptop laptop, Minecraft mc, int mouse if (this.height > this.visibleHeight) { int visibleScrollBarHeight = visibleHeight; int scrollBarHeight = Math.max(20, (int) (visibleHeight / (float) height * (float) visibleScrollBarHeight)); - float scrollPercentage = Mth.clamp(scroll / (float) (height - visibleHeight), 0f, 1f); + float scrollPercentage = MathHelper.clamp(scroll / (float) (height - visibleHeight), 0f, 1f); int scrollBarY = (int) ((visibleScrollBarHeight - scrollBarHeight) * scrollPercentage); int scrollY = yPosition + scrollBarY; fill(pose, xPosition + width - 5, scrollY, xPosition + width - 2, scrollY + scrollBarHeight, placeholderColor); diff --git a/common/src/main/java/com/ultreon/devices/api/app/System.java b/common/src/main/java/com/ultreon/devices/api/app/System.java index 9e3efb1fe..57ada3c3f 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/System.java +++ b/common/src/main/java/com/ultreon/devices/api/app/System.java @@ -4,7 +4,7 @@ import com.ultreon.devices.core.Settings; import com.ultreon.devices.object.AppInfo; import it.unimi.dsi.fastutil.Pair; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.CompoundNBT; import java.util.Collection; @@ -49,7 +49,7 @@ public interface System { * @param info the app info instance of the application to be opened * @param intentTag the tag to pass data to the initialization of an application */ - Application openApplication(AppInfo info, CompoundTag intentTag); + Application openApplication(AppInfo info, CompoundNBT intentTag); /** * Opens the specified application with a file diff --git a/common/src/main/java/com/ultreon/devices/api/app/component/Button.java b/common/src/main/java/com/ultreon/devices/api/app/component/Button.java index a963ed3c3..cc17e304e 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/component/Button.java +++ b/common/src/main/java/com/ultreon/devices/api/app/component/Button.java @@ -1,22 +1,22 @@ package com.ultreon.devices.api.app.component; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.app.Component; import com.ultreon.devices.api.app.IIcon; import com.ultreon.devices.api.app.listener.ClickListener; import com.ultreon.devices.core.Laptop; import com.ultreon.devices.util.GuiHelper; import com.ultreon.devices.util.StringUtils; -import net.minecraft.ChatFormatting; +import net.minecraft.util.text.TextFormatting; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiComponent; -import net.minecraft.client.resources.sounds.SimpleSoundInstance; -import net.minecraft.client.sounds.SoundManager; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.sounds.SoundEvents; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.AbstractGui; +import net.minecraft.client.audio.SimpleSound; +import net.minecraft.client.audio.SoundHandler; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.SoundEvents; import java.awt.*; import java.util.Arrays; @@ -199,7 +199,7 @@ public Button(int left, int top, int buttonWidth, int buttonHeight, String text, public static int getTextWidth(String text) { boolean flag = Minecraft.getInstance().options.forceUnicodeFont; Minecraft.getInstance().options.forceUnicodeFont = false; - Font fontRenderer = Minecraft.getInstance().font; + FontRenderer fontRenderer = Minecraft.getInstance().font; int width = fontRenderer.width(text); Minecraft.getInstance().options.forceUnicodeFont = flag; return width; @@ -211,14 +211,14 @@ protected void handleTick() { } @Override - public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + public void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { if (this.visible) { - RenderSystem.setShaderTexture(0, Component.COMPONENTS_GUI); - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + mc.textureManager.bind(Component.COMPONENTS_GUI); + RenderSystem.blendColor(1f, 1f, 1f, 1f); Color bgColor = new Color(getColorScheme().getBackgroundColor()).brighter().brighter(); float[] hsb = Color.RGBtoHSB(bgColor.getRed(), bgColor.getGreen(), bgColor.getBlue(), null); bgColor = new Color(Color.HSBtoRGB(hsb[0], hsb[1], 1f)); - RenderSystem.setShaderColor(bgColor.getRed() / 255f, bgColor.getGreen() / 255f, bgColor.getBlue() / 255f, 1f); + RenderSystem.blendColor(bgColor.getRed() / 255f, bgColor.getGreen() / 255f, bgColor.getBlue() / 255f, 1f); this.hovered = GuiHelper.isMouseWithin(mouseX, mouseY, x, y, width, height) && windowActive; int i = this.getHoverState(this.hovered); RenderSystem.enableBlend(); @@ -226,22 +226,22 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in RenderSystem.blendFunc(770, 771); /* Corners */ - GuiComponent.blit(pose, x, y, 2, 2, 96 + i * 5, 12, 2, 2, 256, 256); - GuiComponent.blit(pose, x + width - 2, y, 2, 2, 99 + i * 5, 12, 2, 2, 256, 256); - GuiComponent.blit(pose, x + width - 2, y + height - 2, 2, 2, 99 + i * 5, 15, 2, 2, 256, 256); - GuiComponent.blit(pose, x, y + height - 2, 2, 2, 96 + i * 5, 15, 2, 2, 256, 256); + AbstractGui.blit(pose, x, y, 2, 2, 96 + i * 5, 12, 2, 2, 256, 256); + AbstractGui.blit(pose, x + width - 2, y, 2, 2, 99 + i * 5, 12, 2, 2, 256, 256); + AbstractGui.blit(pose, x + width - 2, y + height - 2, 2, 2, 99 + i * 5, 15, 2, 2, 256, 256); + AbstractGui.blit(pose, x, y + height - 2, 2, 2, 96 + i * 5, 15, 2, 2, 256, 256); /* Middles */ - GuiComponent.blit(pose, x + 2, y, width - 4, 2, 98 + i * 5, 12, 1, 2, 256, 256); - GuiComponent.blit(pose, x + width - 2, y + 2, 2, height - 4, 99 + i * 5, 14, 2, 1, 256, 256); - GuiComponent.blit(pose, x + 2, y + height - 2, width - 4, 2, 98 + i * 5, 15, 1, 2, 256, 256); - GuiComponent.blit(pose, x, y + 2, 2, height - 4, 96 + i * 5, 14, 2, 1, 256, 256); + AbstractGui.blit(pose, x + 2, y, width - 4, 2, 98 + i * 5, 12, 1, 2, 256, 256); + AbstractGui.blit(pose, x + width - 2, y + 2, 2, height - 4, 99 + i * 5, 14, 2, 1, 256, 256); + AbstractGui.blit(pose, x + 2, y + height - 2, width - 4, 2, 98 + i * 5, 15, 1, 2, 256, 256); + AbstractGui.blit(pose, x, y + 2, 2, height - 4, 96 + i * 5, 14, 2, 1, 256, 256); /* Center */ - GuiComponent.blit(pose, x + 2, y + 2, width - 4, height - 4, 98 + i * 5, 14, 1, 1, 256, 256); + AbstractGui.blit(pose, x + 2, y + 2, width - 4, height - 4, 98 + i * 5, 14, 1, 1, 256, 256); - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.blendColor(1f, 1f, 1f, 1f); + RenderSystem.blendColor(1f, 1f, 1f, 1f); int contentWidth = (iconResource != null ? iconWidth : 0) + getTextWidth(text); if (iconResource != null && !StringUtils.isNotNullOrEmpty(text)) contentWidth += 3; @@ -249,8 +249,8 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in if (iconResource != null) { int iconY = (height - iconHeight) / 2; - RenderSystem.setShaderTexture(0, iconResource); - GuiComponent.blit(pose, x + contentX, y + iconY, iconWidth, iconHeight, iconU, iconV, iconVWidth, iconUHeight, iconSourceWidth, iconSourceHeight); + mc.textureManager.bind(iconResource); + AbstractGui.blit(pose, x + contentX, y + iconY, iconWidth, iconHeight, iconU, iconV, iconVWidth, iconUHeight, iconSourceWidth, iconSourceHeight); } if (!StringUtils.isNullOrEmpty(text)) { @@ -263,9 +263,9 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in } @Override - public void renderOverlay(PoseStack pose, Laptop laptop, Minecraft mc, int mouseX, int mouseY, boolean windowActive) { + public void renderOverlay(MatrixStack pose, Laptop laptop, Minecraft mc, int mouseX, int mouseY, boolean windowActive) { if (this.hovered && this.toolTip != null && toolTipTick >= TOOLTIP_DELAY) { - laptop.renderComponentTooltip(pose, Arrays.asList(new TextComponent(this.toolTipTitle).withStyle(ChatFormatting.GOLD), new TextComponent(this.toolTip)), mouseX, mouseY); + laptop.renderComponentTooltip(pose, Arrays.asList(new StringTextComponent(this.toolTipTitle).withStyle(TextFormatting.GOLD), new StringTextComponent(this.toolTip)), mouseX, mouseY); } } @@ -304,8 +304,8 @@ protected int getHoverState(boolean mouseOver) { return i; } - protected void playClickSound(SoundManager manager) { - manager.play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1f)); + protected void playClickSound(SoundHandler manager) { + manager.play(SimpleSound.forUI(SoundEvents.UI_BUTTON_CLICK, 1f)); } protected boolean isInside(int mouseX, int mouseY) { diff --git a/common/src/main/java/com/ultreon/devices/api/app/component/ButtonToggle.java b/common/src/main/java/com/ultreon/devices/api/app/component/ButtonToggle.java index 4d7775326..788d7c0f8 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/component/ButtonToggle.java +++ b/common/src/main/java/com/ultreon/devices/api/app/component/ButtonToggle.java @@ -2,7 +2,7 @@ import com.ultreon.devices.api.app.IIcon; import net.minecraft.client.Minecraft; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.ResourceLocation; @SuppressWarnings("unused") public class ButtonToggle extends Button implements RadioGroup.Item { diff --git a/common/src/main/java/com/ultreon/devices/api/app/component/CheckBox.java b/common/src/main/java/com/ultreon/devices/api/app/component/CheckBox.java index 984c39557..1e38f26a3 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/component/CheckBox.java +++ b/common/src/main/java/com/ultreon/devices/api/app/component/CheckBox.java @@ -1,7 +1,7 @@ package com.ultreon.devices.api.app.component; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.app.Component; import com.ultreon.devices.api.app.listener.ClickListener; import com.ultreon.devices.core.Laptop; @@ -56,7 +56,7 @@ public void setClickListener(ClickListener listener) { } @Override - public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + public void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { if (this.visible) { if (group == null) { Color bgColor = new Color(getColorScheme().getBackgroundColor()); @@ -69,8 +69,8 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in Color bgColor = new Color(getColorScheme().getBackgroundColor()).brighter().brighter(); float[] hsb = Color.RGBtoHSB(bgColor.getRed(), bgColor.getGreen(), bgColor.getBlue(), null); bgColor = new Color(Color.HSBtoRGB(hsb[0], hsb[1], 1f)); - RenderSystem.setShaderColor(bgColor.getRed() / 255f, bgColor.getGreen() / 255f, bgColor.getBlue() / 255f, 1f); - RenderSystem.setShaderTexture(0, COMPONENTS_GUI); + RenderSystem.blendColor(bgColor.getRed() / 255f, bgColor.getGreen() / 255f, bgColor.getBlue() / 255f, 1f); + mc.textureManager.bind(COMPONENTS_GUI); blit(pose, xPosition, yPosition, checked ? 10 : 0, 60, 10, 10); } drawString(pose, mc.font, name, xPosition + 12, yPosition + 1, color(textColor, getColorScheme().getTextColor())); diff --git a/common/src/main/java/com/ultreon/devices/api/app/component/ComboBox.java b/common/src/main/java/com/ultreon/devices/api/app/component/ComboBox.java index 75bff5411..f603f7064 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/component/ComboBox.java +++ b/common/src/main/java/com/ultreon/devices/api/app/component/ComboBox.java @@ -1,7 +1,7 @@ package com.ultreon.devices.api.app.component; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.app.Component; import com.ultreon.devices.api.app.Layout; import com.ultreon.devices.api.app.listener.ChangeListener; @@ -10,7 +10,7 @@ import com.ultreon.devices.api.utils.RenderUtil; import com.ultreon.devices.core.Laptop; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.IngameGui; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -49,13 +49,13 @@ public void handleTick() { @Override public void init(Layout layout) { - this.layout.setBackground((pose, gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> Gui.fill(pose, x, y, x + width, y + height, Color.GRAY.getRGB())); + this.layout.setBackground((pose, gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> IngameGui.fill(pose, x, y, x + width, y + height, Color.GRAY.getRGB())); } @Override - public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + public void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { if (this.visible) { - RenderSystem.setShaderTexture(0, Component.COMPONENTS_GUI); + mc.textureManager.bind(Component.COMPONENTS_GUI); RenderSystem.enableBlend(); RenderSystem.blendFuncSeparate(770, 771, 1, 0); @@ -64,7 +64,7 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in Color bgColor = new Color(getColorScheme().getBackgroundColor()).brighter().brighter(); float[] hsb = Color.RGBtoHSB(bgColor.getRed(), bgColor.getGreen(), bgColor.getBlue(), null); bgColor = new Color(Color.HSBtoRGB(hsb[0], hsb[1], 1f)); - RenderSystem.setShaderColor(bgColor.getRed() / 255f, bgColor.getGreen() / 255f, bgColor.getBlue() / 255f, 1f); + RenderSystem.blendColor(bgColor.getRed() / 255f, bgColor.getGreen() / 255f, bgColor.getBlue() / 255f, 1f); this.hovered = isInside(mouseX, mouseY) && windowActive; int i = this.getHoverState(this.hovered); @@ -85,7 +85,7 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in /* Center */ RenderUtil.drawRectWithTexture(pose, xPosition + 2 + xOffset, yPosition + 2, 98 + i * 5, 14, height - 4, height - 4, 1, 1); - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.blendColor(1f, 1f, 1f, 1f); /* Icons */ RenderUtil.drawRectWithTexture(pose, xPosition + xOffset + 3, yPosition + 5, 111, 12, 8, 5, 8, 5); @@ -105,7 +105,7 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in RenderUtil.drawStringClipped(pose, value.toString(), xPosition + 3, yPosition + 3, width - 15, Color.WHITE.getRGB(), true); } - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.blendColor(1f, 1f, 1f, 1f); } } diff --git a/common/src/main/java/com/ultreon/devices/api/app/component/Image.java b/common/src/main/java/com/ultreon/devices/api/app/component/Image.java index bf3798a59..aca1f588c 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/component/Image.java +++ b/common/src/main/java/com/ultreon/devices/api/app/component/Image.java @@ -1,9 +1,9 @@ package com.ultreon.devices.api.app.component; -import com.mojang.blaze3d.platform.NativeImage; -import com.mojang.blaze3d.platform.TextureUtil; +import net.minecraft.client.renderer.texture.NativeImage; +import net.minecraft.client.renderer.texture.TextureUtil; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.Devices; import com.ultreon.devices.api.app.Component; import com.ultreon.devices.api.app.IIcon; @@ -11,14 +11,14 @@ import com.ultreon.devices.api.utils.RenderUtil; import com.ultreon.devices.core.Laptop; import com.ultreon.devices.object.AppInfo; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.AbstractTexture; +import net.minecraft.client.renderer.texture.Texture; import net.minecraft.client.renderer.texture.DynamicTexture; -import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite; +import net.minecraft.client.renderer.texture.MissingTextureSprite; import net.minecraft.client.renderer.texture.SimpleTexture; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.IResourceManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -242,7 +242,7 @@ protected void handleUnload() { } @Override - public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + public void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { if (this.visible) { if (loader != null && loader.setup) { image = loader.load(this); @@ -254,14 +254,14 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in fill(pose, x, y, x + componentWidth, y + componentHeight, borderColor); } - RenderSystem.setShaderColor(tint.get().r/255f, tint.get().g/255f, tint.get().b/255f, alpha); + RenderSystem.blendColor(tint.get().r/255f, tint.get().g/255f, tint.get().b/255f, alpha); if (image != null && image.textureId != -1) { image.restore(); - RenderSystem.setShaderColor(tint.get().r/255f, tint.get().g/255f, tint.get().b/255f, alpha); + RenderSystem.blendColor(tint.get().r/255f, tint.get().g/255f, tint.get().b/255f, alpha); RenderSystem.enableBlend(); - RenderSystem.setShaderTexture(0, image.textureId); + mc.textureManager.bind(image.textureId); if (/*hasBorder*/true) { if (drawFull) { @@ -291,7 +291,7 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in fill(pose, x, y, x + componentWidth, y + componentHeight, Color.LIGHT_GRAY.getRGB()); } } - RenderSystem.setShaderColor(1f, 1f, 1f, alpha); + RenderSystem.blendColor(1f, 1f, 1f, alpha); } } @@ -398,7 +398,7 @@ protected void setup(Image image) { } private static class StandardLoader extends ImageLoader { - private final AbstractTexture texture; + private final Texture texture; private final ResourceLocation resource; public StandardLoader(ResourceLocation resource) { @@ -414,24 +414,24 @@ protected void setup(Image image) { @Override @SuppressWarnings("ConstantConditions") public CachedImage load(Image image) { - @Nullable AbstractTexture textureObj = Minecraft.getInstance().getTextureManager().getTexture(resource, null); + @Nullable Texture textureObj = Minecraft.getInstance().getTextureManager().getTexture(resource, null); if (textureObj != null) { return new CachedImage(textureObj.getId(), 0, 0, false); } else { - AbstractTexture texture = new SimpleTexture(resource); + Texture texture = new SimpleTexture(resource); Minecraft.getInstance().getTextureManager().register(resource, texture); return new CachedImage(texture.getId(), 0, 0, false); } } - public AbstractTexture getTexture() { + public Texture getTexture() { return texture; } } private static class DynamicLoader extends ImageLoader { private final String url; - private AbstractTexture texture; + private Texture texture; public DynamicLoader(String url) { this.url = url; @@ -465,7 +465,7 @@ public void setup(final Image image) { setup = true; }); } catch (IOException e) { - texture = MissingTextureAtlasSprite.getTexture(); + texture = MissingTextureSprite.getTexture(); setup = true; e.printStackTrace(); } @@ -489,12 +489,12 @@ public CachedImage load(Image image) { CACHE.put(url, cachedImage); return cachedImage; } catch (IOException e) { - return new CachedImage(MissingTextureAtlasSprite.getTexture().getId(), 0, 0, true); + return new CachedImage(MissingTextureSprite.getTexture().getId(), 0, 0, true); } } } - private static class DynamicLoadedTexture extends AbstractTexture { + private static class DynamicLoadedTexture extends Texture { private final InputStream in; private final BufferedImage image; @@ -506,7 +506,7 @@ private DynamicLoadedTexture(InputStream in, BufferedImage image) { } @Override - public void load(@NotNull ResourceManager resourceManager) throws IOException { + public void load(@NotNull IResourceManager resourceManager) throws IOException { NativeImage nativeImage = NativeImage.read(in); Minecraft.getInstance().getTextureManager().register(Devices.id("dynamic_loaded/" + getId()), this); this.upload(nativeImage); diff --git a/common/src/main/java/com/ultreon/devices/api/app/component/Inventory.java b/common/src/main/java/com/ultreon/devices/api/app/component/Inventory.java index a526b41c1..2c4fcf69b 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/component/Inventory.java +++ b/common/src/main/java/com/ultreon/devices/api/app/component/Inventory.java @@ -1,7 +1,7 @@ package com.ultreon.devices.api.app.component; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.app.Component; import com.ultreon.devices.api.app.listener.ClickListener; import com.ultreon.devices.api.task.Task; @@ -9,9 +9,9 @@ import com.ultreon.devices.core.Laptop; import com.ultreon.devices.util.GuiHelper; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.ItemStack; +import net.minecraft.client.gui.IngameGui; +import net.minecraft.util.ResourceLocation; +import net.minecraft.item.ItemStack; import java.awt.*; @@ -38,24 +38,24 @@ public Inventory(int left, int top) { } @Override - public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + public void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { if (this.visible) { - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); - RenderSystem.setShaderTexture(0, CHEST_GUI_TEXTURE); + RenderSystem.blendColor(1f, 1f, 1f, 1f); + mc.textureManager.bind(CHEST_GUI_TEXTURE); RenderUtil.drawRectWithTexture(pose, xPosition, yPosition, 7, 139, 162, 54, 162, 54); assert mc.player != null; - net.minecraft.world.entity.player.Inventory inventory = mc.player.getInventory(); + net.minecraft.entity.player.Inventory inventory = mc.player.getInventory(); for (int i = 9; i < inventory.getContainerSize() - 4; i++) { int offsetX = (i % 9) * 18; int offsetY = (i / 9) * 18 - 18; if (selected == i) { - Gui.fill(pose, xPosition + offsetX, yPosition + offsetY, xPosition + offsetX + 18, yPosition + offsetY + 18, selectedColor); + IngameGui.fill(pose, xPosition + offsetX, yPosition + offsetY, xPosition + offsetX + 18, yPosition + offsetY + 18, selectedColor); } if (GuiHelper.isMouseInside(mouseX, mouseY, xPosition + offsetX, yPosition + offsetY, xPosition + offsetX + 17, yPosition + offsetY + 17)) { - Gui.fill(pose, xPosition + offsetX, yPosition + offsetY, xPosition + offsetX + 18, yPosition + offsetY + 18, hoverColor); + IngameGui.fill(pose, xPosition + offsetX, yPosition + offsetY, xPosition + offsetX + 18, yPosition + offsetY + 18, hoverColor); } ItemStack stack = inventory.getItem(i); @@ -67,7 +67,7 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in } @Override - public void renderOverlay(PoseStack pose, Laptop laptop, Minecraft mc, int mouseX, int mouseY, boolean windowActive) { + public void renderOverlay(MatrixStack pose, Laptop laptop, Minecraft mc, int mouseX, int mouseY, boolean windowActive) { if (this.visible) { for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { diff --git a/common/src/main/java/com/ultreon/devices/api/app/component/ItemList.java b/common/src/main/java/com/ultreon/devices/api/app/component/ItemList.java index 66015c686..43cac8487 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/component/ItemList.java +++ b/common/src/main/java/com/ultreon/devices/api/app/component/ItemList.java @@ -1,6 +1,6 @@ package com.ultreon.devices.api.app.component; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.app.Component; import com.ultreon.devices.api.app.Icons; import com.ultreon.devices.api.app.Layout; @@ -9,8 +9,8 @@ import com.ultreon.devices.core.Laptop; import com.ultreon.devices.util.GuiHelper; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.core.NonNullList; +import net.minecraft.client.gui.IngameGui; +import net.minecraft.util.NonNullList; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -88,7 +88,7 @@ public void init(Layout layout) { layoutLoading.setVisible(loading); layoutLoading.addComponent(new Spinner((layoutLoading.width - 12) / 2, (layoutLoading.height - 12) / 2)); layoutLoading.setBackground((pose, gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> - Gui.fill(pose, x, y, x + width, y + height, LOADING_BACKGROUND)); + IngameGui.fill(pose, x, y, x + width, y + height, LOADING_BACKGROUND)); layout.addComponent(layoutLoading); updateButtons(); @@ -98,7 +98,7 @@ public void init(Layout layout) { } @Override - public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + public void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { if (this.visible) { int height = 13; if (renderer != null) { @@ -111,7 +111,7 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in Color borderColor = bgColor.darker().darker(); /* Fill */ - Gui.fill(pose, xPosition + 1, yPosition + 1, xPosition + width - 1, yPosition + (size * height) + size, bgColor.getRGB()); + IngameGui.fill(pose, xPosition + 1, yPosition + 1, xPosition + width - 1, yPosition + (size * height) + size, bgColor.getRGB()); /* Box */ drawHorizontalLine(pose, xPosition, xPosition + width - 1, yPosition, borderColor.getRGB()); diff --git a/common/src/main/java/com/ultreon/devices/api/app/component/Label.java b/common/src/main/java/com/ultreon/devices/api/app/component/Label.java index b6f9f1782..dc921b8cb 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/component/Label.java +++ b/common/src/main/java/com/ultreon/devices/api/app/component/Label.java @@ -1,6 +1,6 @@ package com.ultreon.devices.api.app.component; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.app.Component; import com.ultreon.devices.core.Laptop; import net.minecraft.client.Minecraft; @@ -31,7 +31,7 @@ public Label(String text, int left, int top) { } @Override - public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + public void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { if (this.visible) { pose.pushPose(); { diff --git a/common/src/main/java/com/ultreon/devices/api/app/component/NumberSelector.java b/common/src/main/java/com/ultreon/devices/api/app/component/NumberSelector.java index 0c04a700b..876282150 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/component/NumberSelector.java +++ b/common/src/main/java/com/ultreon/devices/api/app/component/NumberSelector.java @@ -1,6 +1,6 @@ package com.ultreon.devices.api.app.component; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.app.Component; import com.ultreon.devices.api.app.Layout; import com.ultreon.devices.core.Laptop; @@ -70,7 +70,7 @@ public void init(Layout layout) { } @Override - public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + public void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { } @Override diff --git a/common/src/main/java/com/ultreon/devices/api/app/component/ProgressBar.java b/common/src/main/java/com/ultreon/devices/api/app/component/ProgressBar.java index 6881c6f9a..c16d12baf 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/component/ProgressBar.java +++ b/common/src/main/java/com/ultreon/devices/api/app/component/ProgressBar.java @@ -1,6 +1,6 @@ package com.ultreon.devices.api.app.component; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.app.Component; import com.ultreon.devices.core.Laptop; import net.minecraft.client.Minecraft; @@ -31,7 +31,7 @@ public ProgressBar(int left, int top, int width, int height) { } @Override - public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + public void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { if (this.visible) { Color bgColor = new Color(getColorScheme().getBackgroundColor()); fill(pose, xPosition, yPosition, xPosition + width, yPosition + height, bgColor.darker().darker().getRGB()); diff --git a/common/src/main/java/com/ultreon/devices/api/app/component/Slider.java b/common/src/main/java/com/ultreon/devices/api/app/component/Slider.java index c3365b8fb..e9e42c813 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/component/Slider.java +++ b/common/src/main/java/com/ultreon/devices/api/app/component/Slider.java @@ -1,6 +1,6 @@ package com.ultreon.devices.api.app.component; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.app.Component; import com.ultreon.devices.api.app.listener.ClickListener; import com.ultreon.devices.api.app.listener.ReleaseListener; @@ -40,7 +40,7 @@ public Slider(int left, int top, int width) { } @Override - public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + public void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { if (this.visible) { Color bgColor = new Color(getColorScheme().getBackgroundColor()); fill(pose, xPosition, yPosition + 4, xPosition + width, yPosition + 8, bgColor.darker().darker().getRGB()); diff --git a/common/src/main/java/com/ultreon/devices/api/app/component/Spinner.java b/common/src/main/java/com/ultreon/devices/api/app/component/Spinner.java index d5a291fd8..6b3009fee 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/component/Spinner.java +++ b/common/src/main/java/com/ultreon/devices/api/app/component/Spinner.java @@ -1,7 +1,7 @@ package com.ultreon.devices.api.app.component; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.app.Component; import com.ultreon.devices.core.Laptop; import net.minecraft.client.Minecraft; @@ -33,16 +33,16 @@ public void handleTick() { } @Override - public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + public void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { if (this.visible) { - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.blendColor(1f, 1f, 1f, 1f); Color bgColor = new Color(getColorScheme().getBackgroundColor()).brighter().brighter(); float[] hsb = Color.RGBtoHSB(bgColor.getRed(), bgColor.getGreen(), bgColor.getBlue(), null); bgColor = new Color(Color.HSBtoRGB(hsb[0], hsb[1], 1f)); - RenderSystem.setShaderColor(bgColor.getRed() / 255f, bgColor.getGreen() / 255f, bgColor.getBlue() / 255f, 1f); - RenderSystem.setShaderTexture(0, Component.COMPONENTS_GUI); + RenderSystem.blendColor(bgColor.getRed() / 255f, bgColor.getGreen() / 255f, bgColor.getBlue() / 255f, 1f); + mc.textureManager.bind(Component.COMPONENTS_GUI); blit(pose, xPosition, yPosition, (currentProgress % 8) * 12, 12 + 12 * (int) Math.floor((double) currentProgress / 8), 12, 12); - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.blendColor(1f, 1f, 1f, 1f); } } } diff --git a/common/src/main/java/com/ultreon/devices/api/app/component/Text.java b/common/src/main/java/com/ultreon/devices/api/app/component/Text.java index b73d62bb3..3ce26d041 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/component/Text.java +++ b/common/src/main/java/com/ultreon/devices/api/app/component/Text.java @@ -1,13 +1,13 @@ package com.ultreon.devices.api.app.component; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.app.Component; import com.ultreon.devices.core.Laptop; import com.ultreon.devices.util.GuiHelper; -import net.minecraft.ChatFormatting; +import net.minecraft.util.text.TextFormatting; import net.minecraft.client.Minecraft; -import net.minecraft.network.chat.FormattedText; -import net.minecraft.network.chat.Style; +import net.minecraft.util.text.ITextProperties; +import net.minecraft.util.text.Style; import java.awt.*; import java.util.ArrayList; @@ -40,7 +40,7 @@ public Text(String text, int left, int top, int width) { } @Override - public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + public void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { // System.out.println(lines.size() + ", " + rawText + ", " + lines); if (this.visible) { for (int i = 0; i < lines.size(); i++) { @@ -65,7 +65,7 @@ public void setText(String text) { text = text.replace("\\n", "\n"); System.out.println(Laptop.getFont().plainSubstrByWidth(text, width - padding * 2)); var a = new ArrayList(); - Laptop.getFont().getSplitter().splitLines(FormattedText.of(text), width - padding * 2, Style.EMPTY).forEach(b -> a.add(b.getString())); + Laptop.getFont().getSplitter().splitLines(ITextProperties.of(text), width - padding * 2, Style.EMPTY).forEach(b -> a.add(b.getString())); this.lines = a; } @@ -128,7 +128,7 @@ private String getWord(String line, int index) { endIndex = Math.min(endIndex + 1, line.length()); - return ChatFormatting.stripFormatting(line.substring(startIndex, endIndex)); + return TextFormatting.stripFormatting(line.substring(startIndex, endIndex)); } public int getWidth() { diff --git a/common/src/main/java/com/ultreon/devices/api/app/component/TextArea.java b/common/src/main/java/com/ultreon/devices/api/app/component/TextArea.java index af82709d4..6092044b8 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/component/TextArea.java +++ b/common/src/main/java/com/ultreon/devices/api/app/component/TextArea.java @@ -2,7 +2,7 @@ import com.mojang.blaze3d.platform.InputConstants; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.app.Component; import com.ultreon.devices.api.app.interfaces.IHighlight; import com.ultreon.devices.api.app.listener.KeyListener; @@ -10,12 +10,12 @@ import com.ultreon.devices.core.Laptop; import com.ultreon.devices.util.GLHelper; import com.ultreon.devices.util.GuiHelper; -import net.minecraft.ChatFormatting; +import net.minecraft.util.text.TextFormatting; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.IngameGui; import net.minecraft.client.gui.screens.Screen; -import net.minecraft.util.Mth; +import net.minecraft.util.math.MathHelper; import javax.annotation.Nullable; import java.awt.*; @@ -37,7 +37,7 @@ public class TextArea extends Component { SPLIT_REGEX = String.format(UNFORMATTED_SPLIT, "(" + joiner + ")"); } - protected Font font; + protected FontRenderer font; protected String text = ""; protected String placeholder = null; @@ -94,13 +94,13 @@ public void handleTick() { } @Override - public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + public void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { if (this.visible) { - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.blendColor(1f, 1f, 1f, 1f); Color bgColor = new Color(color(backgroundColor, getColorScheme().getBackgroundColor())); - Gui.fill(pose, x, y, x + width, y + height, bgColor.darker().darker().getRGB()); - Gui.fill(pose, x + 1, y + 1, x + width - 1, y + height - 1, bgColor.getRGB()); + IngameGui.fill(pose, x, y, x + width, y + height, bgColor.darker().darker().getRGB()); + IngameGui.fill(pose, x + 1, y + 1, x + width - 1, y + height - 1, bgColor.getRGB()); if (!isFocused && placeholder != null && (lines.isEmpty() || (lines.size() == 1 && lines.get(0).isEmpty()))) { RenderSystem.enableBlend(); @@ -111,19 +111,19 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in for (int i = 0; i < visibleLines && i + verticalScroll < lines.size(); i++) { float scrollPercentage = (verticalScroll + verticalOffset) / (float) (lines.size() - visibleLines); float pixelsPerUnit = (float) maxLineWidth / (float) (width - padding * 2); - int scrollX = Mth.clamp(horizontalScroll + (int) (horizontalOffset * pixelsPerUnit), 0, Math.max(0, maxLineWidth - (width - padding * 2))); + int scrollX = MathHelper.clamp(horizontalScroll + (int) (horizontalOffset * pixelsPerUnit), 0, Math.max(0, maxLineWidth - (width - padding * 2))); int scrollY = (int) ((lines.size() - visibleLines) * (scrollPercentage)); - int lineY = i + Mth.clamp(scrollY, 0, Math.max(0, lines.size() - visibleLines)); + int lineY = i + MathHelper.clamp(scrollY, 0, Math.max(0, lines.size() - visibleLines)); if (highlight != null) { String[] words = lines.get(lineY).split(SPLIT_REGEX); StringBuilder builder = new StringBuilder(); for (String word : words) { - ChatFormatting[] formatting = highlight.getKeywordFormatting(word); - for (ChatFormatting format : formatting) { + TextFormatting[] formatting = highlight.getKeywordFormatting(word); + for (TextFormatting format : formatting) { builder.append(format); } builder.append(word); - builder.append(ChatFormatting.RESET); + builder.append(TextFormatting.RESET); } font.draw(pose, builder.toString(), x + padding - scrollX, y + padding + i * font.lineHeight, -1); } else { @@ -135,16 +135,16 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in GLHelper.pushScissor(x + padding, y + padding - 1, width - padding * 2 + 1, height - padding * 2 + 1); if (editable && isFocused) { float linesPerUnit = (float) lines.size() / (float) visibleLines; - int scroll = Mth.clamp(verticalScroll + verticalOffset * (int) linesPerUnit, 0, Math.max(0, lines.size() - visibleLines)); + int scroll = MathHelper.clamp(verticalScroll + verticalOffset * (int) linesPerUnit, 0, Math.max(0, lines.size() - visibleLines)); if (cursorY >= scroll && cursorY < scroll + visibleLines) { if ((this.cursorTick / 10) % 2 == 0) { String subString = getActiveLine().substring(0, cursorX); int visibleWidth = width - padding * 2; float pixelsPerUnit = (float) maxLineWidth / (float) (width - padding * 2); int stringWidth = font.width(subString); - int posX = x + padding + stringWidth - Mth.clamp(horizontalScroll + (int) (horizontalOffset * pixelsPerUnit), 0, Math.max(0, maxLineWidth - visibleWidth)); + int posX = x + padding + stringWidth - MathHelper.clamp(horizontalScroll + (int) (horizontalOffset * pixelsPerUnit), 0, Math.max(0, maxLineWidth - visibleWidth)); int posY = y + padding + (cursorY - scroll) * font.lineHeight; - Gui.fill(pose, posX, posY - 1, posX + 1, posY + font.lineHeight, Color.WHITE.getRGB()); + IngameGui.fill(pose, posX, posY - 1, posX + 1, posY + font.lineHeight, Color.WHITE.getRGB()); } } } @@ -154,10 +154,10 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in if (lines.size() > visibleLines) { int visibleScrollBarHeight = height - 4; int scrollBarHeight = Math.max(20, (int) ((float) visibleLines / (float) lines.size() * (float) visibleScrollBarHeight)); - float scrollPercentage = Mth.clamp((verticalScroll + verticalOffset) / (float) (lines.size() - visibleLines), 0f, 1f); + float scrollPercentage = MathHelper.clamp((verticalScroll + verticalOffset) / (float) (lines.size() - visibleLines), 0f, 1f); int scrollBarY = (int) ((visibleScrollBarHeight - scrollBarHeight) * scrollPercentage); int scrollY = yPosition + 2 + scrollBarY; - Gui.fill(pose, x + width - 2 - scrollBarSize, scrollY, x + width - 2, scrollY + scrollBarHeight, placeholderColor); + IngameGui.fill(pose, x + width - 2 - scrollBarSize, scrollY, x + width - 2, scrollY + scrollBarHeight, placeholderColor); } if (!wrapText && maxLineWidth >= width - padding * 2) { @@ -166,8 +166,8 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in float scrollPercentage = (float) (horizontalScroll + 1) / (float) (maxLineWidth - visibleWidth + 1); int scrollBarWidth = Math.max(20, (int) ((float) visibleWidth / (float) maxLineWidth * (float) visibleScrollBarWidth)); int relativeScrollX = (int) (scrollPercentage * (visibleScrollBarWidth - scrollBarWidth)); - int scrollX = xPosition + 2 + Mth.clamp(relativeScrollX + horizontalOffset, 0, visibleScrollBarWidth - scrollBarWidth); - Gui.fill(pose, scrollX, y + height - scrollBarSize - 2, scrollX + scrollBarWidth, y + height - 2, placeholderColor); + int scrollX = xPosition + 2 + MathHelper.clamp(relativeScrollX + horizontalOffset, 0, visibleScrollBarWidth - scrollBarWidth); + IngameGui.fill(pose, scrollX, y + height - scrollBarSize - 2, scrollX + scrollBarWidth, y + height - 2, placeholderColor); } } } @@ -198,7 +198,7 @@ public void handleMouseClick(int mouseX, int mouseY, int mouseButton) { cursorX = lines.get(Math.max(0, lines.size() - 1)).length(); cursorY = lines.size() - 1; } else { - cursorX = getClosestLineIndex(lineX, Mth.clamp(lineY, 0, lines.size() - 1)); + cursorX = getClosestLineIndex(lineX, MathHelper.clamp(lineY, 0, lines.size() - 1)); cursorY = lineY; } cursorTick = 0; @@ -227,10 +227,10 @@ protected void handleMouseRelease(int mouseX, int mouseY, int mouseButton) { switch (scrollBar) { case HORIZONTAL -> { float scrollPercentage = (float) maxLineWidth / (float) (width - padding * 2); - horizontalScroll = Mth.clamp(horizontalScroll + (int) (horizontalOffset * scrollPercentage), 0, maxLineWidth - (width - padding * 2)); + horizontalScroll = MathHelper.clamp(horizontalScroll + (int) (horizontalOffset * scrollPercentage), 0, maxLineWidth - (width - padding * 2)); } case VERTICAL -> { - float scrollPercentage = Mth.clamp((verticalScroll + verticalOffset) / (float) (lines.size() - visibleLines), 0f, 1f); + float scrollPercentage = MathHelper.clamp((verticalScroll + verticalOffset) / (float) (lines.size() - visibleLines), 0f, 1f); verticalScroll = (int) ((lines.size() - visibleLines) * (scrollPercentage)); } } @@ -270,13 +270,13 @@ public void handleKeyPressed(int keyCode, int scanCode, int modifiers) { } else { System.out.println("TextArea.handleKeyTypes: keyCode = " + keyCode); switch (keyCode) { - case InputConstants.KEY_BACKSPACE -> performBackspace(); // TODO: Make delete actually work - case InputConstants.KEY_RETURN -> performReturn(); - case InputConstants.KEY_TAB -> writeText('\t'); - case InputConstants.KEY_LEFT -> moveCursorLeft(1); - case InputConstants.KEY_RIGHT -> moveCursorRight(1); - case InputConstants.KEY_UP -> moveCursorUp(); - case InputConstants.KEY_DOWN -> moveCursorDown(); + case GLFW.GLFW_KEY_BACKSPACE -> performBackspace(); // TODO: Make delete actually work + case GLFW.GLFW_KEY_RETURN -> performReturn(); + case GLFW.GLFW_KEY_TAB -> writeText('\t'); + case GLFW.GLFW_KEY_LEFT -> moveCursorLeft(1); + case GLFW.GLFW_KEY_RIGHT -> moveCursorRight(1); + case GLFW.GLFW_KEY_UP -> moveCursorUp(); + case GLFW.GLFW_KEY_DOWN -> moveCursorDown(); } } updateScroll(); @@ -299,7 +299,7 @@ private ScrollBar isMouseInsideScrollBar(int mouseX, int mouseY) { int scrollBarHeight = Math.max(20, (int) ((float) visibleLines / (float) lines.size() * (float) visibleScrollBarHeight)); int relativeScrollY = (int) (scrollPercentage * (visibleScrollBarHeight - scrollBarHeight)); int posX = xPosition + width - 2 - scrollBarSize; - int posY = yPosition + 2 + Mth.clamp(relativeScrollY + verticalOffset, 0, visibleScrollBarHeight - scrollBarHeight); + int posY = yPosition + 2 + MathHelper.clamp(relativeScrollY + verticalOffset, 0, visibleScrollBarHeight - scrollBarHeight); if (GuiHelper.isMouseInside(mouseX, mouseY, posX, posY, posX + scrollBarSize, posY + scrollBarHeight)) { return ScrollBar.VERTICAL; } @@ -311,7 +311,7 @@ private ScrollBar isMouseInsideScrollBar(int mouseX, int mouseY) { float scrollPercentage = (float) horizontalScroll / (float) (maxLineWidth - visibleWidth + 1); int scrollBarWidth = Math.max(20, (int) ((float) visibleWidth / (float) maxLineWidth * (float) visibleScrollBarWidth)); int relativeScrollX = (int) (scrollPercentage * (visibleScrollBarWidth - scrollBarWidth)); - int posX = xPosition + 2 + Mth.clamp(relativeScrollX, 0, visibleScrollBarWidth - scrollBarWidth); + int posX = xPosition + 2 + MathHelper.clamp(relativeScrollX, 0, visibleScrollBarWidth - scrollBarWidth); int posY = yPosition + height - 2 - scrollBarSize; if (GuiHelper.isMouseInside(mouseX, mouseY, posX, posY, posX + scrollBarWidth, posY + scrollBarSize)) { return ScrollBar.HORIZONTAL; @@ -726,7 +726,7 @@ private void recalculateMaxWidth() { private int getClosestLineIndex(int lineX, int lineY) { String line = lines.get(lineY); int clickedCharX = font.plainSubstrByWidth(line, lineX).length(); - int nextCharX = Mth.clamp(clickedCharX + 1, 0, line.length()); + int nextCharX = MathHelper.clamp(clickedCharX + 1, 0, line.length()); int clickedCharWidth = font.width(line.substring(0, clickedCharX)); int nextCharWidth = font.width(line.substring(0, nextCharX)); int clickedDistanceX = Math.abs(clickedCharWidth - lineX); diff --git a/common/src/main/java/com/ultreon/devices/api/app/component/TextField.java b/common/src/main/java/com/ultreon/devices/api/app/component/TextField.java index dc52396dd..3de91f852 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/component/TextField.java +++ b/common/src/main/java/com/ultreon/devices/api/app/component/TextField.java @@ -1,11 +1,11 @@ package com.ultreon.devices.api.app.component; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.app.IIcon; import com.ultreon.devices.core.Laptop; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.IngameGui; import java.awt.*; @@ -26,12 +26,12 @@ public TextField(int left, int top, int width) { } @Override - public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + public void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { if (icon != null) { - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.blendColor(1f, 1f, 1f, 1f); Color bgColor = new Color(color(backgroundColor, getColorScheme().getBackgroundColor())); - Gui.fill(pose, x, y, x + 15, y + 16, bgColor.darker().darker().getRGB()); - Gui.fill(pose, x + 1, y + 1, x + 15, y + 15, bgColor.brighter().getRGB()); + IngameGui.fill(pose, x, y, x + 15, y + 16, bgColor.darker().darker().getRGB()); + IngameGui.fill(pose, x + 1, y + 1, x + 15, y + 15, bgColor.brighter().getRGB()); icon.draw(pose, mc, x + 3, y + 3); } super.render(pose, laptop, mc, x + (icon != null ? 15 : 0), y, mouseX, mouseY, windowActive, partialTicks); diff --git a/common/src/main/java/com/ultreon/devices/api/app/interfaces/IHighlight.java b/common/src/main/java/com/ultreon/devices/api/app/interfaces/IHighlight.java index b733bff0f..f3e6f035d 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/interfaces/IHighlight.java +++ b/common/src/main/java/com/ultreon/devices/api/app/interfaces/IHighlight.java @@ -1,10 +1,10 @@ package com.ultreon.devices.api.app.interfaces; -import net.minecraft.ChatFormatting; +import net.minecraft.util.text.TextFormatting; /** * @author MrCrayfish */ public interface IHighlight { - ChatFormatting[] getKeywordFormatting(String text); + TextFormatting[] getKeywordFormatting(String text); } diff --git a/common/src/main/java/com/ultreon/devices/api/app/renderer/ItemRenderer.java b/common/src/main/java/com/ultreon/devices/api/app/renderer/ItemRenderer.java index a4a3012e6..536cdf634 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/renderer/ItemRenderer.java +++ b/common/src/main/java/com/ultreon/devices/api/app/renderer/ItemRenderer.java @@ -1,12 +1,12 @@ package com.ultreon.devices.api.app.renderer; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.AbstractGui; /** * @author MrCrayfish */ public abstract class ItemRenderer { - public abstract void render(PoseStack pose, E e, GuiComponent gui, Minecraft mc, int x, int y, int width, int height); + public abstract void render(MatrixStack pose, E e, AbstractGui gui, Minecraft mc, int x, int y, int width, int height); } diff --git a/common/src/main/java/com/ultreon/devices/api/app/renderer/ListItemRenderer.java b/common/src/main/java/com/ultreon/devices/api/app/renderer/ListItemRenderer.java index b98f632a7..1fd9e6938 100644 --- a/common/src/main/java/com/ultreon/devices/api/app/renderer/ListItemRenderer.java +++ b/common/src/main/java/com/ultreon/devices/api/app/renderer/ListItemRenderer.java @@ -1,8 +1,8 @@ package com.ultreon.devices.api.app.renderer; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.AbstractGui; public abstract class ListItemRenderer { private final int height; @@ -15,5 +15,5 @@ public final int getHeight() { return height; } - public abstract void render(PoseStack pose, E e, GuiComponent gui, Minecraft mc, int x, int y, int width, int height, boolean selected); + public abstract void render(MatrixStack pose, E e, AbstractGui gui, Minecraft mc, int x, int y, int width, int height, boolean selected); } diff --git a/common/src/main/java/com/ultreon/devices/api/event/LaptopEvent.java b/common/src/main/java/com/ultreon/devices/api/event/LaptopEvent.java index ead5ad636..dd33747ff 100644 --- a/common/src/main/java/com/ultreon/devices/api/event/LaptopEvent.java +++ b/common/src/main/java/com/ultreon/devices/api/event/LaptopEvent.java @@ -2,8 +2,6 @@ import com.ultreon.devices.api.TrayItemAdder; import com.ultreon.devices.core.Laptop; -import dev.architectury.event.Event; -import dev.architectury.event.EventFactory; public interface LaptopEvent { Event SETUP_TRAY_ITEMS = EventFactory.createLoop(); diff --git a/common/src/main/java/com/ultreon/devices/api/io/Drive.java b/common/src/main/java/com/ultreon/devices/api/io/Drive.java index 857229d52..8a0a4cce1 100644 --- a/common/src/main/java/com/ultreon/devices/api/io/Drive.java +++ b/common/src/main/java/com/ultreon/devices/api/io/Drive.java @@ -1,7 +1,7 @@ package com.ultreon.devices.api.io; import com.ultreon.devices.core.io.FileSystem; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.CompoundNBT; import org.jetbrains.annotations.Nullable; import java.util.UUID; @@ -15,7 +15,7 @@ public class Drive { private boolean synced = false; - public Drive(CompoundTag driveTag) { + public Drive(CompoundNBT driveTag) { this.name = driveTag.getString("name"); this.uuid = UUID.fromString(driveTag.getString("uuid")); this.type = Type.fromString(driveTag.getString("type")); diff --git a/common/src/main/java/com/ultreon/devices/api/io/File.java b/common/src/main/java/com/ultreon/devices/api/io/File.java index 50ce37433..96d62f490 100644 --- a/common/src/main/java/com/ultreon/devices/api/io/File.java +++ b/common/src/main/java/com/ultreon/devices/api/io/File.java @@ -5,7 +5,7 @@ import com.ultreon.devices.core.io.FileSystem; import com.ultreon.devices.core.io.action.FileAction; import com.ultreon.devices.programs.system.component.FileBrowser; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.CompoundNBT; import javax.annotation.Nullable; import java.util.Comparator; @@ -26,7 +26,7 @@ public class File { protected Folder parent; protected String name; protected String openingApp; - protected CompoundTag data; + protected CompoundNBT data; protected boolean protect = false; protected boolean valid = false; @@ -41,7 +41,7 @@ protected File() { * @param app the application that is opening the file * @param data the data of the file */ - public File(String name, Application app, CompoundTag data) { + public File(String name, Application app, CompoundNBT data) { this(name, app.getInfo().getFormattedId(), data, false); } @@ -54,11 +54,11 @@ public File(String name, Application app, CompoundTag data) { * @param openingAppId the application identifier of the application that is opening the file * @param data the data of the file */ - public File(String name, String openingAppId, CompoundTag data) { + public File(String name, String openingAppId, CompoundNBT data) { this(name, openingAppId, data, false); } - private File(String name, String openingAppId, CompoundTag data, boolean protect) { + private File(String name, String openingAppId, CompoundNBT data, boolean protect) { this.name = name; this.openingApp = openingAppId; this.data = data; @@ -180,7 +180,7 @@ public String getOpeningApp() { * * @param data the data for the file */ - public void setData(CompoundTag data) { + public void setData(CompoundNBT data) { setData(data, null); } @@ -192,7 +192,7 @@ public void setData(CompoundTag data) { * @param data the data for the file * @param callback the callback to be fired when the data is set */ - public void setData(CompoundTag data, @Nullable Callback callback) { + public void setData(CompoundNBT data, @Nullable Callback callback) { if (!valid) throw new IllegalStateException("File must be added to the system before you can rename it"); @@ -222,12 +222,12 @@ public void setData(CompoundTag data, @Nullable Callback ca /** * Gets the data of this file. The data you receive is a copied version. If you want to update - * it, use {@link #setData(CompoundTag, Callback)} to do so. + * it, use {@link #setData(CompoundNBT, Callback)} to do so. * * @return the file's data */ @Nullable - public CompoundTag getData() { + public CompoundNBT getData() { return data.copy(); } @@ -440,8 +440,8 @@ public void moveTo(Folder destination, boolean override, @Nullable Callback callback) { + public void setData(@Nonnull CompoundNBT data, Callback callback) { if (callback != null) { callback.execute(FileSystem.createResponse(FileSystem.Status.FAILED, "Can not set data of a folder"), false); } @@ -438,10 +438,10 @@ void setDrive(Drive drive) { * * @param list the tag list to read from */ - public void syncFiles(ListTag list) { + public void syncFiles(ListNBT list) { files.removeIf(f -> !f.isFolder()); for (int i = 0; i < list.size(); i++) { - CompoundTag fileTag = list.getCompound(i); + CompoundNBT fileTag = list.getCompound(i); File file = File.fromTag(fileTag.getString("file_name"), fileTag.getCompound("data")); file.drive = drive; file.valid = true; @@ -465,8 +465,8 @@ public void sync(@Nullable Callback callback) { Task task = new TaskGetFiles(this, pos); task.setCallback((tag, success) -> { - if (success && Objects.requireNonNull(tag).contains("files", Tag.TAG_LIST)) { - ListTag files = tag.getList("files", Tag.TAG_COMPOUND); + if (success && Objects.requireNonNull(tag).contains("files", Constants.NBT.TAG_LIST)) { + ListNBT files = tag.getList("files", Constants.NBT.TAG_COMPOUND); syncFiles(files); if (callback != null) { callback.execute(this, true); @@ -517,10 +517,10 @@ public void validate() { * @return the folder tag */ @Override - public CompoundTag toTag() { - CompoundTag folderTag = new CompoundTag(); + public CompoundNBT toTag() { + CompoundNBT folderTag = new CompoundNBT(); - CompoundTag fileList = new CompoundTag(); + CompoundNBT fileList = new CompoundNBT(); files.forEach(file -> fileList.put(file.getName(), file.toTag())); folderTag.put("files", fileList); diff --git a/common/src/main/java/com/ultreon/devices/api/io/MimeType.java b/common/src/main/java/com/ultreon/devices/api/io/MimeType.java index c5371eae8..c871ad614 100644 --- a/common/src/main/java/com/ultreon/devices/api/io/MimeType.java +++ b/common/src/main/java/com/ultreon/devices/api/io/MimeType.java @@ -1,6 +1,6 @@ package com.ultreon.devices.api.io; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.CompoundNBT; public record MimeType(String type, String subType) { public static final MimeType TEXT_PLAIN = new MimeType("text", "plain"); @@ -10,12 +10,12 @@ public record MimeType(String type, String subType) { public static final MimeType TEXT_NOTE_STASH = new MimeType("text", "note-stash"); public static final MimeType IMAGE_MC_IMG = new MimeType("image", "mc-img"); - public static MimeType of(CompoundTag mimeType) { + public static MimeType of(CompoundNBT mimeType) { return new MimeType(mimeType.getString("type"), mimeType.getString("subType")); } - public CompoundTag toNbt() { - CompoundTag mimeType = new CompoundTag(); + public CompoundNBT toNbt() { + CompoundNBT mimeType = new CompoundNBT(); mimeType.putString("type", type); mimeType.putString("subType", subType); return mimeType; diff --git a/common/src/main/java/com/ultreon/devices/api/print/IPrint.java b/common/src/main/java/com/ultreon/devices/api/print/IPrint.java index eb977be46..36b11cfa2 100644 --- a/common/src/main/java/com/ultreon/devices/api/print/IPrint.java +++ b/common/src/main/java/com/ultreon/devices/api/print/IPrint.java @@ -1,12 +1,12 @@ package com.ultreon.devices.api.print; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.init.DeviceBlocks; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.world.item.ItemStack; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.item.ItemStack; import javax.annotation.Nullable; @@ -16,15 +16,15 @@ * @author MrCrayfish */ public interface IPrint { - static CompoundTag save(IPrint print) { - CompoundTag tag = new CompoundTag(); + static CompoundNBT save(IPrint print) { + CompoundNBT tag = new CompoundNBT(); tag.putString("type", PrintingManager.getPrintIdentifier(print)); tag.put("data", print.toTag()); return tag; } @Nullable - static IPrint load(CompoundTag tag) { + static IPrint load(CompoundNBT tag) { IPrint print = PrintingManager.getPrint(tag.getString("type")); if (print != null) { print.fromTag(tag.getCompound("data")); @@ -34,17 +34,17 @@ static IPrint load(CompoundTag tag) { } static ItemStack generateItem(IPrint print) { - CompoundTag blockEntityTag = new CompoundTag(); + CompoundNBT blockEntityTag = new CompoundNBT(); blockEntityTag.put("print", save(print)); - CompoundTag itemTag = new CompoundTag(); + CompoundNBT itemTag = new CompoundNBT(); itemTag.put("BlockEntityTag", blockEntityTag); ItemStack stack = new ItemStack(DeviceBlocks.PAPER.get()); stack.setTag(itemTag); if (print.getName() != null && !print.getName().isEmpty()) { - stack.setHoverName(new TextComponent(print.getName())); + stack.setHoverName(new StringTextComponent(print.getName())); } return stack; } @@ -70,14 +70,14 @@ static ItemStack generateItem(IPrint print) { * * @return nbt form of print */ - CompoundTag toTag(); + CompoundNBT toTag(); - void fromTag(CompoundTag tag); + void fromTag(CompoundNBT tag); - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) Class getRenderer(); interface Renderer { - boolean render(PoseStack pose, CompoundTag data); + boolean render(MatrixStack pose, CompoundNBT data); } } diff --git a/common/src/main/java/com/ultreon/devices/api/print/PrintingManager.java b/common/src/main/java/com/ultreon/devices/api/print/PrintingManager.java index f0407e7f5..bc98bfa9a 100644 --- a/common/src/main/java/com/ultreon/devices/api/print/PrintingManager.java +++ b/common/src/main/java/com/ultreon/devices/api/print/PrintingManager.java @@ -3,9 +3,9 @@ import com.google.common.collect.HashBiMap; import com.ultreon.devices.Devices; import dev.architectury.injectables.annotations.PlatformOnly; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.util.ResourceLocation; import javax.annotation.Nullable; import java.lang.reflect.InvocationTargetException; @@ -17,7 +17,7 @@ public class PrintingManager { private static final HashBiMap> registeredPrints = HashBiMap.create(); - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) private static Map registeredRenders; @PlatformOnly("fabric") public static Map getRegisteredRenders() { @@ -61,13 +61,13 @@ public static IPrint getPrint(String identifier) { return null; } - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) public static IPrint.Renderer getRenderer(IPrint print) { String id = getPrintIdentifier(print); return registeredRenders.get(id); } - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) public static IPrint.Renderer getRenderer(String identifier) { return registeredRenders.get(identifier); } diff --git a/common/src/main/java/com/ultreon/devices/api/task/Task.java b/common/src/main/java/com/ultreon/devices/api/task/Task.java index a439b0d55..21b5e0c02 100644 --- a/common/src/main/java/com/ultreon/devices/api/task/Task.java +++ b/common/src/main/java/com/ultreon/devices/api/task/Task.java @@ -1,9 +1,9 @@ package com.ultreon.devices.api.task; import com.ultreon.devices.core.task.TaskInstallApp; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; /** *

A Task is simple implementation that allows you to make calls to the @@ -11,8 +11,8 @@ * client-server like applications, e.g. Emails, Instant Messaging, etc

* *

Any global variables that are initialized in this class, wont be on the server side. - * To initialize them, first store the data in the NBT tag provided in {@link #prepareRequest(CompoundTag)}, - * then once your Task gets to the server, use {@link #processRequest(CompoundTag, Level, Player)} to + * To initialize them, first store the data in the NBT tag provided in {@link #prepareRequest(CompoundNBT)}, + * then once your Task gets to the server, use {@link #processRequest(CompoundNBT, World, Player)} to * get the data from the NBT tag parameter. Initialize the variables as normal. * *

Please check out the example applications to get a better understanding @@ -22,7 +22,7 @@ */ public abstract class Task { private final String name; - private Callback callback = null; + private Callback callback = null; private boolean success = false; public Task(String name) { @@ -36,7 +36,7 @@ public Task(String name) { * @param callback the callback instance for response processing * @return this Task instance */ - public final Task setCallback(Callback callback) { + public final Task setCallback(Callback callback) { this.callback = callback; return this; } @@ -46,7 +46,7 @@ public final Task setCallback(Callback callback) { * * @param tag the response data */ - public final void callback(CompoundTag tag) { + public final void callback(CompoundNBT tag) { if (callback != null) { callback.execute(tag, success); } @@ -55,7 +55,7 @@ public final void callback(CompoundTag tag) { /** * Sets that this Task was successful. Should be called * if your Task produced the correct results, preferably in - * {@link #processRequest(CompoundTag, Level, Player)} + * {@link #processRequest(CompoundNBT, World, Player)} */ public final void setSuccessful() { if (this instanceof TaskInstallApp) System.out.println("Setting successful..."); @@ -94,16 +94,16 @@ public final String getName() { * * @param tag The NBT to be sent to the server */ - public abstract void prepareRequest(CompoundTag tag); + public abstract void prepareRequest(CompoundNBT tag); /** * Called when the request arrives to the server. Here you can perform actions - * with your request. Data attached to the NBT from {@link Task#prepareRequest(CompoundTag tag)} + * with your request. Data attached to the NBT from {@link Task#prepareRequest(CompoundNBT tag)} * can be accessed from the NBT tag parameter. * * @param tag The NBT Tag received from the client */ - public abstract void processRequest(CompoundTag tag, Level level, Player player); + public abstract void processRequest(CompoundNBT tag, World level, PlayerEntity player); /** * Called before the response is sent back to the client. @@ -111,7 +111,7 @@ public final String getName() { * * @param tag The NBT to be sent back to the client */ - public abstract void prepareResponse(CompoundTag tag); + public abstract void prepareResponse(CompoundNBT tag); /** * Called when the response arrives to the client. Here you can update data @@ -120,5 +120,5 @@ public final String getName() { * * @param tag The NBT Tag received from the server */ - public abstract void processResponse(CompoundTag tag); + public abstract void processResponse(CompoundNBT tag); } diff --git a/common/src/main/java/com/ultreon/devices/api/utils/BankUtil.java b/common/src/main/java/com/ultreon/devices/api/utils/BankUtil.java index 24cc06eed..1a1d228ca 100644 --- a/common/src/main/java/com/ultreon/devices/api/utils/BankUtil.java +++ b/common/src/main/java/com/ultreon/devices/api/utils/BankUtil.java @@ -8,9 +8,9 @@ import com.ultreon.devices.programs.system.task.TaskGetBalance; import com.ultreon.devices.programs.system.task.TaskPay; import com.ultreon.devices.programs.system.task.TaskRemove; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.world.entity.player.Player; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.ListNBT; +import net.minecraft.entity.player.PlayerEntity; import java.util.HashMap; import java.util.Map; @@ -42,7 +42,7 @@ private BankUtil() { * * @param callback he callback object to processing the response */ - public static void getBalance(Callback callback) { + public static void getBalance(Callback callback) { TaskManager.sendTask(new TaskGetBalance().setCallback(callback)); } @@ -55,7 +55,7 @@ public static void getBalance(Callback callback) { * @param amount the amount to pay * @param callback the callback object to processing the response */ - public static void pay(String uuid, int amount, Callback callback) { + public static void pay(String uuid, int amount, Callback callback) { TaskManager.sendTask(new TaskPay().setCallback(callback)); } @@ -66,7 +66,7 @@ public static void pay(String uuid, int amount, Callback callback) * * @param callback he callback object to processing the response */ - public static void add(int amount, Callback callback) { + public static void add(int amount, Callback callback) { TaskManager.sendTask(new TaskAdd(amount).setCallback(callback)); } @@ -77,13 +77,13 @@ public static void add(int amount, Callback callback) { * * @param callback he callback object to processing the response */ - public static void remove(int amount, Callback callback) { + public static void remove(int amount, Callback callback) { TaskManager.sendTask(new TaskRemove(amount).setCallback(callback)); } //TODO: Make private. Only the bank application should have access to these. - public Account getAccount(Player player) { + public Account getAccount(PlayerEntity player) { if (!uuidToAccount.containsKey(player.getUUID())) { uuidToAccount.put(player.getUUID(), new Account(0)); } @@ -94,10 +94,10 @@ public Account getAccount(UUID uuid) { return uuidToAccount.get(uuid); } - public void save(CompoundTag tag) { - ListTag accountList = new ListTag(); + public void save(CompoundNBT tag) { + ListNBT accountList = new ListNBT(); for (UUID uuid : uuidToAccount.keySet()) { - CompoundTag accountTag = new CompoundTag(); + CompoundNBT accountTag = new CompoundNBT(); Account account = uuidToAccount.get(uuid); accountTag.putString("uuid", uuid.toString()); accountTag.putInt("balance", account.getBalance()); @@ -106,10 +106,10 @@ public void save(CompoundTag tag) { tag.put("accounts", accountList); } - public void load(CompoundTag tag) { - ListTag accountList = (ListTag) tag.get("accounts"); + public void load(CompoundNBT tag) { + ListNBT accountList = (ListNBT) tag.get("accounts"); for (int i = 0; i < accountList.size(); i++) { - CompoundTag accountTag = accountList.getCompound(i); + CompoundNBT accountTag = accountList.getCompound(i); UUID uuid = UUID.fromString(accountTag.getString("uuid")); Account account = new Account(accountTag.getInt("balance")); uuidToAccount.put(uuid, account); diff --git a/common/src/main/java/com/ultreon/devices/api/utils/RenderUtil.java b/common/src/main/java/com/ultreon/devices/api/utils/RenderUtil.java index 69dca3745..7e68368b0 100644 --- a/common/src/main/java/com/ultreon/devices/api/utils/RenderUtil.java +++ b/common/src/main/java/com/ultreon/devices/api/utils/RenderUtil.java @@ -1,16 +1,16 @@ package com.ultreon.devices.api.utils; -import com.mojang.blaze3d.platform.Lighting; +import net.minecraft.client.renderer.RenderHelper; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.*; +import com.mojang.blaze3d.matrix.*; import com.ultreon.devices.api.app.component.Image; import com.ultreon.devices.core.Laptop; import com.ultreon.devices.object.AppInfo; -import net.minecraft.ChatFormatting; +import net.minecraft.util.text.TextFormatting; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.renderer.GameRenderer; -import net.minecraft.world.item.ItemStack; +import net.minecraft.item.ItemStack; import javax.annotation.Nullable; import java.awt.*; @@ -21,7 +21,7 @@ public static void renderItem(int x, int y, ItemStack stack, boolean overlay) { RenderSystem.disableDepthTest(); // Todo - Port to 1.18.2 if possible // RenderSystem.enableLighting(); - Lighting.setupForFlatItems(); + RenderHelper.setupForFlatItems(); //RenderSystem.setShader(); Minecraft.getInstance().getItemRenderer().renderAndDecorateItem(stack, x, y); if (overlay) @@ -32,7 +32,7 @@ public static void renderItem(int x, int y, ItemStack stack, boolean overlay) { //Lighting.setupForFlatItems(); } - public static void drawIcon(PoseStack pose, double x, double y, AppInfo info, int width, int height) { + public static void drawIcon(MatrixStack pose, double x, double y, AppInfo info, int width, int height) { //Gui.blit(pose, (int) x, (int) y, width, height, u, v, sourceWidth, sourceHeight, (int) textureWidth, (int) textureHeight); if (info == null) { drawRectWithTexture(pose, x, y, 0, 0, width, height, 14, 14, 224, 224); @@ -44,14 +44,14 @@ public static void drawIcon(PoseStack pose, double x, double y, AppInfo info, in if (glyph.getU() == -1 || glyph.getV() == -1) continue; var col = new Color(info.getTint(glyph.getType())); int[] tint = new int[]{col.getRed(), col.getGreen(), col.getBlue()}; - RenderSystem.setShaderColor(tint[0]/255f, tint[1]/255f, tint[2]/255f, 1f); + RenderSystem.blendColor(tint[0]/255f, tint[1]/255f, tint[2]/255f, 1f); drawRectWithTexture(pose, x, y, glyph.getU(), glyph.getV(), width, height, 14, 14, 224, 224); //image.init(layout); } - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.blendColor(1f, 1f, 1f, 1f); } - public static void drawRectWithTexture(PoseStack pose, double x, double y, float u, float v, int width, int height, float textureWidth, float textureHeight) { + public static void drawRectWithTexture(MatrixStack pose, double x, double y, float u, float v, int width, int height, float textureWidth, float textureHeight) { drawRectWithTexture(pose, x, y, 0, u, v, width, height, textureWidth, textureHeight); // Gui.blit(pose, (int) x, (int) y, width, height, u, v, width, height, (int) textureWidth, (int) textureHeight); } @@ -70,16 +70,16 @@ public static void drawRectWithTexture(PoseStack pose, double x, double y, float * @param textureWidth the width of the texture * @param textureHeight the height of the texture */ - public static void drawRectWithTexture(PoseStack pose, double x, double y, double z, float u, float v, int width, int height, float textureWidth, float textureHeight) { + public static void drawRectWithTexture(MatrixStack pose, double x, double y, double z, float u, float v, int width, int height, float textureWidth, float textureHeight) { //Gui.blit(pose, (int) x, (int) y, width, height, u, v, width, height, (int) textureWidth, (int) textureHeight); float scale = 0.00390625f; RenderSystem.setShader(GameRenderer::getPositionTexShader); - BufferBuilder buffer = Tesselator.getInstance().getBuilder(); + BufferBuilder buffer = Tessellator.getInstance().getBuilder(); try { - buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX); + buffer.begin(GL20.GL_QUADS, DefaultVertexFormats.POSITION_TEX); } catch (IllegalStateException e) { buffer.end(); - buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX); + buffer.begin(GL20.GL_QUADS, DefaultVertexFormats.POSITION_TEX); } buffer.vertex(x, y + height, z).uv(u * scale, (v + textureHeight) * scale).endVertex(); buffer.vertex(x + width, y + height, z).uv((u + textureWidth) * scale, (v + textureHeight) * scale).endVertex(); @@ -89,11 +89,11 @@ public static void drawRectWithTexture(PoseStack pose, double x, double y, doubl BufferUploader.end(buffer); } - public static void drawRectWithFullTexture(PoseStack pose, double x, double y, float u, float v, int width, int height) { + public static void drawRectWithFullTexture(MatrixStack pose, double x, double y, float u, float v, int width, int height) { // Gui.blit(pose, (int) x, (int) y, width, height, u, v, width, height, 256, 256); RenderSystem.setShader(GameRenderer::getPositionTexShader); - BufferBuilder buffer = Tesselator.getInstance().getBuilder(); - buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX); + BufferBuilder buffer = Tessellator.getInstance().getBuilder(); + buffer.begin(GL20.GL_QUADS, DefaultVertexFormats.POSITION_TEX); buffer.vertex(x, y + height, 0).uv(0, 1).endVertex(); buffer.vertex(x + width, y + height, 0).uv(1, 1).endVertex(); buffer.vertex(x + width, y, 0).uv(1, 0).endVertex(); @@ -102,13 +102,13 @@ public static void drawRectWithFullTexture(PoseStack pose, double x, double y, f BufferUploader.end(buffer); } - public static void drawRectWithTexture(PoseStack pose, double x, double y, float u, float v, int width, int height, float textureWidth, float textureHeight, int sourceWidth, int sourceHeight) { + public static void drawRectWithTexture(MatrixStack pose, double x, double y, float u, float v, int width, int height, float textureWidth, float textureHeight, int sourceWidth, int sourceHeight) { //Gui.blit(pose, (int) x, (int) y, width, height, u, v, sourceWidth, sourceHeight, (int) textureWidth, (int) textureHeight); float scaleWidth = 1f / sourceWidth; float scaleHeight = 1f / sourceHeight; RenderSystem.setShader(GameRenderer::getPositionTexShader); - BufferBuilder buffer = Tesselator.getInstance().getBuilder(); - buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX); + BufferBuilder buffer = Tessellator.getInstance().getBuilder(); + buffer.begin(GL20.GL_QUADS, DefaultVertexFormats.POSITION_TEX); buffer.vertex(x, y + height, 0).uv(u * scaleWidth, (v + textureHeight) * scaleHeight).endVertex(); buffer.vertex(x + width, y + height, 0).uv((u + textureWidth) * scaleWidth, (v + textureHeight) * scaleHeight).endVertex(); buffer.vertex(x + width, y, 0).uv((u + textureWidth) * scaleWidth, v * scaleHeight).endVertex(); @@ -117,9 +117,9 @@ public static void drawRectWithTexture(PoseStack pose, double x, double y, float BufferUploader.end(buffer); } - public static void drawApplicationIcon(PoseStack pose, @Nullable AppInfo info, double x, double y) { + public static void drawApplicationIcon(MatrixStack pose, @Nullable AppInfo info, double x, double y) { //TODO: Reset color GlStateManager.color(1f, 1f, 1f); - RenderSystem.setShaderTexture(0, Laptop.ICON_TEXTURES); + mc.textureManager.bind(Laptop.ICON_TEXTURES); if (info != null) { drawIcon(pose, x, y, info, 14, 14); // drawRectWithTexture(pose, x, y, info.getIconU(), info.getIconV(), 14, 14, 14, 14, 224, 224); @@ -128,13 +128,13 @@ public static void drawApplicationIcon(PoseStack pose, @Nullable AppInfo info, d } } - public static void drawStringClipped(PoseStack pose, String text, int x, int y, int width, int color, boolean shadow) { - if (shadow) Laptop.getFont().drawShadow(pose, clipStringToWidth(text, width) + ChatFormatting.RESET, x, y, color); - else Laptop.getFont().draw(pose, Laptop.getFont().plainSubstrByWidth(text, width) + ChatFormatting.RESET, x, y, color); + public static void drawStringClipped(MatrixStack pose, String text, int x, int y, int width, int color, boolean shadow) { + if (shadow) Laptop.getFont().drawShadow(pose, clipStringToWidth(text, width) + TextFormatting.RESET, x, y, color); + else Laptop.getFont().draw(pose, Laptop.getFont().plainSubstrByWidth(text, width) + TextFormatting.RESET, x, y, color); } public static String clipStringToWidth(String text, int width) { - Font fontRenderer = Laptop.getFont(); + FontRenderer fontRenderer = Laptop.getFont(); String clipped = text; if (fontRenderer.width(clipped) > width) { clipped = fontRenderer.plainSubstrByWidth(clipped, width - 8) + "..."; diff --git a/common/src/main/java/com/ultreon/devices/block/DeviceBlock.java b/common/src/main/java/com/ultreon/devices/block/DeviceBlock.java index 2c2a0a50b..325ce0141 100644 --- a/common/src/main/java/com/ultreon/devices/block/DeviceBlock.java +++ b/common/src/main/java/com/ultreon/devices/block/DeviceBlock.java @@ -5,35 +5,34 @@ import com.ultreon.devices.block.entity.DeviceBlockEntity; import com.ultreon.devices.util.BlockEntityUtil; import com.ultreon.devices.util.Colorable; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.item.DyeColor; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.LevelAccessor; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.EntityBlock; -import net.minecraft.world.level.block.HorizontalDirectionalBlock; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.entity.BlockEntityTicker; -import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.Shapes; -import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.item.ItemEntity; +import net.minecraft.item.DyeColor; +import net.minecraft.item.ItemStack; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; +import net.minecraft.world.IWorld; +import net.minecraft.block.Block; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.HorizontalBlock; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityType; +import net.minecraft.block.BlockState; +import net.minecraft.state.StateContainer; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.util.math.shapes.VoxelShapes; +import net.minecraft.util.math.shapes.VoxelShape; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Objects; @SuppressWarnings("deprecation") -public abstract class DeviceBlock extends HorizontalDirectionalBlock implements EntityBlock, IDeviceType { +public abstract class DeviceBlock extends HorizontalBlock implements ITileEntityProvider, IDeviceType { private final ModDeviceTypes deviceType; public DeviceBlock(Properties properties, ModDeviceTypes deviceType) { @@ -48,22 +47,22 @@ public DeviceBlock(Properties properties, ModDeviceTypes deviceType) { @NotNull @Override - public VoxelShape getShape(@NotNull BlockState pState, @NotNull BlockGetter pLevel, @NotNull BlockPos pPos, @NotNull CollisionContext pContext) { - return Shapes.empty(); + public VoxelShape getShape(@NotNull BlockState pState, @NotNull IBlockReader pLevel, @NotNull BlockPos pPos, @NotNull ISelectionContext pContext) { + return VoxelShapes.empty(); } @Nullable @Override - public BlockState getStateForPlacement(@NotNull BlockPlaceContext pContext) { + public BlockState getStateForPlacement(@NotNull BlockItemUseContext pContext) { BlockState state = super.getStateForPlacement(pContext); return state != null ? state.setValue(FACING, Objects.requireNonNull(pContext.getPlayer(), "Player in block placement context is null.").getDirection().getOpposite()) : null; } @Override - public void setPlacedBy(@NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState state, @Nullable LivingEntity placer, @NotNull ItemStack stack) { + public void setPlacedBy(@NotNull World level, @NotNull BlockPos pos, @NotNull BlockState state, @Nullable LivingEntity placer, @NotNull ItemStack stack) { super.setPlacedBy(level, pos, state, placer, stack); - BlockEntity blockEntity = level.getBlockEntity(pos); + TileEntity blockEntity = level.getBlockEntity(pos); if (blockEntity instanceof DeviceBlockEntity deviceBlockEntity) { if (stack.hasCustomHoverName()) { deviceBlockEntity.setCustomName(stack.getHoverName().getString()); @@ -73,17 +72,17 @@ public void setPlacedBy(@NotNull Level level, @NotNull BlockPos pos, @NotNull Bl @Override - public void destroy(LevelAccessor level, BlockPos pos, BlockState state) { + public void destroy(IWorld level, BlockPos pos, BlockState state) { if (!level.isClientSide()) { - BlockEntity blockEntity = level.getBlockEntity(pos); + TileEntity blockEntity = level.getBlockEntity(pos); if (blockEntity instanceof DeviceBlockEntity device) { - CompoundTag blockEntityTag = new CompoundTag(); + CompoundNBT blockEntityTag = new CompoundNBT(); blockEntity.saveWithoutMetadata(); blockEntityTag.remove("id"); removeTagsForDrop(blockEntityTag); - CompoundTag tag = new CompoundTag(); + CompoundNBT tag = new CompoundNBT(); tag.put("BlockEntityTag", blockEntityTag); ItemStack drop; @@ -95,10 +94,10 @@ public void destroy(LevelAccessor level, BlockPos pos, BlockState state) { drop.setTag(tag); if (device.hasCustomName()) { - drop.setHoverName(new TextComponent(device.getCustomName())); + drop.setHoverName(new StringTextComponent(device.getCustomName())); } - level.addFreshEntity(new ItemEntity((Level) level, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, drop)); + level.addFreshEntity(new ItemEntity((World) level, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, drop)); level.removeBlock(pos, false); return; @@ -107,23 +106,23 @@ public void destroy(LevelAccessor level, BlockPos pos, BlockState state) { super.destroy(level, pos, state); } - protected void removeTagsForDrop(CompoundTag blockEntityTag) { + protected void removeTagsForDrop(CompoundNBT blockEntityTag) { } @Nullable @Override - public abstract BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state); + public abstract TileEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state); @Nullable @Override - public BlockEntityTicker getTicker(@NotNull Level level, @NotNull BlockState state, @NotNull BlockEntityType blockEntityType) { + public BlockEntityTicker getTicker(@NotNull World level, @NotNull BlockState state, @NotNull TileEntityType blockEntityType) { return BlockEntityUtil.getTicker(); } @Override - public boolean triggerEvent(@NotNull BlockState state, Level level, @NotNull BlockPos pos, int id, int param) { - BlockEntity blockEntity = level.getBlockEntity(pos); + public boolean triggerEvent(@NotNull BlockState state, World level, @NotNull BlockPos pos, int id, int param) { + TileEntity blockEntity = level.getBlockEntity(pos); return blockEntity != null && blockEntity.triggerEvent(id, param); } @@ -145,9 +144,9 @@ public DyeColor getColor() { } @Override - public void setPlacedBy(@NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState state, @Nullable LivingEntity placer, @NotNull ItemStack stack) { + public void setPlacedBy(@NotNull World level, @NotNull BlockPos pos, @NotNull BlockState state, @Nullable LivingEntity placer, @NotNull ItemStack stack) { super.setPlacedBy(level, pos, state, placer, stack); - BlockEntity blockEntity = level.getBlockEntity(pos); + TileEntity blockEntity = level.getBlockEntity(pos); if (blockEntity instanceof Colorable colored) { colored.setColor(color); } @@ -157,7 +156,7 @@ public void setPlacedBy(@NotNull Level level, @NotNull BlockPos pos, @NotNull Bl @Override - protected void createBlockStateDefinition(StateDefinition.@NotNull Builder pBuilder) { + protected void createBlockStateDefinition(StateContainer.@NotNull Builder pBuilder) { super.createBlockStateDefinition(pBuilder); pBuilder.add(FACING); } diff --git a/common/src/main/java/com/ultreon/devices/block/DigitalClockBlock.java b/common/src/main/java/com/ultreon/devices/block/DigitalClockBlock.java index 19d06053c..4a9fbe282 100644 --- a/common/src/main/java/com/ultreon/devices/block/DigitalClockBlock.java +++ b/common/src/main/java/com/ultreon/devices/block/DigitalClockBlock.java @@ -2,18 +2,18 @@ import dev.architectury.registry.block.BlockProperties; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.IngameGui; import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.resources.language.I18n; -import net.minecraft.network.chat.TranslatableComponent; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.TooltipFlag; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.material.Material; -import net.minecraft.world.level.material.MaterialColor; -import net.minecraft.world.phys.AABB; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.item.ItemStack; +import net.minecraft.item.TooltipFlag; +import net.minecraft.world.World; +import net.minecraft.block.Block; +import net.minecraft.block.AbstractBlock; +import net.minecraft.block.material.Material; +import net.minecraft.block.material.MaterialColor; +import net.minecraft.util.math.AxisAlignedBB; import javax.annotation.Nullable; import java.util.List; @@ -29,7 +29,7 @@ public class DigitalClockBlock{// extends Block { // } // // -//// public static void addInformation(ItemStack stack, @Nullable Level player, List tooltip, TooltipFlag advanced) +//// public static void addInformation(ItemStack stack, @Nullable World player, List tooltip, TooltipFlag advanced) //// { //// if(Screen.hasShiftDown()) //// { diff --git a/common/src/main/java/com/ultreon/devices/block/LaptopBlock.java b/common/src/main/java/com/ultreon/devices/block/LaptopBlock.java index 1a4f0711f..bad7c54d4 100644 --- a/common/src/main/java/com/ultreon/devices/block/LaptopBlock.java +++ b/common/src/main/java/com/ultreon/devices/block/LaptopBlock.java @@ -4,32 +4,32 @@ import com.ultreon.devices.block.entity.LaptopBlockEntity; import com.ultreon.devices.item.FlashDriveItem; import com.ultreon.devices.util.BlockEntityUtil; -import dev.architectury.utils.Env; -import dev.architectury.utils.EnvExecutor; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.util.StringRepresentable; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.DyeColor; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.block.state.properties.EnumProperty; -import net.minecraft.world.level.material.Material; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.Shapes; -import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.DistExecutor; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.Direction; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.IStringSerializable; +import net.minecraft.util.Hand; +import net.minecraft.util.ActionResultType; +import net.minecraft.entity.item.ItemEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.DyeColor; +import net.minecraft.item.ItemStack; +import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; +import net.minecraft.block.Block; +import net.minecraft.block.SoundType; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.block.BlockState; +import net.minecraft.state.StateContainer; +import net.minecraft.state.BooleanProperty; +import net.minecraft.state.EnumProperty; +import net.minecraft.block.material.Material; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.util.math.shapes.VoxelShapes; +import net.minecraft.util.math.shapes.VoxelShape; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -39,10 +39,10 @@ public class LaptopBlock extends DeviceBlock.Colored { public static final EnumProperty TYPE = EnumProperty.create("type", Type.class); public static final BooleanProperty OPEN = BooleanProperty.create("open"); - private static final VoxelShape SHAPE_OPEN_NORTH = Shapes.or(Block.box(1, 0, 12.5, 15, 11.4, 17), Block.box(1, 0, 1, 15, 1.3, 12.5)); - private static final VoxelShape SHAPE_OPEN_EAST = Shapes.or(Block.box(-1, 0, 1, 3.5, 11.4, 15), Block.box(3.5, 0, 1, 15, 1.3, 15)); - private static final VoxelShape SHAPE_OPEN_SOUTH = Shapes.or(Block.box(1, 0, -1, 15, 11.4, 3.5), Block.box(1, 0, 3.5, 15, 1.3, 15)); - private static final VoxelShape SHAPE_OPEN_WEST = Shapes.or(Block.box(12.5, 0, 1, 17, 11.4, 15), Block.box(1, 0, 1, 12.5, 1.3, 15)); + private static final VoxelShape SHAPE_OPEN_NORTH = VoxelShapes.or(Block.box(1, 0, 12.5, 15, 11.4, 17), Block.box(1, 0, 1, 15, 1.3, 12.5)); + private static final VoxelShape SHAPE_OPEN_EAST = VoxelShapes.or(Block.box(-1, 0, 1, 3.5, 11.4, 15), Block.box(3.5, 0, 1, 15, 1.3, 15)); + private static final VoxelShape SHAPE_OPEN_SOUTH = VoxelShapes.or(Block.box(1, 0, -1, 15, 11.4, 3.5), Block.box(1, 0, 3.5, 15, 1.3, 15)); + private static final VoxelShape SHAPE_OPEN_WEST = VoxelShapes.or(Block.box(12.5, 0, 1, 17, 11.4, 15), Block.box(1, 0, 1, 12.5, 1.3, 15)); private static final VoxelShape SHAPE_CLOSED_NORTH = Block.box(1, 0, 1, 15, 2, 13); private static final VoxelShape SHAPE_CLOSED_EAST = Block.box(3, 0, 1, 15, 2, 15); private static final VoxelShape SHAPE_CLOSED_SOUTH = Block.box(1, 0, 3, 15, 2, 15); @@ -54,7 +54,7 @@ public LaptopBlock(DyeColor color) { } @Override - public @NotNull VoxelShape getShape(@NotNull BlockState pState, @NotNull BlockGetter pLevel, @NotNull BlockPos pPos, @NotNull CollisionContext pContext) { + public @NotNull VoxelShape getShape(@NotNull BlockState pState, @NotNull IBlockReader pLevel, @NotNull BlockPos pPos, @NotNull ISelectionContext pContext) { return pState.getValue(OPEN) ? switch (pState.getValue(FACING)) { case NORTH -> SHAPE_OPEN_NORTH; case EAST -> SHAPE_OPEN_EAST; @@ -73,70 +73,70 @@ public LaptopBlock(DyeColor color) { @NotNull @Override @SuppressWarnings("deprecation") - public InteractionResult use(@NotNull BlockState state, @NotNull Level level, @NotNull BlockPos pos, @NotNull Player player, @NotNull InteractionHand hand, @NotNull BlockHitResult hit) { + public ActionResultType use(@NotNull BlockState state, @NotNull World level, @NotNull BlockPos pos, @NotNull PlayerEntity player, @NotNull Hand hand, @NotNull BlockRayTraceResult hit) { - BlockEntity blockEntity = level.getBlockEntity(pos); + TileEntity blockEntity = level.getBlockEntity(pos); if (blockEntity instanceof LaptopBlockEntity laptop) { if (player.isCrouching()) { if (!level.isClientSide) { laptop.openClose(player); } - return InteractionResult.SUCCESS; + return ActionResultType.SUCCESS; } else { - if (hit.getDirection() == state.getValue(FACING).getCounterClockWise(Direction.Axis.Y)) { + if (hit.getDirection() == state.getValue(FACING).getCounterClockWise()) { ItemStack heldItem = player.getItemInHand(hand); if (!heldItem.isEmpty() && heldItem.getItem() instanceof FlashDriveItem) { if (!level.isClientSide) { if (laptop.getFileSystem().setAttachedDrive(heldItem.copy())) { heldItem.shrink(1); - return InteractionResult.CONSUME; + return ActionResultType.CONSUME; } else { - return InteractionResult.FAIL; + return ActionResultType.FAIL; } } - return InteractionResult.PASS; + return ActionResultType.PASS; } if (!level.isClientSide) { ItemStack stack = laptop.getFileSystem().removeAttachedDrive(); if (stack != null) { - BlockPos summonPos = pos.relative(state.getValue(FACING).getCounterClockWise(Direction.Axis.Y)); + BlockPos summonPos = pos.relative(state.getValue(FACING).getCounterClockWise()); level.addFreshEntity(new ItemEntity(level, summonPos.getX() + 0.5, summonPos.getY(), summonPos.getZ() + 0.5, stack)); BlockEntityUtil.markBlockForUpdate(level, pos); } } - return InteractionResult.SUCCESS; + return ActionResultType.SUCCESS; } if (laptop.isOpen() && level.isClientSide) { - EnvExecutor.runInEnv(Env.CLIENT, () -> () -> { + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> { ClientLaptopWrapper.execute(laptop); }); - return InteractionResult.SUCCESS; + return ActionResultType.SUCCESS; } } } - return InteractionResult.PASS; + return ActionResultType.PASS; } @Override - protected void removeTagsForDrop(CompoundTag tileEntityTag) { + protected void removeTagsForDrop(CompoundNBT tileEntityTag) { tileEntityTag.remove("open"); } @Override - public @Nullable BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { - return new LaptopBlockEntity(pos, state); + public @Nullable TileEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { + return new LaptopBlockEntity(); } @Override - protected void createBlockStateDefinition(StateDefinition.@NotNull Builder pBuilder) { + protected void createBlockStateDefinition(StateContainer.@NotNull Builder pBuilder) { super.createBlockStateDefinition(pBuilder); pBuilder.add(TYPE, OPEN); } - public enum Type implements StringRepresentable { + public enum Type implements IStringSerializable { BASE, SCREEN; @NotNull diff --git a/common/src/main/java/com/ultreon/devices/block/OfficeChairBlock.java b/common/src/main/java/com/ultreon/devices/block/OfficeChairBlock.java index e5f1db461..87ac70e6e 100644 --- a/common/src/main/java/com/ultreon/devices/block/OfficeChairBlock.java +++ b/common/src/main/java/com/ultreon/devices/block/OfficeChairBlock.java @@ -4,30 +4,30 @@ import com.ultreon.devices.block.entity.OfficeChairBlockEntity; import com.ultreon.devices.entity.SeatEntity; import com.ultreon.devices.util.SeatUtil; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.client.Minecraft; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.StringRepresentable; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.DyeColor; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.LevelReader; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.level.block.state.properties.EnumProperty; -import net.minecraft.world.level.material.Material; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.Shapes; -import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.Direction; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.IStringSerializable; +import net.minecraft.util.Hand; +import net.minecraft.util.ActionResultType; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.DyeColor; +import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; +import net.minecraft.world.IWorldReader; +import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.block.AbstractBlock; +import net.minecraft.block.BlockState; +import net.minecraft.state.StateContainer; +import net.minecraft.state.EnumProperty; +import net.minecraft.block.material.Material; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.util.math.shapes.VoxelShapes; +import net.minecraft.util.math.shapes.VoxelShape; import org.jetbrains.annotations.NotNull; import javax.annotation.Nullable; @@ -36,16 +36,16 @@ public class OfficeChairBlock extends DeviceBlock.Colored { public static final EnumProperty TYPE = EnumProperty.create("type", Type.class); - private static final VoxelShape EMPTY_BOX = Shapes.box(0, 0, 0, 0, 0, 0); - private static final VoxelShape SELECTION_BOX = Shapes.box(0.0625f, 0, 0.0625f, 0.9375f, /*1.6875f*/0.625f, 0.9375f); - private static final VoxelShape SEAT_BOUNDING_BOX = Shapes.box(0.0625f, 0, 0.0625f, 0.9375f, 0.625f, 0.9375f); + private static final VoxelShape EMPTY_BOX = VoxelShapes.box(0, 0, 0, 0, 0, 0); + private static final VoxelShape SELECTION_BOX = VoxelShapes.box(0.0625f, 0, 0.0625f, 0.9375f, /*1.6875f*/0.625f, 0.9375f); + private static final VoxelShape SEAT_BOUNDING_BOX = VoxelShapes.box(0.0625f, 0, 0.0625f, 0.9375f, 0.625f, 0.9375f); public OfficeChairBlock(DyeColor color) { - super(BlockBehaviour.Properties.of(Material.STONE, color.getMaterialColor()), color, ModDeviceTypes.SEAT); + super(AbstractBlock.Properties.of(Material.STONE, color.getMaterialColor()), color, ModDeviceTypes.SEAT); //this.setUnlocalizedName("office_chair"); //this.setRegistryName("office_chair"); - //this.setCreativeTab(MrCrayfishDeviceMod.TAB_DEVICE); + //this.setCreativeTab(MrCrayfishDeviceMod.GROUP_DEVICE); this.registerDefaultState(this.getStateDefinition().any().setValue(FACING, Direction.NORTH).setValue(TYPE, Type.LEGS)); } @@ -55,23 +55,23 @@ public String getDescriptionId() { } @Override - public boolean canSurvive(BlockState state, LevelReader reader, BlockPos pos) + public boolean canSurvive(BlockState state, IWorldReader reader, BlockPos pos) { return false; } @Override - public @NotNull VoxelShape getShape(@NotNull BlockState pState, @NotNull BlockGetter pLevel, @NotNull BlockPos pPos, @NotNull CollisionContext pContext) { + public @NotNull VoxelShape getShape(@NotNull BlockState pState, @NotNull IBlockReader pLevel, @NotNull BlockPos pPos, @NotNull ISelectionContext pContext) { return SELECTION_BOX; } @Override - public VoxelShape getVisualShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { + public VoxelShape getVisualShape(BlockState state, IBlockReader level, BlockPos pos, ISelectionContext context) { return SEAT_BOUNDING_BOX; } @Override - public VoxelShape getCollisionShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { + public VoxelShape getCollisionShape(BlockState state, IBlockReader level, BlockPos pos, ISelectionContext context) { if(Minecraft.getInstance().player != null && Minecraft.getInstance().player.getVehicle() instanceof SeatEntity) { return EMPTY_BOX; @@ -80,7 +80,7 @@ public VoxelShape getCollisionShape(BlockState state, BlockGetter level, BlockPo } @Override - public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) + public ActionResultType use(BlockState state, World level, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { //System.out.println(DeviceEntities.SEAT.get().create(level).toString()); System.out.println("OKOKJRTKFD"); @@ -88,24 +88,24 @@ public InteractionResult use(BlockState state, Level level, BlockPos pos, Player { SeatUtil.createSeatAndSit(level, pos, player, -1); } - return InteractionResult.SUCCESS; + return ActionResultType.SUCCESS; } @Nullable @Override - public BlockEntity newBlockEntity(BlockPos pos, BlockState state) + public TileEntity newBlockEntity(BlockPos pos, BlockState state) { - return new OfficeChairBlockEntity(pos, state); + return new OfficeChairBlockEntity(); } @Override - protected void createBlockStateDefinition(StateDefinition.@NotNull Builder pBuilder) + protected void createBlockStateDefinition(StateContainer.@NotNull Builder pBuilder) { super.createBlockStateDefinition(pBuilder); pBuilder.add(TYPE); } - public enum Type implements StringRepresentable + public enum Type implements IStringSerializable { LEGS, SEAT, FULL; diff --git a/common/src/main/java/com/ultreon/devices/block/PaperBlock.java b/common/src/main/java/com/ultreon/devices/block/PaperBlock.java index f66fbec6c..67865ccda 100644 --- a/common/src/main/java/com/ultreon/devices/block/PaperBlock.java +++ b/common/src/main/java/com/ultreon/devices/block/PaperBlock.java @@ -2,27 +2,27 @@ import com.ultreon.devices.api.print.IPrint; import com.ultreon.devices.block.entity.PaperBlockEntity; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.EntityBlock; -import net.minecraft.world.level.block.HorizontalDirectionalBlock; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.level.material.Material; -import net.minecraft.world.level.storage.loot.LootContext; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.Direction; +import net.minecraft.util.Hand; +import net.minecraft.util.ActionResultType; +import net.minecraft.entity.item.ItemEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; +import net.minecraft.block.Block; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.HorizontalBlock; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.block.BlockState; +import net.minecraft.state.StateContainer; +import net.minecraft.block.material.Material; +import net.minecraft.world.storage.loot.LootContext; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.util.math.shapes.VoxelShape; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -30,7 +30,7 @@ import java.util.List; @SuppressWarnings("NullableProblems") -public class PaperBlock extends HorizontalDirectionalBlock implements EntityBlock { +public class PaperBlock extends HorizontalBlock implements ITileEntityProvider { private static final VoxelShape SELECTION_BOUNDS = box(15, 0, 0, 16, 16, 16); private static final VoxelShape SELECTION_BOX_NORTH = box(15, 0, 0, 16, 16, 16); @@ -47,7 +47,7 @@ public PaperBlock() { @NotNull @Override - public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) { + public VoxelShape getShape(BlockState pState, IBlockReader pLevel, BlockPos pPos, ISelectionContext pContext) { return switch (pState.getValue(FACING)) { case NORTH -> SELECTION_BOX_NORTH; case SOUTH -> SELECTION_BOX_SOUTH; @@ -59,20 +59,20 @@ public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, @Nullable @Override - public BlockState getStateForPlacement(BlockPlaceContext pContext) { + public BlockState getStateForPlacement(BlockItemUseContext pContext) { BlockState state = super.getStateForPlacement(pContext); return state != null ? state.setValue(FACING, pContext.getHorizontalDirection()) : null; } @Override - public InteractionResult use(BlockState pState, Level level, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHit) { + public ActionResultType use(BlockState pState, World level, BlockPos pPos, PlayerEntity pPlayer, Hand pHand, BlockRayTraceResult pHit) { if (!level.isClientSide) { - BlockEntity blockEntity = level.getBlockEntity(pPos); + TileEntity blockEntity = level.getBlockEntity(pPos); if (blockEntity instanceof PaperBlockEntity paper) { paper.nextRotation(); } } - return InteractionResult.SUCCESS; + return ActionResultType.SUCCESS; } @Override @@ -81,9 +81,9 @@ public List getDrops(BlockState pState, LootContext.Builder pBuilder) } @Override - public void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, World level, BlockPos pos, BlockState newState, boolean isMoving) { if (!level.isClientSide) { - BlockEntity tileEntity = level.getBlockEntity(pos); + TileEntity tileEntity = level.getBlockEntity(pos); if (tileEntity instanceof PaperBlockEntity paper) { ItemStack drop = IPrint.generateItem(paper.getPrint()); level.addFreshEntity(new ItemEntity(level, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, drop)); @@ -93,13 +93,13 @@ public void onRemove(BlockState state, Level level, BlockPos pos, BlockState new } @Override - public boolean triggerEvent(@NotNull BlockState state, Level level, @NotNull BlockPos pos, int id, int param) { - BlockEntity blockEntity = level.getBlockEntity(pos); + public boolean triggerEvent(@NotNull BlockState state, World level, @NotNull BlockPos pos, int id, int param) { + TileEntity blockEntity = level.getBlockEntity(pos); return blockEntity != null && blockEntity.triggerEvent(id, param); } @Override - protected void createBlockStateDefinition(StateDefinition.Builder pBuilder) { + protected void createBlockStateDefinition(StateContainer.Builder pBuilder) { pBuilder.add(FACING); } @@ -110,7 +110,7 @@ protected void createBlockStateDefinition(StateDefinition.Builder SHAPE_NORTH; case EAST -> SHAPE_EAST; @@ -97,24 +97,24 @@ public VoxelShape getShape(@NotNull BlockState pState, @NotNull BlockGetter pLev @NotNull @Override @SuppressWarnings("deprecation") - public InteractionResult use(@NotNull BlockState state, Level level, @NotNull BlockPos pos, Player player, @NotNull InteractionHand hand, @NotNull BlockHitResult hit) { + public ActionResultType use(@NotNull BlockState state, World level, @NotNull BlockPos pos, PlayerEntity player, @NotNull Hand hand, @NotNull BlockRayTraceResult hit) { if (level.isClientSide) { if (player.isCrouching()) { - return InteractionResult.SUCCESS; + return ActionResultType.SUCCESS; } else { return super.use(state, level, pos, player, hand, hit); } } ItemStack heldItem = player.getItemInHand(hand); - BlockEntity tileEntity = level.getChunkAt(pos).getBlockEntity(pos, LevelChunk.EntityCreationType.IMMEDIATE); + TileEntity tileEntity = level.getChunkAt(pos).getBlockEntity(pos, Chunk.CreateEntityType.IMMEDIATE); if (tileEntity instanceof PrinterBlockEntity) { - return ((PrinterBlockEntity) tileEntity).addPaper(heldItem, player.isCrouching()) ? InteractionResult.SUCCESS : InteractionResult.FAIL; + return ((PrinterBlockEntity) tileEntity).addPaper(heldItem, player.isCrouching()) ? ActionResultType.SUCCESS : ActionResultType.FAIL; } - return InteractionResult.PASS; + return ActionResultType.PASS; } @Override - public @Nullable BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { - return new PrinterBlockEntity(pos, state); + public @Nullable TileEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { + return new PrinterBlockEntity(); } } diff --git a/common/src/main/java/com/ultreon/devices/block/RouterBlock.java b/common/src/main/java/com/ultreon/devices/block/RouterBlock.java index 12a4f3816..e134f0a4d 100644 --- a/common/src/main/java/com/ultreon/devices/block/RouterBlock.java +++ b/common/src/main/java/com/ultreon/devices/block/RouterBlock.java @@ -4,25 +4,25 @@ import com.ultreon.devices.block.entity.RouterBlockEntity; import com.ultreon.devices.network.PacketHandler; import com.ultreon.devices.network.task.SyncBlockPacket; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.DyeColor; -import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.material.Material; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.Direction; +import net.minecraft.util.Hand; +import net.minecraft.util.ActionResultType; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.DyeColor; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; +import net.minecraft.block.Block; +import net.minecraft.block.SoundType; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.block.BlockState; +import net.minecraft.state.StateContainer; +import net.minecraft.state.BooleanProperty; +import net.minecraft.block.material.Material; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.util.math.shapes.VoxelShape; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; @@ -64,7 +64,7 @@ public RouterBlock(DyeColor color) { } @Override - public @NotNull VoxelShape getShape(@NotNull BlockState pState, @NotNull BlockGetter pLevel, @NotNull BlockPos pPos, @NotNull CollisionContext pContext) { + public @NotNull VoxelShape getShape(@NotNull BlockState pState, @NotNull IBlockReader pLevel, @NotNull BlockPos pPos, @NotNull ISelectionContext pContext) { return switch (pState.getValue(FACING)) { case NORTH -> pState.getValue(VERTICAL) ? BODY_VERTICAL_BOUNDING_BOX[0] : BODY_BOUNDING_BOX[0]; case EAST -> pState.getValue(VERTICAL) ? BODY_VERTICAL_BOUNDING_BOX[1] : BODY_BOUNDING_BOX[1]; @@ -75,22 +75,22 @@ public RouterBlock(DyeColor color) { } @Override - public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { + public ActionResultType use(BlockState state, World level, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { if (level.isClientSide && player.isCreative()) { - BlockEntity blockEntity = level.getBlockEntity(pos); + TileEntity blockEntity = level.getBlockEntity(pos); if (blockEntity instanceof RouterBlockEntity router) { router.setDebug(true); if (router.isDebug()) { PacketHandler.INSTANCE.sendToServer(new SyncBlockPacket(pos)); } } - return InteractionResult.SUCCESS; + return ActionResultType.SUCCESS; } - return InteractionResult.PASS; + return ActionResultType.PASS; } @Override - public @org.jetbrains.annotations.Nullable BlockState getStateForPlacement(@NotNull BlockPlaceContext pContext) { + public @org.jetbrains.annotations.Nullable BlockState getStateForPlacement(@NotNull BlockItemUseContext pContext) { BlockState state = super.getStateForPlacement(pContext); return state != null ? state.setValue(FACING, pContext.getHorizontalDirection().getOpposite()).setValue(VERTICAL, pContext.getClickLocation().y - pContext.getClickLocation().y > 0.5) : null; } @@ -109,12 +109,12 @@ public InteractionResult use(BlockState state, Level level, BlockPos pos, Player @NotNull @Override @Contract("_, _ -> new") - public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { - return new RouterBlockEntity(pos, state); + public TileEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { + return new RouterBlockEntity(); } @Override - protected void createBlockStateDefinition(StateDefinition.@NotNull Builder pBuilder) { + protected void createBlockStateDefinition(StateContainer.@NotNull Builder pBuilder) { super.createBlockStateDefinition(pBuilder); pBuilder.add(VERTICAL); } diff --git a/common/src/main/java/com/ultreon/devices/block/entity/DeviceBlockEntity.java b/common/src/main/java/com/ultreon/devices/block/entity/DeviceBlockEntity.java index 8188465f4..295d15ba2 100644 --- a/common/src/main/java/com/ultreon/devices/block/entity/DeviceBlockEntity.java +++ b/common/src/main/java/com/ultreon/devices/block/entity/DeviceBlockEntity.java @@ -3,15 +3,15 @@ import com.ultreon.devices.block.DeviceBlock; import com.ultreon.devices.util.Colorable; import com.ultreon.devices.util.Tickable; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.world.item.DyeColor; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.INBT; +import net.minecraft.util.text.Component; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.item.DyeColor; +import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntityType; +import net.minecraft.block.BlockState; import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; @@ -22,8 +22,8 @@ public abstract class DeviceBlockEntity extends SyncBlockEntity implements Ticka private UUID deviceId; private String name; - public DeviceBlockEntity(BlockEntityType pType, BlockPos pWorldPosition, BlockState pBlockState) { - super(pType, pWorldPosition, pBlockState); + public DeviceBlockEntity(TileEntityType pType) { + super(pType); } @NotNull @@ -48,13 +48,13 @@ public boolean hasCustomName() { return name != null && StringUtils.isEmpty(name); } - public Component getDisplayName() { - return new TextComponent(getCustomName()); + public TextComponent getDisplayName() { + return new StringTextComponent(getCustomName()); } @Override - protected void saveAdditional(@NotNull CompoundTag tag) { - super.saveAdditional(tag); + protected void save(BlockState state, @NotNull CompoundNBT tag) { + super.save(tag); tag.putString("deviceId", getId().toString()); if (hasCustomName()) { @@ -65,23 +65,23 @@ protected void saveAdditional(@NotNull CompoundTag tag) { } @Override - public void load(@NotNull CompoundTag tag) { - super.load(tag); + public void load(BlockState state, @NotNull CompoundNBT tag) { + super.load(state, tag); - if (tag.contains("deviceId", Tag.TAG_STRING)) { + if (tag.contains("deviceId", Constants.NBT.TAG_STRING)) { deviceId = UUID.fromString(tag.getString("deviceId")); } - if (tag.contains("name", Tag.TAG_STRING)) { + if (tag.contains("name", Constants.NBT.TAG_STRING)) { name = tag.getString("name"); } - if (tag.contains("color", Tag.TAG_BYTE)) { + if (tag.contains("color", Constants.NBT.TAG_BYTE)) { color = DyeColor.byId(tag.getByte("color")); } } @Override - public CompoundTag saveSyncTag() { - CompoundTag tag = new CompoundTag(); + public CompoundNBT saveSyncTag() { + CompoundNBT tag = new CompoundNBT(); if (hasCustomName()) { tag.putString("name", name); } @@ -106,27 +106,27 @@ public DeviceBlock getDeviceBlock() { public static abstract class Colored extends DeviceBlockEntity implements Colorable { private DyeColor color = DyeColor.RED; - public Colored(BlockEntityType pType, BlockPos pWorldPosition, BlockState pBlockState) { - super(pType, pWorldPosition, pBlockState); + public Colored(TileEntityType pType) { + super(pType); } @Override - public void load(@NotNull CompoundTag tag) { - super.load(tag); - if (tag.contains("color", Tag.TAG_BYTE)) { + public void load(BlockState state, @NotNull CompoundNBT tag) { + super.load(state, tag); + if (tag.contains("color", Constants.NBT.TAG_BYTE)) { color = DyeColor.byId(tag.getByte("color")); } } @Override - protected void saveAdditional(@NotNull CompoundTag tag) { - super.saveAdditional(tag); + protected void save(BlockState state, @NotNull CompoundNBT tag) { + super.save(tag); tag.putByte("color", (byte) color.getId()); } @Override - public CompoundTag saveSyncTag() { - CompoundTag tag = super.saveSyncTag(); + public CompoundNBT saveSyncTag() { + CompoundNBT tag = super.saveSyncTag(); tag.putByte("color", (byte) color.getId()); return tag; } diff --git a/common/src/main/java/com/ultreon/devices/block/entity/LaptopBlockEntity.java b/common/src/main/java/com/ultreon/devices/block/entity/LaptopBlockEntity.java index a1b11d6e5..ae6ba9713 100644 --- a/common/src/main/java/com/ultreon/devices/block/entity/LaptopBlockEntity.java +++ b/common/src/main/java/com/ultreon/devices/block/entity/LaptopBlockEntity.java @@ -4,16 +4,15 @@ import com.ultreon.devices.core.io.FileSystem; import com.ultreon.devices.init.DeviceBlockEntities; import com.ultreon.devices.util.BlockEntityUtil; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.item.DyeColor; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.gameevent.GameEvent; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.INBT; +import net.minecraft.entity.Entity; +import net.minecraft.item.DyeColor; +import net.minecraft.world.World; +import net.minecraft.block.BlockState; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -22,20 +21,20 @@ public class LaptopBlockEntity extends NetworkDeviceBlockEntity.Colored { private boolean open = false; - private CompoundTag applicationData = new CompoundTag(); - private CompoundTag systemData = new CompoundTag(); + private CompoundNBT applicationData = new CompoundNBT(); + private CompoundNBT systemData = new CompoundNBT(); private FileSystem fileSystem; - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) private int rotation; - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) private int prevRotation; private DyeColor externalDriveColor; - public LaptopBlockEntity(BlockPos pWorldPosition, BlockState pBlockState) { - super(DeviceBlockEntities.LAPTOP.get(), pWorldPosition, pBlockState); + public LaptopBlockEntity() { + super(DeviceBlockEntities.LAPTOP.get()); } @Override @@ -62,22 +61,22 @@ public void tick() { } @Override - public void load(@NotNull CompoundTag compound) { - super.load(compound); + public void load(BlockState state, @NotNull CompoundNBT compound) { + super.load(state, compound); if (compound.contains("open")) { this.open = compound.getBoolean("open"); this.getBlockState().setValue(LaptopBlock.OPEN, open); } - if (compound.contains("system_data", Tag.TAG_COMPOUND)) { + if (compound.contains("system_data", Constants.NBT.TAG_COMPOUND)) { this.systemData = compound.getCompound("system_data"); } - if (compound.contains("application_data", Tag.TAG_COMPOUND)) { + if (compound.contains("application_data", Constants.NBT.TAG_COMPOUND)) { this.applicationData = compound.getCompound("application_data"); } if (compound.contains("file_system")) { this.fileSystem = new FileSystem(this, compound.getCompound("file_system")); } - if (compound.contains("external_drive_color", Tag.TAG_BYTE)) { + if (compound.contains("external_drive_color", Constants.NBT.TAG_BYTE)) { this.externalDriveColor = null; if (compound.getByte("external_drive_color") != -1) { this.externalDriveColor = DyeColor.byId(compound.getByte("external_drive_color")); @@ -86,8 +85,8 @@ public void load(@NotNull CompoundTag compound) { } @Override - public void saveAdditional(@NotNull CompoundTag compound) { - super.saveAdditional(compound); + public void save(@NotNull CompoundNBT compound) { + super.save(compound); compound.putBoolean("open", open); if (systemData != null) { @@ -104,8 +103,8 @@ public void saveAdditional(@NotNull CompoundTag compound) { } @Override - public CompoundTag saveSyncTag() { - CompoundTag tag = super.saveSyncTag(); + public CompoundNBT saveSyncTag() { + CompoundNBT tag = super.saveSyncTag(); tag.putBoolean("open", open); tag.put("system_data", getSystemData()); @@ -129,7 +128,7 @@ public CompoundTag saveSyncTag() { // } public void openClose(@Nullable Entity entity) { - Level level = this.level; + World level = this.level; if (level != null) { level.gameEvent(!open ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE, getBlockPos()); } @@ -148,7 +147,7 @@ public void openClose(@Nullable Entity entity) { } } - private static void doNeighborUpdates(Level level, BlockPos pos, BlockState state) { + private static void doNeighborUpdates(World level, BlockPos pos, BlockState state) { state.updateNeighbourShapes(level, pos, 3); } @@ -156,18 +155,18 @@ public boolean isOpen() { return open; } - public CompoundTag getApplicationData() { - return applicationData != null ? applicationData : new CompoundTag(); + public CompoundNBT getApplicationData() { + return applicationData != null ? applicationData : new CompoundNBT(); } - public CompoundTag getSystemData() { + public CompoundNBT getSystemData() { if (systemData == null) { - systemData = new CompoundTag(); + systemData = new CompoundNBT(); } return systemData; } - public void setSystemData(CompoundTag systemData) { + public void setSystemData(CompoundNBT systemData) { this.systemData = systemData; setChanged(); assert level != null; @@ -176,29 +175,29 @@ public void setSystemData(CompoundTag systemData) { public FileSystem getFileSystem() { if (fileSystem == null) { - fileSystem = new FileSystem(this, new CompoundTag()); + fileSystem = new FileSystem(this, new CompoundNBT()); } return fileSystem; } - public void setApplicationData(String appId, CompoundTag applicationData) { + public void setApplicationData(String appId, CompoundNBT applicationData) { this.applicationData = applicationData; setChanged(); assert level != null; BlockEntityUtil.markBlockForUpdate(level, worldPosition); } - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) public float getScreenAngle(float partialTicks) { return -OPENED_ANGLE * ((prevRotation + (rotation - prevRotation) * partialTicks) / OPENED_ANGLE); } - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) public boolean isExternalDriveAttached() { return externalDriveColor != null; } - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) public DyeColor getExternalDriveColor() { return externalDriveColor; } diff --git a/common/src/main/java/com/ultreon/devices/block/entity/NetworkDeviceBlockEntity.java b/common/src/main/java/com/ultreon/devices/block/entity/NetworkDeviceBlockEntity.java index dd5e82fbb..7582d3c39 100644 --- a/common/src/main/java/com/ultreon/devices/block/entity/NetworkDeviceBlockEntity.java +++ b/common/src/main/java/com/ultreon/devices/block/entity/NetworkDeviceBlockEntity.java @@ -1,18 +1,18 @@ package com.ultreon.devices.block.entity; import com.ultreon.devices.DeviceConfig; -import com.ultreon.devices.core.network.Connection; +import com.ultreon.devices.core.network.NetworkManager; import com.ultreon.devices.core.network.Router; import com.ultreon.devices.util.Colorable; import com.ultreon.devices.util.Tickable; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.world.item.DyeColor; -import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.INBT; +import net.minecraft.util.text.Component; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.item.DyeColor; +import net.minecraft.tileentity.TileEntityType; +import net.minecraft.block.BlockState; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -21,10 +21,10 @@ @SuppressWarnings("unused") public abstract class NetworkDeviceBlockEntity extends DeviceBlockEntity implements Tickable { private int counter; - private Connection connection; + private NetworkManager connection; - public NetworkDeviceBlockEntity(BlockEntityType pType, BlockPos pWorldPosition, BlockState pBlockState) { - super(pType, pWorldPosition, pBlockState); + public NetworkDeviceBlockEntity(TileEntityType pType) { + super(pType); } public void tick() { @@ -53,12 +53,12 @@ public void connect(Router router) { connection = null; return; } - connection = new Connection(router); + connection = new NetworkManager(router); counter = 0; this.setChanged(); } - public Connection getConnection() { + public NetworkManager getConnection() { return connection; } @@ -96,50 +96,50 @@ public int getSignalStrength() { @Nullable @Override - public Component getDisplayName() { - return new TextComponent(getCustomName()); + public TextComponent getDisplayName() { + return new StringTextComponent(getCustomName()); } @Override - public void saveAdditional(@NotNull CompoundTag tag) { - super.saveAdditional(tag); + public void save(BlockState state, @NotNull CompoundNBT tag) { + super.save(tag); if (connection != null) { tag.put("connection", connection.toTag()); } } @Override - public void load(@NotNull CompoundTag tag) { - super.load(tag); - if (tag.contains("connection", Tag.TAG_COMPOUND)) { - connection = Connection.fromTag(tag.getCompound("connection")); + public void load(BlockState state, @NotNull CompoundNBT tag) { + super.load(state, tag); + if (tag.contains("connection", Constants.NBT.TAG_COMPOUND)) { + connection = NetworkManager.fromTag(tag.getCompound("connection")); } } public static abstract class Colored extends NetworkDeviceBlockEntity implements Colorable { private DyeColor color = DyeColor.RED; - public Colored(BlockEntityType pType, BlockPos pWorldPosition, BlockState pBlockState) { - super(pType, pWorldPosition, pBlockState); + public Colored(TileEntityType pType) { + super(pType); } @Override - public void load(@NotNull CompoundTag tag) { - super.load(tag); - if (tag.contains("color", Tag.TAG_STRING)) { + public void load(BlockState state, @NotNull CompoundNBT tag) { + super.load(state, tag); + if (tag.contains("color", Constants.NBT.TAG_STRING)) { color = DyeColor.byId(tag.getByte("color")); } } @Override - public void saveAdditional(@NotNull CompoundTag tag) { - super.saveAdditional(tag); + public void save(BlockState state, @NotNull CompoundNBT tag) { + super.save(tag); tag.putByte("color", (byte) color.getId()); } @Override - public CompoundTag saveSyncTag() { - CompoundTag tag = super.saveSyncTag(); + public CompoundNBT saveSyncTag() { + CompoundNBT tag = super.saveSyncTag(); tag.putByte("color", (byte) color.getId()); return tag; } diff --git a/common/src/main/java/com/ultreon/devices/block/entity/OfficeChairBlockEntity.java b/common/src/main/java/com/ultreon/devices/block/entity/OfficeChairBlockEntity.java index a4ee29140..f933fd808 100644 --- a/common/src/main/java/com/ultreon/devices/block/entity/OfficeChairBlockEntity.java +++ b/common/src/main/java/com/ultreon/devices/block/entity/OfficeChairBlockEntity.java @@ -4,17 +4,17 @@ import com.ultreon.devices.entity.SeatEntity; import com.ultreon.devices.init.DeviceBlockEntities; import com.ultreon.devices.util.Colorable; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.vehicle.Boat; -import net.minecraft.world.item.DyeColor; -import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.AABB; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.INBT; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.vehicle.Boat; +import net.minecraft.item.DyeColor; +import net.minecraft.tileentity.TileEntityType; +import net.minecraft.block.BlockState; +import net.minecraft.util.math.AxisAlignedBB; import java.util.List; @@ -22,8 +22,8 @@ public class OfficeChairBlockEntity extends SyncBlockEntity implements Colorable { private DyeColor color = DyeColor.RED; - public OfficeChairBlockEntity(BlockPos pWorldPosition, BlockState pBlockState) { - super(DeviceBlockEntities.SEAT.get(), pWorldPosition, pBlockState); + public OfficeChairBlockEntity() { + super(DeviceBlockEntities.SEAT.get()); } @Override @@ -39,34 +39,34 @@ public void setColor(DyeColor color) } @Override - public void load(CompoundTag compound) + public void load(CompoundNBT compound) { - super.load(compound); - if(compound.contains("color", Tag.TAG_BYTE)) + super.load(state, compound); + if(compound.contains("color", Constants.NBT.TAG_BYTE)) { color = DyeColor.byId(compound.getByte("color")); } } @Override - public void saveAdditional(CompoundTag compound) + public void save(CompoundNBT compound) { - super.saveAdditional(compound); + super.save(compound); compound.putByte("color", (byte) color.getId()); } @Override - public CompoundTag saveSyncTag() + public CompoundNBT saveSyncTag() { - CompoundTag tag = new CompoundTag(); + CompoundNBT tag = new CompoundNBT(); tag.putByte("color", (byte) color.getId()); return tag; } - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) public float getRotation() { - List seats = level.getEntitiesOfClass(SeatEntity.class, new AABB(getBlockPos())); + List seats = level.getEntitiesOfClass(SeatEntity.class, new AxisAlignedBB(getBlockPos())); if(!seats.isEmpty()) { SeatEntity seat = seats.get(0); diff --git a/common/src/main/java/com/ultreon/devices/block/entity/PaperBlockEntity.java b/common/src/main/java/com/ultreon/devices/block/entity/PaperBlockEntity.java index ecf569745..de5f052d7 100644 --- a/common/src/main/java/com/ultreon/devices/block/entity/PaperBlockEntity.java +++ b/common/src/main/java/com/ultreon/devices/block/entity/PaperBlockEntity.java @@ -2,13 +2,13 @@ import com.ultreon.devices.api.print.IPrint; import com.ultreon.devices.init.DeviceBlockEntities; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.INBT; import net.minecraft.sounds.SoundEvent; -import net.minecraft.sounds.SoundEvents; -import net.minecraft.sounds.SoundSource; -import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.util.SoundEvents; +import net.minecraft.sounds.SoundCategory; +import net.minecraft.block.BlockState; import javax.annotation.Nullable; @@ -19,8 +19,8 @@ public class PaperBlockEntity extends SyncBlockEntity { private IPrint print; private byte rotation; - public PaperBlockEntity(BlockPos pWorldPosition, BlockState pBlockState) { - super(DeviceBlockEntities.PAPER.get(), pWorldPosition, pBlockState); + public PaperBlockEntity() { + super(DeviceBlockEntities.PAPER.get()); } public void nextRotation() { @@ -43,19 +43,19 @@ public IPrint getPrint() { } @Override - public void load(CompoundTag compound) { - super.load(compound); - if (compound.contains("print", Tag.TAG_COMPOUND)) { + public void load(BlockState state, CompoundNBT compound) { + super.load(state, compound); + if (compound.contains("print", Constants.NBT.TAG_COMPOUND)) { print = IPrint.load(compound.getCompound("print")); } - if (compound.contains("rotation", Tag.TAG_BYTE)) { + if (compound.contains("rotation", Constants.NBT.TAG_BYTE)) { rotation = compound.getByte("rotation"); } } @Override - public void saveAdditional(CompoundTag compound) { - super.saveAdditional(compound); + public void save(CompoundNBT compound) { + super.save(compound); if (print != null) { compound.put("print", IPrint.save(print)); } @@ -63,8 +63,8 @@ public void saveAdditional(CompoundTag compound) { } @Override - public CompoundTag saveSyncTag() { - CompoundTag tag = new CompoundTag(); + public CompoundNBT saveSyncTag() { + CompoundNBT tag = new CompoundNBT(); if (print != null) { tag.put("print", IPrint.save(print)); } @@ -73,6 +73,6 @@ public CompoundTag saveSyncTag() { } private void playSound(SoundEvent sound) { - level.playSound(null, worldPosition, sound, SoundSource.BLOCKS, 1f, 1f); + level.playSound(null, worldPosition, sound, SoundCategory.BLOCKS, 1f, 1f); } } diff --git a/common/src/main/java/com/ultreon/devices/block/entity/PrinterBlockEntity.java b/common/src/main/java/com/ultreon/devices/block/entity/PrinterBlockEntity.java index cfed0e665..fa217b408 100644 --- a/common/src/main/java/com/ultreon/devices/block/entity/PrinterBlockEntity.java +++ b/common/src/main/java/com/ultreon/devices/block/entity/PrinterBlockEntity.java @@ -4,17 +4,17 @@ import com.ultreon.devices.api.print.IPrint; import com.ultreon.devices.init.DeviceBlockEntities; import com.ultreon.devices.init.DeviceSounds; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.nbt.Tag; -import net.minecraft.sounds.SoundEvents; -import net.minecraft.sounds.SoundSource; -import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.Vec3; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.ListNBT; +import net.minecraft.nbt.INBT; +import net.minecraft.util.SoundEvents; +import net.minecraft.sounds.SoundCategory; +import net.minecraft.entity.item.ItemEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.block.BlockState; +import net.minecraft.util.math.Vec3; import org.jetbrains.annotations.NotNull; import java.util.ArrayDeque; @@ -35,8 +35,8 @@ public class PrinterBlockEntity extends NetworkDeviceBlockEntity.Colored { private int remainingPrintTime; private int paperCount = 0; - public PrinterBlockEntity(BlockPos pWorldPosition, BlockState pBlockState) { - super(DeviceBlockEntities.PRINTER.get(), pWorldPosition, pBlockState); + public PrinterBlockEntity() { + super(DeviceBlockEntities.PRINTER.get()); } @Override @@ -48,7 +48,7 @@ public void tick() { pipeline.putInt("remainingPrintTime", remainingPrintTime); sync(); if (remainingPrintTime != 0 && state == PRINTING) { - level.playSound(null, worldPosition, DeviceSounds.PRINTER_PRINTING.get(), SoundSource.BLOCKS, 0.5f, 1f); + level.playSound(null, worldPosition, DeviceSounds.PRINTER_PRINTING.get(), SoundCategory.BLOCKS, 0.5f, 1f); } } remainingPrintTime--; @@ -79,26 +79,26 @@ public String getDeviceName() { } @Override - public void load(@NotNull CompoundTag compound) { - super.load(compound); - if (compound.contains("currentPrint", Tag.TAG_COMPOUND)) { + public void load(BlockState state, @NotNull CompoundNBT compound) { + super.load(state, compound); + if (compound.contains("currentPrint", Constants.NBT.TAG_COMPOUND)) { currentPrint = IPrint.load(compound.getCompound("currentPrint")); } - if (compound.contains("totalPrintTime", Tag.TAG_INT)) { + if (compound.contains("totalPrintTime", Constants.NBT.TAG_INT)) { totalPrintTime = compound.getInt("totalPrintTime"); } - if (compound.contains("remainingPrintTime", Tag.TAG_INT)) { + if (compound.contains("remainingPrintTime", Constants.NBT.TAG_INT)) { remainingPrintTime = compound.getInt("remainingPrintTime"); } - if (compound.contains("state", Tag.TAG_INT)) { + if (compound.contains("state", Constants.NBT.TAG_INT)) { state = State.values()[compound.getInt("state")]; } - if (compound.contains("paperCount", Tag.TAG_INT)) { + if (compound.contains("paperCount", Constants.NBT.TAG_INT)) { paperCount = compound.getInt("paperCount"); } - if (compound.contains("queue", Tag.TAG_LIST)) { + if (compound.contains("queue", Constants.NBT.TAG_LIST)) { printQueue.clear(); - ListTag queue = compound.getList("queue", Tag.TAG_COMPOUND); + ListNBT queue = compound.getList("queue", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < queue.size(); i++) { IPrint print = IPrint.load(queue.getCompound(i)); printQueue.offer(print); @@ -107,8 +107,8 @@ public void load(@NotNull CompoundTag compound) { } @Override - public void saveAdditional(@NotNull CompoundTag tag) { - super.saveAdditional(tag); + public void save(BlockState state, @NotNull CompoundNBT tag) { + super.save(tag); tag.putInt("totalPrintTime", totalPrintTime); tag.putInt("remainingPrintTime", remainingPrintTime); tag.putInt("state", state.ordinal()); @@ -117,15 +117,15 @@ public void saveAdditional(@NotNull CompoundTag tag) { tag.put("currentPrint", IPrint.save(currentPrint)); } if (!printQueue.isEmpty()) { - ListTag queue = new ListTag(); + ListNBT queue = new ListNBT(); printQueue.forEach(print -> queue.add(IPrint.save(print))); tag.put("queue", queue); } } @Override - public CompoundTag saveSyncTag() { - CompoundTag tag = super.saveSyncTag(); + public CompoundNBT saveSyncTag() { + CompoundNBT tag = super.saveSyncTag(); tag.putInt("paperCount", paperCount); return tag; } @@ -157,7 +157,7 @@ public void addToQueue(IPrint print) { private void print(IPrint print) { assert level != null; - level.playSound(null, worldPosition, DeviceSounds.PRINTER_LOADING_PAPER.get(), SoundSource.BLOCKS, 0.5f, 1f); + level.playSound(null, worldPosition, DeviceSounds.PRINTER_LOADING_PAPER.get(), SoundCategory.BLOCKS, 0.5f, 1f); setState(LOADING_PAPER); currentPrint = print; @@ -197,7 +197,7 @@ public boolean addPaper(ItemStack stack, boolean addAll) { pipeline.putInt("paperCount", paperCount); sync(); assert level != null; - level.playSound(null, worldPosition, SoundEvents.ITEM_FRAME_BREAK, SoundSource.BLOCKS, 1f, 1f); + level.playSound(null, worldPosition, SoundEvents.ITEM_FRAME_BREAK, SoundCategory.BLOCKS, 1f, 1f); return true; } return false; diff --git a/common/src/main/java/com/ultreon/devices/block/entity/RouterBlockEntity.java b/common/src/main/java/com/ultreon/devices/block/entity/RouterBlockEntity.java index 9f0d00624..80e221251 100644 --- a/common/src/main/java/com/ultreon/devices/block/entity/RouterBlockEntity.java +++ b/common/src/main/java/com/ultreon/devices/block/entity/RouterBlockEntity.java @@ -2,22 +2,22 @@ import com.ultreon.devices.core.network.Router; import com.ultreon.devices.init.DeviceBlockEntities; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; -import net.minecraft.world.level.block.state.BlockState; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.INBT; +import net.minecraft.block.BlockState; @SuppressWarnings("unused") public class RouterBlockEntity extends DeviceBlockEntity.Colored { private Router router; - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) private int debugTimer; - public RouterBlockEntity(BlockPos pWorldPosition, BlockState pBlockState) { - super(DeviceBlockEntities.ROUTER.get(), pWorldPosition, pBlockState); + public RouterBlockEntity() { + super(DeviceBlockEntities.ROUTER.get()); } public Router getRouter() { @@ -37,12 +37,12 @@ public void tick() { } } - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) public boolean isDebug() { return debugTimer > 0; } - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) public void setDebug(boolean debug) { if (debug) { debugTimer = 1200; @@ -56,9 +56,9 @@ public String getDeviceName() { } @Override - public void saveAdditional(CompoundTag tag) { - super.saveAdditional(tag); - if (tag.contains("router", Tag.TAG_COMPOUND)) { + public void save(CompoundNBT tag) { + super.save(tag); + if (tag.contains("router", Constants.NBT.TAG_COMPOUND)) { router = Router.fromTag(worldPosition, tag.getCompound("router")); } } diff --git a/common/src/main/java/com/ultreon/devices/block/entity/SyncBlockEntity.java b/common/src/main/java/com/ultreon/devices/block/entity/SyncBlockEntity.java index e08ea6d8c..88eb4dfb6 100644 --- a/common/src/main/java/com/ultreon/devices/block/entity/SyncBlockEntity.java +++ b/common/src/main/java/com/ultreon/devices/block/entity/SyncBlockEntity.java @@ -3,26 +3,26 @@ import com.ultreon.devices.annotations.PlatformOverride; import com.ultreon.devices.util.BlockEntityUtil; import dev.architectury.injectables.annotations.PlatformOnly; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.Connection; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.network.NetworkManager; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientGamePacketListener; -import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; -import net.minecraft.world.item.DebugStickItem; -import net.minecraft.world.level.block.DoorBlock; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.network.protocol.game.SUpdateTileEntityPacket; +import net.minecraft.item.DebugStickItem; +import net.minecraft.block.DoorBlock; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityType; +import net.minecraft.block.BlockState; import org.jetbrains.annotations.Nullable; import java.util.Objects; -public abstract class SyncBlockEntity extends BlockEntity { - protected CompoundTag pipeline = new CompoundTag(); +public abstract class SyncBlockEntity extends TileEntity { + protected CompoundNBT pipeline = new CompoundNBT(); - public SyncBlockEntity(BlockEntityType pType, BlockPos pWorldPosition, BlockState pBlockState) { - super(pType, pWorldPosition, pBlockState); + public SyncBlockEntity(TileEntityType pType) { + super(pType); } public void sync() { @@ -36,34 +36,33 @@ protected void markUpdated() { this.level.sendBlockUpdated(this.getBlockPos(), this.getBlockState(), this.getBlockState(), 3); } - @PlatformOnly("forge") @PlatformOverride("forge") - public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) { + public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt) { this.load(Objects.requireNonNull(pkt.getTag(), "The data packet for the block entity contained no data")); } @Override - public CompoundTag getUpdateTag() { + public CompoundNBT getUpdateTag() { if (!pipeline.isEmpty()) { - CompoundTag updateTag = pipeline; - saveAdditional(updateTag); - pipeline = new CompoundTag(); + CompoundNBT updateTag = pipeline; + save(updateTag); + pipeline = new CompoundNBT(); return updateTag; } - CompoundTag updateTag = saveSyncTag(); - super.saveAdditional(updateTag); + CompoundNBT updateTag = saveSyncTag(); + super.save(updateTag); return updateTag; } - public abstract CompoundTag saveSyncTag(); + public abstract CompoundNBT saveSyncTag(); @Nullable @Override public Packet getUpdatePacket() { - return ClientboundBlockEntityDataPacket.create(this, BlockEntity::getUpdateTag); + return SUpdateTileEntityPacket.create(this, TileEntity::getUpdateTag); } - public CompoundTag getPipeline() { + public CompoundNBT getPipeline() { return pipeline; } } diff --git a/common/src/main/java/com/ultreon/devices/block/entity/renderer/LaptopRenderer.java b/common/src/main/java/com/ultreon/devices/block/entity/renderer/LaptopRenderer.java index d5262ad9c..4b7c2acfd 100644 --- a/common/src/main/java/com/ultreon/devices/block/entity/renderer/LaptopRenderer.java +++ b/common/src/main/java/com/ultreon/devices/block/entity/renderer/LaptopRenderer.java @@ -1,37 +1,36 @@ package com.ultreon.devices.block.entity.renderer; -import com.mojang.blaze3d.platform.Lighting; +import net.minecraft.client.renderer.RenderHelper; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Quaternion; -import com.mojang.math.Vector3f; +import com.mojang.blaze3d.matrix.MatrixStack; +import net.minecraft.util.math.vector.Quaternion; +import net.minecraft.util.math.vector.Vector3f; import com.ultreon.devices.block.LaptopBlock; import com.ultreon.devices.block.entity.LaptopBlockEntity; import com.ultreon.devices.core.laptop.client.ClientLaptop; import com.ultreon.devices.init.DeviceItems; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.block.BlockRenderDispatcher; -import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; -import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; -import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.inventory.InventoryMenu; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.BlockRendererDispatcher; +import net.minecraft.client.renderer.tileentity.TileEntityRenderer; +import net.minecraft.client.renderer.model.IBakedModel; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.Direction; +import net.minecraft.entity.item.ItemEntity; +import net.minecraft.inventory.container.PlayerContainer; +import net.minecraft.item.ItemStack; +import net.minecraft.block.BlockState; -public class LaptopRenderer implements BlockEntityRenderer { - private final BlockEntityRendererProvider.Context context; +public class LaptopRenderer extends TileEntityRenderer { + private final TileEntityRendererProvider.Context context; private final Minecraft mc = Minecraft.getInstance(); - public LaptopRenderer(BlockEntityRendererProvider.Context context) { + public LaptopRenderer() { this.context = context; } @Override - public void render(LaptopBlockEntity blockEntity, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight, int packedOverlay) { + public void render(LaptopBlockEntity blockEntity, float partialTick, MatrixStack matrices, IRenderTypeBuffer bufferSource, int packedLight, int packedOverlay) { // poseStack.pushPose(); // RenderSystem.depthMask(true); // poseStack.scale(0.005f, 0.005f, -1.0f); @@ -45,8 +44,8 @@ public void render(LaptopBlockEntity blockEntity, float partialTick, PoseStack p BlockState state = blockEntity.getBlock().defaultBlockState().setValue(LaptopBlock.TYPE, LaptopBlock.Type.SCREEN); BlockPos pos = blockEntity.getBlockPos(); - RenderSystem.setShaderTexture(0, InventoryMenu.BLOCK_ATLAS); - poseStack.pushPose(); + mc.textureManager.bind(PlayerContainer.BLOCK_ATLAS); + matrices.pushPose(); int x = blockEntity.getBlockPos().getX(); int y = blockEntity.getBlockPos().getY(); @@ -56,52 +55,52 @@ public void render(LaptopBlockEntity blockEntity, float partialTick, PoseStack p //poseStack.translate(x, y, z); if (blockEntity.isExternalDriveAttached()) { - poseStack.pushPose(); + matrices.pushPose(); { - poseStack.translate(0.5, 0, 0.5); - poseStack.mulPose(blockEntity.getBlockState().getValue(LaptopBlock.FACING).getRotation()); - poseStack.translate(-0.5, 0, -0.5); - poseStack.translate(0.595, -0.2075, -0.005); + matrices.translate(0.5, 0, 0.5); + matrices.mulPose(blockEntity.getBlockState().getValue(LaptopBlock.FACING).getRotation()); + matrices.translate(-0.5, 0, -0.5); + matrices.translate(0.595, -0.2075, -0.005); entityItem.flyDist = 0.0F; assert DeviceItems.getFlashDriveByColor(blockEntity.getExternalDriveColor()) != null; entityItem.setItem(new ItemStack(DeviceItems.getFlashDriveByColor(blockEntity.getExternalDriveColor()), 1/*, blockEntity.getExternalDriveColor().*/)); - Minecraft.getInstance().levelRenderer.renderEntity(entityItem, 0.0D, 0.0D, 0.0D, 0.0F, poseStack, bufferSource/*, 0.0F, false*/); - poseStack.translate(0.1, 0, 0); + Minecraft.getInstance().levelRenderer.renderEntity(entityItem, 0.0D, 0.0D, 0.0D, 0.0F, matrices, bufferSource/*, 0.0F, false*/); + matrices.translate(0.1, 0, 0); } - poseStack.popPose(); + matrices.popPose(); } - poseStack.pushPose(); + matrices.pushPose(); { //System.out.println("RENDEEING"); - poseStack.translate(0.5, 0, 0.5);//west/east +90 north/south -90 - poseStack.mulPose(Vector3f.YP.rotationDegrees(blockEntity.getBlockState().getValue(LaptopBlock.FACING) == Direction.EAST || blockEntity.getBlockState().getValue(LaptopBlock.FACING) == Direction.WEST ? direction + 90 : direction - 90)); - poseStack.translate(-0.5, 0, -0.5); - poseStack.translate(0, 0.0625, 0.25); - poseStack.mulPose(Quaternion.fromXYZDegrees(new Vector3f(blockEntity.getScreenAngle(partialTick) + 180, 0, 0))); + matrices.translate(0.5, 0, 0.5);//west/east +90 north/south -90 + matrices.mulPose(Vector3f.YP.rotationDegrees(blockEntity.getBlockState().getValue(LaptopBlock.FACING) == Direction.EAST || blockEntity.getBlockState().getValue(LaptopBlock.FACING) == Direction.WEST ? direction + 90 : direction - 90)); + matrices.translate(-0.5, 0, -0.5); + matrices.translate(0, 0.0625, 0.25); + matrices.mulPose(Quaternion.fromXYZDegrees(new Vector3f(blockEntity.getScreenAngle(partialTick) + 180, 0, 0))); //poseStack.mulPose(Vector3f.YP.rotationDegrees(180)); - poseStack.mulPose(Vector3f.XP.rotationDegrees(180)); - Lighting.setupForFlatItems(); + matrices.mulPose(Vector3f.XP.rotationDegrees(180)); + RenderHelper.setupForFlatItems(); // Tesselator tessellator = Tesselator.getInstance(); //BufferBuilder buffer = tessellator.getBuilder(); //buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK); // poseStack.pushPose(); //poseStack.translate(-pos.getX(), -pos.getY(), -pos.getZ()); - BlockRenderDispatcher blockrendererdispatcher = Minecraft.getInstance().getBlockRenderer(); - BakedModel ibakedmodel = mc.getBlockRenderer().getBlockModel(state); - poseStack.pushPose(); + BlockRendererDispatcher blockrendererdispatcher = Minecraft.getInstance().getBlockRenderer(); + IBakedModel ibakedmodel = mc.getBlockRenderer().getBlockModel(state); + matrices.pushPose(); //poseStack.mulPose(Vector3f.ZP.rotationDegrees(180)); //poseStack.mulPose(Vector3f.XP.rotationDegrees(180)); //poseStack.mulPose(Vector3f.ZP.rotationDegrees(180)); - blockrendererdispatcher.renderSingleBlock(state, poseStack, bufferSource, packedLight, packedOverlay);//.renderModel(poseStack.last(), bufferSource.getBuffer(RenderType.cutout()), state, ibakedmodel, 1, 1, 1, packedLight, packedOverlay); - poseStack.popPose(); + blockrendererdispatcher.renderSingleBlock(state, matrices, bufferSource, packedLight, packedOverlay);//.renderModel(poseStack.last(), bufferSource.getBuffer(RenderType.cutout()), state, ibakedmodel, 1, 1, 1, packedLight, packedOverlay); + matrices.popPose(); //poseStack.popPose(); // tessellator.end(); - Lighting.setupFor3DItems(); + RenderHelper.setupFor3DItems(); } - poseStack.popPose(); + matrices.popPose(); } - poseStack.popPose(); + matrices.popPose(); } } \ No newline at end of file diff --git a/common/src/main/java/com/ultreon/devices/block/entity/renderer/OfficeChairRenderer.java b/common/src/main/java/com/ultreon/devices/block/entity/renderer/OfficeChairRenderer.java index 890e11fec..ef27e633f 100644 --- a/common/src/main/java/com/ultreon/devices/block/entity/renderer/OfficeChairRenderer.java +++ b/common/src/main/java/com/ultreon/devices/block/entity/renderer/OfficeChairRenderer.java @@ -1,33 +1,32 @@ package com.ultreon.devices.block.entity.renderer; import com.mojang.blaze3d.platform.GlStateManager; -import com.mojang.blaze3d.platform.Lighting; +import net.minecraft.client.renderer.RenderHelper; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Quaternion; -import com.mojang.math.Vector3f; +import com.mojang.blaze3d.matrix.MatrixStack; +import net.minecraft.util.math.vector.Quaternion; +import net.minecraft.util.math.vector.Vector3f; import com.ultreon.devices.block.OfficeChairBlock; import com.ultreon.devices.block.entity.OfficeChairBlockEntity; import com.ultreon.devices.init.DeviceBlocks; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.block.BlockRenderDispatcher; -import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; -import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.inventory.InventoryMenu; -import net.minecraft.world.level.block.state.BlockState; - -public class OfficeChairRenderer implements BlockEntityRenderer { +import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.BlockRendererDispatcher; +import net.minecraft.client.renderer.tileentity.TileEntityRenderer; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.Direction; +import net.minecraft.inventory.container.PlayerContainer; +import net.minecraft.block.BlockState; + +public class OfficeChairRenderer extends TileEntityRenderer { private Minecraft mc = Minecraft.getInstance(); - public OfficeChairRenderer(BlockEntityRendererProvider.Context context) { + public OfficeChairRenderer() { } @Override - public void render(OfficeChairBlockEntity blockEntity, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight, int packedOverlay) + public void render(OfficeChairBlockEntity blockEntity, float partialTick, MatrixStack matrices, IRenderTypeBuffer bufferSource, int packedLight, int packedOverlay) { BlockPos pos = blockEntity.getBlockPos(); BlockState tempState = blockEntity.getLevel().getBlockState(pos); @@ -40,20 +39,20 @@ public void render(OfficeChairBlockEntity blockEntity, float partialTick, PoseSt var y = pos.getY(); var z = pos.getZ(); - poseStack.pushPose(); + matrices.pushPose(); { // poseStack.translate(x, y, z); - poseStack.translate(0.5, 0, 0.5); - poseStack.mulPose(Quaternion.fromXYZDegrees(new Vector3f(0, -blockEntity.getRotation()+180, 0))); - poseStack.translate(-0.5, 0, -0.5); + matrices.translate(0.5, 0, 0.5); + matrices.mulPose(Quaternion.fromXYZDegrees(new Vector3f(0, -blockEntity.getRotation()+180, 0))); + matrices.translate(-0.5, 0, -0.5); BlockState state = tempState.setValue(OfficeChairBlock.FACING, Direction.NORTH).setValue(OfficeChairBlock.TYPE, OfficeChairBlock.Type.SEAT); - Lighting.setupForFlatItems(); + RenderHelper.setupForFlatItems(); //GlStateManager.enableTexture2D(); - RenderSystem.setShaderTexture(0, InventoryMenu.BLOCK_ATLAS); + mc.textureManager.bind(PlayerContainer.BLOCK_ATLAS); //Tessellator tessellator = Tessellator.getInstance(); @@ -61,12 +60,12 @@ public void render(OfficeChairBlockEntity blockEntity, float partialTick, PoseSt //buffer.begin(7, DefaultVertexFormats.BLOCK); //buffer.setTranslation(-te.getPos().getX(), -te.getPos().getY(), -te.getPos().getZ()); - BlockRenderDispatcher blockrendererdispatcher = Minecraft.getInstance().getBlockRenderer(); - blockrendererdispatcher.renderSingleBlock(state, poseStack, bufferSource, packedLight, packedOverlay); + BlockRendererDispatcher blockrendererdispatcher = Minecraft.getInstance().getBlockRenderer(); + blockrendererdispatcher.renderSingleBlock(state, matrices, bufferSource, packedLight, packedOverlay); - Lighting.setupFor3DItems(); + RenderHelper.setupFor3DItems(); } - poseStack.popPose(); + matrices.popPose(); } } \ No newline at end of file diff --git a/common/src/main/java/com/ultreon/devices/block/entity/renderer/PaperRenderer.java b/common/src/main/java/com/ultreon/devices/block/entity/renderer/PaperRenderer.java index fadceb526..efa8b0d11 100644 --- a/common/src/main/java/com/ultreon/devices/block/entity/renderer/PaperRenderer.java +++ b/common/src/main/java/com/ultreon/devices/block/entity/renderer/PaperRenderer.java @@ -1,9 +1,9 @@ package com.ultreon.devices.block.entity.renderer; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.*; -import com.mojang.math.Matrix4f; -import com.mojang.math.Quaternion; +import com.mojang.blaze3d.matrix.*; +import net.minecraft.util.math.vector.Matrix4f; +import net.minecraft.util.math.vector.Quaternion; import com.ultreon.devices.DeviceConfig; import com.ultreon.devices.Devices; import com.ultreon.devices.api.print.IPrint; @@ -12,17 +12,16 @@ import com.ultreon.devices.block.entity.PaperBlockEntity; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.MapRenderer; -import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; -import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; +import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.entity.ItemFrameRenderer; import net.minecraft.client.renderer.texture.DynamicTexture; -import net.minecraft.core.Direction; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.util.Direction; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.INBT; +import net.minecraft.util.ResourceLocation; +import net.minecraft.block.BlockState; import org.jetbrains.annotations.NotNull; import java.awt.*; @@ -32,10 +31,10 @@ * @author MrCrayfish */ public record PaperRenderer( - BlockEntityRendererProvider.Context context) implements BlockEntityRenderer { + TileEntityRendererProvider.Context context) extends TileEntityRenderer { @SuppressWarnings("SameParameterValue") - private static void drawCuboid(double x, double y, double z, double width, double height, double depth, MultiBufferSource bufferSource) { + private static void drawCuboid(double x, double y, double z, double width, double height, double depth, IRenderTypeBuffer bufferSource) { x /= 16; y /= 16; z /= 16; @@ -55,7 +54,7 @@ private static void drawCuboid(double x, double y, double z, double width, doubl // GlStateManager.enableLighting(); } - private static void drawQuad(double xFrom, double yFrom, double zFrom, double xTo, double yTo, double zTo, Direction direction, MultiBufferSource bufferSource) { + private static void drawQuad(double xFrom, double yFrom, double zFrom, double xTo, double yTo, double zTo, Direction direction, IRenderTypeBuffer bufferSource) { double textureWidth = Math.abs(xTo - xFrom); double textureHeight = Math.abs(yTo - yFrom); double textureDepth = Math.abs(zTo - zFrom); @@ -64,7 +63,7 @@ private static void drawQuad(double xFrom, double yFrom, double zFrom, double xT } private static long AA = 0; - private static void drawPixels(PoseStack poseStack, int[] pixels, int resolution, boolean cut, int packedLight, MultiBufferSource bufferSource) { + private static void drawPixels(MatrixStack matrices, int[] pixels, int resolution, boolean cut, int packedLight, IRenderTypeBuffer bufferSource) { double scale = 16 / (double) resolution; var d = new DynamicTexture(resolution, resolution, true); for (int i = 0; i < resolution; i++) { @@ -79,7 +78,7 @@ private static void drawPixels(PoseStack poseStack, int[] pixels, int resolution } } ResourceLocation resourcelocation = Minecraft.getInstance().getTextureManager().register("map/" + AA, d); - Matrix4f matrix4f = poseStack.last().pose(); + Matrix4f matrix4f = matrices.last().pose(); var vertexconsumer = bufferSource.getBuffer(RenderType.text(resourcelocation)); vertexconsumer.vertex(matrix4f, 0.0f, 128.0f, -0.01f).color(255, 255, 255, 255).uv(0.0f, 1.0f).uv2(packedLight).endVertex(); vertexconsumer.vertex(matrix4f, 128.0f, 128.0f, -0.01f).color(255, 255, 255, 255).uv(1.0f, 1.0f).uv2(packedLight).endVertex(); @@ -89,7 +88,7 @@ private static void drawPixels(PoseStack poseStack, int[] pixels, int resolution } @Override - public void render(PaperBlockEntity blockEntity, float partialTick, @NotNull PoseStack pose, @NotNull MultiBufferSource bufferSource, int packedLight, int packedOverlay) { + public void render(PaperBlockEntity blockEntity, float partialTick, @NotNull MatrixStack pose, @NotNull IRenderTypeBuffer bufferSource, int packedLight, int packedOverlay) { BlockState state = Objects.requireNonNull(blockEntity.getLevel()).getBlockState(blockEntity.getBlockPos()); if (blockEntity.getBlockState().getBlock() != state.getBlock()) { Devices.LOGGER.error("Paper block mismatch: {} != {}", blockEntity.getBlockState().getBlock(), state.getBlock()); @@ -106,9 +105,9 @@ public void render(PaperBlockEntity blockEntity, float partialTick, @NotNull Pos IPrint print = blockEntity.getPrint(); if (print != null) { - CompoundTag data = print.toTag(); - if (data.contains("pixels", Tag.TAG_INT_ARRAY) && data.contains("resolution", Tag.TAG_INT)) { - RenderSystem.setShaderTexture(0, PrinterRenderer.PaperModel.TEXTURE); + CompoundNBT data = print.toTag(); + if (data.contains("pixels", Constants.NBT.TAG_INT_ARRAY) && data.contains("resolution", Constants.NBT.TAG_INT)) { + mc.textureManager.bind(PrinterRenderer.PaperModel.TEXTURE); if (DeviceConfig.RENDER_PRINTED_3D.get() && !data.getBoolean("cut")) { // drawCuboid(0, 0, 0, 16, 16, 1, bufferSource); } @@ -125,7 +124,7 @@ public void render(PaperBlockEntity blockEntity, float partialTick, @NotNull Pos pose.pushPose(); { if (DeviceConfig.RENDER_PRINTED_3D.get() && data.getBoolean("cut")) { - CompoundTag tag = print.toTag(); + CompoundNBT tag = print.toTag(); drawPixels(pose, tag.getIntArray("pixels"), tag.getInt("resolution"), tag.getBoolean("cut"), packedLight, bufferSource); } } diff --git a/common/src/main/java/com/ultreon/devices/block/entity/renderer/PrinterRenderer.java b/common/src/main/java/com/ultreon/devices/block/entity/renderer/PrinterRenderer.java index 57f3da875..bdede1b67 100644 --- a/common/src/main/java/com/ultreon/devices/block/entity/renderer/PrinterRenderer.java +++ b/common/src/main/java/com/ultreon/devices/block/entity/renderer/PrinterRenderer.java @@ -1,11 +1,11 @@ package com.ultreon.devices.block.entity.renderer; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.BufferBuilder; -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Quaternion; -import com.mojang.math.Vector3f; +import com.mojang.blaze3d.matrix.BufferBuilder; +import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.matrix.VertexConsumer; +import net.minecraft.util.math.vector.Quaternion; +import net.minecraft.util.math.vector.Vector3f; import com.ultreon.devices.Devices; import com.ultreon.devices.Reference; import com.ultreon.devices.block.PrinterBlock; @@ -13,20 +13,19 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.model.Model; import net.minecraft.client.model.geom.ModelLayerLocation; -import net.minecraft.client.model.geom.ModelPart; +import net.minecraft.client.model.geom.ModelRenderer; import net.minecraft.client.model.geom.PartPose; import net.minecraft.client.model.geom.builders.CubeListBuilder; import net.minecraft.client.model.geom.builders.LayerDefinition; import net.minecraft.client.model.geom.builders.MeshDefinition; import net.minecraft.client.model.geom.builders.PartDefinition; -import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; -import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; -import net.minecraft.client.renderer.blockentity.SignRenderer; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.client.renderer.tileentity.TileEntityRenderer; +import net.minecraft.client.renderer.tileentity.SignRenderer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.block.Blocks; +import net.minecraft.block.BlockState; import org.jetbrains.annotations.NotNull; import java.awt.*; @@ -36,9 +35,9 @@ * @author MrCrayfish */ public record PrinterRenderer( - BlockEntityRendererProvider.Context context) implements BlockEntityRenderer { + TileEntityRendererProvider.Context context) extends TileEntityRenderer { @Override - public void render(PrinterBlockEntity blockEntity, float partialTick, @NotNull PoseStack pose, @NotNull MultiBufferSource bufferSource, int packedLight, int packedOverlay) { + public void render(PrinterBlockEntity blockEntity, float partialTick, @NotNull MatrixStack pose, @NotNull IRenderTypeBuffer bufferSource, int packedLight, int packedOverlay) { // PaperModel paperModel = new PaperModel(Minecraft.getInstance().getEntityModels().bakeLayer(PaperModel.LAYER_LOCATION)); // // // Tesselator tesselator = Tesselator.getInstance(); @@ -158,12 +157,12 @@ public void render(PrinterBlockEntity blockEntity, float partialTick, @NotNull P public static class PaperModel extends Model { public static final ResourceLocation TEXTURE = new ResourceLocation(Reference.MOD_ID, "textures/model/paper.png"); public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(Devices.id("paper_model"), "main"); - private final ModelPart root; + private final ModelRenderer root; // private final ModelPart main; // private final ModelRenderer box = new ModelRenderer(this, 0, 0).addBox(0, 0, 0, 22, 30, 1); - public PaperModel(ModelPart pRoot) { + public PaperModel(ModelRenderer pRoot) { super(RenderType::entitySolid); this.root = pRoot; // this.main = pRoot.getChild("main"); @@ -177,13 +176,13 @@ public static LayerDefinition createBodyLayer() { } @Override - public void renderToBuffer(@NotNull PoseStack pPoseStack, @NotNull VertexConsumer pBuffer, int pPackedLight, int pPackedOverlay, float pRed, float pGreen, float pBlue, float pAlpha) { - this.render(pPoseStack, pBuffer, pPackedLight, pPackedOverlay, pRed, pGreen, pBlue, pAlpha); + public void renderToBuffer(@NotNull MatrixStack pMatrixStack, @NotNull VertexConsumer pBuffer, int pPackedLight, int pPackedOverlay, float pRed, float pGreen, float pBlue, float pAlpha) { + this.render(pMatrixStack, pBuffer, pPackedLight, pPackedOverlay, pRed, pGreen, pBlue, pAlpha); } - private void render(PoseStack pPoseStack, VertexConsumer pBuffer, int pPackedLight, int pPackedOverlay, float pRed, float pGreen, float pBlue, float pAlpha) { - RenderSystem.setShaderTexture(0, TEXTURE); - this.root.render(pPoseStack, pBuffer, pPackedLight, pPackedOverlay, pRed, pGreen, pBlue, pAlpha); + private void render(MatrixStack pMatrixStack, VertexConsumer pBuffer, int pPackedLight, int pPackedOverlay, float pRed, float pGreen, float pBlue, float pAlpha) { + mc.textureManager.bind(TEXTURE); + this.root.render(pMatrixStack, pBuffer, pPackedLight, pPackedOverlay, pRed, pGreen, pBlue, pAlpha); } // public ModelPart getMain() { diff --git a/common/src/main/java/com/ultreon/devices/block/entity/renderer/RouterRenderer.java b/common/src/main/java/com/ultreon/devices/block/entity/renderer/RouterRenderer.java index 2b8c0e20c..516fb36ab 100644 --- a/common/src/main/java/com/ultreon/devices/block/entity/renderer/RouterRenderer.java +++ b/common/src/main/java/com/ultreon/devices/block/entity/renderer/RouterRenderer.java @@ -1,21 +1,20 @@ package com.ultreon.devices.block.entity.renderer; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.*; -import com.mojang.math.Quaternion; -import com.mojang.math.Vector3f; +import com.mojang.blaze3d.matrix.*; +import net.minecraft.util.math.vector.Quaternion; +import net.minecraft.util.math.vector.Vector3f; import com.ultreon.devices.block.PrinterBlock; import com.ultreon.devices.block.RouterBlock; import com.ultreon.devices.block.entity.RouterBlockEntity; import com.ultreon.devices.core.network.NetworkDevice; import com.ultreon.devices.core.network.Router; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; -import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.Vec3; +import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.tileentity.TileEntityRenderer; +import net.minecraft.util.math.BlockPos; +import net.minecraft.block.BlockState; +import net.minecraft.util.math.Vec3; import org.jetbrains.annotations.NotNull; import java.util.Collection; @@ -25,10 +24,10 @@ * @author MrCrayfish */ public record RouterRenderer( - BlockEntityRendererProvider.Context context) implements BlockEntityRenderer { + TileEntityRendererProvider.Context context) extends TileEntityRenderer { @Override - public void render(RouterBlockEntity blockEntity, float partialTick, @NotNull PoseStack pose, @NotNull MultiBufferSource bufferSource, int packedLight, int packedOverlay) { + public void render(RouterBlockEntity blockEntity, float partialTick, @NotNull MatrixStack pose, @NotNull IRenderTypeBuffer bufferSource, int packedLight, int packedOverlay) { BlockState state = Objects.requireNonNull(blockEntity.getLevel()).getBlockState(blockEntity.getBlockPos()); if (state.getBlock() != blockEntity.getBlock()) return; @@ -49,23 +48,23 @@ public void render(RouterBlockEntity blockEntity, float partialTick, @NotNull Po final double startLineY = linePositions.y; final double startLineZ = linePositions.z; - Tesselator tesselator = Tesselator.getInstance(); + Tessellator tesselator = Tessellator.getInstance(); BufferBuilder buffer = tesselator.getBuilder(); final Collection DEVICES = router.getConnectedDevices(Minecraft.getInstance().level); DEVICES.forEach(networkDevice -> { BlockPos devicePos = networkDevice.getPos(); - Objects.requireNonNull(devicePos, "Connection device has no position, weird."); + Objects.requireNonNull(devicePos, "NetworkManager device has no position, weird."); RenderSystem.lineWidth(14F); - buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); + buffer.begin(GL20.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); buffer.vertex(startLineX, startLineY, startLineZ).color(0f, 0f, 0f, 0.5f).endVertex(); buffer.vertex((devicePos.getX() - routerPos.getX()) + 0.5f, (devicePos.getY() - routerPos.getY()), (devicePos.getZ() - routerPos.getZ()) + 0.5f).color(1f, 1f, 1f, 0.35f).endVertex(); tesselator.end(); RenderSystem.lineWidth(4F); - buffer.begin(VertexFormat.Mode.LINES, DefaultVertexFormat.POSITION_COLOR); + buffer.begin(GL20.GL_LINES, DefaultVertexFormats.POSITION_COLOR); buffer.vertex(startLineX, startLineY, startLineZ).color(0f, 0f, 0f, 0.5f).endVertex(); buffer.vertex((devicePos.getX() - routerPos.getX()) + 0.5f, (devicePos.getY() - routerPos.getY()), (devicePos.getZ() - routerPos.getZ()) + 0.5f).color(0f, 1f, 0f, 0.5f).endVertex(); tesselator.end(); diff --git a/common/src/main/java/com/ultreon/devices/core/Device.java b/common/src/main/java/com/ultreon/devices/core/Device.java index e88959586..780798d0f 100644 --- a/common/src/main/java/com/ultreon/devices/core/Device.java +++ b/common/src/main/java/com/ultreon/devices/core/Device.java @@ -1,11 +1,11 @@ package com.ultreon.devices.core; import com.ultreon.devices.block.entity.DeviceBlockEntity; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.INBT; +import net.minecraft.world.World; +import net.minecraft.tileentity.TileEntity; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -55,11 +55,11 @@ public void update(@NotNull DeviceBlockEntity device) { } @Nullable - public DeviceBlockEntity getDevice(@NotNull Level level) { + public DeviceBlockEntity getDevice(@NotNull World level) { if (pos == null) return null; - BlockEntity blockEntity = level.getBlockEntity(pos); + TileEntity blockEntity = level.getBlockEntity(pos); if (blockEntity instanceof DeviceBlockEntity deviceBlockEntity) { if (deviceBlockEntity.getId().equals(getId())) { return deviceBlockEntity; @@ -69,8 +69,8 @@ public DeviceBlockEntity getDevice(@NotNull Level level) { return null; } - public CompoundTag toTag(boolean includePos) { - CompoundTag tag = new CompoundTag(); + public CompoundNBT toTag(boolean includePos) { + CompoundNBT tag = new CompoundNBT(); tag.putString("id", getId().toString()); tag.putString("name", getName()); if (includePos) { @@ -79,11 +79,11 @@ public CompoundTag toTag(boolean includePos) { return tag; } - public static Device fromTag(CompoundTag tag) { + public static Device fromTag(CompoundNBT tag) { Device device = new Device(); device.id = UUID.fromString(tag.getString("id")); device.name = tag.getString("name"); - if (tag.contains("pos", Tag.TAG_LONG)) { + if (tag.contains("pos", Constants.NBT.TAG_LONG)) { device.pos = BlockPos.of(tag.getLong("pos")); } return device; diff --git a/common/src/main/java/com/ultreon/devices/core/Laptop.java b/common/src/main/java/com/ultreon/devices/core/Laptop.java index 9fa42e525..d489784f4 100644 --- a/common/src/main/java/com/ultreon/devices/core/Laptop.java +++ b/common/src/main/java/com/ultreon/devices/core/Laptop.java @@ -2,7 +2,7 @@ import com.google.common.collect.ImmutableList; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.Devices; import com.ultreon.devices.Reference; import com.ultreon.devices.api.ApplicationManager; @@ -28,21 +28,21 @@ import it.unimi.dsi.fastutil.Pair; import it.unimi.dsi.fastutil.ints.IntArraySet; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.IngameGui; import net.minecraft.client.gui.screens.Screen; -import net.minecraft.client.resources.sounds.SimpleSoundInstance; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.nbt.StringTag; -import net.minecraft.nbt.Tag; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.FormattedText; -import net.minecraft.network.chat.Style; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.sounds.SoundEvents; +import net.minecraft.client.audio.SimpleSound; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.ListNBT; +import net.minecraft.nbt.StringNBT; +import net.minecraft.nbt.INBT; +import net.minecraft.util.text.Component; +import net.minecraft.util.text.ITextProperties; +import net.minecraft.util.text.Style; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.SoundEvents; import org.jetbrains.annotations.NotNull; import javax.annotation.Nullable; @@ -65,7 +65,7 @@ public class Laptop extends Screen implements System { public static final ResourceLocation ICON_TEXTURES = new ResourceLocation(Reference.MOD_ID, "textures/atlas/app_icons.png"); public static final int ICON_SIZE = 14; private static final ResourceLocation LAPTOP_FONT = Devices.res("laptop"); - private static Font font; + private static FontRenderer font; private static final ResourceLocation LAPTOP_GUI = new ResourceLocation(Reference.MOD_ID, "textures/gui/laptop.png"); private static final List APPLICATIONS = new ArrayList<>(); private static boolean worldLess; @@ -94,8 +94,8 @@ public static List getWallpapers() { private final Settings settings; private final TaskBar bar; final ArrayList> windows; - private final CompoundTag appData; - private final CompoundTag systemData; + private final CompoundNBT appData; + private final CompoundNBT systemData; protected List installedApps = new ArrayList<>(); private Layout context = null; private Wallpaper currentWallpaper; @@ -106,7 +106,7 @@ public static List getWallpapers() { private final Layout wallpaperLayout; private BSOD bsod; - public static Font getFont() { + public static FontRenderer getFont() { if (font == null) { font = Minecraft.getInstance().font; } @@ -128,7 +128,7 @@ public Laptop(LaptopBlockEntity laptop) { * @param laptop the block entity of the laptop in-game, if the laptop is not in-game, the level passed to it should be null. */ public Laptop(LaptopBlockEntity laptop, boolean worldLess) { - super(new TextComponent("Laptop")); + super(new StringTextComponent("Laptop")); instance = this; @@ -240,7 +240,7 @@ public void init() { bar.init(posX + BORDER, posY + DEVICE_HEIGHT - 28); installedApps.clear(); - ListTag list = systemData.getList("InstalledApps", Tag.TAG_STRING); + ListNBT list = systemData.getList("InstalledApps", Constants.NBT.TAG_STRING); for (int i = 0; i < list.size(); i++) { AppInfo info = ApplicationManager.getApplication(list.getString(i)); if (info != null) { @@ -278,8 +278,8 @@ private void updateSystemData() { systemData.put("CurrentWallpaper", currentWallpaper.serialize()); systemData.put("Settings", settings.toTag()); - ListTag tagListApps = new ListTag(); - installedApps.forEach(info -> tagListApps.add(StringTag.valueOf(info.getFormattedId()))); + ListNBT tagListApps = new ListNBT(); + installedApps.forEach(info -> tagListApps.add(StringNBT.valueOf(info.getFormattedId()))); systemData.put("InstalledApps", tagListApps); TaskManager.sendTask(new TaskUpdateSystemData(pos, systemData)); @@ -329,13 +329,13 @@ public void tick() { } @Override - public void render(final @NotNull PoseStack pose, final int mouseX, final int mouseY, float partialTicks) { + public void render(final @NotNull MatrixStack pose, final int mouseX, final int mouseY, float partialTicks) { if (bsod != null) { renderBsod(pose, mouseX, mouseY, partialTicks); return; } - PoseStack.Pose last = pose.last(); + MatrixStack.Entry last = pose.last(); try { renderLaptop(pose, mouseX, mouseY, partialTicks); @@ -354,11 +354,11 @@ public void render(final @NotNull PoseStack pose, final int mouseX, final int mo } } - public void renderBsod(final @NotNull PoseStack pose, final int mouseX, final int mouseY, float partialTicks) { + public void renderBsod(final @NotNull MatrixStack pose, final int mouseX, final int mouseY, float partialTicks) { renderBezels(pose, mouseX, mouseY, partialTicks); int posX = (width - DEVICE_WIDTH) / 2; int posY = (height - DEVICE_HEIGHT) / 2; - Gui.fill(pose, posX+10, posY+10, posX + DEVICE_WIDTH-10, posY + DEVICE_HEIGHT-10, new Color(0, 0, 255).getRGB()); + IngameGui.fill(pose, posX+10, posY+10, posX + DEVICE_WIDTH-10, posY + DEVICE_HEIGHT-10, new Color(0, 0, 255).getRGB()); var bo = new ByteArrayOutputStream(); double scale = Minecraft.getInstance().getWindow().getGuiScale(); @@ -374,32 +374,32 @@ public void renderBsod(final @NotNull PoseStack pose, final int mouseX, final in pose.popPose(); } - public static void drawLines(PoseStack poseStack, Font font, String text, int x, int y, int width, int color) { + public static void drawLines(MatrixStack matrices, FontRenderer font, String text, int x, int y, int width, int color) { var lines = new ArrayList(); - font.getSplitter().splitLines(FormattedText.of(text.replaceAll("\r\n", "\n").replaceAll("\r", "\n")), width, Style.EMPTY).forEach(b -> lines.add(b.getString())); + font.getSplitter().splitLines(ITextProperties.of(text.replaceAll("\r\n", "\n").replaceAll("\r", "\n")), width, Style.EMPTY).forEach(b -> lines.add(b.getString())); var totalTextHeight = font.lineHeight*lines.size(); var textScale = (DEVICE_HEIGHT-20-(getFont().lineHeight*2))/(float)totalTextHeight; textScale = (float) (1f / Minecraft.getInstance().getWindow().getGuiScale()); textScale = Math.max(0.5f, textScale); - poseStack.pushPose(); - poseStack.scale(textScale, textScale, 1); - poseStack.translate(x / textScale, (y+3)/textScale, 0); + matrices.pushPose(); + matrices.scale(textScale, textScale, 1); + matrices.translate(x / textScale, (y+3)/textScale, 0); //poseStack.translate(); var lineNr = 0; for (String s : lines) { - font.draw(poseStack, s.replaceAll("\t", " "), (float)0, (float)0+(lineNr*font.lineHeight), color); + font.draw(matrices, s.replaceAll("\t", " "), (float)0, (float)0+(lineNr*font.lineHeight), color); lineNr++; } - poseStack.popPose(); + matrices.popPose(); } - public void renderBezels(final @NotNull PoseStack pose, final int mouseX, final int mouseY, float partialTicks) { + public void renderBezels(final @NotNull MatrixStack pose, final int mouseX, final int mouseY, float partialTicks) { tasks.clear(); this.renderBackground(pose); - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); - RenderSystem.setShaderTexture(0, LAPTOP_GUI); + RenderSystem.blendColor(1f, 1f, 1f, 1f); + mc.textureManager.bind(LAPTOP_GUI); //*************************// // Physical Screen // @@ -414,13 +414,13 @@ public void renderBezels(final @NotNull PoseStack pose, final int mouseX, final blit(pose, posX, posY + DEVICE_HEIGHT - BORDER, 0, 11, BORDER, BORDER); // BOTTOM-LEFT // Edges - Gui.blit(pose, posX + BORDER, posY, SCREEN_WIDTH, BORDER, 10, 0, 1, BORDER, 256, 256); // TOP - Gui.blit(pose, posX + DEVICE_WIDTH - BORDER, posY + BORDER, BORDER, SCREEN_HEIGHT, 11, 10, BORDER, 1, 256, 256); // RIGHT - Gui.blit(pose, posX + BORDER, posY + DEVICE_HEIGHT - BORDER, SCREEN_WIDTH, BORDER, 10, 11, 1, BORDER, 256, 256); // BOTTOM - Gui.blit(pose, posX, posY + BORDER, BORDER, SCREEN_HEIGHT, 0, 11, BORDER, 1, 256, 256); // LEFT + IngameGui.blit(pose, posX + BORDER, posY, SCREEN_WIDTH, BORDER, 10, 0, 1, BORDER, 256, 256); // TOP + IngameGui.blit(pose, posX + DEVICE_WIDTH - BORDER, posY + BORDER, BORDER, SCREEN_HEIGHT, 11, 10, BORDER, 1, 256, 256); // RIGHT + IngameGui.blit(pose, posX + BORDER, posY + DEVICE_HEIGHT - BORDER, SCREEN_WIDTH, BORDER, 10, 11, 1, BORDER, 256, 256); // BOTTOM + IngameGui.blit(pose, posX, posY + BORDER, BORDER, SCREEN_HEIGHT, 0, 11, BORDER, 1, 256, 256); // LEFT // Center - Gui.blit(pose, posX + BORDER, posY + BORDER, SCREEN_WIDTH, SCREEN_HEIGHT, 10, 10, 1, 1, 256, 256); + IngameGui.blit(pose, posX + BORDER, posY + BORDER, SCREEN_WIDTH, SCREEN_HEIGHT, 10, 10, 1, 1, 256, 256); } @@ -432,7 +432,7 @@ public void renderBezels(final @NotNull PoseStack pose, final int mouseX, final * @param mouseY the current mouse Y position. * @param partialTicks the rendering partial ticks that forge give use (which is useless here). */ - public void renderLaptop(final @NotNull PoseStack pose, final int mouseX, final int mouseY, float partialTicks) { + public void renderLaptop(final @NotNull MatrixStack pose, final int mouseX, final int mouseY, float partialTicks) { int posX = (width - DEVICE_WIDTH) / 2; int posY = (height - DEVICE_HEIGHT) / 2; // Fixes the strange partialTicks that Forge decided to give us @@ -476,7 +476,7 @@ public void renderLaptop(final @NotNull PoseStack pose, final int mouseX, final for (int i = windows.size() - 1; i >= 0; i--) { var window = windows.get(i); if (window != null) { - PoseStack.Pose last = pose.last(); + MatrixStack.Entry last = pose.last(); try { if (i == 0) { window.render(pose, this, minecraft, posX + BORDER, posY + BORDER, mouseX, mouseY, !insideContext, partialTicks); @@ -491,7 +491,7 @@ public void renderLaptop(final @NotNull PoseStack pose, final int mouseX, final e.printStackTrace(); Dialog.Message message = new Dialog.Message("An error has occurred.\nSend logs to devs."); message.setTitle("Error"); - CompoundTag intent = new CompoundTag(); + CompoundNBT intent = new CompoundNBT(); if (window.content instanceof Application app) { AppInfo info = app.getInfo(); if (info != null) { @@ -608,7 +608,7 @@ public boolean mouseClickedInternal(double mouseX, double mouseY, int mouseButto Dialog.Message message = new Dialog.Message("An error has occurred.\nSend logs to devs."); message.setTitle("Error"); if (windows.size() == 0 || windows.get(0) == null) { - CompoundTag intent = new CompoundTag(); + CompoundNBT intent = new CompoundNBT(); AppInfo info = window.content.getInfo(); if (info != null) { intent.putString("name", info.getName()); @@ -783,7 +783,7 @@ public boolean mouseScrolled(double mouseX, double mouseY, double delta) { } @Override - public void renderComponentTooltip(@NotNull PoseStack pose, @NotNull List tooltips, int x, int y) { + public void renderComponentTooltip(@NotNull MatrixStack pose, @NotNull List tooltips, int x, int y) { super.renderComponentTooltip(pose, tooltips, x, y); } @@ -804,18 +804,18 @@ public Pair sendApplicationToFront(AppInfo info) { @Override public Application openApplication(AppInfo info) { - return openApplication(info, (CompoundTag) null); + return openApplication(info, (CompoundNBT) null); } @Override - public Application openApplication(AppInfo info, CompoundTag intentTag) { + public Application openApplication(AppInfo info, CompoundNBT intentTag) { Optional optional = APPLICATIONS.stream().filter(app -> app.getInfo() == info).findFirst(); Application[] a = new Application[]{null}; optional.ifPresent(application -> a[0] = openApplication(application, intentTag)); return a[0]; } - private Application openApplication(Application app, CompoundTag intent) { + private Application openApplication(Application app, CompoundNBT intent) { if (!(app instanceof DiagnosticsApp)) { if (isApplicationNotInstalled(app.getInfo())) return null; @@ -850,7 +850,7 @@ private Application openApplication(Application app, CompoundTag intent) { addWindow(window); - Minecraft.getInstance().getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1f)); + Minecraft.getInstance().getSoundManager().play(SimpleSound.forUI(SoundEvents.UI_BUTTON_CLICK, 1f)); } catch (Exception e) { e.printStackTrace(); AppInfo info = ApplicationManager.getApplication("devices:diagnostics"); @@ -904,7 +904,7 @@ private void closeApplication(Application app) { if (window != null) { if (window.content.getInfo().equals(app.getInfo())) { if (app.isDirty()) { - CompoundTag container = new CompoundTag(); + CompoundNBT container = new CompoundNBT(); app.save(container); app.clean(); appData.put(app.getInfo().getFormattedId(), container); @@ -1139,7 +1139,7 @@ public int getLocation() { return location; } - private Wallpaper(CompoundTag tag) { + private Wallpaper(CompoundNBT tag) { var a = tag.getString("url"); var b = tag.getInt("location"); if (tag.contains("url", 8)) { @@ -1165,7 +1165,7 @@ public boolean isBuiltIn() { } public Tag serialize() { - var a = new CompoundTag(); + var a = new CompoundNBT(); if (isBuiltIn()) { a.putInt("location", location); } else { diff --git a/common/src/main/java/com/ultreon/devices/core/Settings.java b/common/src/main/java/com/ultreon/devices/core/Settings.java index d9eefb0dc..c2f45c36c 100644 --- a/common/src/main/java/com/ultreon/devices/core/Settings.java +++ b/common/src/main/java/com/ultreon/devices/core/Settings.java @@ -1,7 +1,7 @@ package com.ultreon.devices.core; import com.ultreon.devices.programs.system.object.ColorScheme; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.CompoundNBT; /** * @author MrCrayfish @@ -23,14 +23,14 @@ public ColorScheme getColorScheme() { return colorScheme; } - public CompoundTag toTag() { - CompoundTag tag = new CompoundTag(); + public CompoundNBT toTag() { + CompoundNBT tag = new CompoundNBT(); tag.putBoolean("showAllApps", showAllApps); tag.put("colorScheme", colorScheme.toTag()); return tag; } - public static Settings fromTag(CompoundTag tag) { + public static Settings fromTag(CompoundNBT tag) { //showAllApps = tag.getBoolean("showAllApps"); Settings settings = new Settings(); diff --git a/common/src/main/java/com/ultreon/devices/core/TaskBar.java b/common/src/main/java/com/ultreon/devices/core/TaskBar.java index e695d6e6f..4f8ad69e3 100644 --- a/common/src/main/java/com/ultreon/devices/core/TaskBar.java +++ b/common/src/main/java/com/ultreon/devices/core/TaskBar.java @@ -1,7 +1,7 @@ package com.ultreon.devices.core; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.Devices; import com.ultreon.devices.api.TrayItemAdder; import com.ultreon.devices.api.app.Application; @@ -15,10 +15,10 @@ import com.ultreon.devices.programs.system.SettingsApp; import com.ultreon.devices.programs.system.SystemApp; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiComponent; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.client.gui.IngameGui; +import net.minecraft.client.gui.AbstractGui; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.util.ResourceLocation; import org.slf4j.Marker; import org.slf4j.MarkerFactory; @@ -80,30 +80,30 @@ public void onTick() { trayItems.forEach(TrayItem::tick); } - public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, float partialTicks) { - RenderSystem.setShaderColor(1f, 1f, 1f, 0.75f); + public void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, float partialTicks) { + RenderSystem.blendColor(1f, 1f, 1f, 0.75f); RenderSystem.enableBlend(); - RenderSystem.setShaderTexture(0, APP_BAR_GUI); + mc.textureManager.bind(APP_BAR_GUI); // r=217,g=230,b=255 Color bgColor = new Color(laptop.getSettings().getColorScheme().getBackgroundColor());//.brighter().brighter(); float[] hsb = Color.RGBtoHSB(bgColor.getRed(), bgColor.getGreen(), bgColor.getBlue(), null); bgColor = new Color(Color.HSBtoRGB(hsb[0], hsb[1], hsb[2])); - RenderSystem.setShaderColor(bgColor.getRed() / 255f, bgColor.getGreen() / 255f, bgColor.getBlue() / 255f, 1f); + RenderSystem.blendColor(bgColor.getRed() / 255f, bgColor.getGreen() / 255f, bgColor.getBlue() / 255f, 1f); int trayItemsWidth = trayItems.size() * 14; - GuiComponent.blit(pose, x, y, 1, 18, 0, 0, 1, 18, 256, 256); - GuiComponent.blit(pose, x + 1, y, Laptop.SCREEN_WIDTH - 36 - trayItemsWidth, 18, 1, 0, 1, 18, 256, 256); - GuiComponent.blit(pose, x + Laptop.SCREEN_WIDTH - 35 - trayItemsWidth, y, 35 + trayItemsWidth, 18, 2, 0, 1, 18, 256, 256); + AbstractGui.blit(pose, x, y, 1, 18, 0, 0, 1, 18, 256, 256); + AbstractGui.blit(pose, x + 1, y, Laptop.SCREEN_WIDTH - 36 - trayItemsWidth, 18, 1, 0, 1, 18, 256, 256); + AbstractGui.blit(pose, x + Laptop.SCREEN_WIDTH - 35 - trayItemsWidth, y, 35 + trayItemsWidth, 18, 2, 0, 1, 18, 256, 256); RenderSystem.disableBlend(); - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.blendColor(1f, 1f, 1f, 1f); for (int i = 0; i < APPS_DISPLAYED && i < laptop.installedApps.size(); i++) { AppInfo info = laptop.installedApps.get(i + offset); RenderUtil.drawApplicationIcon(pose, info, x + 2 + i * 16, y + 2); if (laptop.isApplicationRunning(info)) { - RenderSystem.setShaderTexture(0, APP_BAR_GUI); + mc.textureManager.bind(APP_BAR_GUI); laptop.blit(pose, x + 1 + i * 16, y + 1, 35, 0, 16, 16); } } @@ -117,23 +117,23 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in for (int i = 0; i < trayItems.size(); i++) { int posX = startX - (trayItems.size() - 1 - i) * 14; if (isMouseInside(mouseX, mouseY, posX, y + 2, posX + 13, y + 15)) { - Gui.fill(pose, posX, y + 2, posX + 14, y + 16, new Color(1f, 1f, 1f, 0.1f).getRGB()); + IngameGui.fill(pose, posX, y + 2, posX + 14, y + 16, new Color(1f, 1f, 1f, 0.1f).getRGB()); } trayItems.get(i).getIcon().draw(pose, mc, posX + 2, y + 4); } - RenderSystem.setShaderTexture(0, APP_BAR_GUI); + mc.textureManager.bind(APP_BAR_GUI); /* Other Apps */ if (isMouseInside(mouseX, mouseY, x + 1, y + 1, x + 236, y + 16)) { int appIndex = (mouseX - x - 1) / 16; if (appIndex >= 0 && appIndex < offset + APPS_DISPLAYED && appIndex < laptop.installedApps.size()) { laptop.blit(pose, x + appIndex * 16 + 1, y + 1, 35, 0, 16, 16); - laptop.renderComponentTooltip(pose, List.of(new TextComponent(laptop.installedApps.get(appIndex).getName())), mouseX, mouseY); + laptop.renderComponentTooltip(pose, List.of(new StringTextComponent(laptop.installedApps.get(appIndex).getName())), mouseX, mouseY); } } - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.blendColor(1f, 1f, 1f, 1f); // RenderHelper.disableStandardItemLighting(); } diff --git a/common/src/main/java/com/ultreon/devices/core/Window.java b/common/src/main/java/com/ultreon/devices/core/Window.java index 9043dfbdb..d6b4cb18f 100644 --- a/common/src/main/java/com/ultreon/devices/core/Window.java +++ b/common/src/main/java/com/ultreon/devices/core/Window.java @@ -1,15 +1,15 @@ package com.ultreon.devices.core; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.app.Application; import com.ultreon.devices.api.app.Dialog; import com.ultreon.devices.gui.GuiButtonClose; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiComponent; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.client.gui.IngameGui; +import net.minecraft.client.gui.AbstractGui; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.ResourceLocation; import javax.annotation.Nullable; import java.awt.*; @@ -47,7 +47,7 @@ void setHeight(int height) { } } - void init(int x, int y, @Nullable CompoundTag intent) { + void init(int x, int y, @Nullable CompoundNBT intent) { try { btnClose = new GuiButtonClose(x + offsetX + width - 12, y + offsetY + 1); content.init(intent); @@ -74,7 +74,7 @@ public void onTick() { content.onTick(); } - public void render(PoseStack pose, Laptop gui, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean active, float partialTicks) { + public void render(MatrixStack pose, Laptop gui, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean active, float partialTicks) { if (content.isPendingLayoutUpdate()) { this.setWidth(content.getWidth()); this.setHeight(content.getHeight()); @@ -86,9 +86,9 @@ public void render(PoseStack pose, Laptop gui, Minecraft mc, int x, int y, int m pose.pushPose(); - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.blendColor(1f, 1f, 1f, 1f); RenderSystem.enableBlend(); - RenderSystem.setShaderTexture(0, WINDOW_GUI); + mc.textureManager.bind(WINDOW_GUI); /* Corners */ gui.blit(pose, x + offsetX, y + offsetY, 0, 0, 1, 13); @@ -97,13 +97,13 @@ public void render(PoseStack pose, Laptop gui, Minecraft mc, int x, int y, int m gui.blit(pose, x + offsetX, y + offsetY + height - 1, 0, 14, 1, 1); /* Edges */ - GuiComponent.blit(pose, x + offsetX + 1, y + offsetY, width - 14, 13, 1, 0, 1, 13, 256, 256); - GuiComponent.blit(pose, x + offsetX + width - 1, y + offsetY + 13, 1, height - 14, 14, 13, 1, 1, 256, 256); - GuiComponent.blit(pose, x + offsetX + 1, y + offsetY + height - 1, width - 2, 1, 1, 14, 13, 1, 256, 256); - GuiComponent.blit(pose, x + offsetX, y + offsetY + 13, 1, height - 14, 0, 13, 1, 1, 256, 256); + AbstractGui.blit(pose, x + offsetX + 1, y + offsetY, width - 14, 13, 1, 0, 1, 13, 256, 256); + AbstractGui.blit(pose, x + offsetX + width - 1, y + offsetY + 13, 1, height - 14, 14, 13, 1, 1, 256, 256); + AbstractGui.blit(pose, x + offsetX + 1, y + offsetY + height - 1, width - 2, 1, 1, 14, 13, 1, 256, 256); + AbstractGui.blit(pose, x + offsetX, y + offsetY + 13, 1, height - 14, 0, 13, 1, 1, 256, 256); /* Center */ - GuiComponent.blit(pose, x + offsetX + 1, y + offsetY + 13, width - 2, height - 14, 1, 13, 13, 1, 256, 256); + AbstractGui.blit(pose, x + offsetX + 1, y + offsetY + 13, width - 2, height - 14, 1, 13, 13, 1, 256, 256); String windowTitle = content.getWindowTitle(); if (mc.font.width(windowTitle) > width - 2 - 13 - 3) { // window width, border, close button, padding, padding @@ -118,10 +118,10 @@ public void render(PoseStack pose, Laptop gui, Minecraft mc, int x, int y, int m /* Render content */ content.render(pose, gui, mc, x + offsetX + 1, y + offsetY + 13, mouseX, mouseY, active && dialogWindow == null, partialTicks); - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.blendColor(1f, 1f, 1f, 1f); if (dialogWindow != null) { - Gui.fill(pose, x + offsetX, y + offsetY, x + offsetX + width, y + offsetY + height, Color_WINDOW_DARK); + IngameGui.fill(pose, x + offsetX, y + offsetY, x + offsetX + width, y + offsetY + height, Color_WINDOW_DARK); dialogWindow.render(pose, gui, mc, x, y, mouseX, mouseY, active, partialTicks); } pose.popPose(); diff --git a/common/src/main/java/com/ultreon/devices/core/Wrappable.java b/common/src/main/java/com/ultreon/devices/core/Wrappable.java index 979e1d308..27b49653d 100644 --- a/common/src/main/java/com/ultreon/devices/core/Wrappable.java +++ b/common/src/main/java/com/ultreon/devices/core/Wrappable.java @@ -1,9 +1,9 @@ package com.ultreon.devices.core; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.app.Dialog; import net.minecraft.client.Minecraft; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.CompoundNBT; import org.jetbrains.annotations.Nullable; public abstract class Wrappable { @@ -17,7 +17,7 @@ public abstract class Wrappable { * * @param intent */ - public abstract void init(@Nullable CompoundTag intent); + public abstract void init(@Nullable CompoundNBT intent); /** * When the games ticks. Note if you override, make sure you call this super @@ -39,7 +39,7 @@ public abstract class Wrappable { * @param active if the window active * @param partialTicks time passed since tick */ - public abstract void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean active, float partialTicks); + public abstract void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean active, float partialTicks); /** * Called when a key is typed from your keyboard. Note if you override, make diff --git a/common/src/main/java/com/ultreon/devices/core/client/ClientNotification.java b/common/src/main/java/com/ultreon/devices/core/client/ClientNotification.java index 278ca28d5..7838481b0 100644 --- a/common/src/main/java/com/ultreon/devices/core/client/ClientNotification.java +++ b/common/src/main/java/com/ultreon/devices/core/client/ClientNotification.java @@ -1,17 +1,17 @@ package com.ultreon.devices.core.client; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.app.IIcon; import com.ultreon.devices.api.utils.RenderUtil; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.components.toasts.Toast; -import net.minecraft.client.gui.components.toasts.ToastComponent; -import net.minecraft.client.resources.language.I18n; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.widget.toasts.Toast; +import net.minecraft.client.gui.widget.toasts.ToastComponent; +import net.minecraft.client.resources.I18n; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.INBT; +import net.minecraft.util.ResourceLocation; import org.jetbrains.annotations.NotNull; /** @@ -29,11 +29,11 @@ private ClientNotification() { @NotNull @Override - public Visibility render(@NotNull PoseStack pose, ToastComponent toastComponent, long timeSinceLastVisible) { - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); - RenderSystem.setShaderTexture(0, TEXTURE_TOASTS); + public Visibility render(@NotNull MatrixStack pose, ToastComponent toastComponent, long timeSinceLastVisible) { + RenderSystem.blendColor(1f, 1f, 1f, 1f); + mc.textureManager.bind(TEXTURE_TOASTS); toastComponent.blit(pose, 0, 0, 0, 0, 160, 32); - Font font = toastComponent.getMinecraft().font; + FontRenderer font = toastComponent.getMinecraft().font; if (subTitle == null) { font.drawShadow(pose, font.plainSubstrByWidth(I18n.get(title), 118), 38, 12, -1); @@ -42,13 +42,13 @@ public Visibility render(@NotNull PoseStack pose, ToastComponent toastComponent, font.draw(pose, font.plainSubstrByWidth(I18n.get(subTitle), 118), 38, 18, -1); } - RenderSystem.setShaderTexture(0, icon.getIconAsset()); + mc.textureManager.bind(icon.getIconAsset()); RenderUtil.drawRectWithTexture(pose, 6, 6, icon.getGridWidth(), icon.getGridHeight(), icon.getU(), icon.getV(), icon.getSourceWidth(), icon.getSourceHeight(), icon.getIconSize(), icon.getIconSize()); return timeSinceLastVisible >= 5000L ? Visibility.HIDE : Visibility.SHOW; } - public static ClientNotification loadFromTag(CompoundTag tag) { + public static ClientNotification loadFromTag(CompoundNBT tag) { ClientNotification notification = new ClientNotification(); int ordinal = tag.getCompound("icon").getInt("ordinal"); @@ -61,7 +61,7 @@ public static ClientNotification loadFromTag(CompoundTag tag) { } notification.title = tag.getString("title"); - if (tag.contains("subTitle", Tag.TAG_STRING)) { + if (tag.contains("subTitle", Constants.NBT.TAG_STRING)) { notification.subTitle = tag.getString("subTitle"); } diff --git a/common/src/main/java/com/ultreon/devices/core/client/LaptopFont.java b/common/src/main/java/com/ultreon/devices/core/client/LaptopFont.java index 4c61772ba..5e309beda 100644 --- a/common/src/main/java/com/ultreon/devices/core/client/LaptopFont.java +++ b/common/src/main/java/com/ultreon/devices/core/client/LaptopFont.java @@ -2,12 +2,12 @@ import com.ultreon.devices.Devices; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.FontRenderer; /** * @author MrCrayfish */ -public class LaptopFont extends Font { +public class LaptopFont extends FontRenderer { private boolean debug = false; public LaptopFont(Minecraft mc) { diff --git a/common/src/main/java/com/ultreon/devices/core/client/LaptopFontSet.java b/common/src/main/java/com/ultreon/devices/core/client/LaptopFontSet.java index e2e1e275b..5c1693e60 100644 --- a/common/src/main/java/com/ultreon/devices/core/client/LaptopFontSet.java +++ b/common/src/main/java/com/ultreon/devices/core/client/LaptopFontSet.java @@ -3,7 +3,7 @@ import com.mojang.blaze3d.font.GlyphInfo; import net.minecraft.client.gui.font.FontSet; import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.ResourceLocation; import org.jetbrains.annotations.Nullable; /** diff --git a/common/src/main/java/com/ultreon/devices/core/client/debug/ClientAppDebug.java b/common/src/main/java/com/ultreon/devices/core/client/debug/ClientAppDebug.java index 6ac989279..c9baaa61f 100644 --- a/common/src/main/java/com/ultreon/devices/core/client/debug/ClientAppDebug.java +++ b/common/src/main/java/com/ultreon/devices/core/client/debug/ClientAppDebug.java @@ -10,10 +10,10 @@ import dev.architectury.event.events.client.ClientGuiEvent; import dev.architectury.platform.Platform; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.components.Button; +import net.minecraft.client.gui.widget.button.Button; import net.minecraft.client.gui.screens.TitleScreen; -import net.minecraft.core.BlockPos; -import net.minecraft.network.chat.TextComponent; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.StringTextComponent; /** * Adds a button to the title screen to test system applications that don't require the system @@ -26,7 +26,7 @@ public static void register() { var rowHeight = 24; var y = screen.height / 4 + 48; - var a = new Button(screen.width / 2 - 100, y + rowHeight * -2, 200, 20, new TextComponent("DV TEST"), (button) -> { + var a = new Button(screen.width / 2 - 100, y + rowHeight * -2, 200, 20, new StringTextComponent("DV TEST"), (button) -> { Minecraft.getInstance().setScreen(new Laptop(new LaptopBlockEntity(new BlockPos(0, 0, 0), DeviceBlocks.WHITE_LAPTOP.get().defaultBlockState()), true)); }, Button.NO_TOOLTIP); access.addRenderableWidget(a); @@ -38,7 +38,7 @@ public static void register() { var rowHeight = 24; var y = screen.height / 4 + 48; - var a = new Button(screen.width / 2 - 100, y + rowHeight * -3, 200, 20, new TextComponent("DV TEST #2"), (button) -> { + var a = new Button(screen.width / 2 - 100, y + rowHeight * -3, 200, 20, new StringTextComponent("DV TEST #2"), (button) -> { var serverLaptop = new ServerLaptop(); ServerLaptop.laptops.put(serverLaptop.getUuid(), serverLaptop); var clientLaptop = new ClientLaptop(); diff --git a/common/src/main/java/com/ultreon/devices/core/io/FileSystem.java b/common/src/main/java/com/ultreon/devices/core/io/FileSystem.java index ee6e4bf08..1ac81111c 100644 --- a/common/src/main/java/com/ultreon/devices/core/io/FileSystem.java +++ b/common/src/main/java/com/ultreon/devices/core/io/FileSystem.java @@ -17,15 +17,15 @@ import com.ultreon.devices.core.io.task.TaskGetMainDrive; import com.ultreon.devices.core.io.task.TaskSendAction; import com.ultreon.devices.init.DeviceItems; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.nbt.Tag; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.world.item.DyeColor; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.ListNBT; +import net.minecraft.nbt.INBT; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.item.DyeColor; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; import java.lang.reflect.Constructor; @@ -52,13 +52,13 @@ public class FileSystem { private final LaptopBlockEntity blockEntity; - public FileSystem(LaptopBlockEntity blockEntity, CompoundTag tag) { + public FileSystem(LaptopBlockEntity blockEntity, CompoundNBT tag) { this.blockEntity = blockEntity; load(tag); } - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) public static void sendAction(Drive drive, FileAction action, @Nullable Callback callback) { if (Laptop.getPos() != null) { System.out.println("Sending action " + action + " to " + drive); @@ -114,8 +114,8 @@ private static void setupApplicationFolder(Application app, Callback cal Task task = new TaskGetFiles(appFolder, Laptop.getPos()); task.setCallback((tag, success) -> { assert tag != null; - if (success && tag.contains("files", Tag.TAG_LIST)) { - ListTag files = tag.getList("files", Tag.TAG_COMPOUND); + if (success && tag.contains("files", Constants.NBT.TAG_LIST)) { + ListNBT files = tag.getList("files", Constants.NBT.TAG_COMPOUND); appFolder.syncFiles(files); callback.execute(appFolder, true); } else { @@ -148,21 +148,21 @@ public static Response createResponse(int status, String message) { return new Response(status, message); } - private void load(CompoundTag tag) { + private void load(CompoundNBT tag) { System.out.println(tag); - if (tag.contains("main_drive", Tag.TAG_COMPOUND)) + if (tag.contains("main_drive", Constants.NBT.TAG_COMPOUND)) mainDrive = InternalDrive.fromTag(tag.getCompound("main_drive")); - if (tag.contains("drives", Tag.TAG_LIST)) { - ListTag list = tag.getList("drives", Tag.TAG_COMPOUND); + if (tag.contains("drives", Constants.NBT.TAG_LIST)) { + ListNBT list = tag.getList("drives", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < list.size(); i++) { - CompoundTag driveTag = list.getCompound(i); + CompoundNBT driveTag = list.getCompound(i); AbstractDrive drive = InternalDrive.fromTag(driveTag.getCompound("drive")); additionalDrives.put(drive.getUuid(), drive); } } - if (tag.contains("external_drive", Tag.TAG_COMPOUND)) + if (tag.contains("external_drive", Constants.NBT.TAG_COMPOUND)) attachedDrive = ExternalDrive.fromTag(tag.getCompound("external_drive")); - if (tag.contains("external_drive_color", Tag.TAG_BYTE)) + if (tag.contains("external_drive_color", Constants.NBT.TAG_BYTE)) attachedDriveColor = DyeColor.byId(tag.getByte("external_drive_color")); setupDefault(); @@ -191,7 +191,7 @@ private ServerFolder createProtectedFolder(String name) { return null; } - public Response readAction(String driveUuid, FileAction action, Level level) { + public Response readAction(String driveUuid, FileAction action, World level) { UUID uuid = UUID.fromString(driveUuid); AbstractDrive drive = getAvailableDrives(level, true).get(uuid); if (drive != null) { @@ -208,7 +208,7 @@ public AbstractDrive getMainDrive() { return mainDrive; } - public Map getAvailableDrives(@Nullable Level level, boolean includeMain) { + public Map getAvailableDrives(@Nullable World level, boolean includeMain) { Map drives = new LinkedHashMap<>(); if (includeMain) { @@ -223,7 +223,7 @@ public Map getAvailableDrives(@Nullable Level level, boolea public boolean setAttachedDrive(ItemStack flashDrive) { if (attachedDrive == null) { - CompoundTag flashDriveTag = getExternalDriveTag(flashDrive); + CompoundNBT flashDriveTag = getExternalDriveTag(flashDrive); AbstractDrive drive = ExternalDrive.fromTag(flashDriveTag.getCompound("drive")); if (drive != null) { drive.setName(flashDrive.getDisplayName().getString()); @@ -253,7 +253,7 @@ public DyeColor getAttachedDriveColor() { public ItemStack removeAttachedDrive() { if (attachedDrive != null) { ItemStack stack = new ItemStack(DeviceItems.getFlashDriveByColor(attachedDriveColor), 1); - stack.setHoverName(new TextComponent(attachedDrive.getName())); + stack.setHoverName(new StringTextComponent(attachedDrive.getName())); stack.getOrCreateTag().put("drive", attachedDrive.toTag()); attachedDrive = null; return stack; @@ -261,25 +261,25 @@ public ItemStack removeAttachedDrive() { return null; } - private CompoundTag getExternalDriveTag(ItemStack stack) { - CompoundTag tag = stack.getTag(); + private CompoundNBT getExternalDriveTag(ItemStack stack) { + CompoundNBT tag = stack.getTag(); if (tag == null) { - tag = new CompoundTag(); + tag = new CompoundNBT(); tag.put("drive", new ExternalDrive(stack.getDisplayName().getString()).toTag()); stack.setTag(tag); - } else if (tag.contains("drive", Tag.TAG_COMPOUND)) { + } else if (tag.contains("drive", Constants.NBT.TAG_COMPOUND)) { tag.put("drive", new ExternalDrive(stack.getDisplayName().getString()).toTag()); } return tag; } - public CompoundTag toTag() { - CompoundTag fileSystemTag = new CompoundTag(); + public CompoundNBT toTag() { + CompoundNBT fileSystemTag = new CompoundNBT(); if (mainDrive != null) fileSystemTag.put("main_drive", mainDrive.toTag()); - ListTag list = new ListTag(); + ListNBT list = new ListNBT(); additionalDrives.forEach((k, v) -> list.add(v.toTag())); fileSystemTag.put("drives", list); @@ -304,7 +304,7 @@ private Response(int status, String message) { this.message = message; } - public static Response fromTag(CompoundTag responseTag) { + public static Response fromTag(CompoundNBT responseTag) { return new Response(responseTag.getInt("status"), responseTag.getString("message")); } @@ -316,8 +316,8 @@ public String getMessage() { return message; } - public CompoundTag toTag() { - CompoundTag responseTag = new CompoundTag(); + public CompoundNBT toTag() { + CompoundNBT responseTag = new CompoundNBT(); responseTag.putInt("status", status); responseTag.putString("message", message); return responseTag; diff --git a/common/src/main/java/com/ultreon/devices/core/io/ServerFile.java b/common/src/main/java/com/ultreon/devices/core/io/ServerFile.java index b34ef18b9..07a1ad034 100644 --- a/common/src/main/java/com/ultreon/devices/core/io/ServerFile.java +++ b/common/src/main/java/com/ultreon/devices/core/io/ServerFile.java @@ -2,7 +2,7 @@ import com.ultreon.devices.api.app.Application; import com.ultreon.devices.api.io.MimeType; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.CompoundNBT; import javax.annotation.Nullable; import java.util.Comparator; @@ -10,7 +10,7 @@ /** * @author MrCrayfish */ -public sealed class ServerFile permits ServerFolder { +public class ServerFile permits ServerFolder { public static final Comparator SORT_BY_NAME = (f1, f2) -> { if (f1.isFolder() && !f2.isFolder()) return -1; if (!f1.isFolder() && f2.isFolder()) return 1; @@ -21,7 +21,7 @@ public sealed class ServerFile permits ServerFolder { protected ServerFolder parent; protected String name; protected String openingApp; - protected CompoundTag data; + protected CompoundNBT data; protected boolean protect = false; protected long lastModified; protected long lastAccessed; @@ -31,23 +31,23 @@ protected ServerFile() { } - public ServerFile(String name, Application app, CompoundTag data) { + public ServerFile(String name, Application app, CompoundNBT data) { this(name, app.getInfo().getFormattedId(), data, false); } - public ServerFile(String name, String openingAppId, CompoundTag data) { + public ServerFile(String name, String openingAppId, CompoundNBT data) { this(name, openingAppId, data, false); } - public ServerFile(String name, String openingAppId, MimeType mimeType, CompoundTag data) { + public ServerFile(String name, String openingAppId, MimeType mimeType, CompoundNBT data) { this(name, openingAppId, data, mimeType, false); } - private ServerFile(String name, String openingAppId, CompoundTag data, boolean protect) { + private ServerFile(String name, String openingAppId, CompoundNBT data, boolean protect) { this(name, openingAppId, data, MimeType.APPLICATION_OCTET_STREAM, protect); } - private ServerFile(String name, String openingAppId, CompoundTag data, MimeType mimeType, boolean protect) { + private ServerFile(String name, String openingAppId, CompoundNBT data, MimeType mimeType, boolean protect) { this.name = name; this.openingApp = openingAppId; this.data = data; @@ -58,7 +58,7 @@ private ServerFile(String name, String openingAppId, CompoundTag data, MimeType this.lastAccessed = this.creationTime; } - private ServerFile(String name, boolean protect, CompoundTag tag) { + private ServerFile(String name, boolean protect, CompoundNBT tag) { this.openingApp = tag.getString("openingApp"); this.name = name; this.data = tag.getCompound("data"); @@ -90,7 +90,7 @@ public String getOpeningApp() { return openingApp; } - public FileSystem.Response setData(CompoundTag data) { + public FileSystem.Response setData(CompoundNBT data) { if (this.protect) return FileSystem.createResponse(FileSystem.Status.FILE_IS_PROTECTED, "Cannot set data on a protected file"); @@ -103,8 +103,8 @@ public FileSystem.Response setData(CompoundTag data) { } @Nullable - public CompoundTag getData() { - CompoundTag data1 = data.copy(); // make a copy to prevent modifying the original data + public CompoundNBT getData() { + CompoundNBT data1 = data.copy(); // make a copy to prevent modifying the original data lastAccessed = System.currentTimeMillis(); return data1; } @@ -148,8 +148,8 @@ public FileSystem.Response delete() { return FileSystem.createResponse(FileSystem.Status.FILE_INVALID, "Invalid file"); } - public CompoundTag toTag() { - CompoundTag tag = new CompoundTag(); + public CompoundNBT toTag() { + CompoundNBT tag = new CompoundNBT(); tag.putString("openingApp", openingApp); tag.putLong("lastModified", lastModified); tag.putLong("lastAccessed", lastAccessed); @@ -158,7 +158,7 @@ public CompoundTag toTag() { return tag; } - public static ServerFile fromTag(String name, CompoundTag tag) { + public static ServerFile fromTag(String name, CompoundNBT tag) { return new ServerFile(name, false, tag); } diff --git a/common/src/main/java/com/ultreon/devices/core/io/ServerFolder.java b/common/src/main/java/com/ultreon/devices/core/io/ServerFolder.java index 1933887d1..77a07095a 100644 --- a/common/src/main/java/com/ultreon/devices/core/io/ServerFolder.java +++ b/common/src/main/java/com/ultreon/devices/core/io/ServerFolder.java @@ -1,9 +1,9 @@ package com.ultreon.devices.core.io; import com.ultreon.devices.core.io.FileSystem.Status; -import net.minecraft.core.NonNullList; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; +import net.minecraft.util.NonNullList; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.INBT; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -27,7 +27,7 @@ private ServerFolder(String name, boolean protect) { this.protect = protect; } - private ServerFolder(String name, boolean protect, CompoundTag tag) { + private ServerFolder(String name, boolean protect, CompoundNBT tag) { this.name = name; this.protect = protect; this.creationTime = tag.getLong("creationTime"); @@ -35,14 +35,14 @@ private ServerFolder(String name, boolean protect, CompoundTag tag) { this.lastAccessed = tag.getLong("lastAccessed"); } - public static ServerFolder fromTag(String name, CompoundTag folderTag) { + public static ServerFolder fromTag(String name, CompoundNBT folderTag) { ServerFolder folder = new ServerFolder(name, false, folderTag); - if (folderTag.contains("protected", Tag.TAG_BYTE)) folder.protect = folderTag.getBoolean("protected"); + if (folderTag.contains("protected", Constants.NBT.TAG_BYTE)) folder.protect = folderTag.getBoolean("protected"); - CompoundTag fileList = folderTag.getCompound("files"); + CompoundNBT fileList = folderTag.getCompound("files"); for (String fileName : fileList.getAllKeys()) { - CompoundTag fileTag = fileList.getCompound(fileName); + CompoundNBT fileTag = fileList.getCompound(fileName); if (fileTag.contains("files")) { folder.add(ServerFolder.fromTag(fileName, fileTag), false); } else { @@ -145,10 +145,10 @@ public boolean isFolder() { } @Override - public CompoundTag toTag() { - CompoundTag folderTag = new CompoundTag(); + public CompoundNBT toTag() { + CompoundNBT folderTag = new CompoundNBT(); - CompoundTag fileList = new CompoundTag(); + CompoundNBT fileList = new CompoundNBT(); files.forEach(file -> fileList.put(file.getName(), file.toTag())); folderTag.put("files", fileList); @@ -162,7 +162,7 @@ public CompoundTag toTag() { } @Override - public FileSystem.Response setData(@Nonnull CompoundTag data) { + public FileSystem.Response setData(@Nonnull CompoundNBT data) { return FileSystem.createResponse(Status.FILE_INVALID_DATA, "Data can not be set to a folder"); } diff --git a/common/src/main/java/com/ultreon/devices/core/io/action/FileAction.java b/common/src/main/java/com/ultreon/devices/core/io/action/FileAction.java index 64d17ed53..b227b9fbe 100644 --- a/common/src/main/java/com/ultreon/devices/core/io/action/FileAction.java +++ b/common/src/main/java/com/ultreon/devices/core/io/action/FileAction.java @@ -2,30 +2,30 @@ import com.ultreon.devices.api.io.File; import com.ultreon.devices.api.io.Folder; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.CompoundNBT; /** * @author MrCrayfish */ public class FileAction { private final Type type; - private final CompoundTag data; + private final CompoundNBT data; - private FileAction(Type type, CompoundTag data) { + private FileAction(Type type, CompoundNBT data) { this.type = type; this.data = data; } - public CompoundTag toTag() { - CompoundTag tag = new CompoundTag(); + public CompoundNBT toTag() { + CompoundNBT tag = new CompoundNBT(); tag.putInt("type", type.ordinal()); tag.put("data", data); return tag; } - public static FileAction fromTag(CompoundTag tag) { + public static FileAction fromTag(CompoundNBT tag) { Type type = Type.values()[tag.getInt("type")]; - CompoundTag data = tag.getCompound("data"); + CompoundNBT data = tag.getCompound("data"); return new FileAction(type, data); } @@ -33,7 +33,7 @@ public Type getType() { return type; } - public CompoundTag getData() { + public CompoundNBT getData() { return data; } @@ -43,7 +43,7 @@ public enum Type { public static class Factory { public static FileAction makeNew(Folder parent, File file, boolean override) { - CompoundTag vars = new CompoundTag(); + CompoundNBT vars = new CompoundNBT(); vars.putString("directory", parent.getPath()); vars.putString("file_name", file.getName()); vars.putBoolean("override", override); @@ -52,22 +52,22 @@ public static FileAction makeNew(Folder parent, File file, boolean override) { } public static FileAction makeDelete(File file) { - CompoundTag vars = new CompoundTag(); + CompoundNBT vars = new CompoundNBT(); vars.putString("directory", file.getLocation()); vars.putString("file_name", file.getName()); return new FileAction(Type.DELETE, vars); } public static FileAction makeRename(File file, String newFileName) { - CompoundTag vars = new CompoundTag(); + CompoundNBT vars = new CompoundNBT(); vars.putString("directory", file.getLocation()); vars.putString("file_name", file.getName()); vars.putString("new_file_name", newFileName); return new FileAction(Type.RENAME, vars); } - public static FileAction makeData(File file, CompoundTag data) { - CompoundTag vars = new CompoundTag(); + public static FileAction makeData(File file, CompoundNBT data) { + CompoundNBT vars = new CompoundNBT(); vars.putString("directory", file.getLocation()); vars.putString("file_name", file.getName()); vars.put("data", data); @@ -75,7 +75,7 @@ public static FileAction makeData(File file, CompoundTag data) { } public static FileAction makeCopyCut(File source, Folder destination, boolean override, boolean cut) { - CompoundTag vars = new CompoundTag(); + CompoundNBT vars = new CompoundNBT(); vars.putString("directory", source.getLocation()); vars.putString("file_name", source.getName()); vars.putString("destination_drive", destination.getDrive().getUUID().toString()); diff --git a/common/src/main/java/com/ultreon/devices/core/io/drive/AbstractDrive.java b/common/src/main/java/com/ultreon/devices/core/io/drive/AbstractDrive.java index fe08e7088..f4906e9f2 100644 --- a/common/src/main/java/com/ultreon/devices/core/io/drive/AbstractDrive.java +++ b/common/src/main/java/com/ultreon/devices/core/io/drive/AbstractDrive.java @@ -4,9 +4,9 @@ import com.ultreon.devices.core.io.ServerFile; import com.ultreon.devices.core.io.ServerFolder; import com.ultreon.devices.core.io.action.FileAction; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; -import net.minecraft.world.level.Level; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.INBT; +import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; import java.lang.reflect.Constructor; @@ -55,18 +55,18 @@ public UUID getUuid() { return uuid; } - public ServerFolder getRoot(Level level) { + public ServerFolder getRoot(World level) { return root; } - public FileSystem.Response handleFileAction(FileSystem fileSystem, FileAction action, Level level) { - CompoundTag actionData = action.getData(); + public FileSystem.Response handleFileAction(FileSystem fileSystem, FileAction action, World level) { + CompoundNBT actionData = action.getData(); ServerFolder folder = getFolder(actionData.getString("directory")); if (folder != null) { - CompoundTag data = actionData.getCompound("data"); + CompoundNBT data = actionData.getCompound("data"); switch (action.getType()) { case NEW: - if (data.contains("files", Tag.TAG_COMPOUND)) { + if (data.contains("files", Constants.NBT.TAG_COMPOUND)) { return folder.add(ServerFolder.fromTag(actionData.getString("file_name"), data), actionData.getBoolean("override")); } return folder.add(ServerFile.fromTag(actionData.getString("file_name"), data), data.getBoolean("override")); @@ -118,7 +118,7 @@ public FileSystem.Response handleFileAction(FileSystem fileSystem, FileAction ac return FileSystem.createResponse(FileSystem.Status.DRIVE_UNAVAILABLE, "Invalid directory"); } - public abstract CompoundTag toTag(); + public abstract CompoundNBT toTag(); public abstract Type getType(); diff --git a/common/src/main/java/com/ultreon/devices/core/io/drive/ExternalDrive.java b/common/src/main/java/com/ultreon/devices/core/io/drive/ExternalDrive.java index 92f1bee68..c1661f3d6 100644 --- a/common/src/main/java/com/ultreon/devices/core/io/drive/ExternalDrive.java +++ b/common/src/main/java/com/ultreon/devices/core/io/drive/ExternalDrive.java @@ -1,8 +1,8 @@ package com.ultreon.devices.core.io.drive; import com.ultreon.devices.core.io.ServerFolder; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.INBT; import org.jetbrains.annotations.Nullable; import java.util.UUID; @@ -12,7 +12,7 @@ * @author MrCrayfish */ public final class ExternalDrive extends AbstractDrive { - private static final Predicate PREDICATE_DRIVE_TAG = tag -> tag.contains("name", Tag.TAG_STRING) && tag.contains("uuid", Tag.TAG_STRING) && tag.contains("root", Tag.TAG_COMPOUND); + private static final Predicate PREDICATE_DRIVE_TAG = tag -> tag.contains("name", Constants.NBT.TAG_STRING) && tag.contains("uuid", Constants.NBT.TAG_STRING) && tag.contains("root", Constants.NBT.TAG_COMPOUND); private ExternalDrive() { } @@ -22,26 +22,26 @@ public ExternalDrive(String displayName) { } @Nullable - public static AbstractDrive fromTag(CompoundTag driveTag) { + public static AbstractDrive fromTag(CompoundNBT driveTag) { if (!PREDICATE_DRIVE_TAG.test(driveTag)) return null; AbstractDrive drive = new ExternalDrive(); drive.name = driveTag.getString("name"); drive.uuid = UUID.fromString(driveTag.getString("uuid")); - CompoundTag folderTag = driveTag.getCompound("root"); + CompoundNBT folderTag = driveTag.getCompound("root"); drive.root = ServerFolder.fromTag(folderTag.getString("file_name"), folderTag.getCompound("data")); return drive; } @Override - public CompoundTag toTag() { - CompoundTag driveTag = new CompoundTag(); + public CompoundNBT toTag() { + CompoundNBT driveTag = new CompoundNBT(); driveTag.putString("name", name); driveTag.putString("uuid", uuid.toString()); - CompoundTag folderTag = new CompoundTag(); + CompoundNBT folderTag = new CompoundNBT(); folderTag.putString("file_name", root.getName()); folderTag.put("data", root.toTag()); driveTag.put("root", folderTag); diff --git a/common/src/main/java/com/ultreon/devices/core/io/drive/InternalDrive.java b/common/src/main/java/com/ultreon/devices/core/io/drive/InternalDrive.java index ed50a4a8a..aeb2a20be 100644 --- a/common/src/main/java/com/ultreon/devices/core/io/drive/InternalDrive.java +++ b/common/src/main/java/com/ultreon/devices/core/io/drive/InternalDrive.java @@ -1,8 +1,8 @@ package com.ultreon.devices.core.io.drive; import com.ultreon.devices.core.io.ServerFolder; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.INBT; import org.jetbrains.annotations.NotNull; /** @@ -13,21 +13,21 @@ public InternalDrive(String name) { super(name); } - public static @NotNull AbstractDrive fromTag(CompoundTag driveTag) { + public static @NotNull AbstractDrive fromTag(CompoundNBT driveTag) { AbstractDrive drive = new InternalDrive(driveTag.getString("name")); - if (driveTag.contains("root", Tag.TAG_COMPOUND)) { - CompoundTag folderTag = driveTag.getCompound("root"); + if (driveTag.contains("root", Constants.NBT.TAG_COMPOUND)) { + CompoundNBT folderTag = driveTag.getCompound("root"); drive.root = ServerFolder.fromTag(folderTag.getString("file_name"), folderTag.getCompound("data")); } return drive; } @Override - public CompoundTag toTag() { - CompoundTag driveTag = new CompoundTag(); + public CompoundNBT toTag() { + CompoundNBT driveTag = new CompoundNBT(); driveTag.putString("name", name); - CompoundTag folderTag = new CompoundTag(); + CompoundNBT folderTag = new CompoundNBT(); folderTag.putString("file_name", root.getName()); folderTag.put("data", root.toTag()); driveTag.put("root", folderTag); diff --git a/common/src/main/java/com/ultreon/devices/core/io/drive/NetworkDrive.java b/common/src/main/java/com/ultreon/devices/core/io/drive/NetworkDrive.java index a60a6e85e..81646dc70 100644 --- a/common/src/main/java/com/ultreon/devices/core/io/drive/NetworkDrive.java +++ b/common/src/main/java/com/ultreon/devices/core/io/drive/NetworkDrive.java @@ -3,10 +3,10 @@ import com.ultreon.devices.core.io.FileSystem; import com.ultreon.devices.core.io.ServerFolder; import com.ultreon.devices.core.io.action.FileAction; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.world.World; +import net.minecraft.tileentity.TileEntity; import javax.annotation.Nullable; @@ -24,8 +24,8 @@ public NetworkDrive(String name, BlockPos pos) { @Nullable @Override - public ServerFolder getRoot(Level level) { - BlockEntity tileEntity = level.getBlockEntity(pos); + public ServerFolder getRoot(World level) { + TileEntity tileEntity = level.getBlockEntity(pos); if (tileEntity instanceof Interface impl) { AbstractDrive drive = impl.getDrive(); if (drive != null) { @@ -36,8 +36,8 @@ public ServerFolder getRoot(Level level) { } @Override - public FileSystem.Response handleFileAction(FileSystem fileSystem, FileAction action, Level level) { - BlockEntity tileEntity = level.getBlockEntity(pos); + public FileSystem.Response handleFileAction(FileSystem fileSystem, FileAction action, World level) { + TileEntity tileEntity = level.getBlockEntity(pos); if (tileEntity instanceof Interface impl) { AbstractDrive drive = impl.getDrive(); if (drive.handleFileAction(fileSystem, action, level).getStatus() == FileSystem.Status.SUCCESSFUL) { @@ -60,7 +60,7 @@ public Type getType() { } @Override - public CompoundTag toTag() { + public CompoundNBT toTag() { return null; } diff --git a/common/src/main/java/com/ultreon/devices/core/io/task/TaskGetFiles.java b/common/src/main/java/com/ultreon/devices/core/io/task/TaskGetFiles.java index 7b8c122a4..e9cd99155 100644 --- a/common/src/main/java/com/ultreon/devices/core/io/task/TaskGetFiles.java +++ b/common/src/main/java/com/ultreon/devices/core/io/task/TaskGetFiles.java @@ -7,13 +7,13 @@ import com.ultreon.devices.core.io.ServerFile; import com.ultreon.devices.core.io.ServerFolder; import com.ultreon.devices.core.io.drive.AbstractDrive; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.ListNBT; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.chunk.Chunk; import java.util.List; import java.util.UUID; @@ -56,15 +56,15 @@ protected static String compileDirectory(ServerFile file) { } @Override - public void prepareRequest(CompoundTag tag) { + public void prepareRequest(CompoundNBT tag) { tag.putString("uuid", uuid); tag.putString("path", path); tag.putLong("pos", pos.asLong()); } @Override - public void processRequest(CompoundTag tag, Level level, Player player) { - BlockEntity tileEntity = level.getChunkAt(BlockPos.of(tag.getLong("pos"))).getBlockEntity(BlockPos.of(tag.getLong("pos")), LevelChunk.EntityCreationType.IMMEDIATE); + public void processRequest(CompoundNBT tag, World level, PlayerEntity player) { + TileEntity tileEntity = level.getChunkAt(BlockPos.of(tag.getLong("pos"))).getBlockEntity(BlockPos.of(tag.getLong("pos")), Chunk.CreateEntityType.IMMEDIATE); if (tileEntity instanceof LaptopBlockEntity laptop) { FileSystem fileSystem = laptop.getFileSystem(); UUID uuid = UUID.fromString(tag.getString("uuid")); @@ -80,11 +80,11 @@ public void processRequest(CompoundTag tag, Level level, Player player) { } @Override - public void prepareResponse(CompoundTag tag) { + public void prepareResponse(CompoundNBT tag) { if (this.files != null) { - ListTag list = new ListTag(); + ListNBT list = new ListNBT(); this.files.forEach(f -> { - CompoundTag fileTag = new CompoundTag(); + CompoundNBT fileTag = new CompoundNBT(); fileTag.putString("file_name", f.getName()); fileTag.put("data", f.toTag()); list.add(fileTag); @@ -94,7 +94,7 @@ public void prepareResponse(CompoundTag tag) { } @Override - public void processResponse(CompoundTag tag) { + public void processResponse(CompoundNBT tag) { } } diff --git a/common/src/main/java/com/ultreon/devices/core/io/task/TaskGetMainDrive.java b/common/src/main/java/com/ultreon/devices/core/io/task/TaskGetMainDrive.java index bc1735c46..3e1585e3d 100644 --- a/common/src/main/java/com/ultreon/devices/core/io/task/TaskGetMainDrive.java +++ b/common/src/main/java/com/ultreon/devices/core/io/task/TaskGetMainDrive.java @@ -8,11 +8,11 @@ import com.ultreon.devices.core.io.FileSystem; import com.ultreon.devices.core.io.drive.AbstractDrive; import net.minecraft.client.Minecraft; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; +import net.minecraft.tileentity.TileEntity; /** * @author MrCrayfish @@ -32,13 +32,13 @@ public TaskGetMainDrive(BlockPos pos) { } @Override - public void prepareRequest(CompoundTag tag) { + public void prepareRequest(CompoundNBT tag) { tag.putLong("pos", pos.asLong()); } @Override - public void processRequest(CompoundTag tag, Level level, Player player) { - BlockEntity tileEntity = level.getBlockEntity(BlockPos.of(tag.getLong("pos"))); + public void processRequest(CompoundNBT tag, World level, PlayerEntity player) { + TileEntity tileEntity = level.getBlockEntity(BlockPos.of(tag.getLong("pos"))); if (tileEntity instanceof LaptopBlockEntity laptop) { FileSystem fileSystem = laptop.getFileSystem(); mainDrive = fileSystem.getMainDrive(); @@ -47,9 +47,9 @@ public void processRequest(CompoundTag tag, Level level, Player player) { } @Override - public void prepareResponse(CompoundTag tag) { + public void prepareResponse(CompoundNBT tag) { if (this.isSucessful()) { - CompoundTag mainDriveTag = new CompoundTag(); + CompoundNBT mainDriveTag = new CompoundNBT(); mainDriveTag.putString("name", mainDrive.getName()); mainDriveTag.putString("uuid", mainDrive.getUuid().toString()); mainDriveTag.putString("type", mainDrive.getType().toString()); @@ -59,10 +59,10 @@ public void prepareResponse(CompoundTag tag) { } @Override - public void processResponse(CompoundTag tag) { + public void processResponse(CompoundNBT tag) { if (this.isSucessful()) { if (Minecraft.getInstance().screen instanceof Laptop) { - CompoundTag structureTag = tag.getCompound("structure"); + CompoundNBT structureTag = tag.getCompound("structure"); Drive drive = new Drive(tag.getCompound("main_drive")); drive.syncRoot(Folder.fromTag(FileSystem.LAPTOP_DRIVE_NAME, structureTag)); drive.getRoot().validate(); diff --git a/common/src/main/java/com/ultreon/devices/core/io/task/TaskGetStructure.java b/common/src/main/java/com/ultreon/devices/core/io/task/TaskGetStructure.java index e4ca329f3..9d3171f6a 100644 --- a/common/src/main/java/com/ultreon/devices/core/io/task/TaskGetStructure.java +++ b/common/src/main/java/com/ultreon/devices/core/io/task/TaskGetStructure.java @@ -6,11 +6,11 @@ import com.ultreon.devices.core.io.FileSystem; import com.ultreon.devices.core.io.ServerFolder; import com.ultreon.devices.core.io.drive.AbstractDrive; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; +import net.minecraft.tileentity.TileEntity; import java.util.UUID; @@ -34,14 +34,14 @@ public TaskGetStructure(Drive drive, BlockPos pos) { } @Override - public void prepareRequest(CompoundTag tag) { + public void prepareRequest(CompoundNBT tag) { tag.putString("uuid", uuid); tag.putLong("pos", pos.asLong()); } @Override - public void processRequest(CompoundTag tag, Level level, Player player) { - BlockEntity tileEntity = level.getBlockEntity(BlockPos.of(tag.getLong("pos"))); + public void processRequest(CompoundNBT tag, World level, PlayerEntity player) { + TileEntity tileEntity = level.getBlockEntity(BlockPos.of(tag.getLong("pos"))); if (tileEntity instanceof LaptopBlockEntity laptop) { FileSystem fileSystem = laptop.getFileSystem(); UUID uuid = UUID.fromString(tag.getString("uuid")); @@ -54,7 +54,7 @@ public void processRequest(CompoundTag tag, Level level, Player player) { } @Override - public void prepareResponse(CompoundTag tag) { + public void prepareResponse(CompoundNBT tag) { if (folder != null) { tag.putString("file_name", folder.getName()); tag.put("structure", folder.toTag()); @@ -62,7 +62,7 @@ public void prepareResponse(CompoundTag tag) { } @Override - public void processResponse(CompoundTag tag) { + public void processResponse(CompoundNBT tag) { } } diff --git a/common/src/main/java/com/ultreon/devices/core/io/task/TaskSendAction.java b/common/src/main/java/com/ultreon/devices/core/io/task/TaskSendAction.java index e96933324..45416341e 100644 --- a/common/src/main/java/com/ultreon/devices/core/io/task/TaskSendAction.java +++ b/common/src/main/java/com/ultreon/devices/core/io/task/TaskSendAction.java @@ -6,12 +6,12 @@ import com.ultreon.devices.core.Laptop; import com.ultreon.devices.core.io.FileSystem; import com.ultreon.devices.core.io.action.FileAction; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.chunk.Chunk; /** * @author MrCrayfish @@ -35,16 +35,16 @@ public TaskSendAction(Drive drive, FileAction action) { } @Override - public void prepareRequest(CompoundTag tag) { + public void prepareRequest(CompoundNBT tag) { tag.putString("uuid", uuid); tag.put("action", action.toTag()); tag.putLong("pos", pos.asLong()); } @Override - public void processRequest(CompoundTag tag, Level level, Player player) { + public void processRequest(CompoundNBT tag, World level, PlayerEntity player) { FileAction action = FileAction.fromTag(tag.getCompound("action")); - BlockEntity tileEntity = level.getChunkAt(BlockPos.of(tag.getLong("pos"))).getBlockEntity(BlockPos.of(tag.getLong("pos")), LevelChunk.EntityCreationType.IMMEDIATE); + TileEntity tileEntity = level.getChunkAt(BlockPos.of(tag.getLong("pos"))).getBlockEntity(BlockPos.of(tag.getLong("pos")), Chunk.CreateEntityType.IMMEDIATE); if (tileEntity instanceof LaptopBlockEntity laptop) { response = laptop.getFileSystem().readAction(tag.getString("uuid"), action, level); this.setSuccessful(); @@ -52,12 +52,12 @@ public void processRequest(CompoundTag tag, Level level, Player player) { } @Override - public void prepareResponse(CompoundTag tag) { + public void prepareResponse(CompoundNBT tag) { tag.put("response", response.toTag()); } @Override - public void processResponse(CompoundTag tag) { + public void processResponse(CompoundNBT tag) { } } diff --git a/common/src/main/java/com/ultreon/devices/core/io/task/TaskSetupFileBrowser.java b/common/src/main/java/com/ultreon/devices/core/io/task/TaskSetupFileBrowser.java index 944c86ca3..c98877c1e 100644 --- a/common/src/main/java/com/ultreon/devices/core/io/task/TaskSetupFileBrowser.java +++ b/common/src/main/java/com/ultreon/devices/core/io/task/TaskSetupFileBrowser.java @@ -4,13 +4,13 @@ import com.ultreon.devices.block.entity.LaptopBlockEntity; import com.ultreon.devices.core.io.FileSystem; import com.ultreon.devices.core.io.drive.AbstractDrive; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.ListNBT; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.chunk.Chunk; import java.util.Map; import java.util.UUID; @@ -36,14 +36,14 @@ public TaskSetupFileBrowser(BlockPos pos, boolean includeMain) { } @Override - public void prepareRequest(CompoundTag tag) { + public void prepareRequest(CompoundNBT tag) { tag.putLong("pos", pos.asLong()); tag.putBoolean("include_main", includeMain); } @Override - public void processRequest(CompoundTag tag, Level level, Player player) { - BlockEntity tileEntity = level.getChunkAt(BlockPos.of(tag.getLong("pos"))).getBlockEntity(BlockPos.of(tag.getLong("pos")), LevelChunk.EntityCreationType.IMMEDIATE); + public void processRequest(CompoundNBT tag, World level, PlayerEntity player) { + TileEntity tileEntity = level.getChunkAt(BlockPos.of(tag.getLong("pos"))).getBlockEntity(BlockPos.of(tag.getLong("pos")), Chunk.CreateEntityType.IMMEDIATE); if (tileEntity instanceof LaptopBlockEntity laptop) { FileSystem fileSystem = laptop.getFileSystem(); if (tag.getBoolean("include_main")) { @@ -55,10 +55,10 @@ public void processRequest(CompoundTag tag, Level level, Player player) { } @Override - public void prepareResponse(CompoundTag tag) { + public void prepareResponse(CompoundNBT tag) { if (this.isSucessful()) { if (mainDrive != null) { - CompoundTag mainDriveTag = new CompoundTag(); + CompoundNBT mainDriveTag = new CompoundNBT(); mainDriveTag.putString("name", mainDrive.getName()); mainDriveTag.putString("uuid", mainDrive.getUuid().toString()); mainDriveTag.putString("type", mainDrive.getType().toString()); @@ -66,9 +66,9 @@ public void prepareResponse(CompoundTag tag) { tag.put("structure", mainDrive.getDriveStructure().toTag()); } - ListTag driveList = new ListTag(); + ListNBT driveList = new ListNBT(); availableDrives.forEach((k, v) -> { - CompoundTag driveTag = new CompoundTag(); + CompoundNBT driveTag = new CompoundNBT(); driveTag.putString("name", v.getName()); driveTag.putString("uuid", v.getUuid().toString()); driveTag.putString("type", v.getType().toString()); @@ -79,7 +79,7 @@ public void prepareResponse(CompoundTag tag) { } @Override - public void processResponse(CompoundTag tag) { + public void processResponse(CompoundNBT tag) { } } diff --git a/common/src/main/java/com/ultreon/devices/core/laptop/client/ClientLaptop.java b/common/src/main/java/com/ultreon/devices/core/laptop/client/ClientLaptop.java index 9dd1a80ac..ff53eabb6 100644 --- a/common/src/main/java/com/ultreon/devices/core/laptop/client/ClientLaptop.java +++ b/common/src/main/java/com/ultreon/devices/core/laptop/client/ClientLaptop.java @@ -1,8 +1,8 @@ package com.ultreon.devices.core.laptop.client; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.*; -import com.mojang.math.Matrix4f; +import com.mojang.blaze3d.matrix.*; +import net.minecraft.util.math.vector.Matrix4f; import com.ultreon.devices.Devices; import com.ultreon.devices.Reference; import com.ultreon.devices.core.laptop.common.C2SUpdatePacket; @@ -11,18 +11,18 @@ import com.ultreon.devices.network.PacketHandler; import net.minecraft.client.Minecraft; import net.minecraft.client.Screenshot; -import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.IngameGui; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.gui.screens.inventory.ContainerScreen; import net.minecraft.client.renderer.GameRenderer; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.entity.player.Inventory; -import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraft.world.inventory.ChestMenu; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.text.Component; +import net.minecraft.util.ResourceLocation; +import net.minecraft.entity.player.Inventory; +import net.minecraft.inventory.container.AbstractContainerMenu; +import net.minecraft.inventory.container.ChestMenu; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -30,7 +30,7 @@ import java.util.UUID; import static com.ultreon.devices.core.laptop.client.ClientLaptopScreen.LAPTOP_GUI; -import static net.minecraft.client.gui.GuiComponent.blit; +import static net.minecraft.client.gui.AbstractGui.blit; // NO STATICS @@ -53,7 +53,7 @@ public ClientLaptop() { //super(Component.translatable("laptop")); //todo } - public void handlePacket(String type, CompoundTag nbt) { + public void handlePacket(String type, CompoundNBT nbt) { if (type.equals("placeSquare")) { System.out.println("moving square lol"); System.out.println(nbt); @@ -63,37 +63,37 @@ public void handlePacket(String type, CompoundTag nbt) { } } - public void sendPacket(String type, CompoundTag nbt) { + public void sendPacket(String type, CompoundNBT nbt) { System.out.printf("Sending packet %s, %s%n", type, nbt); PacketHandler.sendToServer(new C2SUpdatePacket(this.uuid, type, nbt)); } - public void renderBezels(final @NotNull PoseStack pose, final int mouseX, final int mouseY, float partialTicks) { // no bezels + public void renderBezels(final @NotNull MatrixStack pose, final int mouseX, final int mouseY, float partialTicks) { // no bezels } //@Override - public void render(final @NotNull PoseStack pose, final int mouseX, final int mouseY, float partialTicks) { + public void render(final @NotNull MatrixStack pose, final int mouseX, final int mouseY, float partialTicks) { double[] square = new double[2]; Minecraft.getInstance().doRunTask(() -> { square[0] = this.square[0]; square[1] = this.square[1]; }); - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); - RenderSystem.setShaderTexture(0, LAPTOP_GUI); + RenderSystem.blendColor(1f, 1f, 1f, 1f); + mc.textureManager.bind(LAPTOP_GUI); //RenderSystem.disableBlend(); - Gui.blit(pose, 0, 0, ClientLaptop.SCREEN_WIDTH, ClientLaptop.SCREEN_HEIGHT, 10, 10, 1, 1, 256, 256); + IngameGui.blit(pose, 0, 0, ClientLaptop.SCREEN_WIDTH, ClientLaptop.SCREEN_HEIGHT, 10, 10, 1, 1, 256, 256); //RenderSystem.enableBlend(); Minecraft.getInstance().font.draw(pose, "New Laptop System 0.01% complete", 0, 0, 0xffffff); - Gui.fill(pose, 0, 0, 10, 10, 0x2e2e2e); + IngameGui.fill(pose, 0, 0, 10, 10, 0x2e2e2e); taskbar.render(pose, this, Minecraft.getInstance(), 0, SCREEN_HEIGHT-16, mouseX, mouseY, partialTicks); System.out.println("x = " + square[0]); - Gui.fill(pose, (int) square[0], (int) square[1], (int) square[0]+10, (int) square[1]+10, 0xffffff); + IngameGui.fill(pose, (int) square[0], (int) square[1], (int) square[0]+10, (int) square[1]+10, 0xffffff); } public void mouseMoved(double mouseX, double mouseY) { - var nbt = new CompoundTag(); + var nbt = new CompoundNBT(); nbt.putDouble("x", mouseX); nbt.putDouble("y", mouseY); sendPacket("mouseMoved", nbt); diff --git a/common/src/main/java/com/ultreon/devices/core/laptop/client/ClientLaptopScreen.java b/common/src/main/java/com/ultreon/devices/core/laptop/client/ClientLaptopScreen.java index 144b1b1e9..938ed18a9 100644 --- a/common/src/main/java/com/ultreon/devices/core/laptop/client/ClientLaptopScreen.java +++ b/common/src/main/java/com/ultreon/devices/core/laptop/client/ClientLaptopScreen.java @@ -1,13 +1,13 @@ package com.ultreon.devices.core.laptop.client; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.Reference; -import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.IngameGui; import net.minecraft.client.gui.screens.Screen; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.text.Component; +import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.util.ResourceLocation; import org.jetbrains.annotations.NotNull; import java.util.Arrays; @@ -20,15 +20,15 @@ public class ClientLaptopScreen extends Screen { public ClientLaptopScreen(ClientLaptop laptop) { - super(new TranslatableComponent(laptop.toString())); + super(new TranslationTextComponent(laptop.toString())); this.laptop = laptop; } - public void renderBezels(final @NotNull PoseStack pose, final int mouseX, final int mouseY, float partialTicks) { + public void renderBezels(final @NotNull MatrixStack pose, final int mouseX, final int mouseY, float partialTicks) { this.renderBackground(pose); - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); - RenderSystem.setShaderTexture(0, LAPTOP_GUI); + RenderSystem.blendColor(1f, 1f, 1f, 1f); + mc.textureManager.bind(LAPTOP_GUI); //*************************// // Physical Screen // @@ -43,24 +43,24 @@ public void renderBezels(final @NotNull PoseStack pose, final int mouseX, final blit(pose, posX, posY + ClientLaptop.DEVICE_HEIGHT - BORDER, 0, 11, BORDER, BORDER); // BOTTOM-LEFT // Edges - Gui.blit(pose, posX + BORDER, posY, ClientLaptop.SCREEN_WIDTH, BORDER, 10, 0, 1, BORDER, 256, 256); // TOP - Gui.blit(pose, posX + ClientLaptop.DEVICE_WIDTH - BORDER, posY + BORDER, BORDER, ClientLaptop.SCREEN_HEIGHT, 11, 10, BORDER, 1, 256, 256); // RIGHT - Gui.blit(pose, posX + BORDER, posY + ClientLaptop.DEVICE_HEIGHT - BORDER, ClientLaptop.SCREEN_WIDTH, BORDER, 10, 11, 1, BORDER, 256, 256); // BOTTOM - Gui.blit(pose, posX, posY + BORDER, BORDER, ClientLaptop.SCREEN_HEIGHT, 0, 11, BORDER, 1, 256, 256); // LEFT + IngameGui.blit(pose, posX + BORDER, posY, ClientLaptop.SCREEN_WIDTH, BORDER, 10, 0, 1, BORDER, 256, 256); // TOP + IngameGui.blit(pose, posX + ClientLaptop.DEVICE_WIDTH - BORDER, posY + BORDER, BORDER, ClientLaptop.SCREEN_HEIGHT, 11, 10, BORDER, 1, 256, 256); // RIGHT + IngameGui.blit(pose, posX + BORDER, posY + ClientLaptop.DEVICE_HEIGHT - BORDER, ClientLaptop.SCREEN_WIDTH, BORDER, 10, 11, 1, BORDER, 256, 256); // BOTTOM + IngameGui.blit(pose, posX, posY + BORDER, BORDER, ClientLaptop.SCREEN_HEIGHT, 0, 11, BORDER, 1, 256, 256); // LEFT // Center - Gui.blit(pose, posX + BORDER, posY + BORDER, ClientLaptop.SCREEN_WIDTH, ClientLaptop.SCREEN_HEIGHT, 10, 10, 1, 1, 256, 256); + IngameGui.blit(pose, posX + BORDER, posY + BORDER, ClientLaptop.SCREEN_WIDTH, ClientLaptop.SCREEN_HEIGHT, 10, 10, 1, 1, 256, 256); } @Override - public void render(PoseStack poseStack, int mouseX, int mouseY, float partialTick) { + public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTick) { int posX = (width - ClientLaptop.DEVICE_WIDTH) / 2 + BORDER; int posY = (height - ClientLaptop.DEVICE_HEIGHT) / 2 + BORDER; - super.render(poseStack, mouseX, mouseY, partialTick); - renderBezels(poseStack, mouseX, mouseY, partialTick); - poseStack.translate(posX, posY, 0); - laptop.render(poseStack, mouseX-posX, mouseY-posY, partialTick); + super.render(matrices, mouseX, mouseY, partialTick); + renderBezels(matrices, mouseX, mouseY, partialTick); + matrices.translate(posX, posY, 0); + laptop.render(matrices, mouseX-posX, mouseY-posY, partialTick); } @Override diff --git a/common/src/main/java/com/ultreon/devices/core/laptop/common/C2SUpdatePacket.java b/common/src/main/java/com/ultreon/devices/core/laptop/common/C2SUpdatePacket.java index 843a2daa1..a1597dd47 100644 --- a/common/src/main/java/com/ultreon/devices/core/laptop/common/C2SUpdatePacket.java +++ b/common/src/main/java/com/ultreon/devices/core/laptop/common/C2SUpdatePacket.java @@ -3,37 +3,37 @@ import com.ultreon.devices.core.laptop.client.ClientLaptop; import com.ultreon.devices.core.laptop.server.ServerLaptop; import com.ultreon.devices.network.Packet; -import dev.architectury.networking.NetworkManager; -import net.fabricmc.api.EnvType; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.FriendlyByteBuf; +import net.minecraftforge.fml.network.NetworkEvent; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.network.PacketBuffer; import java.util.UUID; import java.util.function.Supplier; public class C2SUpdatePacket extends Packet { - private final CompoundTag nbt; + private final CompoundNBT nbt; - public C2SUpdatePacket(UUID laptop, String type, CompoundTag nbt) { - this.nbt = new CompoundTag(); + public C2SUpdatePacket(UUID laptop, String type, CompoundNBT nbt) { + this.nbt = new CompoundNBT(); this.nbt.putUUID("uuid", laptop); // laptop uuid this.nbt.putString("type", type); this.nbt.put("data", nbt); } @Deprecated // do not call - public C2SUpdatePacket(FriendlyByteBuf buf) { + public C2SUpdatePacket(PacketBuffer buf) { this.nbt = buf.readNbt(); } @Override - public void toBytes(FriendlyByteBuf buf) { + public void toBytes(PacketBuffer buf) { buf.writeNbt(nbt); } @Override - public boolean onMessage(Supplier ctx) { - if (ctx.get().getEnv().equals(EnvType.SERVER)) { - ServerLaptop.laptops.get(this.nbt.getUUID("uuid")).handlePacket(ctx.get().getPlayer(), this.nbt.getString("type"), this.nbt.getCompound("data")); + public boolean onMessage(Supplier ctx) { + if (ctx.get().getDirection().getReceptionSide().equals(LogicalSide.SERVER)) { + ServerLaptop.laptops.get(this.nbt.getUUID("uuid")).handlePacket(ctx.get().getSender(), this.nbt.getString("type"), this.nbt.getCompound("data")); } return false; } diff --git a/common/src/main/java/com/ultreon/devices/core/laptop/common/S2CUpdatePacket.java b/common/src/main/java/com/ultreon/devices/core/laptop/common/S2CUpdatePacket.java index 3873c95ca..a2a687ec6 100644 --- a/common/src/main/java/com/ultreon/devices/core/laptop/common/S2CUpdatePacket.java +++ b/common/src/main/java/com/ultreon/devices/core/laptop/common/S2CUpdatePacket.java @@ -3,38 +3,38 @@ import com.ultreon.devices.core.laptop.client.ClientLaptop; import com.ultreon.devices.core.laptop.server.ServerLaptop; import com.ultreon.devices.network.Packet; -import dev.architectury.networking.NetworkManager; -import net.fabricmc.api.EnvType; +import net.minecraftforge.fml.network.NetworkEvent; +import net.minecraftforge.api.distmarker.Dist; import net.minecraft.client.Minecraft; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.network.PacketBuffer; import java.util.Arrays; import java.util.UUID; import java.util.function.Supplier; public class S2CUpdatePacket extends Packet { - private final CompoundTag nbt; + private final CompoundNBT nbt; - public S2CUpdatePacket(UUID laptop, String type, CompoundTag nbt) { - this.nbt = new CompoundTag(); + public S2CUpdatePacket(UUID laptop, String type, CompoundNBT nbt) { + this.nbt = new CompoundNBT(); this.nbt.putUUID("uuid", laptop); // laptop uuid this.nbt.putString("type", type); this.nbt.put("data", nbt); } @Deprecated // do not call - public S2CUpdatePacket(FriendlyByteBuf buf) { + public S2CUpdatePacket(PacketBuffer buf) { this.nbt = buf.readNbt(); } @Override - public void toBytes(FriendlyByteBuf buf) { + public void toBytes(PacketBuffer buf) { buf.writeNbt(nbt); } @Override - public boolean onMessage(Supplier ctx) { - if (ctx.get().getEnv().equals(EnvType.CLIENT)) { + public boolean onMessage(Supplier ctx) { + if (ctx.get().getDirection().getReceptionSide().equals(LogicalSide.CLIENT)) { ClientLaptop.laptops.get(this.nbt.getUUID("uuid")).handlePacket(this.nbt.getString("type"), this.nbt.getCompound("data")); System.out.println("SQUARE: " + Arrays.toString(ClientLaptop.laptops.get(this.nbt.getUUID("uuid")).square)); } diff --git a/common/src/main/java/com/ultreon/devices/core/laptop/common/TaskBar.java b/common/src/main/java/com/ultreon/devices/core/laptop/common/TaskBar.java index 59f740569..7d091084f 100644 --- a/common/src/main/java/com/ultreon/devices/core/laptop/common/TaskBar.java +++ b/common/src/main/java/com/ultreon/devices/core/laptop/common/TaskBar.java @@ -1,7 +1,7 @@ package com.ultreon.devices.core.laptop.common; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.Devices; import com.ultreon.devices.api.TrayItemAdder; import com.ultreon.devices.api.app.Application; @@ -17,10 +17,10 @@ import com.ultreon.devices.programs.system.SystemApp; import com.ultreon.devices.programs.system.object.ColorScheme; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiComponent; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.client.gui.IngameGui; +import net.minecraft.client.gui.AbstractGui; +import net.minecraft.util.text.Component; +import net.minecraft.util.ResourceLocation; import org.slf4j.Marker; import org.slf4j.MarkerFactory; @@ -56,10 +56,10 @@ public TaskBar(ClientLaptop laptop) { // trayItems.forEach(TrayItem::tick); // } - public void render(PoseStack pose, ClientLaptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, float partialTicks) { - RenderSystem.setShaderColor(1f, 1f, 1f, 0.75f); + public void render(MatrixStack pose, ClientLaptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, float partialTicks) { + RenderSystem.blendColor(1f, 1f, 1f, 0.75f); RenderSystem.enableBlend(); - RenderSystem.setShaderTexture(0, APP_BAR_GUI); + mc.textureManager.bind(APP_BAR_GUI); // r=217,g=230,b=255 var colorScheme = new ColorScheme(); @@ -67,16 +67,16 @@ public void render(PoseStack pose, ClientLaptop laptop, Minecraft mc, int x, int Color bgColor = new Color(colorScheme.getBackgroundColor());//.brighter().brighter(); float[] hsb = Color.RGBtoHSB(bgColor.getRed(), bgColor.getGreen(), bgColor.getBlue(), null); bgColor = new Color(Color.HSBtoRGB(hsb[0], hsb[1], hsb[2])); - RenderSystem.setShaderColor(bgColor.getRed() / 255f, bgColor.getGreen() / 255f, bgColor.getBlue() / 255f, 1f); + RenderSystem.blendColor(bgColor.getRed() / 255f, bgColor.getGreen() / 255f, bgColor.getBlue() / 255f, 1f); int trayItemsWidth = /*trayItems.size()*/0 * 14; - GuiComponent.blit(pose, x, y, 1, 18, 0, 0, 1, 18, 256, 256); - GuiComponent.blit(pose, x + 1, y, ClientLaptop.SCREEN_WIDTH - 36 - trayItemsWidth, 18, 1, 0, 1, 18, 256, 256); - GuiComponent.blit(pose, x + ClientLaptop.SCREEN_WIDTH - 35 - trayItemsWidth, y, 35 + trayItemsWidth, 18, 2, 0, 1, 18, 256, 256); + AbstractGui.blit(pose, x, y, 1, 18, 0, 0, 1, 18, 256, 256); + AbstractGui.blit(pose, x + 1, y, ClientLaptop.SCREEN_WIDTH - 36 - trayItemsWidth, 18, 1, 0, 1, 18, 256, 256); + AbstractGui.blit(pose, x + ClientLaptop.SCREEN_WIDTH - 35 - trayItemsWidth, y, 35 + trayItemsWidth, 18, 2, 0, 1, 18, 256, 256); RenderSystem.disableBlend(); - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.blendColor(1f, 1f, 1f, 1f); // for (int i = 0; i < APPS_DISPLAYED && i < laptop.installedApps.size(); i++) { // AppInfo info = laptop.installedApps.get(i + offset); // RenderUtil.drawApplicationIcon(pose, info, x + 2 + i * 16, y + 2); @@ -100,7 +100,7 @@ public void render(PoseStack pose, ClientLaptop laptop, Minecraft mc, int x, int // trayItems.get(i).getIcon().draw(pose, mc, posX + 2, y + 4); // } - RenderSystem.setShaderTexture(0, APP_BAR_GUI); + mc.textureManager.bind(APP_BAR_GUI); // /* Other Apps */ // if (isMouseInside(mouseX, mouseY, x + 1, y + 1, x + 236, y + 16)) { @@ -111,7 +111,7 @@ public void render(PoseStack pose, ClientLaptop laptop, Minecraft mc, int x, int // } // } - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.blendColor(1f, 1f, 1f, 1f); // RenderHelper.disableStandardItemLighting(); } diff --git a/common/src/main/java/com/ultreon/devices/core/laptop/server/ServerLaptop.java b/common/src/main/java/com/ultreon/devices/core/laptop/server/ServerLaptop.java index 5bee26ba0..3dd2b8561 100644 --- a/common/src/main/java/com/ultreon/devices/core/laptop/server/ServerLaptop.java +++ b/common/src/main/java/com/ultreon/devices/core/laptop/server/ServerLaptop.java @@ -2,8 +2,8 @@ import com.ultreon.devices.core.laptop.common.S2CUpdatePacket; import com.ultreon.devices.network.PacketHandler; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.player.Player; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.entity.player.PlayerEntity; import java.util.HashMap; import java.util.UUID; @@ -11,7 +11,7 @@ public class ServerLaptop { public static HashMap laptops = new HashMap<>(); private final UUID uuid = new UUID(430985038594038L, 493058808830598L); - public void sendPacket(Player player, String type, CompoundTag nbt) { + public void sendPacket(PlayerEntity player, String type, CompoundNBT nbt) { PacketHandler.sendToClient(new S2CUpdatePacket(this.uuid, type, nbt), player); } @@ -19,7 +19,7 @@ public UUID getUuid() { return uuid; } - public void handlePacket(Player player, String type, CompoundTag data) { + public void handlePacket(PlayerEntity player, String type, CompoundNBT data) { System.out.printf("Handling %s, %s%n", type, data); if (type.equals("mouseMoved")) { var x = data.getDouble("x"); diff --git a/common/src/main/java/com/ultreon/devices/core/network/Connection.java b/common/src/main/java/com/ultreon/devices/core/network/Connection.java index 76f07a3f5..39de3a14d 100644 --- a/common/src/main/java/com/ultreon/devices/core/network/Connection.java +++ b/common/src/main/java/com/ultreon/devices/core/network/Connection.java @@ -1,24 +1,24 @@ package com.ultreon.devices.core.network; import com.ultreon.devices.block.entity.RouterBlockEntity; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.world.World; +import net.minecraft.tileentity.TileEntity; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.UUID; -public class Connection { +public class NetworkManager { private UUID routerId; private BlockPos routerPos; - private Connection() { + private NetworkManager() { } - public Connection(Router router) { + public NetworkManager(Router router) { this.routerId = router.getId(); this.routerPos = router.getPos(); } @@ -37,11 +37,11 @@ public void setRouterPos(@Nullable BlockPos routerPos) { } @Nullable - public Router getRouter(@NotNull Level level) { + public Router getRouter(@NotNull World level) { if (routerPos == null) return null; - BlockEntity blockEntity = level.getBlockEntity(routerPos); + TileEntity blockEntity = level.getBlockEntity(routerPos); if (blockEntity instanceof RouterBlockEntity router) { if (router.getRouter().getId().equals(routerId)) { return router.getRouter(); @@ -54,14 +54,14 @@ public boolean isConnected() { return routerPos != null; } - public CompoundTag toTag() { - CompoundTag tag = new CompoundTag(); + public CompoundNBT toTag() { + CompoundNBT tag = new CompoundNBT(); tag.putString("id", routerId.toString()); return tag; } - public static Connection fromTag(CompoundTag tag) { - Connection connection = new Connection(); + public static NetworkManager fromTag(CompoundNBT tag) { + NetworkManager connection = new NetworkManager(); connection.routerId = UUID.fromString(tag.getString("id")); return connection; } diff --git a/common/src/main/java/com/ultreon/devices/core/network/NetworkDevice.java b/common/src/main/java/com/ultreon/devices/core/network/NetworkDevice.java index 37d2f7e51..4b779f652 100644 --- a/common/src/main/java/com/ultreon/devices/core/network/NetworkDevice.java +++ b/common/src/main/java/com/ultreon/devices/core/network/NetworkDevice.java @@ -2,11 +2,11 @@ import com.ultreon.devices.block.entity.NetworkDeviceBlockEntity; import com.ultreon.devices.core.Device; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.INBT; +import net.minecraft.world.World; +import net.minecraft.tileentity.TileEntity; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -25,12 +25,12 @@ public NetworkDevice(@NotNull UUID id, @NotNull String name, @NotNull Router rou super(id, name); } - public boolean isConnected(Level level) { + public boolean isConnected(World level) { if (pos == null) { return false; } - BlockEntity blockEntity = level.getBlockEntity(pos); + TileEntity blockEntity = level.getBlockEntity(pos); if (blockEntity instanceof NetworkDeviceBlockEntity device) { Router router = device.getRouter(); return router != null && router.getId().equals(this.getId()); @@ -40,11 +40,11 @@ public boolean isConnected(Level level) { @Nullable @Override - public NetworkDeviceBlockEntity getDevice(@NotNull Level level) { + public NetworkDeviceBlockEntity getDevice(@NotNull World level) { if (pos == null) return null; - BlockEntity blockEntity = level.getBlockEntity(pos); + TileEntity blockEntity = level.getBlockEntity(pos); if (blockEntity instanceof NetworkDeviceBlockEntity device) { return device; } @@ -52,20 +52,20 @@ public NetworkDeviceBlockEntity getDevice(@NotNull Level level) { } @Override - public CompoundTag toTag(boolean includePos) { - CompoundTag tag = super.toTag(includePos); + public CompoundNBT toTag(boolean includePos) { + CompoundNBT tag = super.toTag(includePos); if (includePos && pos != null) { tag.putLong("pos", pos.asLong()); } return tag; } - public static NetworkDevice fromTag(CompoundTag tag) { + public static NetworkDevice fromTag(CompoundNBT tag) { NetworkDevice device = new NetworkDevice(); device.id = UUID.fromString(tag.getString("id")); device.name = tag.getString("name"); - if (tag.contains("pos", Tag.TAG_LONG)) { + if (tag.contains("pos", Constants.NBT.TAG_LONG)) { device.pos = BlockPos.of(tag.getLong("pos")); } return device; diff --git a/common/src/main/java/com/ultreon/devices/core/network/Router.java b/common/src/main/java/com/ultreon/devices/core/network/Router.java index 566f936fc..5469e57ee 100644 --- a/common/src/main/java/com/ultreon/devices/core/network/Router.java +++ b/common/src/main/java/com/ultreon/devices/core/network/Router.java @@ -2,11 +2,11 @@ import com.ultreon.devices.DeviceConfig; import com.ultreon.devices.block.entity.NetworkDeviceBlockEntity; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.ListNBT; +import net.minecraft.world.World; +import net.minecraft.tileentity.TileEntity; import org.jetbrains.annotations.Nullable; import java.util.Collection; @@ -26,7 +26,7 @@ public Router(BlockPos pos) { this.pos = pos; } - public void tick(Level level) { + public void tick(World level) { if (++timer >= DeviceConfig.BEACON_INTERVAL.get()) { sendBeacon(level); timer = 0; @@ -67,7 +67,7 @@ public void removeDevice(NetworkDeviceBlockEntity device) { } @Nullable - public NetworkDeviceBlockEntity getDevice(Level level, UUID id) { + public NetworkDeviceBlockEntity getDevice(World level, UUID id) { return NETWORK_DEVICES.containsKey(id) ? NETWORK_DEVICES.get(id).getDevice(level) : null; } @@ -75,17 +75,17 @@ public Collection getNetworkDevices() { return NETWORK_DEVICES.values(); } - public Collection getConnectedDevices(Level level) { + public Collection getConnectedDevices(World level) { sendBeacon(level); return NETWORK_DEVICES.values().stream().filter(device -> device.getPos() != null).toList(); } - public Collection getConnectedDevices(final Level level, Class type) { + public Collection getConnectedDevices(final World level, Class type) { final Predicate DEVICE_TYPE = networkDevice -> { if (networkDevice.getPos() == null) return false; - BlockEntity blockEntity = level.getBlockEntity(networkDevice.getPos()); + TileEntity blockEntity = level.getBlockEntity(networkDevice.getPos()); if (blockEntity instanceof NetworkDeviceBlockEntity device) { return type.isAssignableFrom(device.getClass()); } @@ -94,7 +94,7 @@ public Collection getConnectedDevices(final Level level, Class { deviceList.add(device.toTag(includePos)); }); @@ -145,11 +145,11 @@ public CompoundTag toTag(boolean includePos) { return tag; } - public static Router fromTag(BlockPos pos, CompoundTag tag) { + public static Router fromTag(BlockPos pos, CompoundNBT tag) { Router router = new Router(pos); router.routerId = tag.getUUID("id"); - ListTag deviceList = tag.getList("network_devices", 10); + ListNBT deviceList = tag.getList("network_devices", 10); for (int i = 0; i < deviceList.size(); i++) { NetworkDevice device = NetworkDevice.fromTag(deviceList.getCompound(i)); router.NETWORK_DEVICES.put(device.getId(), device); diff --git a/common/src/main/java/com/ultreon/devices/core/network/TrayItemWifi.java b/common/src/main/java/com/ultreon/devices/core/network/TrayItemWifi.java index 7e7dcf3a5..51d74ae98 100644 --- a/common/src/main/java/com/ultreon/devices/core/network/TrayItemWifi.java +++ b/common/src/main/java/com/ultreon/devices/core/network/TrayItemWifi.java @@ -1,6 +1,6 @@ package com.ultreon.devices.core.network; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.DeviceConfig; import com.ultreon.devices.api.app.Icons; import com.ultreon.devices.api.app.Layout; @@ -17,11 +17,11 @@ import com.ultreon.devices.core.network.task.TaskPing; import com.ultreon.devices.object.TrayItem; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiComponent; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.client.gui.IngameGui; +import net.minecraft.client.gui.AbstractGui; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.tileentity.TileEntity; import java.awt.*; import java.util.ArrayList; @@ -39,14 +39,14 @@ public TrayItemWifi() { private static Layout createWifiMenu(TrayItem item) { Layout layout = new Layout.Context(100, 100); - layout.setBackground((pose, gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> Gui.fill(pose, x, y, x + width, y + height, new Color(0.65f, 0.65f, 0.65f, 0.9f).getRGB())); + layout.setBackground((pose, gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> IngameGui.fill(pose, x, y, x + width, y + height, new Color(0.65f, 0.65f, 0.65f, 0.9f).getRGB())); ItemList itemListRouters = new ItemList<>(5, 5, 90, 4); itemListRouters.setItems(getRouters()); itemListRouters.setListItemRenderer(new ListItemRenderer<>(16) { @Override - public void render(PoseStack pose, Device device, GuiComponent gui, Minecraft mc, int x, int y, int width, int height, boolean selected) { - Gui.fill(pose, x, y, x + width, y + height, selected ? Color.DARK_GRAY.getRGB() : Color.GRAY.getRGB()); + public void render(MatrixStack pose, Device device, AbstractGui gui, Minecraft mc, int x, int y, int width, int height, boolean selected) { + IngameGui.fill(pose, x, y, x + width, y + height, selected ? Color.DARK_GRAY.getRGB() : Color.GRAY.getRGB()); RenderUtil.drawStringClipped(pose, device.getName(), x + 16, y + 4, 70, Color.WHITE.getRGB(), false); if (device.getPos() == null) return; @@ -97,7 +97,7 @@ public void render(PoseStack pose, Device device, GuiComponent gui, Minecraft mc private static List getRouters() { List routers = new ArrayList<>(); - Level level = Minecraft.getInstance().level; + World level = Minecraft.getInstance().level; if (Laptop.isWorldLess()) { return new ArrayList<>(); } @@ -111,7 +111,7 @@ private static List getRouters() { assert laptopPos != null; BlockPos pos = new BlockPos(laptopPos.getX() + x, laptopPos.getY() + y, laptopPos.getZ() + z); assert level != null; - BlockEntity tileEntity = level.getBlockEntity(pos); + TileEntity tileEntity = level.getBlockEntity(pos); if (tileEntity instanceof RouterBlockEntity) { routers.add(new Device((DeviceBlockEntity) tileEntity)); } diff --git a/common/src/main/java/com/ultreon/devices/core/network/task/TaskConnect.java b/common/src/main/java/com/ultreon/devices/core/network/task/TaskConnect.java index 56f467d6f..8f2e26142 100644 --- a/common/src/main/java/com/ultreon/devices/core/network/task/TaskConnect.java +++ b/common/src/main/java/com/ultreon/devices/core/network/task/TaskConnect.java @@ -4,12 +4,12 @@ import com.ultreon.devices.block.entity.NetworkDeviceBlockEntity; import com.ultreon.devices.block.entity.RouterBlockEntity; import com.ultreon.devices.core.network.Router; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.chunk.Chunk; /** * @author MrCrayfish @@ -29,18 +29,18 @@ public TaskConnect(BlockPos devicePos, BlockPos routerPos) { } @Override - public void prepareRequest(CompoundTag tag) { + public void prepareRequest(CompoundNBT tag) { tag.putLong("devicePos", devicePos.asLong()); tag.putLong("routerPos", routerPos.asLong()); } @Override - public void processRequest(CompoundTag tag, Level level, Player player) { - BlockEntity tileEntity = level.getChunkAt(BlockPos.of(tag.getLong("routerPos"))).getBlockEntity(BlockPos.of(tag.getLong("routerPos")), LevelChunk.EntityCreationType.IMMEDIATE); + public void processRequest(CompoundNBT tag, World level, PlayerEntity player) { + TileEntity tileEntity = level.getChunkAt(BlockPos.of(tag.getLong("routerPos"))).getBlockEntity(BlockPos.of(tag.getLong("routerPos")), Chunk.CreateEntityType.IMMEDIATE); if (tileEntity instanceof RouterBlockEntity tileEntityRouter) { Router router = tileEntityRouter.getRouter(); - BlockEntity tileEntity1 = level.getChunkAt(BlockPos.of(tag.getLong("devicePos"))).getBlockEntity(BlockPos.of(tag.getLong("devicePos")), LevelChunk.EntityCreationType.IMMEDIATE); + TileEntity tileEntity1 = level.getChunkAt(BlockPos.of(tag.getLong("devicePos"))).getBlockEntity(BlockPos.of(tag.getLong("devicePos")), Chunk.CreateEntityType.IMMEDIATE); if (tileEntity1 instanceof NetworkDeviceBlockEntity tileEntityNetworkDevice) { if (router.addDevice(tileEntityNetworkDevice)) { tileEntityNetworkDevice.connect(router); @@ -51,12 +51,12 @@ public void processRequest(CompoundTag tag, Level level, Player player) { } @Override - public void prepareResponse(CompoundTag tag) { + public void prepareResponse(CompoundNBT tag) { } @Override - public void processResponse(CompoundTag tag) { + public void processResponse(CompoundNBT tag) { } } diff --git a/common/src/main/java/com/ultreon/devices/core/network/task/TaskGetDevices.java b/common/src/main/java/com/ultreon/devices/core/network/task/TaskGetDevices.java index a0814552b..642b9bfc2 100644 --- a/common/src/main/java/com/ultreon/devices/core/network/task/TaskGetDevices.java +++ b/common/src/main/java/com/ultreon/devices/core/network/task/TaskGetDevices.java @@ -4,13 +4,13 @@ import com.ultreon.devices.block.entity.NetworkDeviceBlockEntity; import com.ultreon.devices.core.network.NetworkDevice; import com.ultreon.devices.core.network.Router; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.ListNBT; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.chunk.Chunk; import java.util.Collection; @@ -39,7 +39,7 @@ public TaskGetDevices(BlockPos devicePos, Class targetDeviceClass = null; try { @@ -60,7 +60,7 @@ public void processRequest(CompoundTag tag, Level level, Player player) { e.printStackTrace(); } - BlockEntity tileEntity = level.getChunkAt(devicePos).getBlockEntity(devicePos, LevelChunk.EntityCreationType.IMMEDIATE); + TileEntity tileEntity = level.getChunkAt(devicePos).getBlockEntity(devicePos, Chunk.CreateEntityType.IMMEDIATE); if (tileEntity instanceof NetworkDeviceBlockEntity tileEntityNetworkDevice) { if (tileEntityNetworkDevice.isConnected()) { Router router = tileEntityNetworkDevice.getRouter(); @@ -77,16 +77,16 @@ public void processRequest(CompoundTag tag, Level level, Player player) { } @Override - public void prepareResponse(CompoundTag tag) { + public void prepareResponse(CompoundNBT tag) { if (this.isSucessful()) { - ListTag deviceList = new ListTag(); + ListNBT deviceList = new ListNBT(); foundDevices.forEach(device -> deviceList.add(device.toTag(true))); tag.put("network_devices", deviceList); } } @Override - public void processResponse(CompoundTag tag) { + public void processResponse(CompoundNBT tag) { } } diff --git a/common/src/main/java/com/ultreon/devices/core/network/task/TaskPing.java b/common/src/main/java/com/ultreon/devices/core/network/task/TaskPing.java index 57731d06b..ef1d9703b 100644 --- a/common/src/main/java/com/ultreon/devices/core/network/task/TaskPing.java +++ b/common/src/main/java/com/ultreon/devices/core/network/task/TaskPing.java @@ -2,12 +2,12 @@ import com.ultreon.devices.api.task.Task; import com.ultreon.devices.block.entity.NetworkDeviceBlockEntity; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.chunk.Chunk; /** * @author MrCrayfish @@ -26,13 +26,13 @@ public TaskPing(BlockPos sourceDevicePos) { } @Override - public void prepareRequest(CompoundTag tag) { + public void prepareRequest(CompoundNBT tag) { tag.putLong("sourceDevicePos", sourceDevicePos.asLong()); } @Override - public void processRequest(CompoundTag tag, Level level, Player player) { - BlockEntity blockEntity = level.getChunkAt(BlockPos.of(tag.getLong("sourceDevicePos"))).getBlockEntity(BlockPos.of(tag.getLong("sourceDevicePos")), LevelChunk.EntityCreationType.IMMEDIATE); + public void processRequest(CompoundNBT tag, World level, PlayerEntity player) { + TileEntity blockEntity = level.getChunkAt(BlockPos.of(tag.getLong("sourceDevicePos"))).getBlockEntity(BlockPos.of(tag.getLong("sourceDevicePos")), Chunk.CreateEntityType.IMMEDIATE); if (blockEntity instanceof NetworkDeviceBlockEntity networkDevice) { if (networkDevice.isConnected()) { this.strength = networkDevice.getSignalStrength(); @@ -42,14 +42,14 @@ public void processRequest(CompoundTag tag, Level level, Player player) { } @Override - public void prepareResponse(CompoundTag tag) { + public void prepareResponse(CompoundNBT tag) { if (this.isSucessful()) { tag.putInt("strength", strength); } } @Override - public void processResponse(CompoundTag tag) { + public void processResponse(CompoundNBT tag) { } } diff --git a/common/src/main/java/com/ultreon/devices/core/print/task/TaskPrint.java b/common/src/main/java/com/ultreon/devices/core/print/task/TaskPrint.java index 2bbca5792..9dfb20df8 100644 --- a/common/src/main/java/com/ultreon/devices/core/print/task/TaskPrint.java +++ b/common/src/main/java/com/ultreon/devices/core/print/task/TaskPrint.java @@ -6,12 +6,12 @@ import com.ultreon.devices.block.entity.PrinterBlockEntity; import com.ultreon.devices.core.network.NetworkDevice; import com.ultreon.devices.core.network.Router; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.chunk.Chunk; import java.util.UUID; @@ -35,15 +35,15 @@ public TaskPrint(BlockPos devicePos, NetworkDevice printer, IPrint print) { } @Override - public void prepareRequest(CompoundTag tag) { + public void prepareRequest(CompoundNBT tag) { tag.putLong("devicePos", devicePos.asLong()); tag.putUUID("printerId", printerId); tag.put("print", IPrint.save(print)); } @Override - public void processRequest(CompoundTag tag, Level level, Player player) { - BlockEntity tileEntity = level.getChunkAt(BlockPos.of(tag.getLong("devicePos"))).getBlockEntity(BlockPos.of(tag.getLong("devicePos")), LevelChunk.EntityCreationType.IMMEDIATE); + public void processRequest(CompoundNBT tag, World level, PlayerEntity player) { + TileEntity tileEntity = level.getChunkAt(BlockPos.of(tag.getLong("devicePos"))).getBlockEntity(BlockPos.of(tag.getLong("devicePos")), Chunk.CreateEntityType.IMMEDIATE); if (tileEntity instanceof NetworkDeviceBlockEntity device) { Router router = device.getRouter(); if (router != null) { @@ -58,12 +58,12 @@ public void processRequest(CompoundTag tag, Level level, Player player) { } @Override - public void prepareResponse(CompoundTag tag) { + public void prepareResponse(CompoundNBT tag) { } @Override - public void processResponse(CompoundTag tag) { + public void processResponse(CompoundNBT tag) { } } diff --git a/common/src/main/java/com/ultreon/devices/core/task/TaskInstallApp.java b/common/src/main/java/com/ultreon/devices/core/task/TaskInstallApp.java index bef35408d..f8be1f7dc 100644 --- a/common/src/main/java/com/ultreon/devices/core/task/TaskInstallApp.java +++ b/common/src/main/java/com/ultreon/devices/core/task/TaskInstallApp.java @@ -3,15 +3,15 @@ import com.ultreon.devices.api.task.Task; import com.ultreon.devices.block.entity.LaptopBlockEntity; import com.ultreon.devices.object.AppInfo; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.nbt.StringTag; -import net.minecraft.nbt.Tag; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.ListNBT; +import net.minecraft.nbt.StringNBT; +import net.minecraft.nbt.INBT; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.chunk.Chunk; /** * @author MrCrayfish @@ -33,7 +33,7 @@ public TaskInstallApp(AppInfo info, BlockPos laptopPos, boolean install) { } @Override - public void prepareRequest(CompoundTag tag) { + public void prepareRequest(CompoundNBT tag) { tag.putString("appId", appId); tag.putLong("pos", laptopPos.asLong()); tag.putBoolean("install", install); @@ -41,16 +41,16 @@ public void prepareRequest(CompoundTag tag) { } @Override - public void processRequest(CompoundTag tag, Level level, Player player) { + public void processRequest(CompoundNBT tag, World level, PlayerEntity player) { System.out.println("Proc message " + tag.getString("appId") + ", " + BlockPos.of(tag.getLong("pos")) + ", " + tag.getBoolean("install")); String appId = tag.getString("appId"); System.out.println(level.getBlockState(BlockPos.of(tag.getLong("pos"))).getBlock().toString()); - BlockEntity tileEntity = level.getChunkAt(BlockPos.of(tag.getLong("pos"))).getBlockEntity(BlockPos.of(tag.getLong("pos")), LevelChunk.EntityCreationType.IMMEDIATE); + TileEntity tileEntity = level.getChunkAt(BlockPos.of(tag.getLong("pos"))).getBlockEntity(BlockPos.of(tag.getLong("pos")), Chunk.CreateEntityType.IMMEDIATE); System.out.println(tileEntity); if (tileEntity instanceof LaptopBlockEntity laptop) { System.out.println("laptop is made out of laptop"); - CompoundTag systemData = laptop.getSystemData(); - ListTag list = systemData.getList("InstalledApps", Tag.TAG_STRING); + CompoundNBT systemData = laptop.getSystemData(); + ListNBT list = systemData.getList("InstalledApps", Constants.NBT.TAG_STRING); if (tag.getBoolean("install")) { for (int i = 0; i < list.size(); i++) { @@ -59,7 +59,7 @@ public void processRequest(CompoundTag tag, Level level, Player player) { return; } } - list.add(StringTag.valueOf(appId)); + list.add(StringNBT.valueOf(appId)); this.setSuccessful(); } else { list.removeIf(appTag -> { @@ -78,12 +78,12 @@ public void processRequest(CompoundTag tag, Level level, Player player) { @Override - public void prepareResponse(CompoundTag tag) { + public void prepareResponse(CompoundNBT tag) { } @Override - public void processResponse(CompoundTag tag) { + public void processResponse(CompoundNBT tag) { } } diff --git a/common/src/main/java/com/ultreon/devices/entity/SeatEntity.java b/common/src/main/java/com/ultreon/devices/entity/SeatEntity.java index ef245fd36..605993e0f 100644 --- a/common/src/main/java/com/ultreon/devices/entity/SeatEntity.java +++ b/common/src/main/java/com/ultreon/devices/entity/SeatEntity.java @@ -1,19 +1,19 @@ package com.ultreon.devices.entity; import com.ultreon.devices.init.DeviceEntities; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityDimensions; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.Pose; -import net.minecraft.world.entity.decoration.ArmorStand; -import net.minecraft.world.entity.vehicle.Boat; -import net.minecraft.world.entity.vehicle.Minecart; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.AABB; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityDimensions; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.Pose; +import net.minecraft.entity.decoration.ArmorStand; +import net.minecraft.entity.vehicle.Boat; +import net.minecraft.entity.vehicle.Minecart; +import net.minecraft.world.World; +import net.minecraft.util.math.AxisAlignedBB; import javax.annotation.Nullable; import java.util.List; @@ -21,10 +21,10 @@ public class SeatEntity extends Entity { private double yOffset; - public SeatEntity(EntityType type, Level worldIn) + public SeatEntity(EntityType type, World worldIn) { super(type, worldIn); - this.setBoundingBox(new AABB(0.001F, 0.001F, 0.001F, -0.001F, -0.001F, -0.001F)); + this.setBoundingBox(new AxisAlignedBB(0.001F, 0.001F, 0.001F, -0.001F, -0.001F, -0.001F)); this.setInvisible(true); } @@ -33,7 +33,7 @@ protected float getEyeHeight(Pose pose, EntityDimensions dimensions) { return 0; } - public SeatEntity(Level worldIn, BlockPos pos, double yOffset) + public SeatEntity(World worldIn, BlockPos pos, double yOffset) { this(DeviceEntities.SEAT.get(), worldIn); this.setPos(pos.getX() + 0.5, pos.getY() + yOffset, pos.getZ() + 0.5); @@ -86,8 +86,8 @@ public Packet getAddEntityPacket() { // protected void init() {} @Override - protected void readAdditionalSaveData(CompoundTag compound) {} + protected void readAdditionalSaveData(CompoundNBT compound) {} @Override - protected void addAdditionalSaveData(CompoundTag compound) {} + protected void addAdditionalSaveData(CompoundNBT compound) {} } diff --git a/common/src/main/java/com/ultreon/devices/entity/renderer/SeatEntityRenderer.java b/common/src/main/java/com/ultreon/devices/entity/renderer/SeatEntityRenderer.java index 723cf767b..f7203e308 100644 --- a/common/src/main/java/com/ultreon/devices/entity/renderer/SeatEntityRenderer.java +++ b/common/src/main/java/com/ultreon/devices/entity/renderer/SeatEntityRenderer.java @@ -1,15 +1,15 @@ package com.ultreon.devices.entity.renderer; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.entity.ThrownItemRenderer; import net.minecraft.client.renderer.texture.TextureAtlas; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.entity.Entity; +import net.minecraft.util.ResourceLocation; +import net.minecraft.entity.Entity; -@Environment(EnvType.CLIENT) +@OnlyIn(Dist.CLIENT) public class SeatEntityRenderer extends EntityRenderer { diff --git a/common/src/main/java/com/ultreon/devices/event/WorldDataHandler.java b/common/src/main/java/com/ultreon/devices/event/WorldDataHandler.java index 2f7ee3b0f..6eb4a5026 100644 --- a/common/src/main/java/com/ultreon/devices/event/WorldDataHandler.java +++ b/common/src/main/java/com/ultreon/devices/event/WorldDataHandler.java @@ -1,16 +1,16 @@ package com.ultreon.devices.event; import com.ultreon.devices.api.WorldSavedData; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.NbtIo; -import net.minecraft.world.level.storage.LevelResource; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.world.storage.FolderName; import java.io.File; import java.io.IOException; import java.nio.file.Files; //TODO public class WorldDataHandler { - private static final LevelResource DEVICES_MOD_DATA = new LevelResource("data/devices-mod"); + private static final FolderName DEVICES_MOD_DATA = new FolderName("data/devices-mod"); // @SubscribeEvent // public void load(final LifecycleEvent.START event) { @@ -58,7 +58,7 @@ private void loadData(File modData, String fileName, WorldSavedData data) { return; } try { - CompoundTag nbt = NbtIo.readCompressed(dataFile); + CompoundNBT nbt = CompressedStreamTools.readCompressed(dataFile); data.load(nbt); } catch (IOException e) { throw new RuntimeException(e); @@ -72,9 +72,9 @@ private void saveData(File modData, String fileName, WorldSavedData data) { Files.createFile(dataFile.toPath()); } - CompoundTag nbt = new CompoundTag(); + CompoundNBT nbt = new CompoundNBT(); data.save(nbt); - NbtIo.writeCompressed(nbt, dataFile); + CompressedStreamTools.writeCompressed(nbt, dataFile); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/common/src/main/java/com/ultreon/devices/gui/GuiButtonClose.java b/common/src/main/java/com/ultreon/devices/gui/GuiButtonClose.java index 1f30f2faa..1122dd7ee 100644 --- a/common/src/main/java/com/ultreon/devices/gui/GuiButtonClose.java +++ b/common/src/main/java/com/ultreon/devices/gui/GuiButtonClose.java @@ -1,27 +1,27 @@ package com.ultreon.devices.gui; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.core.Window; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.components.Button; -import net.minecraft.network.chat.TextComponent; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.widget.button.Button; +import net.minecraft.util.text.StringTextComponent; import org.jetbrains.annotations.NotNull; public class GuiButtonClose extends Button { public GuiButtonClose(int x, int y) { - super(x, y, 11, 11, new TextComponent(""), (button) -> { + super(x, y, 11, 11, new StringTextComponent(""), (button) -> { }); } @Override - public void renderButton(@NotNull PoseStack pose, int mouseX, int mouseY, float partialTicks) { + public void renderButton(@NotNull MatrixStack pose, int mouseX, int mouseY, float partialTicks) { if (this.visible) { - Font font = Minecraft.getInstance().font; - RenderSystem.setShaderTexture(0, Window.WINDOW_GUI); - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + FontRenderer font = Minecraft.getInstance().font; + mc.textureManager.bind(Window.WINDOW_GUI); + RenderSystem.blendColor(1f, 1f, 1f, 1f); this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height; RenderSystem.enableBlend(); diff --git a/common/src/main/java/com/ultreon/devices/init/DeviceBlockEntities.java b/common/src/main/java/com/ultreon/devices/init/DeviceBlockEntities.java index d357f8780..63f982702 100644 --- a/common/src/main/java/com/ultreon/devices/init/DeviceBlockEntities.java +++ b/common/src/main/java/com/ultreon/devices/init/DeviceBlockEntities.java @@ -3,20 +3,20 @@ import com.ultreon.devices.Devices; import com.ultreon.devices.block.entity.*; import dev.architectury.registry.registries.Registrar; -import dev.architectury.registry.registries.RegistrySupplier; -import net.minecraft.core.Registry; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraftforge.fml.RegistryObject; +import net.minecraft.util.Registry; +import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntityType; @SuppressWarnings("ConstantConditions") public class DeviceBlockEntities { - private static final Registrar> REGISTER = Devices.REGISTRIES.get().get(Registry.BLOCK_ENTITY_TYPE_REGISTRY); + private static final Registrar> REGISTER = Devices.REGISTRIES.get().get(Registry.BLOCK_ENTITY_TYPE_REGISTRY); - public static final RegistrySupplier> PAPER = REGISTER.register(Devices.id("paper"), () -> BlockEntityType.Builder.of(PaperBlockEntity::new, DeviceBlocks.PAPER.get()).build(null)); - public static final RegistrySupplier> LAPTOP = REGISTER.register(Devices.id("laptop"), () -> BlockEntityType.Builder.of(LaptopBlockEntity::new, DeviceBlocks.getAllLaptops().toArray(new Block[]{})).build(null)); - public static final RegistrySupplier> PRINTER = REGISTER.register(Devices.id("printer"), () -> BlockEntityType.Builder.of(PrinterBlockEntity::new, DeviceBlocks.getAllPrinters().toArray(new Block[]{})).build(null)); - public static final RegistrySupplier> ROUTER = REGISTER.register(Devices.id("router"), () -> BlockEntityType.Builder.of(RouterBlockEntity::new, DeviceBlocks.getAllRouters().toArray(new Block[]{})).build(null)); - public static final RegistrySupplier> SEAT = REGISTER.register(Devices.id("seat"), () -> BlockEntityType.Builder.of(OfficeChairBlockEntity::new, DeviceBlocks.getAllOfficeChairs().toArray(new Block[]{})).build(null)); + public static final RegistryObject> PAPER = REGISTER.register(Devices.id("paper"), () -> TileEntityType.Builder.of(PaperBlockEntity::new, DeviceBlocks.PAPER.get()).build(null)); + public static final RegistryObject> LAPTOP = REGISTER.register(Devices.id("laptop"), () -> TileEntityType.Builder.of(LaptopBlockEntity::new, DeviceBlocks.getAllLaptops().toArray(new Block[]{})).build(null)); + public static final RegistryObject> PRINTER = REGISTER.register(Devices.id("printer"), () -> TileEntityType.Builder.of(PrinterBlockEntity::new, DeviceBlocks.getAllPrinters().toArray(new Block[]{})).build(null)); + public static final RegistryObject> ROUTER = REGISTER.register(Devices.id("router"), () -> TileEntityType.Builder.of(RouterBlockEntity::new, DeviceBlocks.getAllRouters().toArray(new Block[]{})).build(null)); + public static final RegistryObject> SEAT = REGISTER.register(Devices.id("seat"), () -> TileEntityType.Builder.of(OfficeChairBlockEntity::new, DeviceBlocks.getAllOfficeChairs().toArray(new Block[]{})).build(null)); public static void register() { // Marker diff --git a/common/src/main/java/com/ultreon/devices/init/DeviceBlocks.java b/common/src/main/java/com/ultreon/devices/init/DeviceBlocks.java index 829f44145..18df72058 100644 --- a/common/src/main/java/com/ultreon/devices/init/DeviceBlocks.java +++ b/common/src/main/java/com/ultreon/devices/init/DeviceBlocks.java @@ -3,10 +3,10 @@ import com.ultreon.devices.Devices; import com.ultreon.devices.block.*; import dev.architectury.registry.registries.Registrar; -import dev.architectury.registry.registries.RegistrySupplier; -import net.minecraft.core.Registry; -import net.minecraft.world.item.DyeColor; -import net.minecraft.world.level.block.Block; +import net.minecraftforge.fml.RegistryObject; +import net.minecraft.util.Registry; +import net.minecraft.item.DyeColor; +import net.minecraft.block.Block; import java.util.List; import java.util.stream.Stream; @@ -17,74 +17,74 @@ public class DeviceBlocks { public static void register() { } - public static final RegistrySupplier WHITE_LAPTOP = REGISTER.register(Devices.id("white_laptop"), () -> new LaptopBlock(DyeColor.WHITE)); - public static final RegistrySupplier ORANGE_LAPTOP = REGISTER.register(Devices.id("orange_laptop"), () -> new LaptopBlock(DyeColor.ORANGE)); - public static final RegistrySupplier MAGENTA_LAPTOP = REGISTER.register(Devices.id("magenta_laptop"), () -> new LaptopBlock(DyeColor.MAGENTA)); - public static final RegistrySupplier LIGHT_BLUE_LAPTOP = REGISTER.register(Devices.id("light_blue_laptop"), () -> new LaptopBlock(DyeColor.LIGHT_BLUE)); - public static final RegistrySupplier YELLOW_LAPTOP = REGISTER.register(Devices.id("yellow_laptop"), () -> new LaptopBlock(DyeColor.YELLOW)); - public static final RegistrySupplier LIME_LAPTOP = REGISTER.register(Devices.id("lime_laptop"), () -> new LaptopBlock(DyeColor.LIME)); - public static final RegistrySupplier PINK_LAPTOP = REGISTER.register(Devices.id("pink_laptop"), () -> new LaptopBlock(DyeColor.PINK)); - public static final RegistrySupplier GRAY_LAPTOP = REGISTER.register(Devices.id("gray_laptop"), () -> new LaptopBlock(DyeColor.GRAY)); - public static final RegistrySupplier LIGHT_GRAY_LAPTOP = REGISTER.register(Devices.id("light_gray_laptop"), () -> new LaptopBlock(DyeColor.LIGHT_GRAY)); - public static final RegistrySupplier CYAN_LAPTOP = REGISTER.register(Devices.id("cyan_laptop"), () -> new LaptopBlock(DyeColor.CYAN)); - public static final RegistrySupplier PURPLE_LAPTOP = REGISTER.register(Devices.id("purple_laptop"), () -> new LaptopBlock(DyeColor.PURPLE)); - public static final RegistrySupplier BLUE_LAPTOP = REGISTER.register(Devices.id("blue_laptop"), () -> new LaptopBlock(DyeColor.BLUE)); - public static final RegistrySupplier BROWN_LAPTOP = REGISTER.register(Devices.id("brown_laptop"), () -> new LaptopBlock(DyeColor.BROWN)); - public static final RegistrySupplier GREEN_LAPTOP = REGISTER.register(Devices.id("green_laptop"), () -> new LaptopBlock(DyeColor.GREEN)); - public static final RegistrySupplier RED_LAPTOP = REGISTER.register(Devices.id("red_laptop"), () -> new LaptopBlock(DyeColor.RED)); - public static final RegistrySupplier BLACK_LAPTOP = REGISTER.register(Devices.id("black_laptop"), () -> new LaptopBlock(DyeColor.BLACK)); + public static final RegistryObject WHITE_LAPTOP = REGISTER.register(Devices.id("white_laptop"), () -> new LaptopBlock(DyeColor.WHITE)); + public static final RegistryObject ORANGE_LAPTOP = REGISTER.register(Devices.id("orange_laptop"), () -> new LaptopBlock(DyeColor.ORANGE)); + public static final RegistryObject MAGENTA_LAPTOP = REGISTER.register(Devices.id("magenta_laptop"), () -> new LaptopBlock(DyeColor.MAGENTA)); + public static final RegistryObject LIGHT_BLUE_LAPTOP = REGISTER.register(Devices.id("light_blue_laptop"), () -> new LaptopBlock(DyeColor.LIGHT_BLUE)); + public static final RegistryObject YELLOW_LAPTOP = REGISTER.register(Devices.id("yellow_laptop"), () -> new LaptopBlock(DyeColor.YELLOW)); + public static final RegistryObject LIME_LAPTOP = REGISTER.register(Devices.id("lime_laptop"), () -> new LaptopBlock(DyeColor.LIME)); + public static final RegistryObject PINK_LAPTOP = REGISTER.register(Devices.id("pink_laptop"), () -> new LaptopBlock(DyeColor.PINK)); + public static final RegistryObject GRAY_LAPTOP = REGISTER.register(Devices.id("gray_laptop"), () -> new LaptopBlock(DyeColor.GRAY)); + public static final RegistryObject LIGHT_GRAY_LAPTOP = REGISTER.register(Devices.id("light_gray_laptop"), () -> new LaptopBlock(DyeColor.LIGHT_GRAY)); + public static final RegistryObject CYAN_LAPTOP = REGISTER.register(Devices.id("cyan_laptop"), () -> new LaptopBlock(DyeColor.CYAN)); + public static final RegistryObject PURPLE_LAPTOP = REGISTER.register(Devices.id("purple_laptop"), () -> new LaptopBlock(DyeColor.PURPLE)); + public static final RegistryObject BLUE_LAPTOP = REGISTER.register(Devices.id("blue_laptop"), () -> new LaptopBlock(DyeColor.BLUE)); + public static final RegistryObject BROWN_LAPTOP = REGISTER.register(Devices.id("brown_laptop"), () -> new LaptopBlock(DyeColor.BROWN)); + public static final RegistryObject GREEN_LAPTOP = REGISTER.register(Devices.id("green_laptop"), () -> new LaptopBlock(DyeColor.GREEN)); + public static final RegistryObject RED_LAPTOP = REGISTER.register(Devices.id("red_laptop"), () -> new LaptopBlock(DyeColor.RED)); + public static final RegistryObject BLACK_LAPTOP = REGISTER.register(Devices.id("black_laptop"), () -> new LaptopBlock(DyeColor.BLACK)); - public static final RegistrySupplier WHITE_PRINTER = REGISTER.register(Devices.id("white_printer"), () -> new PrinterBlock(DyeColor.WHITE)); - public static final RegistrySupplier ORANGE_PRINTER = REGISTER.register(Devices.id("orange_printer"), () -> new PrinterBlock(DyeColor.ORANGE)); - public static final RegistrySupplier MAGENTA_PRINTER = REGISTER.register(Devices.id("magenta_printer"), () -> new PrinterBlock(DyeColor.MAGENTA)); - public static final RegistrySupplier LIGHT_BLUE_PRINTER = REGISTER.register(Devices.id("light_blue_printer"), () -> new PrinterBlock(DyeColor.LIGHT_BLUE)); - public static final RegistrySupplier YELLOW_PRINTER = REGISTER.register(Devices.id("yellow_printer"), () -> new PrinterBlock(DyeColor.YELLOW)); - public static final RegistrySupplier LIME_PRINTER = REGISTER.register(Devices.id("lime_printer"), () -> new PrinterBlock(DyeColor.LIME)); - public static final RegistrySupplier PINK_PRINTER = REGISTER.register(Devices.id("pink_printer"), () -> new PrinterBlock(DyeColor.PINK)); - public static final RegistrySupplier GRAY_PRINTER = REGISTER.register(Devices.id("gray_printer"), () -> new PrinterBlock(DyeColor.GRAY)); - public static final RegistrySupplier LIGHT_GRAY_PRINTER = REGISTER.register(Devices.id("light_gray_printer"), () -> new PrinterBlock(DyeColor.LIGHT_GRAY)); - public static final RegistrySupplier CYAN_PRINTER = REGISTER.register(Devices.id("cyan_printer"), () -> new PrinterBlock(DyeColor.CYAN)); - public static final RegistrySupplier PURPLE_PRINTER = REGISTER.register(Devices.id("purple_printer"), () -> new PrinterBlock(DyeColor.PURPLE)); - public static final RegistrySupplier BLUE_PRINTER = REGISTER.register(Devices.id("blue_printer"), () -> new PrinterBlock(DyeColor.BLUE)); - public static final RegistrySupplier BROWN_PRINTER = REGISTER.register(Devices.id("brown_printer"), () -> new PrinterBlock(DyeColor.BROWN)); - public static final RegistrySupplier GREEN_PRINTER = REGISTER.register(Devices.id("green_printer"), () -> new PrinterBlock(DyeColor.GREEN)); - public static final RegistrySupplier RED_PRINTER = REGISTER.register(Devices.id("red_printer"), () -> new PrinterBlock(DyeColor.RED)); - public static final RegistrySupplier BLACK_PRINTER = REGISTER.register(Devices.id("black_printer"), () -> new PrinterBlock(DyeColor.BLACK)); + public static final RegistryObject WHITE_PRINTER = REGISTER.register(Devices.id("white_printer"), () -> new PrinterBlock(DyeColor.WHITE)); + public static final RegistryObject ORANGE_PRINTER = REGISTER.register(Devices.id("orange_printer"), () -> new PrinterBlock(DyeColor.ORANGE)); + public static final RegistryObject MAGENTA_PRINTER = REGISTER.register(Devices.id("magenta_printer"), () -> new PrinterBlock(DyeColor.MAGENTA)); + public static final RegistryObject LIGHT_BLUE_PRINTER = REGISTER.register(Devices.id("light_blue_printer"), () -> new PrinterBlock(DyeColor.LIGHT_BLUE)); + public static final RegistryObject YELLOW_PRINTER = REGISTER.register(Devices.id("yellow_printer"), () -> new PrinterBlock(DyeColor.YELLOW)); + public static final RegistryObject LIME_PRINTER = REGISTER.register(Devices.id("lime_printer"), () -> new PrinterBlock(DyeColor.LIME)); + public static final RegistryObject PINK_PRINTER = REGISTER.register(Devices.id("pink_printer"), () -> new PrinterBlock(DyeColor.PINK)); + public static final RegistryObject GRAY_PRINTER = REGISTER.register(Devices.id("gray_printer"), () -> new PrinterBlock(DyeColor.GRAY)); + public static final RegistryObject LIGHT_GRAY_PRINTER = REGISTER.register(Devices.id("light_gray_printer"), () -> new PrinterBlock(DyeColor.LIGHT_GRAY)); + public static final RegistryObject CYAN_PRINTER = REGISTER.register(Devices.id("cyan_printer"), () -> new PrinterBlock(DyeColor.CYAN)); + public static final RegistryObject PURPLE_PRINTER = REGISTER.register(Devices.id("purple_printer"), () -> new PrinterBlock(DyeColor.PURPLE)); + public static final RegistryObject BLUE_PRINTER = REGISTER.register(Devices.id("blue_printer"), () -> new PrinterBlock(DyeColor.BLUE)); + public static final RegistryObject BROWN_PRINTER = REGISTER.register(Devices.id("brown_printer"), () -> new PrinterBlock(DyeColor.BROWN)); + public static final RegistryObject GREEN_PRINTER = REGISTER.register(Devices.id("green_printer"), () -> new PrinterBlock(DyeColor.GREEN)); + public static final RegistryObject RED_PRINTER = REGISTER.register(Devices.id("red_printer"), () -> new PrinterBlock(DyeColor.RED)); + public static final RegistryObject BLACK_PRINTER = REGISTER.register(Devices.id("black_printer"), () -> new PrinterBlock(DyeColor.BLACK)); - public static final RegistrySupplier WHITE_ROUTER = REGISTER.register(Devices.id("white_router"), () -> new RouterBlock(DyeColor.WHITE)); - public static final RegistrySupplier ORANGE_ROUTER = REGISTER.register(Devices.id("orange_router"), () -> new RouterBlock(DyeColor.ORANGE)); - public static final RegistrySupplier MAGENTA_ROUTER = REGISTER.register(Devices.id("magenta_router"), () -> new RouterBlock(DyeColor.MAGENTA)); - public static final RegistrySupplier LIGHT_BLUE_ROUTER = REGISTER.register(Devices.id("light_blue_router"), () -> new RouterBlock(DyeColor.LIGHT_BLUE)); - public static final RegistrySupplier YELLOW_ROUTER = REGISTER.register(Devices.id("yellow_router"), () -> new RouterBlock(DyeColor.YELLOW)); - public static final RegistrySupplier LIME_ROUTER = REGISTER.register(Devices.id("lime_router"), () -> new RouterBlock(DyeColor.LIME)); - public static final RegistrySupplier PINK_ROUTER = REGISTER.register(Devices.id("pink_router"), () -> new RouterBlock(DyeColor.PINK)); - public static final RegistrySupplier GRAY_ROUTER = REGISTER.register(Devices.id("gray_router"), () -> new RouterBlock(DyeColor.GRAY)); - public static final RegistrySupplier LIGHT_GRAY_ROUTER = REGISTER.register(Devices.id("light_gray_router"), () -> new RouterBlock(DyeColor.LIGHT_GRAY)); - public static final RegistrySupplier CYAN_ROUTER = REGISTER.register(Devices.id("cyan_router"), () -> new RouterBlock(DyeColor.CYAN)); - public static final RegistrySupplier PURPLE_ROUTER = REGISTER.register(Devices.id("purple_router"), () -> new RouterBlock(DyeColor.PURPLE)); - public static final RegistrySupplier BLUE_ROUTER = REGISTER.register(Devices.id("blue_router"), () -> new RouterBlock(DyeColor.BLUE)); - public static final RegistrySupplier BROWN_ROUTER = REGISTER.register(Devices.id("brown_router"), () -> new RouterBlock(DyeColor.BROWN)); - public static final RegistrySupplier GREEN_ROUTER = REGISTER.register(Devices.id("green_router"), () -> new RouterBlock(DyeColor.GREEN)); - public static final RegistrySupplier RED_ROUTER = REGISTER.register(Devices.id("red_router"), () -> new RouterBlock(DyeColor.RED)); - public static final RegistrySupplier BLACK_ROUTER = REGISTER.register(Devices.id("black_router"), () -> new RouterBlock(DyeColor.BLACK)); - public static final RegistrySupplier PAPER = REGISTER.register(Devices.id("paper"), PaperBlock::new); + public static final RegistryObject WHITE_ROUTER = REGISTER.register(Devices.id("white_router"), () -> new RouterBlock(DyeColor.WHITE)); + public static final RegistryObject ORANGE_ROUTER = REGISTER.register(Devices.id("orange_router"), () -> new RouterBlock(DyeColor.ORANGE)); + public static final RegistryObject MAGENTA_ROUTER = REGISTER.register(Devices.id("magenta_router"), () -> new RouterBlock(DyeColor.MAGENTA)); + public static final RegistryObject LIGHT_BLUE_ROUTER = REGISTER.register(Devices.id("light_blue_router"), () -> new RouterBlock(DyeColor.LIGHT_BLUE)); + public static final RegistryObject YELLOW_ROUTER = REGISTER.register(Devices.id("yellow_router"), () -> new RouterBlock(DyeColor.YELLOW)); + public static final RegistryObject LIME_ROUTER = REGISTER.register(Devices.id("lime_router"), () -> new RouterBlock(DyeColor.LIME)); + public static final RegistryObject PINK_ROUTER = REGISTER.register(Devices.id("pink_router"), () -> new RouterBlock(DyeColor.PINK)); + public static final RegistryObject GRAY_ROUTER = REGISTER.register(Devices.id("gray_router"), () -> new RouterBlock(DyeColor.GRAY)); + public static final RegistryObject LIGHT_GRAY_ROUTER = REGISTER.register(Devices.id("light_gray_router"), () -> new RouterBlock(DyeColor.LIGHT_GRAY)); + public static final RegistryObject CYAN_ROUTER = REGISTER.register(Devices.id("cyan_router"), () -> new RouterBlock(DyeColor.CYAN)); + public static final RegistryObject PURPLE_ROUTER = REGISTER.register(Devices.id("purple_router"), () -> new RouterBlock(DyeColor.PURPLE)); + public static final RegistryObject BLUE_ROUTER = REGISTER.register(Devices.id("blue_router"), () -> new RouterBlock(DyeColor.BLUE)); + public static final RegistryObject BROWN_ROUTER = REGISTER.register(Devices.id("brown_router"), () -> new RouterBlock(DyeColor.BROWN)); + public static final RegistryObject GREEN_ROUTER = REGISTER.register(Devices.id("green_router"), () -> new RouterBlock(DyeColor.GREEN)); + public static final RegistryObject RED_ROUTER = REGISTER.register(Devices.id("red_router"), () -> new RouterBlock(DyeColor.RED)); + public static final RegistryObject BLACK_ROUTER = REGISTER.register(Devices.id("black_router"), () -> new RouterBlock(DyeColor.BLACK)); + public static final RegistryObject PAPER = REGISTER.register(Devices.id("paper"), PaperBlock::new); - public static final RegistrySupplier WHITE_OFFICE_CHAIR = REGISTER.register(Devices.id("white_office_chair"), () -> new OfficeChairBlock(DyeColor.WHITE)); - public static final RegistrySupplier ORANGE_OFFICE_CHAIR = REGISTER.register(Devices.id("orange_office_chair"), () -> new OfficeChairBlock(DyeColor.ORANGE)); - public static final RegistrySupplier MAGENTA_OFFICE_CHAIR = REGISTER.register(Devices.id("magenta_office_chair"), () -> new OfficeChairBlock(DyeColor.MAGENTA)); - public static final RegistrySupplier LIGHT_BLUE_OFFICE_CHAIR = REGISTER.register(Devices.id("light_blue_office_chair"), () -> new OfficeChairBlock(DyeColor.LIGHT_BLUE)); - public static final RegistrySupplier YELLOW_OFFICE_CHAIR = REGISTER.register(Devices.id("yellow_office_chair"), () -> new OfficeChairBlock(DyeColor.YELLOW)); - public static final RegistrySupplier LIME_OFFICE_CHAIR = REGISTER.register(Devices.id("lime_office_chair"), () -> new OfficeChairBlock(DyeColor.LIME)); - public static final RegistrySupplier PINK_OFFICE_CHAIR = REGISTER.register(Devices.id("pink_office_chair"), () -> new OfficeChairBlock(DyeColor.PINK)); - public static final RegistrySupplier GRAY_OFFICE_CHAIR = REGISTER.register(Devices.id("gray_office_chair"), () -> new OfficeChairBlock(DyeColor.GRAY)); - public static final RegistrySupplier LIGHT_GRAY_OFFICE_CHAIR = REGISTER.register(Devices.id("light_gray_office_chair"), () -> new OfficeChairBlock(DyeColor.LIGHT_GRAY)); - public static final RegistrySupplier CYAN_OFFICE_CHAIR = REGISTER.register(Devices.id("cyan_office_chair"), () -> new OfficeChairBlock(DyeColor.CYAN)); - public static final RegistrySupplier PURPLE_OFFICE_CHAIR = REGISTER.register(Devices.id("purple_office_chair"), () -> new OfficeChairBlock(DyeColor.PURPLE)); - public static final RegistrySupplier BLUE_OFFICE_CHAIR = REGISTER.register(Devices.id("blue_office_chair"), () -> new OfficeChairBlock(DyeColor.BLUE)); - public static final RegistrySupplier BROWN_OFFICE_CHAIR = REGISTER.register(Devices.id("brown_office_chair"), () -> new OfficeChairBlock(DyeColor.BROWN)); - public static final RegistrySupplier GREEN_OFFICE_CHAIR = REGISTER.register(Devices.id("green_office_chair"), () -> new OfficeChairBlock(DyeColor.GREEN)); - public static final RegistrySupplier RED_OFFICE_CHAIR = REGISTER.register(Devices.id("red_office_chair"), () -> new OfficeChairBlock(DyeColor.RED)); - public static final RegistrySupplier BLACK_OFFICE_CHAIR = REGISTER.register(Devices.id("black_office_chair"), () -> new OfficeChairBlock(DyeColor.BLACK)); + public static final RegistryObject WHITE_OFFICE_CHAIR = REGISTER.register(Devices.id("white_office_chair"), () -> new OfficeChairBlock(DyeColor.WHITE)); + public static final RegistryObject ORANGE_OFFICE_CHAIR = REGISTER.register(Devices.id("orange_office_chair"), () -> new OfficeChairBlock(DyeColor.ORANGE)); + public static final RegistryObject MAGENTA_OFFICE_CHAIR = REGISTER.register(Devices.id("magenta_office_chair"), () -> new OfficeChairBlock(DyeColor.MAGENTA)); + public static final RegistryObject LIGHT_BLUE_OFFICE_CHAIR = REGISTER.register(Devices.id("light_blue_office_chair"), () -> new OfficeChairBlock(DyeColor.LIGHT_BLUE)); + public static final RegistryObject YELLOW_OFFICE_CHAIR = REGISTER.register(Devices.id("yellow_office_chair"), () -> new OfficeChairBlock(DyeColor.YELLOW)); + public static final RegistryObject LIME_OFFICE_CHAIR = REGISTER.register(Devices.id("lime_office_chair"), () -> new OfficeChairBlock(DyeColor.LIME)); + public static final RegistryObject PINK_OFFICE_CHAIR = REGISTER.register(Devices.id("pink_office_chair"), () -> new OfficeChairBlock(DyeColor.PINK)); + public static final RegistryObject GRAY_OFFICE_CHAIR = REGISTER.register(Devices.id("gray_office_chair"), () -> new OfficeChairBlock(DyeColor.GRAY)); + public static final RegistryObject LIGHT_GRAY_OFFICE_CHAIR = REGISTER.register(Devices.id("light_gray_office_chair"), () -> new OfficeChairBlock(DyeColor.LIGHT_GRAY)); + public static final RegistryObject CYAN_OFFICE_CHAIR = REGISTER.register(Devices.id("cyan_office_chair"), () -> new OfficeChairBlock(DyeColor.CYAN)); + public static final RegistryObject PURPLE_OFFICE_CHAIR = REGISTER.register(Devices.id("purple_office_chair"), () -> new OfficeChairBlock(DyeColor.PURPLE)); + public static final RegistryObject BLUE_OFFICE_CHAIR = REGISTER.register(Devices.id("blue_office_chair"), () -> new OfficeChairBlock(DyeColor.BLUE)); + public static final RegistryObject BROWN_OFFICE_CHAIR = REGISTER.register(Devices.id("brown_office_chair"), () -> new OfficeChairBlock(DyeColor.BROWN)); + public static final RegistryObject GREEN_OFFICE_CHAIR = REGISTER.register(Devices.id("green_office_chair"), () -> new OfficeChairBlock(DyeColor.GREEN)); + public static final RegistryObject RED_OFFICE_CHAIR = REGISTER.register(Devices.id("red_office_chair"), () -> new OfficeChairBlock(DyeColor.RED)); + public static final RegistryObject BLACK_OFFICE_CHAIR = REGISTER.register(Devices.id("black_office_chair"), () -> new OfficeChairBlock(DyeColor.BLACK)); public static Stream getAllBlocks() { return REGISTER.getIds().stream().map(REGISTER::get); diff --git a/common/src/main/java/com/ultreon/devices/init/DeviceEntities.java b/common/src/main/java/com/ultreon/devices/init/DeviceEntities.java index cb08d061a..1e3123e76 100644 --- a/common/src/main/java/com/ultreon/devices/init/DeviceEntities.java +++ b/common/src/main/java/com/ultreon/devices/init/DeviceEntities.java @@ -3,15 +3,15 @@ import com.ultreon.devices.Devices; import com.ultreon.devices.entity.SeatEntity; import dev.architectury.registry.registries.Registrar; -import dev.architectury.registry.registries.RegistrySupplier; -import net.minecraft.core.Registry; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.MobCategory; +import net.minecraftforge.fml.RegistryObject; +import net.minecraft.util.Registry; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.MobCategory; public class DeviceEntities { private static final Registrar> REGISTER = Devices.REGISTRIES.get().get(Registry.ENTITY_TYPE_REGISTRY); - public static final RegistrySupplier> SEAT = REGISTER.register(Devices.id("seat"), () -> EntityType.Builder.of(SeatEntity::new, MobCategory.MISC).sized(0.5f, 1.975f).clientTrackingRange(10).noSummon().build(Devices.id("seat").toString())); + public static final RegistryObject> SEAT = REGISTER.register(Devices.id("seat"), () -> EntityType.Builder.of(SeatEntity::new, MobCategory.MISC).sized(0.5f, 1.975f).clientTrackingRange(10).noSummon().build(Devices.id("seat").toString())); public static void register() { diff --git a/common/src/main/java/com/ultreon/devices/init/DeviceEntityRenderers.java b/common/src/main/java/com/ultreon/devices/init/DeviceEntityRenderers.java index 4e84b7780..be12a788f 100644 --- a/common/src/main/java/com/ultreon/devices/init/DeviceEntityRenderers.java +++ b/common/src/main/java/com/ultreon/devices/init/DeviceEntityRenderers.java @@ -5,8 +5,8 @@ import dev.architectury.registry.client.level.entity.EntityRendererRegistry; import dev.architectury.registry.registries.Registrar; import net.minecraft.client.renderer.entity.EntityRendererProvider; -import net.minecraft.core.Registry; -import net.minecraft.world.level.block.Block; +import net.minecraft.util.Registry; +import net.minecraft.block.Block; public class DeviceEntityRenderers { static { diff --git a/common/src/main/java/com/ultreon/devices/init/DeviceItems.java b/common/src/main/java/com/ultreon/devices/init/DeviceItems.java index 7d9a82149..ecefd2e4c 100644 --- a/common/src/main/java/com/ultreon/devices/init/DeviceItems.java +++ b/common/src/main/java/com/ultreon/devices/init/DeviceItems.java @@ -4,11 +4,11 @@ import com.ultreon.devices.Devices; import com.ultreon.devices.item.*; import dev.architectury.registry.registries.Registrar; -import dev.architectury.registry.registries.RegistrySupplier; -import net.minecraft.core.Registry; -import net.minecraft.world.item.BlockItem; -import net.minecraft.world.item.DyeColor; -import net.minecraft.world.item.Item; +import net.minecraftforge.fml.RegistryObject; +import net.minecraft.util.Registry; +import net.minecraft.item.BlockItem; +import net.minecraft.item.DyeColor; +import net.minecraft.item.Item; import org.jetbrains.annotations.Nullable; import java.util.List; @@ -19,99 +19,99 @@ public class DeviceItems { private static final Registrar REGISTER = Devices.REGISTRIES.get().get(Registry.ITEM_REGISTRY); // Laptops - public static final RegistrySupplier WHITE_LAPTOP = REGISTER.register(Devices.id("white_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.WHITE_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.WHITE, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier ORANGE_LAPTOP = REGISTER.register(Devices.id("orange_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.ORANGE_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.ORANGE, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier MAGENTA_LAPTOP = REGISTER.register(Devices.id("magenta_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.MAGENTA_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.MAGENTA, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier LIGHT_BLUE_LAPTOP = REGISTER.register(Devices.id("light_blue_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.LIGHT_BLUE_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.LIGHT_BLUE, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier YELLOW_LAPTOP = REGISTER.register(Devices.id("yellow_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.YELLOW_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.YELLOW, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier LIME_LAPTOP = REGISTER.register(Devices.id("lime_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.LIME_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.LIME, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier PINK_LAPTOP = REGISTER.register(Devices.id("pink_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.PINK_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.PINK, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier GRAY_LAPTOP = REGISTER.register(Devices.id("gray_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.GRAY_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.GRAY, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier LIGHT_GRAY_LAPTOP = REGISTER.register(Devices.id("light_gray_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.LIGHT_GRAY_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.LIGHT_GRAY, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier CYAN_LAPTOP = REGISTER.register(Devices.id("cyan_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.CYAN_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.CYAN, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier PURPLE_LAPTOP = REGISTER.register(Devices.id("purple_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.PURPLE_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.PURPLE, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier BLUE_LAPTOP = REGISTER.register(Devices.id("blue_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.BLUE_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.BLUE, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier BROWN_LAPTOP = REGISTER.register(Devices.id("brown_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.BROWN_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.BROWN, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier GREEN_LAPTOP = REGISTER.register(Devices.id("green_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.GREEN_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.GREEN, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier RED_LAPTOP = REGISTER.register(Devices.id("red_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.RED_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.RED, ModDeviceTypes.LAPTOP)); - public static final RegistrySupplier BLACK_LAPTOP = REGISTER.register(Devices.id("black_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.BLACK_LAPTOP.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.BLACK, ModDeviceTypes.LAPTOP)); + public static final RegistryObject WHITE_LAPTOP = REGISTER.register(Devices.id("white_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.WHITE_LAPTOP.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.WHITE, ModDeviceTypes.LAPTOP)); + public static final RegistryObject ORANGE_LAPTOP = REGISTER.register(Devices.id("orange_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.ORANGE_LAPTOP.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.ORANGE, ModDeviceTypes.LAPTOP)); + public static final RegistryObject MAGENTA_LAPTOP = REGISTER.register(Devices.id("magenta_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.MAGENTA_LAPTOP.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.MAGENTA, ModDeviceTypes.LAPTOP)); + public static final RegistryObject LIGHT_BLUE_LAPTOP = REGISTER.register(Devices.id("light_blue_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.LIGHT_BLUE_LAPTOP.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.LIGHT_BLUE, ModDeviceTypes.LAPTOP)); + public static final RegistryObject YELLOW_LAPTOP = REGISTER.register(Devices.id("yellow_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.YELLOW_LAPTOP.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.YELLOW, ModDeviceTypes.LAPTOP)); + public static final RegistryObject LIME_LAPTOP = REGISTER.register(Devices.id("lime_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.LIME_LAPTOP.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.LIME, ModDeviceTypes.LAPTOP)); + public static final RegistryObject PINK_LAPTOP = REGISTER.register(Devices.id("pink_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.PINK_LAPTOP.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.PINK, ModDeviceTypes.LAPTOP)); + public static final RegistryObject GRAY_LAPTOP = REGISTER.register(Devices.id("gray_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.GRAY_LAPTOP.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.GRAY, ModDeviceTypes.LAPTOP)); + public static final RegistryObject LIGHT_GRAY_LAPTOP = REGISTER.register(Devices.id("light_gray_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.LIGHT_GRAY_LAPTOP.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.LIGHT_GRAY, ModDeviceTypes.LAPTOP)); + public static final RegistryObject CYAN_LAPTOP = REGISTER.register(Devices.id("cyan_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.CYAN_LAPTOP.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.CYAN, ModDeviceTypes.LAPTOP)); + public static final RegistryObject PURPLE_LAPTOP = REGISTER.register(Devices.id("purple_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.PURPLE_LAPTOP.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.PURPLE, ModDeviceTypes.LAPTOP)); + public static final RegistryObject BLUE_LAPTOP = REGISTER.register(Devices.id("blue_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.BLUE_LAPTOP.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.BLUE, ModDeviceTypes.LAPTOP)); + public static final RegistryObject BROWN_LAPTOP = REGISTER.register(Devices.id("brown_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.BROWN_LAPTOP.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.BROWN, ModDeviceTypes.LAPTOP)); + public static final RegistryObject GREEN_LAPTOP = REGISTER.register(Devices.id("green_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.GREEN_LAPTOP.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.GREEN, ModDeviceTypes.LAPTOP)); + public static final RegistryObject RED_LAPTOP = REGISTER.register(Devices.id("red_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.RED_LAPTOP.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.RED, ModDeviceTypes.LAPTOP)); + public static final RegistryObject BLACK_LAPTOP = REGISTER.register(Devices.id("black_laptop"), () -> new ColoredDeviceItem(DeviceBlocks.BLACK_LAPTOP.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.BLACK, ModDeviceTypes.LAPTOP)); // Printers - public static final RegistrySupplier WHITE_PRINTER = REGISTER.register(Devices.id("white_printer"), () -> new ColoredDeviceItem(DeviceBlocks.WHITE_PRINTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.WHITE, ModDeviceTypes.PRINTER)); - public static final RegistrySupplier ORANGE_PRINTER = REGISTER.register(Devices.id("orange_printer"), () -> new ColoredDeviceItem(DeviceBlocks.ORANGE_PRINTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.ORANGE, ModDeviceTypes.PRINTER)); - public static final RegistrySupplier MAGENTA_PRINTER = REGISTER.register(Devices.id("magenta_printer"), () -> new ColoredDeviceItem(DeviceBlocks.MAGENTA_PRINTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.MAGENTA, ModDeviceTypes.PRINTER)); - public static final RegistrySupplier LIGHT_BLUE_PRINTER = REGISTER.register(Devices.id("light_blue_printer"), () -> new ColoredDeviceItem(DeviceBlocks.LIGHT_BLUE_PRINTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.LIGHT_BLUE, ModDeviceTypes.PRINTER)); - public static final RegistrySupplier YELLOW_PRINTER = REGISTER.register(Devices.id("yellow_printer"), () -> new ColoredDeviceItem(DeviceBlocks.YELLOW_PRINTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.YELLOW, ModDeviceTypes.PRINTER)); - public static final RegistrySupplier LIME_PRINTER = REGISTER.register(Devices.id("lime_printer"), () -> new ColoredDeviceItem(DeviceBlocks.LIME_PRINTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.LIME, ModDeviceTypes.PRINTER)); - public static final RegistrySupplier PINK_PRINTER = REGISTER.register(Devices.id("pink_printer"), () -> new ColoredDeviceItem(DeviceBlocks.PINK_PRINTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.PINK, ModDeviceTypes.PRINTER)); - public static final RegistrySupplier GRAY_PRINTER = REGISTER.register(Devices.id("gray_printer"), () -> new ColoredDeviceItem(DeviceBlocks.GRAY_PRINTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.GRAY, ModDeviceTypes.PRINTER)); - public static final RegistrySupplier LIGHT_GRAY_PRINTER = REGISTER.register(Devices.id("light_gray_printer"), () -> new ColoredDeviceItem(DeviceBlocks.LIGHT_GRAY_PRINTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.LIGHT_GRAY, ModDeviceTypes.PRINTER)); - public static final RegistrySupplier CYAN_PRINTER = REGISTER.register(Devices.id("cyan_printer"), () -> new ColoredDeviceItem(DeviceBlocks.CYAN_PRINTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.CYAN, ModDeviceTypes.PRINTER)); - public static final RegistrySupplier PURPLE_PRINTER = REGISTER.register(Devices.id("purple_printer"), () -> new ColoredDeviceItem(DeviceBlocks.PURPLE_PRINTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.PURPLE, ModDeviceTypes.PRINTER)); - public static final RegistrySupplier BLUE_PRINTER = REGISTER.register(Devices.id("blue_printer"), () -> new ColoredDeviceItem(DeviceBlocks.BLUE_PRINTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.BLUE, ModDeviceTypes.PRINTER)); - public static final RegistrySupplier BROWN_PRINTER = REGISTER.register(Devices.id("brown_printer"), () -> new ColoredDeviceItem(DeviceBlocks.BROWN_PRINTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.BROWN, ModDeviceTypes.PRINTER)); - public static final RegistrySupplier GREEN_PRINTER = REGISTER.register(Devices.id("green_printer"), () -> new ColoredDeviceItem(DeviceBlocks.GREEN_PRINTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.GREEN, ModDeviceTypes.PRINTER)); - public static final RegistrySupplier RED_PRINTER = REGISTER.register(Devices.id("red_printer"), () -> new ColoredDeviceItem(DeviceBlocks.RED_PRINTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.RED, ModDeviceTypes.PRINTER)); - public static final RegistrySupplier BLACK_PRINTER = REGISTER.register(Devices.id("black_printer"), () -> new ColoredDeviceItem(DeviceBlocks.BLACK_PRINTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.BLACK, ModDeviceTypes.PRINTER)); + public static final RegistryObject WHITE_PRINTER = REGISTER.register(Devices.id("white_printer"), () -> new ColoredDeviceItem(DeviceBlocks.WHITE_PRINTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.WHITE, ModDeviceTypes.PRINTER)); + public static final RegistryObject ORANGE_PRINTER = REGISTER.register(Devices.id("orange_printer"), () -> new ColoredDeviceItem(DeviceBlocks.ORANGE_PRINTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.ORANGE, ModDeviceTypes.PRINTER)); + public static final RegistryObject MAGENTA_PRINTER = REGISTER.register(Devices.id("magenta_printer"), () -> new ColoredDeviceItem(DeviceBlocks.MAGENTA_PRINTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.MAGENTA, ModDeviceTypes.PRINTER)); + public static final RegistryObject LIGHT_BLUE_PRINTER = REGISTER.register(Devices.id("light_blue_printer"), () -> new ColoredDeviceItem(DeviceBlocks.LIGHT_BLUE_PRINTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.LIGHT_BLUE, ModDeviceTypes.PRINTER)); + public static final RegistryObject YELLOW_PRINTER = REGISTER.register(Devices.id("yellow_printer"), () -> new ColoredDeviceItem(DeviceBlocks.YELLOW_PRINTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.YELLOW, ModDeviceTypes.PRINTER)); + public static final RegistryObject LIME_PRINTER = REGISTER.register(Devices.id("lime_printer"), () -> new ColoredDeviceItem(DeviceBlocks.LIME_PRINTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.LIME, ModDeviceTypes.PRINTER)); + public static final RegistryObject PINK_PRINTER = REGISTER.register(Devices.id("pink_printer"), () -> new ColoredDeviceItem(DeviceBlocks.PINK_PRINTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.PINK, ModDeviceTypes.PRINTER)); + public static final RegistryObject GRAY_PRINTER = REGISTER.register(Devices.id("gray_printer"), () -> new ColoredDeviceItem(DeviceBlocks.GRAY_PRINTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.GRAY, ModDeviceTypes.PRINTER)); + public static final RegistryObject LIGHT_GRAY_PRINTER = REGISTER.register(Devices.id("light_gray_printer"), () -> new ColoredDeviceItem(DeviceBlocks.LIGHT_GRAY_PRINTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.LIGHT_GRAY, ModDeviceTypes.PRINTER)); + public static final RegistryObject CYAN_PRINTER = REGISTER.register(Devices.id("cyan_printer"), () -> new ColoredDeviceItem(DeviceBlocks.CYAN_PRINTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.CYAN, ModDeviceTypes.PRINTER)); + public static final RegistryObject PURPLE_PRINTER = REGISTER.register(Devices.id("purple_printer"), () -> new ColoredDeviceItem(DeviceBlocks.PURPLE_PRINTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.PURPLE, ModDeviceTypes.PRINTER)); + public static final RegistryObject BLUE_PRINTER = REGISTER.register(Devices.id("blue_printer"), () -> new ColoredDeviceItem(DeviceBlocks.BLUE_PRINTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.BLUE, ModDeviceTypes.PRINTER)); + public static final RegistryObject BROWN_PRINTER = REGISTER.register(Devices.id("brown_printer"), () -> new ColoredDeviceItem(DeviceBlocks.BROWN_PRINTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.BROWN, ModDeviceTypes.PRINTER)); + public static final RegistryObject GREEN_PRINTER = REGISTER.register(Devices.id("green_printer"), () -> new ColoredDeviceItem(DeviceBlocks.GREEN_PRINTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.GREEN, ModDeviceTypes.PRINTER)); + public static final RegistryObject RED_PRINTER = REGISTER.register(Devices.id("red_printer"), () -> new ColoredDeviceItem(DeviceBlocks.RED_PRINTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.RED, ModDeviceTypes.PRINTER)); + public static final RegistryObject BLACK_PRINTER = REGISTER.register(Devices.id("black_printer"), () -> new ColoredDeviceItem(DeviceBlocks.BLACK_PRINTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.BLACK, ModDeviceTypes.PRINTER)); // Routers - public static final RegistrySupplier WHITE_ROUTER = REGISTER.register(Devices.id("white_router"), () -> new ColoredDeviceItem(DeviceBlocks.WHITE_ROUTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.WHITE, ModDeviceTypes.ROUTER)); - public static final RegistrySupplier ORANGE_ROUTER = REGISTER.register(Devices.id("orange_router"), () -> new ColoredDeviceItem(DeviceBlocks.ORANGE_ROUTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.ORANGE, ModDeviceTypes.ROUTER)); - public static final RegistrySupplier MAGENTA_ROUTER = REGISTER.register(Devices.id("magenta_router"), () -> new ColoredDeviceItem(DeviceBlocks.MAGENTA_ROUTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.MAGENTA, ModDeviceTypes.ROUTER)); - public static final RegistrySupplier LIGHT_BLUE_ROUTER = REGISTER.register(Devices.id("light_blue_router"), () -> new ColoredDeviceItem(DeviceBlocks.LIGHT_BLUE_ROUTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.LIGHT_BLUE, ModDeviceTypes.ROUTER)); - public static final RegistrySupplier YELLOW_ROUTER = REGISTER.register(Devices.id("yellow_router"), () -> new ColoredDeviceItem(DeviceBlocks.YELLOW_ROUTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.YELLOW, ModDeviceTypes.ROUTER)); - public static final RegistrySupplier LIME_ROUTER = REGISTER.register(Devices.id("lime_router"), () -> new ColoredDeviceItem(DeviceBlocks.LIME_ROUTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.LIME, ModDeviceTypes.ROUTER)); - public static final RegistrySupplier PINK_ROUTER = REGISTER.register(Devices.id("pink_router"), () -> new ColoredDeviceItem(DeviceBlocks.PINK_ROUTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.PINK, ModDeviceTypes.ROUTER)); - public static final RegistrySupplier GRAY_ROUTER = REGISTER.register(Devices.id("gray_router"), () -> new ColoredDeviceItem(DeviceBlocks.GRAY_ROUTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.GRAY, ModDeviceTypes.ROUTER)); - public static final RegistrySupplier LIGHT_GRAY_ROUTER = REGISTER.register(Devices.id("light_gray_router"), () -> new ColoredDeviceItem(DeviceBlocks.LIGHT_GRAY_ROUTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.LIGHT_GRAY, ModDeviceTypes.ROUTER)); - public static final RegistrySupplier CYAN_ROUTER = REGISTER.register(Devices.id("cyan_router"), () -> new ColoredDeviceItem(DeviceBlocks.CYAN_ROUTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.CYAN, ModDeviceTypes.ROUTER)); - public static final RegistrySupplier PURPLE_ROUTER = REGISTER.register(Devices.id("purple_router"), () -> new ColoredDeviceItem(DeviceBlocks.PURPLE_ROUTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.PURPLE, ModDeviceTypes.ROUTER)); - public static final RegistrySupplier BLUE_ROUTER = REGISTER.register(Devices.id("blue_router"), () -> new ColoredDeviceItem(DeviceBlocks.BLUE_ROUTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.BLUE, ModDeviceTypes.ROUTER)); - public static final RegistrySupplier BROWN_ROUTER = REGISTER.register(Devices.id("brown_router"), () -> new ColoredDeviceItem(DeviceBlocks.BROWN_ROUTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.BROWN, ModDeviceTypes.ROUTER)); - public static final RegistrySupplier GREEN_ROUTER = REGISTER.register(Devices.id("green_router"), () -> new ColoredDeviceItem(DeviceBlocks.GREEN_ROUTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.GREEN, ModDeviceTypes.ROUTER)); - public static final RegistrySupplier RED_ROUTER = REGISTER.register(Devices.id("red_router"), () -> new ColoredDeviceItem(DeviceBlocks.RED_ROUTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.RED, ModDeviceTypes.ROUTER)); - public static final RegistrySupplier BLACK_ROUTER = REGISTER.register(Devices.id("black_router"), () -> new ColoredDeviceItem(DeviceBlocks.BLACK_ROUTER.get(), new Item.Properties().tab(Devices.TAB_DEVICE), DyeColor.BLACK, ModDeviceTypes.ROUTER)); + public static final RegistryObject WHITE_ROUTER = REGISTER.register(Devices.id("white_router"), () -> new ColoredDeviceItem(DeviceBlocks.WHITE_ROUTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.WHITE, ModDeviceTypes.ROUTER)); + public static final RegistryObject ORANGE_ROUTER = REGISTER.register(Devices.id("orange_router"), () -> new ColoredDeviceItem(DeviceBlocks.ORANGE_ROUTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.ORANGE, ModDeviceTypes.ROUTER)); + public static final RegistryObject MAGENTA_ROUTER = REGISTER.register(Devices.id("magenta_router"), () -> new ColoredDeviceItem(DeviceBlocks.MAGENTA_ROUTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.MAGENTA, ModDeviceTypes.ROUTER)); + public static final RegistryObject LIGHT_BLUE_ROUTER = REGISTER.register(Devices.id("light_blue_router"), () -> new ColoredDeviceItem(DeviceBlocks.LIGHT_BLUE_ROUTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.LIGHT_BLUE, ModDeviceTypes.ROUTER)); + public static final RegistryObject YELLOW_ROUTER = REGISTER.register(Devices.id("yellow_router"), () -> new ColoredDeviceItem(DeviceBlocks.YELLOW_ROUTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.YELLOW, ModDeviceTypes.ROUTER)); + public static final RegistryObject LIME_ROUTER = REGISTER.register(Devices.id("lime_router"), () -> new ColoredDeviceItem(DeviceBlocks.LIME_ROUTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.LIME, ModDeviceTypes.ROUTER)); + public static final RegistryObject PINK_ROUTER = REGISTER.register(Devices.id("pink_router"), () -> new ColoredDeviceItem(DeviceBlocks.PINK_ROUTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.PINK, ModDeviceTypes.ROUTER)); + public static final RegistryObject GRAY_ROUTER = REGISTER.register(Devices.id("gray_router"), () -> new ColoredDeviceItem(DeviceBlocks.GRAY_ROUTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.GRAY, ModDeviceTypes.ROUTER)); + public static final RegistryObject LIGHT_GRAY_ROUTER = REGISTER.register(Devices.id("light_gray_router"), () -> new ColoredDeviceItem(DeviceBlocks.LIGHT_GRAY_ROUTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.LIGHT_GRAY, ModDeviceTypes.ROUTER)); + public static final RegistryObject CYAN_ROUTER = REGISTER.register(Devices.id("cyan_router"), () -> new ColoredDeviceItem(DeviceBlocks.CYAN_ROUTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.CYAN, ModDeviceTypes.ROUTER)); + public static final RegistryObject PURPLE_ROUTER = REGISTER.register(Devices.id("purple_router"), () -> new ColoredDeviceItem(DeviceBlocks.PURPLE_ROUTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.PURPLE, ModDeviceTypes.ROUTER)); + public static final RegistryObject BLUE_ROUTER = REGISTER.register(Devices.id("blue_router"), () -> new ColoredDeviceItem(DeviceBlocks.BLUE_ROUTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.BLUE, ModDeviceTypes.ROUTER)); + public static final RegistryObject BROWN_ROUTER = REGISTER.register(Devices.id("brown_router"), () -> new ColoredDeviceItem(DeviceBlocks.BROWN_ROUTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.BROWN, ModDeviceTypes.ROUTER)); + public static final RegistryObject GREEN_ROUTER = REGISTER.register(Devices.id("green_router"), () -> new ColoredDeviceItem(DeviceBlocks.GREEN_ROUTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.GREEN, ModDeviceTypes.ROUTER)); + public static final RegistryObject RED_ROUTER = REGISTER.register(Devices.id("red_router"), () -> new ColoredDeviceItem(DeviceBlocks.RED_ROUTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.RED, ModDeviceTypes.ROUTER)); + public static final RegistryObject BLACK_ROUTER = REGISTER.register(Devices.id("black_router"), () -> new ColoredDeviceItem(DeviceBlocks.BLACK_ROUTER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE), DyeColor.BLACK, ModDeviceTypes.ROUTER)); // Flash drives - public static final RegistrySupplier WHITE_FLASH_DRIVE = REGISTER.register(Devices.id("white_flash_drive"), () -> new FlashDriveItem(DyeColor.WHITE)); - public static final RegistrySupplier ORANGE_FLASH_DRIVE = REGISTER.register(Devices.id("orange_flash_drive"), () -> new FlashDriveItem(DyeColor.ORANGE)); - public static final RegistrySupplier MAGENTA_FLASH_DRIVE = REGISTER.register(Devices.id("magenta_flash_drive"), () -> new FlashDriveItem(DyeColor.MAGENTA)); - public static final RegistrySupplier LIGHT_BLUE_FLASH_DRIVE = REGISTER.register(Devices.id("light_blue_flash_drive"), () -> new FlashDriveItem(DyeColor.LIGHT_BLUE)); - public static final RegistrySupplier YELLOW_FLASH_DRIVE = REGISTER.register(Devices.id("yellow_flash_drive"), () -> new FlashDriveItem(DyeColor.YELLOW)); - public static final RegistrySupplier LIME_FLASH_DRIVE = REGISTER.register(Devices.id("lime_flash_drive"), () -> new FlashDriveItem(DyeColor.LIME)); - public static final RegistrySupplier PINK_FLASH_DRIVE = REGISTER.register(Devices.id("pink_flash_drive"), () -> new FlashDriveItem(DyeColor.PINK)); - public static final RegistrySupplier GRAY_FLASH_DRIVE = REGISTER.register(Devices.id("gray_flash_drive"), () -> new FlashDriveItem(DyeColor.GRAY)); - public static final RegistrySupplier LIGHT_GRAY_FLASH_DRIVE = REGISTER.register(Devices.id("light_gray_flash_drive"), () -> new FlashDriveItem(DyeColor.LIGHT_GRAY)); - public static final RegistrySupplier CYAN_FLASH_DRIVE = REGISTER.register(Devices.id("cyan_flash_drive"), () -> new FlashDriveItem(DyeColor.CYAN)); - public static final RegistrySupplier PURPLE_FLASH_DRIVE = REGISTER.register(Devices.id("purple_flash_drive"), () -> new FlashDriveItem(DyeColor.PURPLE)); - public static final RegistrySupplier BLUE_FLASH_DRIVE = REGISTER.register(Devices.id("blue_flash_drive"), () -> new FlashDriveItem(DyeColor.BLUE)); - public static final RegistrySupplier BROWN_FLASH_DRIVE = REGISTER.register(Devices.id("brown_flash_drive"), () -> new FlashDriveItem(DyeColor.BROWN)); - public static final RegistrySupplier GREEN_FLASH_DRIVE = REGISTER.register(Devices.id("green_flash_drive"), () -> new FlashDriveItem(DyeColor.GREEN)); - public static final RegistrySupplier RED_FLASH_DRIVE = REGISTER.register(Devices.id("red_flash_drive"), () -> new FlashDriveItem(DyeColor.RED)); - public static final RegistrySupplier BLACK_FLASH_DRIVE = REGISTER.register(Devices.id("black_flash_drive"), () -> new FlashDriveItem(DyeColor.BLACK)); - public static final RegistrySupplier PAPER = REGISTER.register(Devices.id("paper"), () -> new BlockItem(DeviceBlocks.PAPER.get(), new Item.Properties().tab(Devices.TAB_DEVICE))); - - public static final RegistrySupplier PLASTIC_UNREFINED = REGISTER.register(Devices.id("plastic_unrefined"), () -> new BasicItem(new Item.Properties().tab(Devices.TAB_DEVICE))); - public static final RegistrySupplier PLASTIC = REGISTER.register(Devices.id("plastic"), () -> new BasicItem(new Item.Properties().tab(Devices.TAB_DEVICE))); - public static final RegistrySupplier PLASTIC_FRAME = REGISTER.register(Devices.id("plastic_frame"), () -> new BasicItem(new Item.Properties().tab(Devices.TAB_DEVICE))); - public static final RegistrySupplier WHEEL = REGISTER.register(Devices.id("wheel"), () -> new BasicItem(new Item.Properties().tab(Devices.TAB_DEVICE))); - - public static final RegistrySupplier COMPONENT_CIRCUIT_BOARD = REGISTER.register(Devices.id("circuit_board"), () -> new ComponentItem(new Item.Properties().tab(Devices.TAB_DEVICE))); - public static final RegistrySupplier COMPONENT_MOTHERBOARD = REGISTER.register(Devices.id("motherboard"), () -> new MotherboardItem(new Item.Properties().tab(Devices.TAB_DEVICE))); - public static final RegistrySupplier COMPONENT_CPU = REGISTER.register(Devices.id("cpu"), () -> new MotherboardItem.Component(new Item.Properties().tab(Devices.TAB_DEVICE))); - public static final RegistrySupplier COMPONENT_RAM = REGISTER.register(Devices.id("ram"), () -> new MotherboardItem.Component(new Item.Properties().tab(Devices.TAB_DEVICE))); - public static final RegistrySupplier COMPONENT_GPU = REGISTER.register(Devices.id("gpu"), () -> new MotherboardItem.Component(new Item.Properties().tab(Devices.TAB_DEVICE))); - public static final RegistrySupplier COMPONENT_WIFI = REGISTER.register(Devices.id("wifi"), () -> new MotherboardItem.Component(new Item.Properties().tab(Devices.TAB_DEVICE))); - public static final RegistrySupplier COMPONENT_HARD_DRIVE = REGISTER.register(Devices.id("hard_drive"), () -> new ComponentItem(new Item.Properties().tab(Devices.TAB_DEVICE))); - public static final RegistrySupplier COMPONENT_FLASH_CHIP = REGISTER.register(Devices.id("flash_chip"), () -> new ComponentItem(new Item.Properties().tab(Devices.TAB_DEVICE))); - public static final RegistrySupplier COMPONENT_SOLID_STATE_DRIVE = REGISTER.register(Devices.id("solid_state_drive"), () -> new ComponentItem(new Item.Properties().tab(Devices.TAB_DEVICE))); - public static final RegistrySupplier COMPONENT_BATTERY = REGISTER.register(Devices.id("battery"), () -> new ComponentItem(new Item.Properties().tab(Devices.TAB_DEVICE))); - public static final RegistrySupplier COMPONENT_SCREEN = REGISTER.register(Devices.id("screen"), () -> new ComponentItem(new Item.Properties().tab(Devices.TAB_DEVICE))); - public static final RegistrySupplier COMPONENT_CONTROLLER_UNIT = REGISTER.register(Devices.id("controller_unit"), () -> new ComponentItem(new Item.Properties().tab(Devices.TAB_DEVICE))); - public static final RegistrySupplier COMPONENT_SMALL_ELECTRIC_MOTOR = REGISTER.register(Devices.id("small_electric_motor"), () -> new ComponentItem(new Item.Properties().tab(Devices.TAB_DEVICE))); - public static final RegistrySupplier COMPONENT_CARRIAGE = REGISTER.register(Devices.id("carriage"), () -> new ComponentItem(new Item.Properties().tab(Devices.TAB_DEVICE))); - - public static final RegistrySupplier ETHERNET_CABLE = REGISTER.register(Devices.id("ethernet_cable"), () -> new EthernetCableItem()); + public static final RegistryObject WHITE_FLASH_DRIVE = REGISTER.register(Devices.id("white_flash_drive"), () -> new FlashDriveItem(DyeColor.WHITE)); + public static final RegistryObject ORANGE_FLASH_DRIVE = REGISTER.register(Devices.id("orange_flash_drive"), () -> new FlashDriveItem(DyeColor.ORANGE)); + public static final RegistryObject MAGENTA_FLASH_DRIVE = REGISTER.register(Devices.id("magenta_flash_drive"), () -> new FlashDriveItem(DyeColor.MAGENTA)); + public static final RegistryObject LIGHT_BLUE_FLASH_DRIVE = REGISTER.register(Devices.id("light_blue_flash_drive"), () -> new FlashDriveItem(DyeColor.LIGHT_BLUE)); + public static final RegistryObject YELLOW_FLASH_DRIVE = REGISTER.register(Devices.id("yellow_flash_drive"), () -> new FlashDriveItem(DyeColor.YELLOW)); + public static final RegistryObject LIME_FLASH_DRIVE = REGISTER.register(Devices.id("lime_flash_drive"), () -> new FlashDriveItem(DyeColor.LIME)); + public static final RegistryObject PINK_FLASH_DRIVE = REGISTER.register(Devices.id("pink_flash_drive"), () -> new FlashDriveItem(DyeColor.PINK)); + public static final RegistryObject GRAY_FLASH_DRIVE = REGISTER.register(Devices.id("gray_flash_drive"), () -> new FlashDriveItem(DyeColor.GRAY)); + public static final RegistryObject LIGHT_GRAY_FLASH_DRIVE = REGISTER.register(Devices.id("light_gray_flash_drive"), () -> new FlashDriveItem(DyeColor.LIGHT_GRAY)); + public static final RegistryObject CYAN_FLASH_DRIVE = REGISTER.register(Devices.id("cyan_flash_drive"), () -> new FlashDriveItem(DyeColor.CYAN)); + public static final RegistryObject PURPLE_FLASH_DRIVE = REGISTER.register(Devices.id("purple_flash_drive"), () -> new FlashDriveItem(DyeColor.PURPLE)); + public static final RegistryObject BLUE_FLASH_DRIVE = REGISTER.register(Devices.id("blue_flash_drive"), () -> new FlashDriveItem(DyeColor.BLUE)); + public static final RegistryObject BROWN_FLASH_DRIVE = REGISTER.register(Devices.id("brown_flash_drive"), () -> new FlashDriveItem(DyeColor.BROWN)); + public static final RegistryObject GREEN_FLASH_DRIVE = REGISTER.register(Devices.id("green_flash_drive"), () -> new FlashDriveItem(DyeColor.GREEN)); + public static final RegistryObject RED_FLASH_DRIVE = REGISTER.register(Devices.id("red_flash_drive"), () -> new FlashDriveItem(DyeColor.RED)); + public static final RegistryObject BLACK_FLASH_DRIVE = REGISTER.register(Devices.id("black_flash_drive"), () -> new FlashDriveItem(DyeColor.BLACK)); + public static final RegistryObject PAPER = REGISTER.register(Devices.id("paper"), () -> new BlockItem(DeviceBlocks.PAPER.get(), new Item.Properties().tab(Devices.GROUP_DEVICE))); + + public static final RegistryObject PLASTIC_UNREFINED = REGISTER.register(Devices.id("plastic_unrefined"), () -> new BasicItem(new Item.Properties().tab(Devices.GROUP_DEVICE))); + public static final RegistryObject PLASTIC = REGISTER.register(Devices.id("plastic"), () -> new BasicItem(new Item.Properties().tab(Devices.GROUP_DEVICE))); + public static final RegistryObject PLASTIC_FRAME = REGISTER.register(Devices.id("plastic_frame"), () -> new BasicItem(new Item.Properties().tab(Devices.GROUP_DEVICE))); + public static final RegistryObject WHEEL = REGISTER.register(Devices.id("wheel"), () -> new BasicItem(new Item.Properties().tab(Devices.GROUP_DEVICE))); + + public static final RegistryObject COMPONENT_CIRCUIT_BOARD = REGISTER.register(Devices.id("circuit_board"), () -> new ComponentItem(new Item.Properties().tab(Devices.GROUP_DEVICE))); + public static final RegistryObject COMPONENT_MOTHERBOARD = REGISTER.register(Devices.id("motherboard"), () -> new MotherboardItem(new Item.Properties().tab(Devices.GROUP_DEVICE))); + public static final RegistryObject COMPONENT_CPU = REGISTER.register(Devices.id("cpu"), () -> new MotherboardItem.Component(new Item.Properties().tab(Devices.GROUP_DEVICE))); + public static final RegistryObject COMPONENT_RAM = REGISTER.register(Devices.id("ram"), () -> new MotherboardItem.Component(new Item.Properties().tab(Devices.GROUP_DEVICE))); + public static final RegistryObject COMPONENT_GPU = REGISTER.register(Devices.id("gpu"), () -> new MotherboardItem.Component(new Item.Properties().tab(Devices.GROUP_DEVICE))); + public static final RegistryObject COMPONENT_WIFI = REGISTER.register(Devices.id("wifi"), () -> new MotherboardItem.Component(new Item.Properties().tab(Devices.GROUP_DEVICE))); + public static final RegistryObject COMPONENT_HARD_DRIVE = REGISTER.register(Devices.id("hard_drive"), () -> new ComponentItem(new Item.Properties().tab(Devices.GROUP_DEVICE))); + public static final RegistryObject COMPONENT_FLASH_CHIP = REGISTER.register(Devices.id("flash_chip"), () -> new ComponentItem(new Item.Properties().tab(Devices.GROUP_DEVICE))); + public static final RegistryObject COMPONENT_SOLID_STATE_DRIVE = REGISTER.register(Devices.id("solid_state_drive"), () -> new ComponentItem(new Item.Properties().tab(Devices.GROUP_DEVICE))); + public static final RegistryObject COMPONENT_BATTERY = REGISTER.register(Devices.id("battery"), () -> new ComponentItem(new Item.Properties().tab(Devices.GROUP_DEVICE))); + public static final RegistryObject COMPONENT_SCREEN = REGISTER.register(Devices.id("screen"), () -> new ComponentItem(new Item.Properties().tab(Devices.GROUP_DEVICE))); + public static final RegistryObject COMPONENT_CONTROLLER_UNIT = REGISTER.register(Devices.id("controller_unit"), () -> new ComponentItem(new Item.Properties().tab(Devices.GROUP_DEVICE))); + public static final RegistryObject COMPONENT_SMALL_ELECTRIC_MOTOR = REGISTER.register(Devices.id("small_electric_motor"), () -> new ComponentItem(new Item.Properties().tab(Devices.GROUP_DEVICE))); + public static final RegistryObject COMPONENT_CARRIAGE = REGISTER.register(Devices.id("carriage"), () -> new ComponentItem(new Item.Properties().tab(Devices.GROUP_DEVICE))); + + public static final RegistryObject ETHERNET_CABLE = REGISTER.register(Devices.id("ethernet_cable"), () -> new EthernetCableItem()); public static Stream getAllItems() { diff --git a/common/src/main/java/com/ultreon/devices/init/DeviceSounds.java b/common/src/main/java/com/ultreon/devices/init/DeviceSounds.java index 247d8cc10..e89d260b7 100644 --- a/common/src/main/java/com/ultreon/devices/init/DeviceSounds.java +++ b/common/src/main/java/com/ultreon/devices/init/DeviceSounds.java @@ -3,9 +3,9 @@ import com.ultreon.devices.Devices; import com.ultreon.devices.Reference; import dev.architectury.registry.registries.Registrar; -import dev.architectury.registry.registries.RegistrySupplier; -import net.minecraft.core.Registry; -import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.fml.RegistryObject; +import net.minecraft.util.Registry; +import net.minecraft.util.ResourceLocation; import net.minecraft.sounds.SoundEvent; /** @@ -14,8 +14,8 @@ public class DeviceSounds { private static final Registrar REGISTER = Devices.REGISTRIES.get().get(Registry.SOUND_EVENT_REGISTRY); - public static final RegistrySupplier PRINTER_PRINTING = REGISTER.register(Devices.id("printer_printing"), () -> new SoundEvent(new ResourceLocation(Reference.MOD_ID, "printer_printing"))); - public static final RegistrySupplier PRINTER_LOADING_PAPER = REGISTER.register(Devices.id("printer_loading_paper"), () -> new SoundEvent(new ResourceLocation(Reference.MOD_ID, "printer_loading_paper"))); + public static final RegistryObject PRINTER_PRINTING = REGISTER.register(Devices.id("printer_printing"), () -> new SoundEvent(new ResourceLocation(Reference.MOD_ID, "printer_printing"))); + public static final RegistryObject PRINTER_LOADING_PAPER = REGISTER.register(Devices.id("printer_loading_paper"), () -> new SoundEvent(new ResourceLocation(Reference.MOD_ID, "printer_loading_paper"))); // static { // PRINTER_PRINTING = registerSound("devices:printing_ink"); diff --git a/common/src/main/java/com/ultreon/devices/init/ModTags.java b/common/src/main/java/com/ultreon/devices/init/ModTags.java index 85103f817..2b19c6dbe 100644 --- a/common/src/main/java/com/ultreon/devices/init/ModTags.java +++ b/common/src/main/java/com/ultreon/devices/init/ModTags.java @@ -1,10 +1,10 @@ package com.ultreon.devices.init; import com.ultreon.devices.Devices; -import net.minecraft.core.Registry; +import net.minecraft.util.Registry; import net.minecraft.tags.TagKey; -import net.minecraft.world.item.Item; -import net.minecraft.world.level.block.Block; +import net.minecraft.item.Item; +import net.minecraft.block.Block; /** * @author Qboi diff --git a/common/src/main/java/com/ultreon/devices/init/RegistrationHandler.java b/common/src/main/java/com/ultreon/devices/init/RegistrationHandler.java index f0b05d952..a9e9c575a 100644 --- a/common/src/main/java/com/ultreon/devices/init/RegistrationHandler.java +++ b/common/src/main/java/com/ultreon/devices/init/RegistrationHandler.java @@ -1,7 +1,7 @@ package com.ultreon.devices.init; -import dev.architectury.utils.EnvExecutor; -import net.fabricmc.api.EnvType; +import net.minecraftforge.api.distmarker.DistExecutor; +import net.minecraftforge.api.distmarker.Dist; /** * @author MrCrayfish @@ -13,6 +13,6 @@ public static void register() { DeviceBlocks.register(); DeviceItems.register(); DeviceSounds.register(); - EnvExecutor.runInEnv(EnvType.CLIENT, () -> DeviceEntityRenderers::register); + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> DeviceEntityRenderers::register); } } diff --git a/common/src/main/java/com/ultreon/devices/item/BasicItem.java b/common/src/main/java/com/ultreon/devices/item/BasicItem.java index 3f75d3cd6..48a6e1c14 100644 --- a/common/src/main/java/com/ultreon/devices/item/BasicItem.java +++ b/common/src/main/java/com/ultreon/devices/item/BasicItem.java @@ -1,13 +1,13 @@ package com.ultreon.devices.item; import com.ultreon.devices.Devices; -import net.minecraft.world.item.Item; +import net.minecraft.item.Item; /** * @author MrCrayfish */ public class BasicItem extends Item { public BasicItem(Properties pProperties) { - super(pProperties.tab(Devices.TAB_DEVICE)); + super(pProperties.tab(Devices.GROUP_DEVICE)); } } diff --git a/common/src/main/java/com/ultreon/devices/item/ColoredDeviceItem.java b/common/src/main/java/com/ultreon/devices/item/ColoredDeviceItem.java index 700c05f56..fb887751b 100644 --- a/common/src/main/java/com/ultreon/devices/item/ColoredDeviceItem.java +++ b/common/src/main/java/com/ultreon/devices/item/ColoredDeviceItem.java @@ -2,8 +2,8 @@ import com.ultreon.devices.ModDeviceTypes; import com.ultreon.devices.util.Colored; -import net.minecraft.world.item.DyeColor; -import net.minecraft.world.level.block.Block; +import net.minecraft.item.DyeColor; +import net.minecraft.block.Block; import org.jetbrains.annotations.NotNull; public class ColoredDeviceItem extends DeviceItem implements Colored { diff --git a/common/src/main/java/com/ultreon/devices/item/ComponentItem.java b/common/src/main/java/com/ultreon/devices/item/ComponentItem.java index 2d16f0cad..59b6fe9c4 100644 --- a/common/src/main/java/com/ultreon/devices/item/ComponentItem.java +++ b/common/src/main/java/com/ultreon/devices/item/ComponentItem.java @@ -1,10 +1,10 @@ package com.ultreon.devices.item; import com.ultreon.devices.Devices; -import net.minecraft.world.item.Item; +import net.minecraft.item.Item; public class ComponentItem extends Item { public ComponentItem(Properties pProperties) { - super(pProperties.tab(Devices.TAB_DEVICE)); + super(pProperties.tab(Devices.GROUP_DEVICE)); } } diff --git a/common/src/main/java/com/ultreon/devices/item/DeviceItem.java b/common/src/main/java/com/ultreon/devices/item/DeviceItem.java index 2ef8a89a0..5e096cdc5 100644 --- a/common/src/main/java/com/ultreon/devices/item/DeviceItem.java +++ b/common/src/main/java/com/ultreon/devices/item/DeviceItem.java @@ -3,11 +3,11 @@ import com.ultreon.devices.ModDeviceTypes; import com.ultreon.devices.IDeviceType; import dev.architectury.injectables.annotations.PlatformOnly; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; -import net.minecraft.world.item.BlockItem; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.block.Block; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.INBT; +import net.minecraft.item.BlockItem; +import net.minecraft.item.ItemStack; +import net.minecraft.block.Block; import org.jetbrains.annotations.Nullable; import java.util.Objects; @@ -24,9 +24,9 @@ public DeviceItem(Block block, Properties properties, ModDeviceTypes deviceType) @Nullable @PlatformOnly(PlatformOnly.FORGE) // @Override - public CompoundTag getShareTag(ItemStack stack) { - CompoundTag tag = new CompoundTag(); - if (stack.getTag() != null && stack.getTag().contains("display", Tag.TAG_COMPOUND)) { + public CompoundNBT getShareTag(ItemStack stack) { + CompoundNBT tag = new CompoundNBT(); + if (stack.getTag() != null && stack.getTag().contains("display", Constants.NBT.TAG_COMPOUND)) { tag.put("display", Objects.requireNonNull(stack.getTag().get("display"))); } return tag; diff --git a/common/src/main/java/com/ultreon/devices/item/EthernetCableItem.java b/common/src/main/java/com/ultreon/devices/item/EthernetCableItem.java index a75cd2db9..81eb4a595 100644 --- a/common/src/main/java/com/ultreon/devices/item/EthernetCableItem.java +++ b/common/src/main/java/com/ultreon/devices/item/EthernetCableItem.java @@ -6,27 +6,27 @@ import com.ultreon.devices.block.entity.RouterBlockEntity; import com.ultreon.devices.core.network.Router; import com.ultreon.devices.util.KeyboardHelper; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.ChatFormatting; -import net.minecraft.Util; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.chat.ChatType; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.network.chat.TranslatableComponent; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.InteractionResultHolder; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.TooltipFlag; -import net.minecraft.world.item.context.UseOnContext; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.Util; +import net.minecraft.util.math.BlockPos; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.text.ChatType; +import net.minecraft.util.text.Component; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.util.Hand; +import net.minecraft.util.ActionResultType; +import net.minecraft.util.ActionResult; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.TooltipFlag; +import net.minecraft.item.ItemUseContext; +import net.minecraft.world.World; +import net.minecraft.tileentity.TileEntity; import org.jetbrains.annotations.NotNull; import java.util.List; @@ -36,7 +36,7 @@ */ public class EthernetCableItem extends Item { public EthernetCableItem() { - super(new Properties().tab(Devices.TAB_DEVICE).stacksTo(1)); + super(new Properties().tab(Devices.GROUP_DEVICE).stacksTo(1)); } private static double getDistance(BlockPos source, BlockPos target) { @@ -44,29 +44,29 @@ private static double getDistance(BlockPos source, BlockPos target) { } @Override - public InteractionResult useOn(UseOnContext context) { - Level level = context.getLevel(); - Player player = context.getPlayer(); + public ActionResultType useOn(ItemUseContext context) { + World level = context.getLevel(); + PlayerEntity player = context.getPlayer(); BlockPos pos = context.getClickedPos(); - InteractionHand hand = context.getHand(); + Hand hand = context.getHand(); if (!level.isClientSide && player != null) { ItemStack heldItem = player.getItemInHand(hand); - BlockEntity blockEntity = level.getBlockEntity(pos); + TileEntity blockEntity = level.getBlockEntity(pos); if (blockEntity instanceof RouterBlockEntity routerBE) { if (!heldItem.hasTag()) { sendGameInfoMessage(player, "message.devices.invalid_cable"); - return InteractionResult.SUCCESS; + return ActionResultType.SUCCESS; } Router router = routerBE.getRouter(); - CompoundTag tag = heldItem.getTag(); + CompoundNBT tag = heldItem.getTag(); assert tag != null; BlockPos devicePos = BlockPos.of(tag.getLong("pos")); - BlockEntity tileEntity1 = level.getBlockEntity(devicePos); + TileEntity tileEntity1 = level.getBlockEntity(devicePos); if (tileEntity1 instanceof NetworkDeviceBlockEntity networkDeviceBlockEntity) { if (!router.isDeviceRegistered(networkDeviceBlockEntity)) { if (router.addDevice(networkDeviceBlockEntity)) { @@ -91,76 +91,76 @@ public InteractionResult useOn(UseOnContext context) { sendGameInfoMessage(player, "message.devices.router_max_devices"); } } - return InteractionResult.SUCCESS; + return ActionResultType.SUCCESS; } if (blockEntity instanceof NetworkDeviceBlockEntity networkDeviceBlockEntity) { - heldItem.setTag(new CompoundTag()); - CompoundTag tag = heldItem.getTag(); + heldItem.setTag(new CompoundNBT()); + CompoundNBT tag = heldItem.getTag(); assert tag != null; tag.putUUID("id", networkDeviceBlockEntity.getId()); tag.putString("name", networkDeviceBlockEntity.getCustomName()); tag.putLong("pos", networkDeviceBlockEntity.getBlockPos().asLong()); sendGameInfoMessage(player, "message.devices.select_router"); - return InteractionResult.SUCCESS; + return ActionResultType.SUCCESS; } } - return InteractionResult.SUCCESS; + return ActionResultType.SUCCESS; } - private void sendGameInfoMessage(Player player, String message) { - if (player instanceof ServerPlayer serverPlayer) { - serverPlayer.sendMessage(new TranslatableComponent(message), ChatType.GAME_INFO, Util.NIL_UUID); + private void sendGameInfoMessage(PlayerEntity player, String message) { + if (player instanceof ServerPlayerEntity serverPlayer) { + serverPlayer.sendMessage(new TranslationTextComponent(message), ChatType.GAME_INFO, Util.NIL_UUID); } } @NotNull @Override - public InteractionResultHolder use(Level level, @NotNull Player player, @NotNull InteractionHand usedHand) { + public ActionResult use(World level, @NotNull PlayerEntity player, @NotNull Hand usedHand) { if (!level.isClientSide) { ItemStack heldItem = player.getItemInHand(usedHand); if (player.isCrouching()) { heldItem.resetHoverName(); heldItem.setTag(null); - return new InteractionResultHolder<>(InteractionResult.SUCCESS, heldItem); + return new ActionResult<>(ActionResultType.SUCCESS, heldItem); } } return super.use(level, player, usedHand); } @Override - public void appendHoverText(ItemStack stack, @org.jetbrains.annotations.Nullable Level level, @NotNull List tooltip, @NotNull TooltipFlag isAdvanced) { + public void appendHoverText(ItemStack stack, @org.jetbrains.annotations.Nullable World level, @NotNull List tooltip, @NotNull TooltipFlag isAdvanced) { if (stack.hasTag()) { - CompoundTag tag = stack.getTag(); + CompoundNBT tag = stack.getTag(); if (tag != null) { - tooltip.add(new TextComponent(ChatFormatting.RED.toString() + ChatFormatting.BOLD + "ID: " + ChatFormatting.RESET + tag.getUUID("id"))); - tooltip.add(new TextComponent(ChatFormatting.RED.toString() + ChatFormatting.BOLD + "Device: " + ChatFormatting.RESET + tag.getString("name"))); + tooltip.add(new StringTextComponent(TextFormatting.RED.toString() + TextFormatting.BOLD + "ID: " + TextFormatting.RESET + tag.getUUID("id"))); + tooltip.add(new StringTextComponent(TextFormatting.RED.toString() + TextFormatting.BOLD + "Device: " + TextFormatting.RESET + tag.getString("name"))); BlockPos devicePos = BlockPos.of(tag.getLong("pos")); - String text = ChatFormatting.RED.toString() + ChatFormatting.BOLD + "X: " + ChatFormatting.RESET + devicePos.getX() + " " + - ChatFormatting.RED + ChatFormatting.BOLD + "Y: " + ChatFormatting.RESET + devicePos.getY() + " " + - ChatFormatting.RED + ChatFormatting.BOLD + "Z: " + ChatFormatting.RESET + devicePos.getZ(); - tooltip.add(new TextComponent(text)); + String text = TextFormatting.RED.toString() + TextFormatting.BOLD + "X: " + TextFormatting.RESET + devicePos.getX() + " " + + TextFormatting.RED + TextFormatting.BOLD + "Y: " + TextFormatting.RESET + devicePos.getY() + " " + + TextFormatting.RED + TextFormatting.BOLD + "Z: " + TextFormatting.RESET + devicePos.getZ(); + tooltip.add(new StringTextComponent(text)); } } else { if (!KeyboardHelper.isShiftDown()) { - tooltip.add(new TextComponent(ChatFormatting.GRAY + "Use this cable to connect")); - tooltip.add(new TextComponent(ChatFormatting.GRAY + "a device to a router.")); - tooltip.add(new TextComponent(ChatFormatting.YELLOW + "Hold SHIFT for How-To")); + tooltip.add(new StringTextComponent(TextFormatting.GRAY + "Use this cable to connect")); + tooltip.add(new StringTextComponent(TextFormatting.GRAY + "a device to a router.")); + tooltip.add(new StringTextComponent(TextFormatting.YELLOW + "Hold SHIFT for How-To")); return; } - tooltip.add(new TextComponent(ChatFormatting.GRAY + "Start by right clicking a")); - tooltip.add(new TextComponent(ChatFormatting.GRAY + "device with this cable")); - tooltip.add(new TextComponent(ChatFormatting.GRAY + "then right click the ")); - tooltip.add(new TextComponent(ChatFormatting.GRAY + "router you want to")); - tooltip.add(new TextComponent(ChatFormatting.GRAY + "connect this device to.")); + tooltip.add(new StringTextComponent(TextFormatting.GRAY + "Start by right clicking a")); + tooltip.add(new StringTextComponent(TextFormatting.GRAY + "device with this cable")); + tooltip.add(new StringTextComponent(TextFormatting.GRAY + "then right click the ")); + tooltip.add(new StringTextComponent(TextFormatting.GRAY + "router you want to")); + tooltip.add(new StringTextComponent(TextFormatting.GRAY + "connect this device to.")); } super.appendHoverText(stack, level, tooltip, isAdvanced); } - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) public boolean hasEffect(ItemStack stack) { return stack.hasTag(); } @@ -169,7 +169,7 @@ public boolean hasEffect(ItemStack stack) { @Override public Component getName(ItemStack stack) { if (stack.hasTag()) { - return super.getDescription().copy().withStyle(ChatFormatting.GRAY, ChatFormatting.BOLD); + return super.getDescription().copy().withStyle(TextFormatting.GRAY, TextFormatting.BOLD); } return super.getName(stack); } diff --git a/common/src/main/java/com/ultreon/devices/item/FlashDriveItem.java b/common/src/main/java/com/ultreon/devices/item/FlashDriveItem.java index e0d373c37..d5aeff6da 100644 --- a/common/src/main/java/com/ultreon/devices/item/FlashDriveItem.java +++ b/common/src/main/java/com/ultreon/devices/item/FlashDriveItem.java @@ -6,14 +6,14 @@ import com.ultreon.devices.Reference; import com.ultreon.devices.util.Colored; import dev.architectury.registry.registries.Registries; -import net.minecraft.ChatFormatting; -import net.minecraft.core.NonNullList; -import net.minecraft.core.Registry; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.*; -import net.minecraft.world.level.Level; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.NonNullList; +import net.minecraft.util.Registry; +import net.minecraft.util.text.Component; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.util.ResourceLocation; +import net.minecraft.item.*; +import net.minecraft.world.World; import org.apache.commons.lang3.text.WordUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -26,35 +26,35 @@ public class FlashDriveItem extends Item implements Colored, SubItems, IDeviceTy private final DyeColor color; public FlashDriveItem(DyeColor color) { - super(new Properties().tab(Devices.TAB_DEVICE).rarity(Rarity.UNCOMMON).stacksTo(1)); + super(new Properties().tab(Devices.GROUP_DEVICE).rarity(Rarity.UNCOMMON).stacksTo(1)); this.color = color; } - private static ChatFormatting getFromColor(DyeColor color) { + private static TextFormatting getFromColor(DyeColor color) { return switch (color) { - case ORANGE, BROWN -> ChatFormatting.GOLD; - case MAGENTA, PINK -> ChatFormatting.LIGHT_PURPLE; - case LIGHT_BLUE -> ChatFormatting.BLUE; - case YELLOW -> ChatFormatting.YELLOW; - case LIME -> ChatFormatting.GREEN; - case GRAY -> ChatFormatting.DARK_GRAY; - case LIGHT_GRAY -> ChatFormatting.GRAY; - case CYAN -> ChatFormatting.DARK_AQUA; - case PURPLE -> ChatFormatting.DARK_PURPLE; - case BLUE -> ChatFormatting.DARK_BLUE; - case GREEN -> ChatFormatting.DARK_GREEN; - case RED -> ChatFormatting.DARK_RED; - case BLACK -> ChatFormatting.BLACK; - default -> ChatFormatting.WHITE; + case ORANGE, BROWN -> TextFormatting.GOLD; + case MAGENTA, PINK -> TextFormatting.LIGHT_PURPLE; + case LIGHT_BLUE -> TextFormatting.BLUE; + case YELLOW -> TextFormatting.YELLOW; + case LIME -> TextFormatting.GREEN; + case GRAY -> TextFormatting.DARK_GRAY; + case LIGHT_GRAY -> TextFormatting.GRAY; + case CYAN -> TextFormatting.DARK_AQUA; + case PURPLE -> TextFormatting.DARK_PURPLE; + case BLUE -> TextFormatting.DARK_BLUE; + case GREEN -> TextFormatting.DARK_GREEN; + case RED -> TextFormatting.DARK_RED; + case BLACK -> TextFormatting.BLACK; + default -> TextFormatting.WHITE; }; } @Override @SuppressWarnings("deprecation") - public void appendHoverText(@NotNull ItemStack stack, @Nullable Level level, List tooltip, @NotNull TooltipFlag isAdvanced) { + public void appendHoverText(@NotNull ItemStack stack, @Nullable World level, List tooltip, @NotNull TooltipFlag isAdvanced) { String colorName = color.getName().replace("_", " "); colorName = WordUtils.capitalize(colorName); - tooltip.add(new TextComponent("Color: " + ChatFormatting.BOLD + getFromColor(color).toString() + colorName)); + tooltip.add(new StringTextComponent("Color: " + TextFormatting.BOLD + getFromColor(color).toString() + colorName)); } @Override diff --git a/common/src/main/java/com/ultreon/devices/item/MotherboardItem.java b/common/src/main/java/com/ultreon/devices/item/MotherboardItem.java index 8ed2a73ee..634e6c98b 100644 --- a/common/src/main/java/com/ultreon/devices/item/MotherboardItem.java +++ b/common/src/main/java/com/ultreon/devices/item/MotherboardItem.java @@ -1,13 +1,13 @@ package com.ultreon.devices.item; import com.ultreon.devices.util.KeyboardHelper; -import net.minecraft.ChatFormatting; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.TooltipFlag; -import net.minecraft.world.level.Level; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.INBT; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.item.ItemStack; +import net.minecraft.item.TooltipFlag; +import net.minecraft.world.World; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -22,30 +22,30 @@ public MotherboardItem(Properties properties) { } @Override - public void appendHoverText(ItemStack stack, @Nullable Level level, @NotNull List tooltip, @NotNull TooltipFlag isAdvanced) { - CompoundTag tag = stack.getTag(); + public void appendHoverText(ItemStack stack, @Nullable World level, @NotNull List tooltip, @NotNull TooltipFlag isAdvanced) { + CompoundNBT tag = stack.getTag(); if (!KeyboardHelper.isShiftDown()) { - tooltip.add(new TextComponent("CPU: " + getComponentStatus(tag, "cpu"))); - tooltip.add(new TextComponent("RAM: " + getComponentStatus(tag, "ram"))); - tooltip.add(new TextComponent("GPU: " + getComponentStatus(tag, "gpu"))); - tooltip.add(new TextComponent("WIFI: " + getComponentStatus(tag, "wifi"))); - tooltip.add(new TextComponent(ChatFormatting.YELLOW + "Hold shift for help")); + tooltip.add(new StringTextComponent("CPU: " + getComponentStatus(tag, "cpu"))); + tooltip.add(new StringTextComponent("RAM: " + getComponentStatus(tag, "ram"))); + tooltip.add(new StringTextComponent("GPU: " + getComponentStatus(tag, "gpu"))); + tooltip.add(new StringTextComponent("WIFI: " + getComponentStatus(tag, "wifi"))); + tooltip.add(new StringTextComponent(TextFormatting.YELLOW + "Hold shift for help")); } else { - tooltip.add(new TextComponent("To add the required components")); - tooltip.add(new TextComponent("place the motherboard and the")); - tooltip.add(new TextComponent("corresponding component into a")); - tooltip.add(new TextComponent("crafting table to combine them.")); + tooltip.add(new StringTextComponent("To add the required components")); + tooltip.add(new StringTextComponent("place the motherboard and the")); + tooltip.add(new StringTextComponent("corresponding component into a")); + tooltip.add(new StringTextComponent("crafting table to combine them.")); } } - private String getComponentStatus(CompoundTag tag, String component) { - if (tag != null && tag.contains("components", Tag.TAG_COMPOUND)) { - CompoundTag components = tag.getCompound("components"); - if (components.contains(component, Tag.TAG_BYTE)) { - return ChatFormatting.GREEN + "Added"; + private String getComponentStatus(CompoundNBT tag, String component) { + if (tag != null && tag.contains("components", Constants.NBT.TAG_COMPOUND)) { + CompoundNBT components = tag.getCompound("components"); + if (components.contains(component, Constants.NBT.TAG_BYTE)) { + return TextFormatting.GREEN + "Added"; } } - return ChatFormatting.RED + "Missing"; + return TextFormatting.RED + "Missing"; } public static class Component extends ComponentItem { diff --git a/common/src/main/java/com/ultreon/devices/item/SubItems.java b/common/src/main/java/com/ultreon/devices/item/SubItems.java index 35590a543..bc0511bd4 100644 --- a/common/src/main/java/com/ultreon/devices/item/SubItems.java +++ b/common/src/main/java/com/ultreon/devices/item/SubItems.java @@ -1,7 +1,7 @@ package com.ultreon.devices.item; -import net.minecraft.core.NonNullList; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.NonNullList; +import net.minecraft.util.ResourceLocation; /** * @author MrCrayfish diff --git a/common/src/main/java/com/ultreon/devices/mixin/common/FontSetMixin.java b/common/src/main/java/com/ultreon/devices/mixin/common/FontSetMixin.java index 89e37072d..cdd7e60bd 100644 --- a/common/src/main/java/com/ultreon/devices/mixin/common/FontSetMixin.java +++ b/common/src/main/java/com/ultreon/devices/mixin/common/FontSetMixin.java @@ -3,7 +3,7 @@ import com.mojang.blaze3d.font.GlyphInfo; import com.ultreon.devices.Devices; import net.minecraft.client.gui.font.FontSet; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.ResourceLocation; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; diff --git a/common/src/main/java/com/ultreon/devices/network/Packet.java b/common/src/main/java/com/ultreon/devices/network/Packet.java index 9be8fcb6e..cc407f5c7 100644 --- a/common/src/main/java/com/ultreon/devices/network/Packet.java +++ b/common/src/main/java/com/ultreon/devices/network/Packet.java @@ -1,7 +1,7 @@ package com.ultreon.devices.network; -import dev.architectury.networking.NetworkManager; -import net.minecraft.network.FriendlyByteBuf; +import net.minecraftforge.fml.network.NetworkEvent; +import net.minecraft.network.PacketBuffer; import java.util.function.Supplier; @@ -10,12 +10,12 @@ public Packet() { } - public abstract void toBytes(FriendlyByteBuf buf); + public abstract void toBytes(PacketBuffer buf); @Deprecated - public void fromBytes(FriendlyByteBuf buf) { + public void fromBytes(PacketBuffer buf) { } - public abstract boolean onMessage(Supplier ctx); + public abstract boolean onMessage(Supplier ctx); } diff --git a/common/src/main/java/com/ultreon/devices/network/PacketHandler.java b/common/src/main/java/com/ultreon/devices/network/PacketHandler.java index bd3fc6b6d..827ea5c0b 100644 --- a/common/src/main/java/com/ultreon/devices/network/PacketHandler.java +++ b/common/src/main/java/com/ultreon/devices/network/PacketHandler.java @@ -5,15 +5,15 @@ import com.ultreon.devices.core.laptop.common.S2CUpdatePacket; import com.ultreon.devices.network.task.*; import dev.architectury.networking.NetworkChannel; -import dev.architectury.networking.NetworkManager; -import dev.architectury.utils.Env; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; +import net.minecraftforge.fml.network.NetworkEvent; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraft.client.Minecraft; -import net.minecraft.resources.ResourceKey; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; +import net.minecraft.util.RegistryKey; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; public class PacketHandler { public static final NetworkChannel INSTANCE = NetworkChannel.create(Devices.id("main_channel")); @@ -34,16 +34,16 @@ private static int nextId() { return id++; } - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) public static > void sendToServer(T message) { if (Minecraft.getInstance().getConnection() != null) { INSTANCE.sendToServer(message); } else { Minecraft.getInstance().doRunTask(() -> - message.onMessage(() -> new NetworkManager.PacketContext() { + message.onMessage(() -> new NetworkEvent.Context() { @Override - public Player getPlayer() { + public PlayerEntity getPlayer() { return Minecraft.getInstance().player; } @@ -53,18 +53,18 @@ public void queue(Runnable runnable) { } @Override - public Env getEnvironment() { - return Env.SERVER; + public Dist getOnlyIn() { + return Dist.SERVER; } })); } } - public static > void sendToClient(Packet messageNotification, Player player) { // has to be ServerPlayer if world is not null + public static > void sendToClient(Packet messageNotification, PlayerEntity player) { // has to be ServerPlayer if world is not null if (player == null || player.level == null) { - messageNotification.onMessage(() -> new NetworkManager.PacketContext() { + messageNotification.onMessage(() -> new NetworkEvent.Context() { @Override - public Player getPlayer() { + public PlayerEntity getPlayer() { return player; } @@ -74,23 +74,23 @@ public void queue(Runnable runnable) { } @Override - public Env getEnvironment() { - return Env.CLIENT; + public Dist getOnlyIn() { + return Dist.CLIENT; } }); return; } - INSTANCE.sendToPlayer((ServerPlayer) player, messageNotification); + INSTANCE.sendToPlayer((ServerPlayerEntity) player, messageNotification); //INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), messageNotification); } // seems to be unused - public static > void sendToDimension(Packet messageNotification, ResourceKey level) { + public static > void sendToDimension(Packet messageNotification, RegistryKey level) { //INSTANCE.sendToServer(); //INSTANCE.send(PacketDistributor.DIMENSION.with(() -> level), messageNotification); } -// public static > void sendToDimension(Packet messageNotification, Level level) { +// public static > void sendToDimension(Packet messageNotification, World level) { // INSTANCE.send(PacketDistributor.DIMENSION.with(level::dimension), messageNotification); // } // @@ -102,11 +102,11 @@ public static > void sendToDimension(Packet messageNotifi // INSTANCE.send(PacketDistributor.ALL.noArg(), messageNotification); // } // -// public static > void sendToAllAround(Packet messageNotification, ResourceKey level, double x, double y, double z, double radius) { +// public static > void sendToAllAround(Packet messageNotification, ResourceKey level, double x, double y, double z, double radius) { // INSTANCE.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(x, y, z, radius, level)), messageNotification); // } // -// public static > void sendToAllAround(Packet messageNotification, Level level, double x, double y, double z, double radius) { +// public static > void sendToAllAround(Packet messageNotification, World level, double x, double y, double z, double radius) { // INSTANCE.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(x, y, z, radius, level.dimension())), messageNotification); // } // @@ -114,7 +114,7 @@ public static > void sendToDimension(Packet messageNotifi // INSTANCE.send(PacketDistributor.TRACKING_CHUNK.with(() -> chunk), messageNotification); // } // -// public static > void sendToTrackingChunk(Packet messageNotification, Level level, int x, int z) { +// public static > void sendToTrackingChunk(Packet messageNotification, World level, int x, int z) { // INSTANCE.send(PacketDistributor.TRACKING_CHUNK.with(() -> level.getChunk(x, z)), messageNotification); // } // @@ -122,7 +122,7 @@ public static > void sendToDimension(Packet messageNotifi // INSTANCE.send(PacketDistributor.TRACKING_ENTITY.with(() -> entity), messageNotification); // } // -// public static > void sendToTrackingEntity(Packet messageNotification, Level level, int entityId) { +// public static > void sendToTrackingEntity(Packet messageNotification, World level, int entityId) { // INSTANCE.send(PacketDistributor.TRACKING_ENTITY.with(() -> level.getEntity(entityId)), messageNotification); // } // @@ -130,7 +130,7 @@ public static > void sendToDimension(Packet messageNotifi // INSTANCE.send(PacketDistributor.TRACKING_ENTITY_AND_SELF.with(() -> entity), messageNotification); // } // -// public static > void sendToTrackingEntityAndSelf(Packet messageNotification, Level level, int entityId) { +// public static > void sendToTrackingEntityAndSelf(Packet messageNotification, World level, int entityId) { // INSTANCE.send(PacketDistributor.TRACKING_ENTITY_AND_SELF.with(() -> level.getEntity(entityId)), messageNotification); // } } diff --git a/common/src/main/java/com/ultreon/devices/network/task/NotificationPacket.java b/common/src/main/java/com/ultreon/devices/network/task/NotificationPacket.java index ac10bcd66..5ae199e48 100644 --- a/common/src/main/java/com/ultreon/devices/network/task/NotificationPacket.java +++ b/common/src/main/java/com/ultreon/devices/network/task/NotificationPacket.java @@ -3,9 +3,9 @@ import com.ultreon.devices.Devices; import com.ultreon.devices.api.app.Notification; import com.ultreon.devices.network.Packet; -import dev.architectury.networking.NetworkManager; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.FriendlyByteBuf; +import net.minecraftforge.fml.network.NetworkEvent; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.network.PacketBuffer; import java.util.function.Supplier; @@ -13,9 +13,9 @@ * @author MrCrayfish */ public class NotificationPacket extends Packet { - private final CompoundTag notificationTag; + private final CompoundNBT notificationTag; - public NotificationPacket(FriendlyByteBuf buf) { + public NotificationPacket(PacketBuffer buf) { notificationTag = buf.readNbt(); } @@ -24,12 +24,12 @@ public NotificationPacket(Notification notification) { } @Override - public void toBytes(FriendlyByteBuf buf) { + public void toBytes(PacketBuffer buf) { buf.writeNbt(notificationTag); } @Override - public boolean onMessage(Supplier ctx) { + public boolean onMessage(Supplier ctx) { Devices.showNotification(notificationTag); return true; } diff --git a/common/src/main/java/com/ultreon/devices/network/task/RequestPacket.java b/common/src/main/java/com/ultreon/devices/network/task/RequestPacket.java index a2a66cc49..4de2a4f11 100644 --- a/common/src/main/java/com/ultreon/devices/network/task/RequestPacket.java +++ b/common/src/main/java/com/ultreon/devices/network/task/RequestPacket.java @@ -4,10 +4,10 @@ import com.ultreon.devices.api.task.TaskManager; import com.ultreon.devices.network.Packet; import com.ultreon.devices.network.PacketHandler; -import dev.architectury.networking.NetworkManager; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.server.level.ServerPlayer; +import net.minecraftforge.fml.network.NetworkEvent; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.network.PacketBuffer; +import net.minecraft.entity.player.ServerPlayerEntity; import java.util.Objects; import java.util.function.Supplier; @@ -15,9 +15,9 @@ public class RequestPacket extends Packet { private final int id; private final Task request; - private CompoundTag tag; + private CompoundNBT tag; - public RequestPacket(FriendlyByteBuf buf) { + public RequestPacket(PacketBuffer buf) { this.id = buf.readInt(); String name = buf.readUtf(); this.request = TaskManager.getTask(name); @@ -31,19 +31,19 @@ public RequestPacket(int id, Task request) { } @Override - public void toBytes(FriendlyByteBuf buf) { + public void toBytes(PacketBuffer buf) { buf.writeInt(this.id); buf.writeUtf(this.request.getName()); - CompoundTag tag = new CompoundTag(); + CompoundNBT tag = new CompoundNBT(); this.request.prepareRequest(tag); buf.writeNbt(tag); } @Override - public boolean onMessage(Supplier ctx) { + public boolean onMessage(Supplier ctx) { //System.out.println("RECEIVED from " + ctx.get().getPlayer().getUUID()); - request.processRequest(tag, Objects.requireNonNull(ctx.get().getPlayer()).level, ctx.get().getPlayer()); - if (ctx.get().getPlayer() instanceof ServerPlayer player) + request.processRequest(tag, Objects.requireNonNull(ctx.get().getSender()).level, ctx.get().getSender()); + if (ctx.get().getSender() instanceof ServerPlayerEntity player) PacketHandler.sendToClient(new ResponsePacket(id, request), player); return true; } diff --git a/common/src/main/java/com/ultreon/devices/network/task/ResponsePacket.java b/common/src/main/java/com/ultreon/devices/network/task/ResponsePacket.java index 32d016260..2890b9e0d 100644 --- a/common/src/main/java/com/ultreon/devices/network/task/ResponsePacket.java +++ b/common/src/main/java/com/ultreon/devices/network/task/ResponsePacket.java @@ -3,18 +3,18 @@ import com.ultreon.devices.api.task.Task; import com.ultreon.devices.api.task.TaskManager; import com.ultreon.devices.network.Packet; -import dev.architectury.networking.NetworkManager; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.FriendlyByteBuf; +import net.minecraftforge.fml.network.NetworkEvent; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.network.PacketBuffer; import java.util.function.Supplier; public class ResponsePacket extends Packet { private final int id; private final Task request; - private CompoundTag tag; + private CompoundNBT tag; - public ResponsePacket(FriendlyByteBuf buf) { + public ResponsePacket(PacketBuffer buf) { this.id = buf.readInt(); boolean successful = buf.readBoolean(); this.request = TaskManager.getTaskAndRemove(this.id); @@ -29,18 +29,18 @@ public ResponsePacket(int id, Task request) { } @Override - public void toBytes(FriendlyByteBuf buf) { + public void toBytes(PacketBuffer buf) { buf.writeInt(this.id); buf.writeBoolean(this.request.isSucessful()); buf.writeUtf(this.request.getName()); - CompoundTag tag = new CompoundTag(); + CompoundNBT tag = new CompoundNBT(); this.request.prepareResponse(tag); buf.writeNbt(tag); this.request.complete(); } @Override - public boolean onMessage(Supplier ctx) { + public boolean onMessage(Supplier ctx) { request.processResponse(tag); request.callback(tag); return false; diff --git a/common/src/main/java/com/ultreon/devices/network/task/SyncApplicationPacket.java b/common/src/main/java/com/ultreon/devices/network/task/SyncApplicationPacket.java index 492feaf3d..147f9de30 100644 --- a/common/src/main/java/com/ultreon/devices/network/task/SyncApplicationPacket.java +++ b/common/src/main/java/com/ultreon/devices/network/task/SyncApplicationPacket.java @@ -5,8 +5,8 @@ import com.ultreon.devices.api.ApplicationManager; import com.ultreon.devices.network.Packet; import com.ultreon.devices.object.AppInfo; -import dev.architectury.networking.NetworkManager; -import net.minecraft.network.FriendlyByteBuf; +import net.minecraftforge.fml.network.NetworkEvent; +import net.minecraft.network.PacketBuffer; import java.util.List; import java.util.function.Supplier; @@ -17,7 +17,7 @@ public class SyncApplicationPacket extends Packet { private final List allowedApps; - public SyncApplicationPacket(FriendlyByteBuf buf) { + public SyncApplicationPacket(PacketBuffer buf) { int size = buf.readInt(); ImmutableList.Builder builder = ImmutableList.builder(); for (int i = 0; i < size; i++) { @@ -38,7 +38,7 @@ public SyncApplicationPacket(List allowedApps) { } @Override - public void toBytes(FriendlyByteBuf buf) { + public void toBytes(PacketBuffer buf) { buf.writeInt(allowedApps.size()); for (AppInfo appInfo : allowedApps) { buf.writeResourceLocation(appInfo.getId()); @@ -46,7 +46,7 @@ public void toBytes(FriendlyByteBuf buf) { } @Override - public boolean onMessage(Supplier ctx) { + public boolean onMessage(Supplier ctx) { Devices.setAllowedApps(allowedApps); return true; } diff --git a/common/src/main/java/com/ultreon/devices/network/task/SyncBlockPacket.java b/common/src/main/java/com/ultreon/devices/network/task/SyncBlockPacket.java index b7c686088..cac828269 100644 --- a/common/src/main/java/com/ultreon/devices/network/task/SyncBlockPacket.java +++ b/common/src/main/java/com/ultreon/devices/network/task/SyncBlockPacket.java @@ -2,12 +2,12 @@ import com.ultreon.devices.block.entity.RouterBlockEntity; import com.ultreon.devices.network.Packet; -import dev.architectury.networking.NetworkManager; -import net.minecraft.core.BlockPos; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraftforge.fml.network.NetworkEvent; +import net.minecraft.util.math.BlockPos; +import net.minecraft.network.PacketBuffer; +import net.minecraft.world.World; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.chunk.Chunk; import java.util.Objects; import java.util.function.Supplier; @@ -18,7 +18,7 @@ public class SyncBlockPacket extends Packet { private final BlockPos routerPos; - public SyncBlockPacket(FriendlyByteBuf buf) { + public SyncBlockPacket(PacketBuffer buf) { this.routerPos = buf.readBlockPos(); } @@ -27,14 +27,14 @@ public SyncBlockPacket(BlockPos routerPos) { } @Override - public void toBytes(FriendlyByteBuf buf) { + public void toBytes(PacketBuffer buf) { buf.writeBlockPos(routerPos); } @Override - public boolean onMessage(Supplier ctx) { - Level level = Objects.requireNonNull(ctx.get().getPlayer()).level; - BlockEntity blockEntity = level.getChunkAt(routerPos).getBlockEntity(routerPos, LevelChunk.EntityCreationType.IMMEDIATE); + public boolean onMessage(Supplier ctx) { + World level = Objects.requireNonNull(ctx.get().getSender()).level; + TileEntity blockEntity = level.getChunkAt(routerPos).getBlockEntity(routerPos, Chunk.CreateEntityType.IMMEDIATE); if (blockEntity instanceof RouterBlockEntity router) { router.syncDevicesToClient(); } diff --git a/common/src/main/java/com/ultreon/devices/network/task/SyncConfigPacket.java b/common/src/main/java/com/ultreon/devices/network/task/SyncConfigPacket.java index ab025bcb6..b0de83db1 100644 --- a/common/src/main/java/com/ultreon/devices/network/task/SyncConfigPacket.java +++ b/common/src/main/java/com/ultreon/devices/network/task/SyncConfigPacket.java @@ -2,8 +2,8 @@ import com.ultreon.devices.DeviceConfig; import com.ultreon.devices.network.Packet; -import dev.architectury.networking.NetworkManager; -import net.minecraft.network.FriendlyByteBuf; +import net.minecraftforge.fml.network.NetworkEvent; +import net.minecraft.network.PacketBuffer; import java.util.Objects; import java.util.function.Supplier; @@ -16,17 +16,17 @@ public SyncConfigPacket() { } - public SyncConfigPacket(FriendlyByteBuf buf) { + public SyncConfigPacket(PacketBuffer buf) { DeviceConfig.readSyncTag(Objects.requireNonNull(buf.readNbt())); } @Override - public void toBytes(FriendlyByteBuf buf) { + public void toBytes(PacketBuffer buf) { buf.writeNbt(DeviceConfig.writeSyncTag()); } @Override - public boolean onMessage(Supplier ctx) { + public boolean onMessage(Supplier ctx) { return true; } } diff --git a/common/src/main/java/com/ultreon/devices/object/AppInfo.java b/common/src/main/java/com/ultreon/devices/object/AppInfo.java index cbaa779cd..6c464b541 100644 --- a/common/src/main/java/com/ultreon/devices/object/AppInfo.java +++ b/common/src/main/java/com/ultreon/devices/object/AppInfo.java @@ -5,8 +5,8 @@ import com.ultreon.devices.Devices; import com.ultreon.devices.core.Laptop; import dev.architectury.injectables.annotations.PlatformOnly; -import net.minecraft.client.resources.language.I18n; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.ResourceLocation; import org.jetbrains.annotations.ApiStatus; import java.awt.*; diff --git a/common/src/main/java/com/ultreon/devices/object/Canvas.java b/common/src/main/java/com/ultreon/devices/object/Canvas.java index 6dbe2392b..e768d20d9 100644 --- a/common/src/main/java/com/ultreon/devices/object/Canvas.java +++ b/common/src/main/java/com/ultreon/devices/object/Canvas.java @@ -1,6 +1,6 @@ package com.ultreon.devices.object; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.app.Component; import com.ultreon.devices.api.app.Layout; import com.ultreon.devices.core.Laptop; @@ -50,7 +50,7 @@ public void init(Layout layout) { } @Override - public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + public void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { fill(pose, xPosition, yPosition, xPosition + picture.getWidth() * picture.getPixelWidth() + 2, yPosition + picture.getHeight() * picture.getPixelHeight() + 2, Color.DARK_GRAY.getRGB()); fill(pose, xPosition + 1, yPosition + 1, xPosition + picture.getWidth() * picture.getPixelWidth() + 1, yPosition + picture.getHeight() * picture.getPixelHeight() + 1, Color.WHITE.getRGB()); for (int i = 0; i < picture.getHeight(); i++) { diff --git a/common/src/main/java/com/ultreon/devices/object/ColorGrid.java b/common/src/main/java/com/ultreon/devices/object/ColorGrid.java index 3aaa96032..8811e69a0 100644 --- a/common/src/main/java/com/ultreon/devices/object/ColorGrid.java +++ b/common/src/main/java/com/ultreon/devices/object/ColorGrid.java @@ -1,6 +1,6 @@ package com.ultreon.devices.object; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.app.Component; import com.ultreon.devices.api.app.component.Slider; import com.ultreon.devices.core.Laptop; @@ -31,7 +31,7 @@ public ColorGrid(int left, int top, int width, Canvas canvas, Slider redSlider, } @Override - public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + public void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { int endX = xPosition + width + 2; int endY = yPosition + (colors.length / 5) * 10 + 2; fill(pose, xPosition, yPosition, endX, endY, Color.DARK_GRAY.getRGB()); diff --git a/common/src/main/java/com/ultreon/devices/object/Game.java b/common/src/main/java/com/ultreon/devices/object/Game.java index 31a14e7c1..e5827a321 100644 --- a/common/src/main/java/com/ultreon/devices/object/Game.java +++ b/common/src/main/java/com/ultreon/devices/object/Game.java @@ -2,14 +2,14 @@ import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.app.Component; import com.ultreon.devices.core.Laptop; import com.ultreon.devices.exception.WorldLessException; import com.ultreon.devices.object.tiles.Tile; import com.ultreon.devices.util.GuiHelper; import net.minecraft.client.Minecraft; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.ResourceLocation; import java.awt.*; import java.util.HashMap; @@ -19,7 +19,7 @@ public class Game extends Component { public static final ResourceLocation ICONS = new ResourceLocation("devices:textures/gui/mine_racer.png"); private static final Map registeredTiles = new HashMap(); - private final Player player; + private final PlayerEntity player; public int mapWidth; public int mapHeight; private Tile[][] tiles; @@ -40,7 +40,7 @@ public Game(int left, int top, int mapWidth, int mapHeight) throws Exception { if (mapWidth % Tile.WIDTH != 0 || mapHeight % Tile.HEIGHT != 0) throw new Exception("Width and height need to be a multiple of " + Tile.WIDTH); - this.player = new Player(this); + this.player = new PlayerEntity(this); this.mapWidth = mapWidth / Tile.WIDTH; this.mapHeight = mapHeight / Tile.HEIGHT; this.tiles = new Tile[4][this.mapWidth * this.mapHeight]; @@ -115,7 +115,7 @@ public void handleMouseDrag(int mouseX, int mouseY, int mouseButton) { } @Override - public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + public void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { //long start = System.currentTimeMillis(); if (editorMode) { @@ -123,8 +123,8 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in } pose.pushPose(); - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); - RenderSystem.setShaderTexture(0, ICONS); + RenderSystem.blendColor(1f, 1f, 1f, 1f); + mc.textureManager.bind(ICONS); if (renderBackground) { for (int i = 0; i < tiles[0].length; i++) { @@ -162,7 +162,7 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in player.render(pose, xPosition, yPosition, partialTicks); } - RenderSystem.setShaderTexture(0, ICONS); + mc.textureManager.bind(ICONS); if (renderMidgroundHigh) { for (int i = 0; i < tiles[2].length; i++) { Tile tile = tiles[2][i]; diff --git a/common/src/main/java/com/ultreon/devices/object/Picture.java b/common/src/main/java/com/ultreon/devices/object/Picture.java index 721da3ba4..2ff0914c5 100644 --- a/common/src/main/java/com/ultreon/devices/object/Picture.java +++ b/common/src/main/java/com/ultreon/devices/object/Picture.java @@ -1,7 +1,7 @@ package com.ultreon.devices.object; import com.ultreon.devices.api.io.File; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.CompoundNBT; import java.awt.*; import java.util.Arrays; @@ -23,7 +23,7 @@ public Picture(String name, String author, Size size) { } public static Picture fromFile(File file) { - CompoundTag data = file.getData(); + CompoundNBT data = file.getData(); assert data != null; Picture picture = new Picture(data.getString("Name"), data.getString("Author"), Objects.requireNonNull(Size.getFromSize(data.getInt("Resolution")))); picture.source = file; @@ -78,7 +78,7 @@ public String toString() { return name; } - public void writeToNBT(CompoundTag tagCompound) { + public void writeToNBT(CompoundNBT tagCompound) { tagCompound.putString("Name", getName()); tagCompound.putString("Author", getAuthor()); tagCompound.putIntArray("Pixels", pixels); diff --git a/common/src/main/java/com/ultreon/devices/object/Player.java b/common/src/main/java/com/ultreon/devices/object/Player.java index 17906cc67..fc982e66c 100644 --- a/common/src/main/java/com/ultreon/devices/object/Player.java +++ b/common/src/main/java/com/ultreon/devices/object/Player.java @@ -2,23 +2,23 @@ import com.mojang.blaze3d.platform.InputConstants; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.Tesselator; -import com.mojang.math.Quaternion; +import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.matrix.Tessellator; +import net.minecraft.util.math.vector.Quaternion; import com.ultreon.devices.core.Laptop; import com.ultreon.devices.object.tiles.Tile; import com.ultreon.devices.util.KeyboardHelper; import com.ultreon.devices.util.Vec2d; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.entity.BoatRenderer; import net.minecraft.client.renderer.entity.EntityRendererProvider; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.entity.vehicle.Boat; +import net.minecraft.util.ResourceLocation; +import net.minecraft.entity.vehicle.Boat; import java.util.Objects; -public class Player { +public class PlayerEntity { private static final ResourceLocation boatTextures = new ResourceLocation("textures/entity/boat/oak.png"); boolean canMove = false; private final Game game; @@ -36,7 +36,7 @@ public static EntityRendererProvider.Context createEntityRendererContext() { return new EntityRendererProvider.Context(Minecraft.getInstance().getEntityRenderDispatcher(), Minecraft.getInstance().getItemRenderer(), Minecraft.getInstance().getResourceManager(), Minecraft.getInstance().getEntityModels(), Minecraft.getInstance().font); } - public Player(Game game) { + public PlayerEntity(Game game) { this.game = game; this.direction = new Vec2d(0, 0); this.velocity = new Vec2d(0, 0); @@ -56,7 +56,7 @@ public void tick() { posXPrev = posX; posYPrev = posY; - if (KeyboardHelper.isKeyDown(InputConstants.KEY_UP)) { + if (KeyboardHelper.isKeyDown(GLFW.GLFW_KEY_UP)) { speed += 0.5; if (speed >= 3) { speed = 3; @@ -67,10 +67,10 @@ public void tick() { } else { speed /= 1.1; } - if (KeyboardHelper.isKeyDown(InputConstants.KEY_LEFT)) { + if (KeyboardHelper.isKeyDown(GLFW.GLFW_KEY_LEFT)) { rotation -= 8; } - if (KeyboardHelper.isKeyDown(InputConstants.KEY_RIGHT)) { + if (KeyboardHelper.isKeyDown(GLFW.GLFW_KEY_RIGHT)) { rotation += 8; } @@ -110,7 +110,7 @@ public int getPosY() { return (int) (posY / Tile.HEIGHT); } - public void render(PoseStack pose, int x, int y, float partialTicks) { + public void render(MatrixStack pose, int x, int y, float partialTicks) { float scale = 0.5f; double px = x + posXPrev + (posX - posXPrev) * partialTicks; double py = y + posYPrev + (posY - posYPrev) * partialTicks; @@ -124,8 +124,8 @@ public void render(PoseStack pose, int x, int y, float partialTicks) { pose.translate(0f, -3d, 0f); pose.mulPose(new Quaternion(-90, 1f, 0f, 0f)); pose.mulPose(new Quaternion(rot, 0f, 1f, 0f)); - RenderSystem.setShaderTexture(0, boatTextures); - Minecraft.getInstance().getEntityRenderDispatcher().render(this.boat, 0, 0, 0, 0f, partialTicks, pose, MultiBufferSource.immediate(Tesselator.getInstance().getBuilder()), 1); + mc.textureManager.bind(boatTextures); + Minecraft.getInstance().getEntityRenderDispatcher().render(this.boat, 0, 0, 0, 0f, partialTicks, pose, IRenderTypeBuffer.immediate(Tessellator.getInstance().getBuilder()), 1); boatModel.render(boat, 0f, 0f, pose, Minecraft.getInstance().renderBuffers().bufferSource(), 1); pose.popPose(); @@ -144,7 +144,7 @@ public void render(PoseStack pose, int x, int y, float partialTicks) { pose.popPose(); } -// public static class ModelDummyPlayer extends PlayerModel { +// public static class ModelDummyPlayer extends PlayerModel { // public ModelPart bipedLeftArmwear; // public ModelPart bipedRightArmwear; // public ModelPart bipedLeftLegwear; diff --git a/common/src/main/java/com/ultreon/devices/object/TileGrid.java b/common/src/main/java/com/ultreon/devices/object/TileGrid.java index 09b6aa117..a3b0b5308 100644 --- a/common/src/main/java/com/ultreon/devices/object/TileGrid.java +++ b/common/src/main/java/com/ultreon/devices/object/TileGrid.java @@ -1,8 +1,8 @@ package com.ultreon.devices.object; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.Tesselator; +import com.mojang.blaze3d.matrix.MatrixStack; +import com.mojang.blaze3d.matrix.Tessellator; import com.ultreon.devices.api.app.Component; import com.ultreon.devices.api.app.Icons; import com.ultreon.devices.api.app.Layout; @@ -79,10 +79,10 @@ public void onClick(int mouseX, int mouseY, int mouseButton) } @Override - public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) + public void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { try { - Tesselator.getInstance().getBuilder().end(); + Tessellator.getInstance().getBuilder().end(); } catch (IllegalStateException e) { // ignore it } @@ -90,7 +90,7 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in fill(pose, xPosition + 1, yPosition + 16, xPosition + 92, yPosition + 99, Color.GRAY.getRGB()); - RenderSystem.setShaderTexture(0, Game.ICONS); + mc.textureManager.bind(Game.ICONS); for(int i = 0; i < tabTiles.size(); i++) { Tile tile = tabTiles.get(i); @@ -101,7 +101,7 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in else fill(pose, tileX - 1, tileY - 1, tileX + 13, tileY + 13, Color.LIGHT_GRAY.getRGB()); pose.pushPose(); - RenderSystem.setShaderColor(1F, 1F, 1F, 1F); + RenderSystem.blendColor(1F, 1F, 1F, 1F); RenderUtil.drawRectWithTexture(pose, tileX, tileY, tile.x * 16, tile.y * 16, 12, 12, 16, 16); pose.popPose(); } diff --git a/common/src/main/java/com/ultreon/devices/object/tiles/Tile.java b/common/src/main/java/com/ultreon/devices/object/tiles/Tile.java index 3e72abd52..a30548982 100644 --- a/common/src/main/java/com/ultreon/devices/object/tiles/Tile.java +++ b/common/src/main/java/com/ultreon/devices/object/tiles/Tile.java @@ -1,6 +1,6 @@ package com.ultreon.devices.object.tiles; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.utils.RenderUtil; import com.ultreon.devices.object.Game; @@ -72,12 +72,12 @@ public Tile setCategory(Category category) return this; } - public void render(PoseStack pose, Game game, int x, int y, Game.Layer layer) + public void render(MatrixStack pose, Game game, int x, int y, Game.Layer layer) { RenderUtil.drawRectWithTexture(pose, game.xPosition + x * Tile.WIDTH , game.yPosition + y * Tile.HEIGHT, this.x * 16, this.y * 16, WIDTH, HEIGHT, 16, 16); } - public void renderForeground(PoseStack pose, Game game, int x, int y, Game.Layer layer) {} + public void renderForeground(MatrixStack pose, Game game, int x, int y, Game.Layer layer) {} public boolean isFullTile() { diff --git a/common/src/main/java/com/ultreon/devices/object/tiles/TileBlock.java b/common/src/main/java/com/ultreon/devices/object/tiles/TileBlock.java index 7f7220881..e94272be2 100644 --- a/common/src/main/java/com/ultreon/devices/object/tiles/TileBlock.java +++ b/common/src/main/java/com/ultreon/devices/object/tiles/TileBlock.java @@ -1,7 +1,7 @@ package com.ultreon.devices.object.tiles; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.utils.RenderUtil; import com.ultreon.devices.object.Game; @@ -18,16 +18,16 @@ public TileBlock(int id, int x, int y, int topX, int topY) } @Override - public void render(PoseStack pose, Game game, int x, int y, Game.Layer layer) + public void render(MatrixStack pose, Game game, int x, int y, Game.Layer layer) { if(layer == Game.Layer.BACKGROUND) { super.render(pose, game, x, y, layer); if(!game.isFullTile(layer, x, y + 1) && this != Tile.water) { - RenderSystem.setShaderColor(0.6f, 0.6f, 0.6f, 1f); + RenderSystem.blendColor(0.6f, 0.6f, 0.6f, 1f); RenderUtil.drawRectWithTexture(pose, game.xPosition + x * Tile.WIDTH, game.yPosition + y * Tile.HEIGHT + 6, layer.zLevel, this.x * 16, this.y * 16, WIDTH, 2, 16, 4); - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.blendColor(1f, 1f, 1f, 1f); } return; } @@ -37,13 +37,13 @@ public void render(PoseStack pose, Game game, int x, int y, Game.Layer layer) RenderUtil.drawRectWithTexture(pose, game.xPosition + x * Tile.WIDTH, game.yPosition + y * Tile.HEIGHT - 6, layer.zLevel, this.topX * 16, this.topY * 16, WIDTH, HEIGHT, 16, 16); } - RenderSystem.setShaderColor(0.6f, 0.6f, 0.6f, 1f); + RenderSystem.blendColor(0.6f, 0.6f, 0.6f, 1f); RenderUtil.drawRectWithTexture(pose, game.xPosition + x * Tile.WIDTH, game.yPosition + y * Tile.HEIGHT, layer.zLevel, this.x * 16, this.y * 16, WIDTH, 6, 16, 16); - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.blendColor(1f, 1f, 1f, 1f); } @Override - public void renderForeground(PoseStack pose, Game game, int x, int y, Game.Layer layer) + public void renderForeground(MatrixStack pose, Game game, int x, int y, Game.Layer layer) { if(layer != Game.Layer.BACKGROUND || this == Tile.water) return; @@ -51,9 +51,9 @@ public void renderForeground(PoseStack pose, Game game, int x, int y, Game.Layer Tile tileDown = game.getTile(layer, x, y + 1); if(game.getTile(layer, x, y + 1) == Tile.water) { - RenderSystem.setShaderColor(0.6f, 0.6f, 0.6f, 1f); + RenderSystem.blendColor(0.6f, 0.6f, 0.6f, 1f); RenderUtil.drawRectWithTexture(pose, game.xPosition + x * Tile.WIDTH, game.yPosition + y * Tile.HEIGHT + 6, layer.zLevel, this.x * 16, this.y * 16, WIDTH, 1, 16, 2); - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.blendColor(1f, 1f, 1f, 1f); } } } diff --git a/common/src/main/java/com/ultreon/devices/object/tiles/TileCactus.java b/common/src/main/java/com/ultreon/devices/object/tiles/TileCactus.java index 307b5d1a2..a0e976d21 100644 --- a/common/src/main/java/com/ultreon/devices/object/tiles/TileCactus.java +++ b/common/src/main/java/com/ultreon/devices/object/tiles/TileCactus.java @@ -1,7 +1,7 @@ package com.ultreon.devices.object.tiles; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.utils.RenderUtil; import com.ultreon.devices.object.Game; @@ -13,7 +13,7 @@ public TileCactus(int id) } @Override - public void render(PoseStack pose, Game game, int x, int y, Game.Layer layer) + public void render(MatrixStack pose, Game game, int x, int y, Game.Layer layer) { if(game.getTile(layer.up(), x, y - 1) != this || layer == Game.Layer.FOREGROUND) { @@ -21,9 +21,9 @@ public void render(PoseStack pose, Game game, int x, int y, Game.Layer layer) RenderUtil.drawRectWithTexture(pose, game.xPosition + x * WIDTH + 0.5, game.yPosition + y * HEIGHT - 5.5, layer.zLevel, (this.x + 1) * 16 + 1, this.y * 16 + 1, WIDTH - 1, HEIGHT - 1, 14, 14); } - RenderSystem.setShaderColor(0.6f, 0.6f, 0.6f, 1f); + RenderSystem.blendColor(0.6f, 0.6f, 0.6f, 1f); RenderUtil.drawRectWithTexture(pose, game.xPosition + x * WIDTH, game.yPosition + y * HEIGHT - 0.5, layer.zLevel, this.x * 16, this.y * 16, WIDTH, HEIGHT, 16, 16); - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.blendColor(1f, 1f, 1f, 1f); } @Override diff --git a/common/src/main/java/com/ultreon/devices/object/tiles/TileEnchantmentTable.java b/common/src/main/java/com/ultreon/devices/object/tiles/TileEnchantmentTable.java index d2dd06b67..bb81e5535 100644 --- a/common/src/main/java/com/ultreon/devices/object/tiles/TileEnchantmentTable.java +++ b/common/src/main/java/com/ultreon/devices/object/tiles/TileEnchantmentTable.java @@ -1,7 +1,7 @@ package com.ultreon.devices.object.tiles; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.utils.RenderUtil; import com.ultreon.devices.object.Game; @@ -13,16 +13,16 @@ public TileEnchantmentTable(int id, int x, int y) } @Override - public void render(PoseStack pose, Game game, int x, int y, Game.Layer layer) + public void render(MatrixStack pose, Game game, int x, int y, Game.Layer layer) { if(game.getTile(layer.up(), x, y - 1) != this || layer == Game.Layer.FOREGROUND) { RenderUtil.drawRectWithTexture(pose, game.xPosition + x * WIDTH, game.yPosition + y * HEIGHT - 4, layer.zLevel, this.topX * 16 + 16, this.topY * 16, WIDTH, HEIGHT, 16, 16); } - RenderSystem.setShaderColor(0.6f, 0.6f, 0.6f, 1f); + RenderSystem.blendColor(0.6f, 0.6f, 0.6f, 1f); RenderUtil.drawRectWithTexture(pose, game.xPosition + x * WIDTH, game.yPosition + y * HEIGHT + 2, layer.zLevel, this.x * 16, this.y * 16 + 4, WIDTH, 4, 16, 12); - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.blendColor(1f, 1f, 1f, 1f); } @Override diff --git a/common/src/main/java/com/ultreon/devices/object/tiles/TileFlower.java b/common/src/main/java/com/ultreon/devices/object/tiles/TileFlower.java index d5351b79b..1c7a9772e 100644 --- a/common/src/main/java/com/ultreon/devices/object/tiles/TileFlower.java +++ b/common/src/main/java/com/ultreon/devices/object/tiles/TileFlower.java @@ -1,6 +1,6 @@ package com.ultreon.devices.object.tiles; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.utils.RenderUtil; import com.ultreon.devices.object.Game; @@ -12,7 +12,7 @@ public TileFlower(int id, int x, int y) } @Override - public void render(PoseStack pose, Game game, int x, int y, Game.Layer layer) + public void render(MatrixStack pose, Game game, int x, int y, Game.Layer layer) { RenderUtil.drawRectWithTexture(pose, game.xPosition + x * WIDTH, game.yPosition + y * HEIGHT - 4, this.x * 16, this.y * 16, WIDTH, 8, 16, 16); } diff --git a/common/src/main/java/com/ultreon/devices/object/tiles/TileGrass.java b/common/src/main/java/com/ultreon/devices/object/tiles/TileGrass.java index 50024d2c4..6adaeaabb 100644 --- a/common/src/main/java/com/ultreon/devices/object/tiles/TileGrass.java +++ b/common/src/main/java/com/ultreon/devices/object/tiles/TileGrass.java @@ -1,7 +1,7 @@ package com.ultreon.devices.object.tiles; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.utils.RenderUtil; import com.ultreon.devices.object.Game; @@ -13,19 +13,19 @@ public TileGrass(int id, int x, int y) } @Override - public void render(PoseStack pose, Game game, int x, int y, Game.Layer layer) + public void render(MatrixStack pose, Game game, int x, int y, Game.Layer layer) { super.render(pose, game, x, y, layer); if(!game.isFullTile(layer, x, y + 1)) { - RenderSystem.setShaderColor(0.6f, 0.6f, 0.6f, 1f); + RenderSystem.blendColor(0.6f, 0.6f, 0.6f, 1f); RenderUtil.drawRectWithTexture(pose, game.xPosition + x * WIDTH, game.yPosition + y * HEIGHT + 6, dirt.x * 16, dirt.y * 16, WIDTH, HEIGHT, 16, 16); - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.blendColor(1f, 1f, 1f, 1f); } } @Override - public void renderForeground(PoseStack pose, Game game, int x, int y, Game.Layer layer) + public void renderForeground(MatrixStack pose, Game game, int x, int y, Game.Layer layer) { super.renderForeground(pose, game, x, y, layer); diff --git a/common/src/main/java/com/ultreon/devices/object/tiles/TileWheat.java b/common/src/main/java/com/ultreon/devices/object/tiles/TileWheat.java index dac5a12b6..49c689bac 100644 --- a/common/src/main/java/com/ultreon/devices/object/tiles/TileWheat.java +++ b/common/src/main/java/com/ultreon/devices/object/tiles/TileWheat.java @@ -1,7 +1,7 @@ package com.ultreon.devices.object.tiles; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.utils.RenderUtil; import com.ultreon.devices.object.Game; @@ -13,7 +13,7 @@ public TileWheat(int id, int x, int y) } @Override - public void render(PoseStack pose, Game game, int x, int y, Game.Layer layer) + public void render(MatrixStack pose, Game game, int x, int y, Game.Layer layer) { RenderUtil.drawRectWithTexture(pose, game.xPosition + x * Tile.WIDTH, game.yPosition + y * Tile.HEIGHT - 6, this.x * 16, this.y * 16, WIDTH, HEIGHT + 1, 16, 16); RenderUtil.drawRectWithTexture(pose, game.xPosition + x * Tile.WIDTH, game.yPosition + y * Tile.HEIGHT - 2, this.x * 16, this.y * 16, WIDTH, HEIGHT + 1, 16, 16); diff --git a/common/src/main/java/com/ultreon/devices/programs/BoatRacersApp.java b/common/src/main/java/com/ultreon/devices/programs/BoatRacersApp.java index c1c0b102d..5f2e4a36a 100644 --- a/common/src/main/java/com/ultreon/devices/programs/BoatRacersApp.java +++ b/common/src/main/java/com/ultreon/devices/programs/BoatRacersApp.java @@ -13,7 +13,7 @@ import com.ultreon.devices.object.Game; import com.ultreon.devices.object.TileGrid; import com.ultreon.devices.object.tiles.Tile; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.CompoundNBT; import javax.annotation.Nullable; @@ -35,7 +35,7 @@ public BoatRacersApp() { } @Override - public void init(@Nullable CompoundTag intent) { + public void init(@Nullable CompoundNBT intent) { layoutLevelEditor = new Layout(364, 178); try { @@ -108,13 +108,13 @@ public void onTick() { } @Override - public void load(CompoundTag tagCompound) { + public void load(CompoundNBT tagCompound) { // TODO Auto-generated method stub } @Override - public void save(CompoundTag tagCompound) { + public void save(CompoundNBT tagCompound) { // TODO Auto-generated method stub } diff --git a/common/src/main/java/com/ultreon/devices/programs/IconsApp.java b/common/src/main/java/com/ultreon/devices/programs/IconsApp.java index 0485297fd..5c7df7927 100644 --- a/common/src/main/java/com/ultreon/devices/programs/IconsApp.java +++ b/common/src/main/java/com/ultreon/devices/programs/IconsApp.java @@ -4,8 +4,8 @@ import com.ultreon.devices.api.app.component.Button; import com.ultreon.devices.api.app.component.ComboBox; import com.ultreon.devices.programs.system.layout.StandardLayout; -import net.minecraft.ChatFormatting; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.nbt.CompoundNBT; import javax.annotation.Nullable; @@ -25,8 +25,8 @@ public IconsApp() { } @Override - public void init(@Nullable CompoundTag intent) { - layoutMain = new StandardLayout(ChatFormatting.BOLD + "Icons", 330, 153, this, null); + public void init(@Nullable CompoundNBT intent) { + layoutMain = new StandardLayout(TextFormatting.BOLD + "Icons", 330, 153, this, null); layoutMain.setIcon(Icons.HOME); layoutContainer = new Layout(330, 153); @@ -94,12 +94,12 @@ public void onClose() { } @Override - public void load(CompoundTag tag) { + public void load(CompoundNBT tag) { } @Override - public void save(CompoundTag tag) { + public void save(CompoundNBT tag) { } diff --git a/common/src/main/java/com/ultreon/devices/programs/NoteStashApp.java b/common/src/main/java/com/ultreon/devices/programs/NoteStashApp.java index d3ecbb826..e3677a83f 100644 --- a/common/src/main/java/com/ultreon/devices/programs/NoteStashApp.java +++ b/common/src/main/java/com/ultreon/devices/programs/NoteStashApp.java @@ -7,8 +7,8 @@ import com.ultreon.devices.api.app.component.*; import com.ultreon.devices.api.io.File; import com.ultreon.devices.core.io.FileSystem; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.INBT; import org.slf4j.Marker; import org.slf4j.MarkerFactory; @@ -20,8 +20,8 @@ public class NoteStashApp extends Application { @SuppressWarnings("ConstantConditions") private static final Predicate PREDICATE_FILE_NOTE = file -> !file.isFolder() - && file.getData().contains("title", Tag.TAG_STRING) - && file.getData().contains("content", Tag.TAG_STRING); + && file.getData().contains("title", Constants.NBT.TAG_STRING) + && file.getData().contains("content", Constants.NBT.TAG_STRING); private static final Marker MARKER = MarkerFactory.getMarker("Note Stash App"); /* Main */ @@ -49,7 +49,7 @@ public NoteStashApp() { } @Override - public void init(@Nullable CompoundTag intent) { + public void init(@Nullable CompoundNBT intent) { /* Main */ layoutMain = new Layout(180, 80); @@ -136,7 +136,7 @@ public void init(@Nullable CompoundTag intent) { btnSave = new Button(124, 5, "Save"); btnSave.setSize(50, 20); btnSave.setClickListener((mouseX, mouseY, mouseButton) -> { - CompoundTag data = new CompoundTag(); + CompoundNBT data = new CompoundNBT(); data.putString("title", title.getText()); data.putString("content", textArea.getText()); @@ -181,11 +181,11 @@ public void init(@Nullable CompoundTag intent) { } @Override - public void load(CompoundTag tagCompound) { + public void load(CompoundNBT tagCompound) { } @Override - public void save(CompoundTag tagCompound) { + public void save(CompoundNBT tagCompound) { } @Override @@ -198,7 +198,7 @@ public void onClose() { public boolean handleFile(File file) { if (!PREDICATE_FILE_NOTE.test(file)) return false; - CompoundTag data = file.getData(); + CompoundNBT data = file.getData(); assert data != null; noteTitle.setText(data.getString("title")); noteContent.setText(data.getString("content")); diff --git a/common/src/main/java/com/ultreon/devices/programs/PixelPainterApp.java b/common/src/main/java/com/ultreon/devices/programs/PixelPainterApp.java index bc6e8d961..bb0a7bc4a 100644 --- a/common/src/main/java/com/ultreon/devices/programs/PixelPainterApp.java +++ b/common/src/main/java/com/ultreon/devices/programs/PixelPainterApp.java @@ -1,10 +1,10 @@ package com.ultreon.devices.programs; -import com.mojang.blaze3d.platform.NativeImage; -import com.mojang.blaze3d.platform.TextureUtil; +import net.minecraft.client.renderer.texture.NativeImage; +import net.minecraft.client.renderer.texture.TextureUtil; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Quaternion; +import com.mojang.blaze3d.matrix.MatrixStack; +import net.minecraft.util.math.vector.Quaternion; import com.ultreon.devices.Reference; import com.ultreon.devices.api.app.Component; import com.ultreon.devices.api.app.Dialog; @@ -24,11 +24,11 @@ import com.ultreon.devices.object.Picture; import com.ultreon.devices.programs.system.layout.StandardLayout; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiComponent; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.client.gui.IngameGui; +import net.minecraft.client.gui.AbstractGui; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.INBT; +import net.minecraft.util.ResourceLocation; import javax.annotation.Nullable; import java.awt.*; @@ -89,7 +89,7 @@ public PixelPainterApp() { @SuppressWarnings("StatementWithEmptyBody") @Override - public void init(@Nullable CompoundTag intent) { + public void init(@Nullable CompoundNBT intent) { /* Main Menu */ layoutMainMenu = new StandardLayout("Main Menu", 201, 125, this, null); layoutMainMenu.setIcon(Icons.HOME); @@ -97,7 +97,7 @@ public void init(@Nullable CompoundTag intent) { ItemList pictureList = new ItemList<>(5, 43, 80, 4); pictureList.setListItemRenderer(new ListItemRenderer<>(18) { @Override - public void render(PoseStack pose, Picture picture, GuiComponent gui, Minecraft mc, int x, int y, int width, int height, boolean selected) { + public void render(MatrixStack pose, Picture picture, AbstractGui gui, Minecraft mc, int x, int y, int width, int height, boolean selected) { RenderUtil.drawStringClipped(pose, "Henlo", x, y, 100, AUTHOR_TEXT.getRGB(), true); } }); @@ -186,8 +186,8 @@ public void render(PoseStack pose, Picture picture, GuiComponent gui, Minecraft listPictures = new ItemList<>(5, 5, 80, 5); listPictures.setListItemRenderer(new ListItemRenderer<>(20) { @Override - public void render(PoseStack pose, Picture picture, GuiComponent gui, Minecraft mc, int x, int y, int width, int height, boolean selected) { - Gui.fill(pose, x, y, x + width, y + height, selected ? ITEM_SELECTED.getRGB() : ITEM_BACKGROUND.getRGB()); + public void render(MatrixStack pose, Picture picture, AbstractGui gui, Minecraft mc, int x, int y, int width, int height, boolean selected) { + IngameGui.fill(pose, x, y, x + width, y + height, selected ? ITEM_SELECTED.getRGB() : ITEM_BACKGROUND.getRGB()); mc.font.draw(pose, picture.getName(), x + 2, y + 2, Color.WHITE.getRGB()); mc.font.draw(pose, picture.getAuthor(), x + 2, y + 11, AUTHOR_TEXT.getRGB()); } @@ -331,7 +331,7 @@ public void render(PoseStack pose, Picture picture, GuiComponent gui, Minecraft { canvas.picture.pixels = canvas.copyPixels(); - CompoundTag pictureTag = new CompoundTag(); + CompoundNBT pictureTag = new CompoundNBT(); canvas.picture.writeToNBT(pictureTag); if (canvas.isExistingImage()) { @@ -380,7 +380,7 @@ public void render(PoseStack pose, Picture picture, GuiComponent gui, Minecraft colorDisplay = new Component(158, 5) { @Override - public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + public void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { fill(pose, xPosition, yPosition, xPosition + 50, yPosition + 20, Color.DARK_GRAY.getRGB()); fill(pose, xPosition + 1, yPosition + 1, xPosition + 49, yPosition + 19, canvas.getCurrentColor()); } @@ -398,12 +398,12 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in } @Override - public void load(CompoundTag tagCompound) { + public void load(CompoundNBT tagCompound) { } @Override - public void save(CompoundTag tagCompound) { + public void save(CompoundNBT tagCompound) { } @@ -461,8 +461,8 @@ public boolean requiresColor() { } @Override - public CompoundTag toTag() { - CompoundTag tag = new CompoundTag(); + public CompoundNBT toTag() { + CompoundNBT tag = new CompoundNBT(); tag.putString("name", name); tag.putIntArray("pixels", pixels); tag.putInt("resolution", resolution); @@ -471,7 +471,7 @@ public CompoundTag toTag() { } @Override - public void fromTag(CompoundTag tag) { + public void fromTag(CompoundNBT tag) { name = tag.getString("name"); cut = tag.getBoolean("cut"); setPicture(tag.getIntArray("pixels")); @@ -488,8 +488,8 @@ public static class PictureRenderer implements IPrint.Renderer { @SuppressWarnings("resource") @Override - public boolean render(PoseStack pose, CompoundTag data) { - if (data.contains("pixels", Tag.TAG_INT_ARRAY) && data.contains("resolution", Tag.TAG_INT)) { + public boolean render(MatrixStack pose, CompoundNBT data) { + if (data.contains("pixels", Constants.NBT.TAG_INT_ARRAY) && data.contains("resolution", Constants.NBT.TAG_INT)) { int[] pixels = data.getIntArray("pixels"); int resolution = data.getInt("resolution"); boolean cut = data.getBoolean("cut"); @@ -504,7 +504,7 @@ public boolean render(PoseStack pose, CompoundTag data) { // This is for the paper background if (!cut) { - RenderSystem.setShaderTexture(0, TEXTURE); + mc.textureManager.bind(TEXTURE); RenderUtil.drawRectWithTexture(pose, -1, 0, 0, 0, 1, 1, resolution, resolution, resolution, resolution); } @@ -520,7 +520,7 @@ public boolean render(PoseStack pose, CompoundTag data) { int textureId = TextureUtil.generateTextureId(); TextureUtil.prepareImage(textureId, resolution, resolution); - RenderSystem.setShaderTexture(0, textureId); + mc.textureManager.bind(textureId); RenderUtil.drawRectWithTexture(pose, -1, 0, 0, 0, 1, 1, resolution, resolution, resolution, resolution); RenderSystem.deleteTexture(textureId); diff --git a/common/src/main/java/com/ultreon/devices/programs/TestApp.java b/common/src/main/java/com/ultreon/devices/programs/TestApp.java index 3b411bb4e..19e765115 100644 --- a/common/src/main/java/com/ultreon/devices/programs/TestApp.java +++ b/common/src/main/java/com/ultreon/devices/programs/TestApp.java @@ -4,7 +4,7 @@ import com.ultreon.devices.api.app.Dialog; import com.ultreon.devices.api.app.Icons; import com.ultreon.devices.api.app.component.Button; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.CompoundNBT; import javax.annotation.Nullable; @@ -13,7 +13,7 @@ */ public class TestApp extends Application { @Override - public void init(@Nullable CompoundTag intent) { + public void init(@Nullable CompoundNBT intent) { Button button = new Button(5, 5, Icons.PRINTER); button.setClickListener((mouseX, mouseY, mouseButton) -> { if (mouseButton == 0) { @@ -51,19 +51,19 @@ public void init(@Nullable CompoundTag intent) { Button button4 = new Button(105, 5, Icons.PRINTER); button4.setClickListener((mouseX, mouseY, mouseButton) -> { if (mouseButton == 0) { - openDialog(new Dialog.SaveFile(this, new CompoundTag())); + openDialog(new Dialog.SaveFile(this, new CompoundNBT())); } }); super.addComponent(button4); } @Override - public void load(CompoundTag tagCompound) { + public void load(CompoundNBT tagCompound) { } @Override - public void save(CompoundTag tagCompound) { + public void save(CompoundNBT tagCompound) { } } diff --git a/common/src/main/java/com/ultreon/devices/programs/auction/AuctionManager.java b/common/src/main/java/com/ultreon/devices/programs/auction/AuctionManager.java index 81007c6a5..8a2eee029 100644 --- a/common/src/main/java/com/ultreon/devices/programs/auction/AuctionManager.java +++ b/common/src/main/java/com/ultreon/devices/programs/auction/AuctionManager.java @@ -1,8 +1,8 @@ package com.ultreon.devices.programs.auction; import com.ultreon.devices.programs.auction.object.AuctionItem; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.ListNBT; import java.util.ArrayList; import java.util.List; @@ -61,22 +61,22 @@ public void tick() { } } - public void writeToNBT(CompoundTag tag) { - ListTag tagList = new ListTag(); + public void writeToNBT(CompoundNBT tag) { + ListNBT tagList = new ListNBT(); items.stream().filter(i -> i.isValid()).forEach(i -> { - CompoundTag itemTag = new CompoundTag(); + CompoundNBT itemTag = new CompoundNBT(); i.writeToNBT(itemTag); tagList.add(itemTag); }); tag.put("auctionItems", tagList); } - public void readFromNBT(CompoundTag tag) { + public void readFromNBT(CompoundNBT tag) { items.clear(); - ListTag tagList = (ListTag) tag.get("auctionItems"); + ListNBT tagList = (ListNBT) tag.get("auctionItems"); for (int i = 0; i < tagList.size(); i++) { - CompoundTag itemTag = tagList.getCompound(i); + CompoundNBT itemTag = tagList.getCompound(i); AuctionItem item = AuctionItem.readFromNBT(itemTag); items.add(item); } diff --git a/common/src/main/java/com/ultreon/devices/programs/auction/MineBayApp.java b/common/src/main/java/com/ultreon/devices/programs/auction/MineBayApp.java index 463d13f03..a95c8c0a0 100644 --- a/common/src/main/java/com/ultreon/devices/programs/auction/MineBayApp.java +++ b/common/src/main/java/com/ultreon/devices/programs/auction/MineBayApp.java @@ -1,7 +1,7 @@ package com.ultreon.devices.programs.auction; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.api.app.Application; import com.ultreon.devices.api.app.Dialog; import com.ultreon.devices.api.app.Layout; @@ -18,14 +18,14 @@ import com.ultreon.devices.programs.auction.task.TaskGetAuctions; import com.ultreon.devices.programs.system.layout.StandardLayout; import com.ultreon.devices.util.TimeUtil; -import net.minecraft.ChatFormatting; +import net.minecraft.util.text.TextFormatting; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiComponent; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; +import net.minecraft.client.gui.IngameGui; +import net.minecraft.client.gui.AbstractGui; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.ResourceLocation; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import javax.annotation.Nullable; import java.awt.*; @@ -84,17 +84,17 @@ public void onTick() { } @Override - public void init(@Nullable CompoundTag intent) { - var layoutMain = new StandardLayout(ChatFormatting.BOLD + "Icons", 330, 153, this, null); + public void init(@Nullable CompoundNBT intent) { + var layoutMain = new StandardLayout(TextFormatting.BOLD + "Icons", 330, 153, this, null); setCurrentLayout(layoutMain); getCurrentLayout().setBackground((pose, gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> { - Gui.fill(pose, x, y, x + width, y + 25, Color.GRAY.getRGB()); - Gui.fill(pose, x, y + 24, x + width, y + 25, Color.DARK_GRAY.getRGB()); - Gui.fill(pose, x, y + 25, x + 95, y + height, Color.LIGHT_GRAY.getRGB()); - Gui.fill(pose, x + 94, y + 25, x + 95, y + height, Color.GRAY.getRGB()); + IngameGui.fill(pose, x, y, x + width, y + 25, Color.GRAY.getRGB()); + IngameGui.fill(pose, x, y + 24, x + width, y + 25, Color.DARK_GRAY.getRGB()); + IngameGui.fill(pose, x, y + 25, x + 95, y + height, Color.LIGHT_GRAY.getRGB()); + IngameGui.fill(pose, x + 94, y + 25, x + 95, y + height, Color.GRAY.getRGB()); - RenderSystem.setShaderTexture(0, MINEBAY_ASSETS); - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + mc.textureManager.bind(MINEBAY_ASSETS); + RenderSystem.blendColor(1f, 1f, 1f, 1f); RenderUtil.drawRectWithTexture(pose, x + 5, y + 6, 0, 0, 61, 11, 61, 12); }); @@ -145,11 +145,11 @@ public void init(@Nullable CompoundTag intent) { items = new ItemList<>(100, 40, 180, 4); items.setListItemRenderer(new ListItemRenderer<>(20) { @Override - public void render(PoseStack pose, AuctionItem e, GuiComponent gui, Minecraft mc, int x, int y, int width, int height, boolean selected) { + public void render(MatrixStack pose, AuctionItem e, AbstractGui gui, Minecraft mc, int x, int y, int width, int height, boolean selected) { if (selected) { - Gui.fill(pose, x, y, x + width, y + height, Color.DARK_GRAY.getRGB()); + IngameGui.fill(pose, x, y, x + width, y + height, Color.DARK_GRAY.getRGB()); } else { - Gui.fill(pose, x, y, x + width, y + height, Color.GRAY.getRGB()); + IngameGui.fill(pose, x, y, x + width, y + height, Color.GRAY.getRGB()); } RenderUtil.renderItem(x + 2, y + 2, e.getStack(), true); @@ -202,8 +202,8 @@ public void render(PoseStack pose, AuctionItem e, GuiComponent gui, Minecraft mc layoutSelectItem = new Layout(172, 87); layoutSelectItem.setTitle("Add Item"); layoutSelectItem.setBackground((pose, gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> { - Gui.fill(pose, x, y, x + width, y + 22, Color.LIGHT_GRAY.getRGB()); - Gui.fill(pose, x, y + 22, x + width, y + 23, Color.DARK_GRAY.getRGB()); + IngameGui.fill(pose, x, y, x + width, y + 22, Color.LIGHT_GRAY.getRGB()); + IngameGui.fill(pose, x, y + 22, x + width, y + 23, Color.DARK_GRAY.getRGB()); mc.font.drawShadow(pose, "Select an Item...", x + 5, y + 7, Color.WHITE.getRGB()); }); @@ -246,18 +246,18 @@ public void render(PoseStack pose, AuctionItem e, GuiComponent gui, Minecraft mc layoutAmountAndPrice = new Layout(172, 87); layoutAmountAndPrice.setTitle("Add Item"); layoutAmountAndPrice.setBackground((pose, gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> { - Gui.fill(pose, x, y, x + width, y + 22, Color.LIGHT_GRAY.getRGB()); - Gui.fill(pose, x, y + 22, x + width, y + 23, Color.DARK_GRAY.getRGB()); + IngameGui.fill(pose, x, y, x + width, y + 22, Color.LIGHT_GRAY.getRGB()); + IngameGui.fill(pose, x, y + 22, x + width, y + 23, Color.DARK_GRAY.getRGB()); mc.font.drawShadow(pose, "Set amount and price...", x + 5, y + 7, Color.WHITE.getRGB()); int offsetX = 14; int offsetY = 40; - Gui.fill(pose, x + offsetX, y + offsetY, x + offsetX + 38, y + offsetY + 38, Color.BLACK.getRGB()); - Gui.fill(pose, x + offsetX + 1, y + offsetY + 1, x + offsetX + 37, y + offsetY + 37, Color.DARK_GRAY.getRGB()); + IngameGui.fill(pose, x + offsetX, y + offsetY, x + offsetX + 38, y + offsetY + 38, Color.BLACK.getRGB()); + IngameGui.fill(pose, x + offsetX + 1, y + offsetY + 1, x + offsetX + 37, y + offsetY + 37, Color.DARK_GRAY.getRGB()); offsetX = 90; - Gui.fill(pose, x + offsetX, y + offsetY, x + offsetX + 38, y + offsetY + 38, Color.BLACK.getRGB()); - Gui.fill(pose, x + offsetX + 1, y + offsetY + 1, x + offsetX + 37, y + offsetY + 37, Color.DARK_GRAY.getRGB()); + IngameGui.fill(pose, x + offsetX, y + offsetY, x + offsetX + 38, y + offsetY + 38, Color.BLACK.getRGB()); + IngameGui.fill(pose, x + offsetX + 1, y + offsetY + 1, x + offsetX + 37, y + offsetY + 37, Color.DARK_GRAY.getRGB()); if (inventory.getSelectedSlotIndex() != -1) { assert mc.player != null; @@ -313,8 +313,8 @@ public void render(PoseStack pose, AuctionItem e, GuiComponent gui, Minecraft mc layoutDuration = new Layout(172, 87); layoutDuration.setTitle("Add Item"); layoutDuration.setBackground((pose, gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> { - Gui.fill(pose, x, y, x + width, y + 22, Color.LIGHT_GRAY.getRGB()); - Gui.fill(pose, x, y + 22, x + width, y + 23, Color.DARK_GRAY.getRGB()); + IngameGui.fill(pose, x, y, x + width, y + 22, Color.LIGHT_GRAY.getRGB()); + IngameGui.fill(pose, x, y + 22, x + width, y + 23, Color.DARK_GRAY.getRGB()); mc.font.drawShadow(pose, "Set duration...", x + 5, y + 7, Color.WHITE.getRGB()); }); @@ -399,12 +399,12 @@ public void render(PoseStack pose, AuctionItem e, GuiComponent gui, Minecraft mc } @Override - public void load(CompoundTag tagCompound) { + public void load(CompoundNBT tagCompound) { } @Override - public void save(CompoundTag tagCompound) { + public void save(CompoundNBT tagCompound) { } } diff --git a/common/src/main/java/com/ultreon/devices/programs/auction/object/AuctionItem.java b/common/src/main/java/com/ultreon/devices/programs/auction/object/AuctionItem.java index 6aa86e8df..c94e10dd2 100644 --- a/common/src/main/java/com/ultreon/devices/programs/auction/object/AuctionItem.java +++ b/common/src/main/java/com/ultreon/devices/programs/auction/object/AuctionItem.java @@ -1,7 +1,7 @@ package com.ultreon.devices.programs.auction.object; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.item.ItemStack; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.item.ItemStack; import java.util.UUID; @@ -28,9 +28,9 @@ public AuctionItem(UUID id, ItemStack stack, int price, long timeLeft, UUID sell this.sellerId = sellerId; } - public static AuctionItem readFromNBT(CompoundTag tag) { + public static AuctionItem readFromNBT(CompoundNBT tag) { UUID id = UUID.fromString(tag.getString("id")); - CompoundTag item = tag.getCompound("item"); + CompoundNBT item = tag.getCompound("item"); ItemStack stack = ItemStack.of(item); int price = tag.getInt("price"); long timeLeft = tag.getLong("time"); @@ -72,9 +72,9 @@ public void setSold() { this.timeLeft = 0; } - public void writeToNBT(CompoundTag tag) { + public void writeToNBT(CompoundNBT tag) { tag.putString("id", id.toString()); - CompoundTag item = new CompoundTag(); + CompoundNBT item = new CompoundNBT(); item = stack.save(item); tag.put("item", item); tag.putInt("price", price); diff --git a/common/src/main/java/com/ultreon/devices/programs/auction/task/TaskAddAuction.java b/common/src/main/java/com/ultreon/devices/programs/auction/task/TaskAddAuction.java index 80e6748eb..68d01d80c 100644 --- a/common/src/main/java/com/ultreon/devices/programs/auction/task/TaskAddAuction.java +++ b/common/src/main/java/com/ultreon/devices/programs/auction/task/TaskAddAuction.java @@ -3,10 +3,10 @@ import com.ultreon.devices.api.task.Task; import com.ultreon.devices.programs.auction.AuctionManager; import com.ultreon.devices.programs.auction.object.AuctionItem; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public class TaskAddAuction extends Task { private int slot; @@ -29,7 +29,7 @@ public TaskAddAuction(int slot, int amount, int price, int duration) { } @Override - public void prepareRequest(CompoundTag nbt) { + public void prepareRequest(CompoundNBT nbt) { nbt.putInt("slot", slot); nbt.putInt("amount", amount); nbt.putInt("price", price); @@ -37,7 +37,7 @@ public void prepareRequest(CompoundTag nbt) { } @Override - public void processRequest(CompoundTag nbt, Level level, Player player) { + public void processRequest(CompoundNBT nbt, World level, PlayerEntity player) { int slot = nbt.getInt("slot"); int amount = nbt.getInt("amount"); int price = nbt.getInt("price"); @@ -61,14 +61,14 @@ public void processRequest(CompoundTag nbt, Level level, Player player) { } @Override - public void prepareResponse(CompoundTag nbt) { + public void prepareResponse(CompoundNBT nbt) { if (isSucessful()) { item.writeToNBT(nbt); } } @Override - public void processResponse(CompoundTag nbt) { + public void processResponse(CompoundNBT nbt) { if (isSucessful()) { AuctionManager.INSTANCE.addItem(AuctionItem.readFromNBT(nbt)); } diff --git a/common/src/main/java/com/ultreon/devices/programs/auction/task/TaskBuyItem.java b/common/src/main/java/com/ultreon/devices/programs/auction/task/TaskBuyItem.java index 97da8bfde..f47ff4915 100644 --- a/common/src/main/java/com/ultreon/devices/programs/auction/task/TaskBuyItem.java +++ b/common/src/main/java/com/ultreon/devices/programs/auction/task/TaskBuyItem.java @@ -5,10 +5,10 @@ import com.ultreon.devices.programs.auction.AuctionManager; import com.ultreon.devices.programs.auction.object.AuctionItem; import com.ultreon.devices.programs.system.object.Account; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.entity.item.ItemEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; import java.util.UUID; @@ -25,12 +25,12 @@ public TaskBuyItem(UUID id) { } @Override - public void prepareRequest(CompoundTag nbt) { + public void prepareRequest(CompoundNBT nbt) { nbt.putString("id", id.toString()); } @Override - public void processRequest(CompoundTag nbt, Level world, Player player) { + public void processRequest(CompoundNBT nbt, World world, PlayerEntity player) { this.id = UUID.fromString(nbt.getString("id")); AuctionItem item = AuctionManager.INSTANCE.getItem(id); if (item != null && item.isValid()) { @@ -46,10 +46,10 @@ public void processRequest(CompoundTag nbt, Level world, Player player) { } @Override - public void prepareResponse(CompoundTag nbt) { + public void prepareResponse(CompoundNBT nbt) { } @Override - public void processResponse(CompoundTag nbt) { + public void processResponse(CompoundNBT nbt) { } } diff --git a/common/src/main/java/com/ultreon/devices/programs/auction/task/TaskGetAuctions.java b/common/src/main/java/com/ultreon/devices/programs/auction/task/TaskGetAuctions.java index 842c43139..f2bf20e06 100644 --- a/common/src/main/java/com/ultreon/devices/programs/auction/task/TaskGetAuctions.java +++ b/common/src/main/java/com/ultreon/devices/programs/auction/task/TaskGetAuctions.java @@ -3,10 +3,10 @@ import com.ultreon.devices.api.task.Task; import com.ultreon.devices.programs.auction.AuctionManager; import com.ultreon.devices.programs.auction.object.AuctionItem; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.ListNBT; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; import java.util.List; import java.util.UUID; @@ -24,26 +24,26 @@ public TaskGetAuctions(UUID seller) { } @Override - public void prepareRequest(CompoundTag nbt) { + public void prepareRequest(CompoundNBT nbt) { if (seller != null) { nbt.putString("seller", seller.toString()); } } @Override - public void processRequest(CompoundTag nbt, Level world, Player player) { + public void processRequest(CompoundNBT nbt, World world, PlayerEntity player) { if (nbt.contains("seller")) { seller = UUID.fromString(nbt.getString("seller")); } } @Override - public void prepareResponse(CompoundTag nbt) { + public void prepareResponse(CompoundNBT nbt) { if (seller != null) { List items = AuctionManager.INSTANCE.getItemsForSeller(seller); - ListTag tagList = new ListTag(); + ListNBT tagList = new ListNBT(); items.forEach(i -> { - CompoundTag itemTag = new CompoundTag(); + CompoundNBT itemTag = new CompoundNBT(); i.writeToNBT(itemTag); tagList.add(itemTag); }); @@ -55,7 +55,7 @@ public void prepareResponse(CompoundTag nbt) { } @Override - public void processResponse(CompoundTag nbt) { + public void processResponse(CompoundNBT nbt) { AuctionManager.INSTANCE.readFromNBT(nbt); } } diff --git a/common/src/main/java/com/ultreon/devices/programs/debug/TextAreaApp.java b/common/src/main/java/com/ultreon/devices/programs/debug/TextAreaApp.java index c5f721ad8..e2940ff21 100644 --- a/common/src/main/java/com/ultreon/devices/programs/debug/TextAreaApp.java +++ b/common/src/main/java/com/ultreon/devices/programs/debug/TextAreaApp.java @@ -6,8 +6,8 @@ import com.ultreon.devices.api.app.component.ButtonToggle; import com.ultreon.devices.api.app.component.TextArea; import com.ultreon.devices.api.app.interfaces.IHighlight; -import net.minecraft.ChatFormatting; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.nbt.CompoundNBT; import javax.annotation.Nullable; @@ -16,9 +16,9 @@ */ public class TextAreaApp extends Application { public static final IHighlight JAVA_HIGHLIGHT = text -> { - if (text.startsWith("@")) return asArray(ChatFormatting.YELLOW); + if (text.startsWith("@")) return asArray(TextFormatting.YELLOW); - if (text.startsWith("\"") && text.endsWith("\"")) return asArray(ChatFormatting.AQUA); + if (text.startsWith("\"") && text.endsWith("\"")) return asArray(TextFormatting.AQUA); return switch (text) { case "abstract", "continue", "for", "new", "switch", "assert", "default", "goto", "package", "synchronized", @@ -26,8 +26,8 @@ public class TextAreaApp extends Application { "byte", "else", "import", "public", "throws", "case", "enum", "instanceof", "return", "transient", "catch", "extends", "int", "short", "try", "char", "final", "interface", "static", "void", "class", "finally", "long", "strictfp", "volatile", "const", "float", "native", "super", "while", "null", - "record", "sealed" -> asArray(ChatFormatting.BLUE); - default -> asArray(ChatFormatting.WHITE); + "record", "sealed" -> asArray(TextFormatting.BLUE); + default -> asArray(TextFormatting.WHITE); }; }; @@ -37,7 +37,7 @@ private static T[] asArray(T... t) { } @Override - public void init(@Nullable CompoundTag intent) { + public void init(@Nullable CompoundNBT intent) { Layout layout = new Layout(250, 150); TextArea textArea = new TextArea(5, 25, 240, 120); @@ -79,12 +79,12 @@ public void init(@Nullable CompoundTag intent) { } @Override - public void load(CompoundTag tagCompound) { + public void load(CompoundNBT tagCompound) { } @Override - public void save(CompoundTag tagCompound) { + public void save(CompoundNBT tagCompound) { } } diff --git a/common/src/main/java/com/ultreon/devices/programs/email/EmailApp.java b/common/src/main/java/com/ultreon/devices/programs/email/EmailApp.java index a757a8a1b..00792293d 100644 --- a/common/src/main/java/com/ultreon/devices/programs/email/EmailApp.java +++ b/common/src/main/java/com/ultreon/devices/programs/email/EmailApp.java @@ -1,7 +1,7 @@ package com.ultreon.devices.programs.email; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.Resources; import com.ultreon.devices.api.ApplicationManager; import com.ultreon.devices.api.app.Component; @@ -22,14 +22,14 @@ import com.ultreon.devices.programs.email.object.Contact; import com.ultreon.devices.programs.email.object.Email; import com.ultreon.devices.programs.email.task.*; -import net.minecraft.ChatFormatting; +import net.minecraft.util.text.TextFormatting; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiComponent; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.network.chat.FormattedText; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.client.gui.IngameGui; +import net.minecraft.client.gui.AbstractGui; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.ListNBT; +import net.minecraft.util.text.ITextProperties; +import net.minecraft.util.ResourceLocation; import javax.annotation.Nullable; import java.awt.*; @@ -124,7 +124,7 @@ public class EmailApp extends Application { private List contacts; // TODO unused @Override - public void init(@Nullable CompoundTag intent) { + public void init(@Nullable CompoundNBT intent) { /* Loading Layout */ layoutInit = new Layout(40, 40); @@ -167,7 +167,7 @@ public void init(@Nullable CompoundTag intent) { image.setAlpha(0.85f); layoutRegisterAccount.addComponent(image); - labelEmail = new Label(ChatFormatting.BOLD + "Choose your email", layoutRegisterAccount.width / 2, 30); + labelEmail = new Label(TextFormatting.BOLD + "Choose your email", layoutRegisterAccount.width / 2, 30); labelEmail.setAlignment(Component.ALIGN_CENTER); layoutRegisterAccount.addComponent(labelEmail); @@ -211,40 +211,40 @@ public void init(@Nullable CompoundTag intent) { TaskManager.sendTask(taskUpdateInbox); }); layoutInbox.setBackground((pose, gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> { - RenderSystem.setShaderTexture(0, ENDER_MAIL_BACKGROUND); + mc.textureManager.bind(ENDER_MAIL_BACKGROUND); RenderUtil.drawRectWithTexture(pose, x, y, 0, 0, width, height, 640, 360, 640, 360); Color temp = new Color(Laptop.getSystem().getSettings().getColorScheme().getBackgroundColor()); Color color = new Color(temp.getRed(), temp.getGreen(), temp.getBlue(), 150); - Gui.fill(pose, x, y, x + 125, y + height, color.getRGB()); - Gui.fill(pose, x + 125, y, x + 126, y + height, color.darker().getRGB()); + IngameGui.fill(pose, x, y, x + 125, y + height, color.getRGB()); + IngameGui.fill(pose, x + 125, y, x + 126, y + height, color.darker().getRGB()); Email e = listEmails.getSelectedItem(); if (e != null) { - Gui.fill(pose, x + 130, y + 5, x + width - 5, y + 34, color.getRGB()); - Gui.fill(pose, x + 130, y + 34, x + width - 5, y + 35, color.darker().getRGB()); - Gui.fill(pose, x + 130, y + 35, x + width - 5, y + height - 5, new Color(1f, 1f, 1f, 0.25f).getRGB()); + IngameGui.fill(pose, x + 130, y + 5, x + width - 5, y + 34, color.getRGB()); + IngameGui.fill(pose, x + 130, y + 34, x + width - 5, y + 35, color.darker().getRGB()); + IngameGui.fill(pose, x + 130, y + 35, x + width - 5, y + height - 5, new Color(1f, 1f, 1f, 0.25f).getRGB()); RenderUtil.drawStringClipped(pose, e.getSubject(), x + 135, y + 10, 120, Color.WHITE.getRGB(), true); RenderUtil.drawStringClipped(pose, e.getAuthor() + "@endermail.official", x + 135, y + 22, 120, Color.LIGHT_GRAY.getRGB(), false); - Laptop.getFont().drawWordWrap(FormattedText.of(e.getMessage()), x + 135, y + 40, 115, Color.WHITE.getRGB()); + Laptop.getFont().drawWordWrap(ITextProperties.of(e.getMessage()), x + 135, y + 40, 115, Color.WHITE.getRGB()); } }); listEmails = new ItemList<>(5, 25, 116, 4); listEmails.setListItemRenderer(new ListItemRenderer<>(28) { @Override - public void render(PoseStack pose, Email e, GuiComponent gui, Minecraft mc, int x, int y, int width, int height, boolean selected) { - Gui.fill(pose, x, y, x + width, y + height, selected ? Color.DARK_GRAY.getRGB() : Color.GRAY.getRGB()); + public void render(MatrixStack pose, Email e, AbstractGui gui, Minecraft mc, int x, int y, int width, int height, boolean selected) { + IngameGui.fill(pose, x, y, x + width, y + height, selected ? Color.DARK_GRAY.getRGB() : Color.GRAY.getRGB()); if (!e.isRead()) { - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.blendColor(1f, 1f, 1f, 1f); RenderUtil.drawApplicationIcon(pose, info, x + width - 16, y + 2); } if (e.getAttachment() != null) { - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.blendColor(1f, 1f, 1f, 1f); int posX = x + (!e.isRead() ? -12 : 0) + width; - RenderSystem.setShaderTexture(0, ENDER_MAIL_ICONS); + mc.textureManager.bind(ENDER_MAIL_ICONS); RenderUtil.drawRectWithTexture(pose, posX, y + 16, 20, 10, 7, 10, 13, 20); } RenderUtil.drawStringClipped(pose, e.getSubject(), x + 5, y + 5, width - 20, Color.WHITE.getRGB(), false); @@ -423,13 +423,13 @@ public void render(PoseStack pose, Email e, GuiComponent gui, Minecraft mc, int layoutViewEmail = new Layout(240, 156); layoutViewEmail.setBackground((pose, gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> { - Gui.fill(pose, x, y + 22, x + layoutViewEmail.width, y + 50, Color.GRAY.getRGB()); - Gui.fill(pose, x, y + 22, x + layoutViewEmail.width, y + 23, Color.DARK_GRAY.getRGB()); - Gui.fill(pose, x, y + 49, x + layoutViewEmail.width, y + 50, Color.DARK_GRAY.getRGB()); - Gui.fill(pose, x, y + 50, x + layoutViewEmail.width, y + 156, COLOR_EMAIL_CONTENT_BACKGROUND.getRGB()); + IngameGui.fill(pose, x, y + 22, x + layoutViewEmail.width, y + 50, Color.GRAY.getRGB()); + IngameGui.fill(pose, x, y + 22, x + layoutViewEmail.width, y + 23, Color.DARK_GRAY.getRGB()); + IngameGui.fill(pose, x, y + 49, x + layoutViewEmail.width, y + 50, Color.DARK_GRAY.getRGB()); + IngameGui.fill(pose, x, y + 50, x + layoutViewEmail.width, y + 156, COLOR_EMAIL_CONTENT_BACKGROUND.getRGB()); if (attachedFile != null) { - RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.blendColor(1f, 1f, 1f, 1f); AppInfo info = ApplicationManager.getApplication(Objects.requireNonNull(attachedFile.getOpeningApp(), "Attached file has no opening app")); RenderUtil.drawApplicationIcon(pose, info, x + 204, y + 4); } @@ -506,25 +506,25 @@ private void resetAttachedFile() { } @Override - public void load(CompoundTag tagCompound) { + public void load(CompoundNBT tagCompound) { } @Override - public void save(CompoundTag tagCompound) { + public void save(CompoundNBT tagCompound) { // Save emails - ListTag emailsTag = new ListTag(); + ListNBT emailsTag = new ListNBT(); for (Email email : listEmails) { - CompoundTag emailTag = new CompoundTag(); + CompoundNBT emailTag = new CompoundNBT(); email.save(emailTag); emailsTag.add(emailTag); } tagCompound.put("emails", emailsTag); // Save contacts - ListTag contactsTag = new ListTag(); + ListNBT contactsTag = new ListNBT(); for (Contact contact : listContacts) { - CompoundTag contactTag = new CompoundTag(); + CompoundNBT contactTag = new CompoundNBT(); contact.save(contactTag); contactsTag.add(contactTag); } diff --git a/common/src/main/java/com/ultreon/devices/programs/email/EmailManager.java b/common/src/main/java/com/ultreon/devices/programs/email/EmailManager.java index a16a06ac3..40533ea3b 100644 --- a/common/src/main/java/com/ultreon/devices/programs/email/EmailManager.java +++ b/common/src/main/java/com/ultreon/devices/programs/email/EmailManager.java @@ -6,13 +6,13 @@ import com.ultreon.devices.api.app.Icons; import com.ultreon.devices.api.app.Notification; import com.ultreon.devices.programs.email.object.Email; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.ListNBT; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.player.Player; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.entity.player.PlayerEntity; import java.util.*; @@ -25,7 +25,7 @@ public class EmailManager implements WorldSavedData { public static final EmailManager INSTANCE = new EmailManager(); private final HashBiMap uuidToName = HashBiMap.create(); private final Map> nameToInbox = new HashMap<>(); - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) private List inbox; public boolean addEmailToInbox(Email email, String to) { @@ -37,7 +37,7 @@ public boolean addEmailToInbox(Email email, String to) { return false; } - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) public List getInbox() { if (inbox == null) { inbox = new ArrayList<>(); @@ -45,14 +45,14 @@ public List getInbox() { return inbox; } - public List getEmailsForAccount(Player player) { + public List getEmailsForAccount(PlayerEntity player) { if (uuidToName.containsKey(player.getUUID())) { return nameToInbox.get(uuidToName.get(player.getUUID())); } return new ArrayList(); } - public boolean addAccount(Player player, String name) { + public boolean addAccount(PlayerEntity player, String name) { if (!uuidToName.containsKey(player.getUUID())) { if (!uuidToName.containsValue(name)) { uuidToName.put(player.getUUID(), name); @@ -67,22 +67,22 @@ public boolean hasAccount(UUID uuid) { return uuidToName.containsKey(uuid); } - public String getName(Player player) { + public String getName(PlayerEntity player) { return uuidToName.get(player.getUUID()); } - public void load(CompoundTag nbt) { + public void load(CompoundNBT nbt) { nameToInbox.clear(); - ListTag inboxes = (ListTag) nbt.get("Inboxes"); + ListNBT inboxes = (ListNBT) nbt.get("Inboxes"); for (int i = 0; i < inboxes.size(); i++) { - CompoundTag inbox = inboxes.getCompound(i); + CompoundNBT inbox = inboxes.getCompound(i); String name = inbox.getString("Name"); List emails = new ArrayList(); - ListTag emailTagList = (ListTag) inbox.get("Emails"); + ListNBT emailTagList = (ListNBT) inbox.get("Emails"); for (int j = 0; j < emailTagList.size(); j++) { - CompoundTag emailTag = emailTagList.getCompound(j); + CompoundNBT emailTag = emailTagList.getCompound(j); Email email = Email.readFromNBT(emailTag); emails.add(email); } @@ -91,25 +91,25 @@ public void load(CompoundTag nbt) { uuidToName.clear(); - ListTag accounts = (ListTag) nbt.get("Accounts"); + ListNBT accounts = (ListNBT) nbt.get("Accounts"); for (int i = 0; i < accounts.size(); i++) { - CompoundTag account = accounts.getCompound(i); + CompoundNBT account = accounts.getCompound(i); UUID uuid = UUID.fromString(account.getString("UUID")); String name = account.getString("Name"); uuidToName.put(uuid, name); } } - public void save(CompoundTag nbt) { - ListTag inboxes = new ListTag(); + public void save(CompoundNBT nbt) { + ListNBT inboxes = new ListNBT(); for (String key : nameToInbox.keySet()) { - CompoundTag inbox = new CompoundTag(); + CompoundNBT inbox = new CompoundNBT(); inbox.putString("Name", key); - ListTag emailTagList = new ListTag(); + ListNBT emailTagList = new ListNBT(); List emails = nameToInbox.get(key); for (Email email : emails) { - CompoundTag emailTag = new CompoundTag(); + CompoundNBT emailTag = new CompoundNBT(); email.save(emailTag); emailTagList.add(emailTag); } @@ -118,9 +118,9 @@ public void save(CompoundTag nbt) { } nbt.put("Inboxes", inboxes); - ListTag accounts = new ListTag(); + ListNBT accounts = new ListNBT(); for (UUID key : uuidToName.keySet()) { - CompoundTag account = new CompoundTag(); + CompoundNBT account = new CompoundNBT(); account.putString("UUID", key.toString()); account.putString("Name", Objects.requireNonNull(uuidToName.get(key))); accounts.add(account); @@ -138,7 +138,7 @@ private void sendNotification(String name, Email email) { MinecraftServer server = Devices.getServer(); UUID id = uuidToName.inverse().get(name); if (id != null) { - ServerPlayer player = server.getPlayerList().getPlayer(id); + ServerPlayerEntity player = server.getPlayerList().getPlayer(id); if (player != null) { Notification notification = new Notification(Icons.MAIL, "New Email!", "from " + email.getAuthor()); notification.pushTo(player); diff --git a/common/src/main/java/com/ultreon/devices/programs/email/object/Contact.java b/common/src/main/java/com/ultreon/devices/programs/email/object/Contact.java index 15eea7b64..700f0db92 100644 --- a/common/src/main/java/com/ultreon/devices/programs/email/object/Contact.java +++ b/common/src/main/java/com/ultreon/devices/programs/email/object/Contact.java @@ -1,6 +1,6 @@ package com.ultreon.devices.programs.email.object; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.CompoundNBT; /** * @author MrCrayfish @@ -27,7 +27,7 @@ public String toString() { return nickname; } - public void save(CompoundTag contactTag) { + public void save(CompoundNBT contactTag) { contactTag.putString("nickname", nickname); contactTag.putString("email", email); } diff --git a/common/src/main/java/com/ultreon/devices/programs/email/object/Email.java b/common/src/main/java/com/ultreon/devices/programs/email/object/Email.java index 1621f84f1..29314cd2f 100644 --- a/common/src/main/java/com/ultreon/devices/programs/email/object/Email.java +++ b/common/src/main/java/com/ultreon/devices/programs/email/object/Email.java @@ -1,8 +1,8 @@ package com.ultreon.devices.programs.email.object; import com.ultreon.devices.api.io.File; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.INBT; import javax.annotation.Nullable; @@ -28,10 +28,10 @@ public Email(String subject, String author, String message, @Nullable File attac this.author = author; } - public static Email readFromNBT(CompoundTag nbt) { + public static Email readFromNBT(CompoundNBT nbt) { File attachment = null; - if (nbt.contains("attachment", Tag.TAG_COMPOUND)) { - CompoundTag fileTag = nbt.getCompound("attachment"); + if (nbt.contains("attachment", Constants.NBT.TAG_COMPOUND)) { + CompoundNBT fileTag = nbt.getCompound("attachment"); attachment = File.fromTag(fileTag.getString("file_name"), fileTag.getCompound("data")); } Email email = new Email(nbt.getString("subject"), nbt.getString("author"), nbt.getString("message"), attachment); @@ -67,14 +67,14 @@ public void setRead(boolean read) { this.read = read; } - public void save(CompoundTag nbt) { + public void save(CompoundNBT nbt) { nbt.putString("subject", this.subject); if (author != null) nbt.putString("author", this.author); nbt.putString("message", this.message); nbt.putBoolean("read", this.read); if (attachment != null) { - CompoundTag fileTag = new CompoundTag(); + CompoundNBT fileTag = new CompoundNBT(); fileTag.putString("file_name", attachment.getName()); fileTag.put("data", attachment.toTag()); nbt.put("attachment", fileTag); diff --git a/common/src/main/java/com/ultreon/devices/programs/email/task/TaskCheckEmailAccount.java b/common/src/main/java/com/ultreon/devices/programs/email/task/TaskCheckEmailAccount.java index 97b4499ad..1f7693024 100644 --- a/common/src/main/java/com/ultreon/devices/programs/email/task/TaskCheckEmailAccount.java +++ b/common/src/main/java/com/ultreon/devices/programs/email/task/TaskCheckEmailAccount.java @@ -2,9 +2,9 @@ import com.ultreon.devices.api.task.Task; import com.ultreon.devices.programs.email.EmailManager; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; public class TaskCheckEmailAccount extends Task { private boolean hasAccount = false; @@ -15,12 +15,12 @@ public TaskCheckEmailAccount() { } @Override - public void prepareRequest(CompoundTag tag) { + public void prepareRequest(CompoundNBT tag) { } @Override - public void processRequest(CompoundTag tag, Level level, Player player) { + public void processRequest(CompoundNBT tag, World level, PlayerEntity player) { this.hasAccount = EmailManager.INSTANCE.hasAccount(player.getUUID()); if (this.hasAccount) { this.name = EmailManager.INSTANCE.getName(player); @@ -29,12 +29,12 @@ public void processRequest(CompoundTag tag, Level level, Player player) { } @Override - public void prepareResponse(CompoundTag tag) { + public void prepareResponse(CompoundNBT tag) { if (this.isSucessful()) tag.putString("Name", this.name); } @Override - public void processResponse(CompoundTag tag) { + public void processResponse(CompoundNBT tag) { } diff --git a/common/src/main/java/com/ultreon/devices/programs/email/task/TaskDeleteEmail.java b/common/src/main/java/com/ultreon/devices/programs/email/task/TaskDeleteEmail.java index 9702f271e..0caf58afa 100644 --- a/common/src/main/java/com/ultreon/devices/programs/email/task/TaskDeleteEmail.java +++ b/common/src/main/java/com/ultreon/devices/programs/email/task/TaskDeleteEmail.java @@ -3,9 +3,9 @@ import com.ultreon.devices.api.task.Task; import com.ultreon.devices.programs.email.EmailManager; import com.ultreon.devices.programs.email.object.Email; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; import java.util.List; @@ -23,12 +23,12 @@ public TaskDeleteEmail(int index) { } @Override - public void prepareRequest(CompoundTag nbt) { + public void prepareRequest(CompoundNBT nbt) { nbt.putInt("Index", this.index); } @Override - public void processRequest(CompoundTag nbt, Level level, Player player) { + public void processRequest(CompoundNBT nbt, World level, PlayerEntity player) { List emails = EmailManager.INSTANCE.getEmailsForAccount(player); if (emails != null) { int index = nbt.getInt("Index"); @@ -40,10 +40,10 @@ public void processRequest(CompoundTag nbt, Level level, Player player) { } @Override - public void prepareResponse(CompoundTag nbt) { + public void prepareResponse(CompoundNBT nbt) { } @Override - public void processResponse(CompoundTag nbt) { + public void processResponse(CompoundNBT nbt) { } } diff --git a/common/src/main/java/com/ultreon/devices/programs/email/task/TaskRegisterEmailAccount.java b/common/src/main/java/com/ultreon/devices/programs/email/task/TaskRegisterEmailAccount.java index a7d20cde5..332b5787d 100644 --- a/common/src/main/java/com/ultreon/devices/programs/email/task/TaskRegisterEmailAccount.java +++ b/common/src/main/java/com/ultreon/devices/programs/email/task/TaskRegisterEmailAccount.java @@ -2,9 +2,9 @@ import com.ultreon.devices.api.task.Task; import com.ultreon.devices.programs.email.EmailManager; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; public class TaskRegisterEmailAccount extends Task { private String name; @@ -19,23 +19,23 @@ public TaskRegisterEmailAccount(String name) { } @Override - public void prepareRequest(CompoundTag nbt) { + public void prepareRequest(CompoundNBT nbt) { nbt.putString("AccountName", this.name); } @Override - public void processRequest(CompoundTag nbt, Level level, Player player) { + public void processRequest(CompoundNBT nbt, World level, PlayerEntity player) { if (EmailManager.INSTANCE.addAccount(player, nbt.getString("AccountName"))) { this.setSuccessful(); } } @Override - public void prepareResponse(CompoundTag nbt) { + public void prepareResponse(CompoundNBT nbt) { } @Override - public void processResponse(CompoundTag nbt) { + public void processResponse(CompoundNBT nbt) { } } diff --git a/common/src/main/java/com/ultreon/devices/programs/email/task/TaskSendEmail.java b/common/src/main/java/com/ultreon/devices/programs/email/task/TaskSendEmail.java index ee7bc30d5..64fc945f9 100644 --- a/common/src/main/java/com/ultreon/devices/programs/email/task/TaskSendEmail.java +++ b/common/src/main/java/com/ultreon/devices/programs/email/task/TaskSendEmail.java @@ -3,9 +3,9 @@ import com.ultreon.devices.api.task.Task; import com.ultreon.devices.programs.email.EmailManager; import com.ultreon.devices.programs.email.object.Email; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; public class TaskSendEmail extends Task { private Email email; @@ -22,13 +22,13 @@ public TaskSendEmail(Email email, String to) { } @Override - public void prepareRequest(CompoundTag nbt) { + public void prepareRequest(CompoundNBT nbt) { this.email.save(nbt); nbt.putString("to", this.to); } @Override - public void processRequest(CompoundTag nbt, Level level, Player player) { + public void processRequest(CompoundNBT nbt, World level, PlayerEntity player) { String name = EmailManager.INSTANCE.getName(player); if (name != null) { Email email = Email.readFromNBT(nbt); @@ -40,11 +40,11 @@ public void processRequest(CompoundTag nbt, Level level, Player player) { } @Override - public void prepareResponse(CompoundTag nbt) { + public void prepareResponse(CompoundNBT nbt) { } @Override - public void processResponse(CompoundTag nbt) { + public void processResponse(CompoundNBT nbt) { } } diff --git a/common/src/main/java/com/ultreon/devices/programs/email/task/TaskUpdateInbox.java b/common/src/main/java/com/ultreon/devices/programs/email/task/TaskUpdateInbox.java index 3d350dda6..3c0587c78 100644 --- a/common/src/main/java/com/ultreon/devices/programs/email/task/TaskUpdateInbox.java +++ b/common/src/main/java/com/ultreon/devices/programs/email/task/TaskUpdateInbox.java @@ -3,10 +3,10 @@ import com.ultreon.devices.api.task.Task; import com.ultreon.devices.programs.email.EmailManager; import com.ultreon.devices.programs.email.object.Email; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.ListNBT; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; import java.util.List; @@ -18,20 +18,20 @@ public TaskUpdateInbox() { } @Override - public void prepareRequest(CompoundTag nbt) { + public void prepareRequest(CompoundNBT nbt) { } @Override - public void processRequest(CompoundTag nbt, Level world, Player player) { + public void processRequest(CompoundNBT nbt, World world, PlayerEntity player) { this.emails = EmailManager.INSTANCE.getEmailsForAccount(player); } @Override - public void prepareResponse(CompoundTag nbt) { - ListTag tagList = new ListTag(); + public void prepareResponse(CompoundNBT nbt) { + ListNBT tagList = new ListNBT(); if (emails != null) { for (Email email : emails) { - CompoundTag emailTag = new CompoundTag(); + CompoundNBT emailTag = new CompoundNBT(); email.save(emailTag); tagList.add(emailTag); } @@ -40,11 +40,11 @@ public void prepareResponse(CompoundTag nbt) { } @Override - public void processResponse(CompoundTag nbt) { + public void processResponse(CompoundNBT nbt) { EmailManager.INSTANCE.getInbox().clear(); - ListTag emails = (ListTag) nbt.get("emails"); + ListNBT emails = (ListNBT) nbt.get("emails"); for (int i = 0; i < emails.size(); i++) { - CompoundTag emailTag = emails.getCompound(i); + CompoundNBT emailTag = emails.getCompound(i); Email email = Email.readFromNBT(emailTag); EmailManager.INSTANCE.getInbox().add(email); } diff --git a/common/src/main/java/com/ultreon/devices/programs/email/task/TaskViewEmail.java b/common/src/main/java/com/ultreon/devices/programs/email/task/TaskViewEmail.java index f0a4027a8..a45354561 100644 --- a/common/src/main/java/com/ultreon/devices/programs/email/task/TaskViewEmail.java +++ b/common/src/main/java/com/ultreon/devices/programs/email/task/TaskViewEmail.java @@ -3,9 +3,9 @@ import com.ultreon.devices.api.task.Task; import com.ultreon.devices.programs.email.EmailManager; import com.ultreon.devices.programs.email.object.Email; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; import java.util.List; @@ -22,12 +22,12 @@ public TaskViewEmail(int index) { } @Override - public void prepareRequest(CompoundTag nbt) { + public void prepareRequest(CompoundNBT nbt) { nbt.putInt("Index", this.index); } @Override - public void processRequest(CompoundTag nbt, Level world, Player player) { + public void processRequest(CompoundNBT nbt, World world, PlayerEntity player) { List emails = EmailManager.INSTANCE.getEmailsForAccount(player); if (emails != null) { int index = nbt.getInt("Index"); @@ -38,11 +38,11 @@ public void processRequest(CompoundTag nbt, Level world, Player player) { } @Override - public void prepareResponse(CompoundTag nbt) { + public void prepareResponse(CompoundNBT nbt) { } @Override - public void processResponse(CompoundTag nbt) { + public void processResponse(CompoundNBT nbt) { } } diff --git a/common/src/main/java/com/ultreon/devices/programs/example/ExampleApp.java b/common/src/main/java/com/ultreon/devices/programs/example/ExampleApp.java index 713547a0f..18a2b7be7 100644 --- a/common/src/main/java/com/ultreon/devices/programs/example/ExampleApp.java +++ b/common/src/main/java/com/ultreon/devices/programs/example/ExampleApp.java @@ -5,7 +5,7 @@ import com.ultreon.devices.api.app.component.*; import com.ultreon.devices.api.task.TaskManager; import com.ultreon.devices.programs.example.task.TaskNotificationTest; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.CompoundNBT; import javax.annotation.Nullable; @@ -35,7 +35,7 @@ public ExampleApp() { } @Override - public void init(@Nullable CompoundTag intent) { + public void init(@Nullable CompoundNBT intent) { label = new Label("Label", 5, 5); super.addComponent(label); @@ -109,12 +109,12 @@ public void init(@Nullable CompoundTag intent) { } @Override - public void load(CompoundTag tagCompound) { + public void load(CompoundNBT tagCompound) { } @Override - public void save(CompoundTag tagCompound) { + public void save(CompoundNBT tagCompound) { } diff --git a/common/src/main/java/com/ultreon/devices/programs/example/task/TaskNotificationTest.java b/common/src/main/java/com/ultreon/devices/programs/example/task/TaskNotificationTest.java index b0e593c27..a9f0083a8 100644 --- a/common/src/main/java/com/ultreon/devices/programs/example/task/TaskNotificationTest.java +++ b/common/src/main/java/com/ultreon/devices/programs/example/task/TaskNotificationTest.java @@ -3,10 +3,10 @@ import com.ultreon.devices.api.app.Icons; import com.ultreon.devices.api.app.Notification; import com.ultreon.devices.api.task.Task; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; /** * @author MrCrayfish @@ -17,14 +17,14 @@ public TaskNotificationTest() { } @Override - public void prepareRequest(CompoundTag nbt) { + public void prepareRequest(CompoundNBT nbt) { } @Override - public void processRequest(CompoundTag nbt, Level world, Player player) { + public void processRequest(CompoundNBT nbt, World world, PlayerEntity player) { Notification notification = new Notification(Icons.MAIL, "New Email!", "Check your inbox"); - notification.pushTo((ServerPlayer) player); + notification.pushTo((ServerPlayerEntity) player); /* MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); List players = server.getPlayerList().getPlayers(); @@ -32,12 +32,12 @@ public void processRequest(CompoundTag nbt, Level world, Player player) { } @Override - public void prepareResponse(CompoundTag nbt) { + public void prepareResponse(CompoundNBT nbt) { } @Override - public void processResponse(CompoundTag nbt) { + public void processResponse(CompoundNBT nbt) { } } diff --git a/common/src/main/java/com/ultreon/devices/programs/gitweb/GitWebApp.java b/common/src/main/java/com/ultreon/devices/programs/gitweb/GitWebApp.java index c7925bb36..dadc3dbbb 100644 --- a/common/src/main/java/com/ultreon/devices/programs/gitweb/GitWebApp.java +++ b/common/src/main/java/com/ultreon/devices/programs/gitweb/GitWebApp.java @@ -11,8 +11,8 @@ import com.ultreon.devices.programs.system.SettingsApp; import com.ultreon.devices.programs.system.layout.StandardLayout; import com.ultreon.devices.util.DataHandler; -import net.minecraft.client.gui.Gui; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.client.gui.IngameGui; +import net.minecraft.nbt.CompoundNBT; import javax.annotation.Nullable; import java.awt.*; @@ -42,11 +42,11 @@ public Optional getSystem() { } @Override - public void init(@Nullable CompoundTag intent) { + public void init(@Nullable CompoundNBT intent) { layoutBrowser = new StandardLayout(null, 362, 240, this, null); layoutBrowser.setBackground((pose, gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> { Color color = new Color(Laptop.getSystem().getSettings().getColorScheme().getItemBackgroundColor()); - Gui.fill(pose, x, y + 21, x + width, y + 164, color.getRGB()); + IngameGui.fill(pose, x, y + 21, x + width, y + 164, color.getRGB()); }); layoutPref = new SettingsApp.Menu("Preferences"); @@ -124,11 +124,11 @@ private String getAddress() { } @Override - public void load(CompoundTag tag) { + public void load(CompoundNBT tag) { } @Override - public void save(CompoundTag tag) { + public void save(CompoundNBT tag) { } @Override diff --git a/common/src/main/java/com/ultreon/devices/programs/gitweb/component/container/AnvilBox.java b/common/src/main/java/com/ultreon/devices/programs/gitweb/component/container/AnvilBox.java index feaf30199..5854df24e 100644 --- a/common/src/main/java/com/ultreon/devices/programs/gitweb/component/container/AnvilBox.java +++ b/common/src/main/java/com/ultreon/devices/programs/gitweb/component/container/AnvilBox.java @@ -1,7 +1,7 @@ package com.ultreon.devices.programs.gitweb.component.container; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.block.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.block.Blocks; /** * @author MrCrayfish diff --git a/common/src/main/java/com/ultreon/devices/programs/gitweb/component/container/BrewingBox.java b/common/src/main/java/com/ultreon/devices/programs/gitweb/component/container/BrewingBox.java index 82517cc89..9ac0eb9d9 100644 --- a/common/src/main/java/com/ultreon/devices/programs/gitweb/component/container/BrewingBox.java +++ b/common/src/main/java/com/ultreon/devices/programs/gitweb/component/container/BrewingBox.java @@ -1,11 +1,11 @@ package com.ultreon.devices.programs.gitweb.component.container; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.core.Laptop; import net.minecraft.client.Minecraft; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; /** * @author MrCrayfish @@ -43,10 +43,10 @@ protected void handleTick() { } @Override - protected void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + protected void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { super.render(pose, laptop, mc, x, y, mouseX, mouseY, windowActive, partialTicks); - RenderSystem.setShaderTexture(0, CONTAINER_BOXES_TEXTURE); + mc.textureManager.bind(CONTAINER_BOXES_TEXTURE); this.blit(pose, x + 56, y + 47, 152, 252, 18, 4); diff --git a/common/src/main/java/com/ultreon/devices/programs/gitweb/component/container/ContainerBox.java b/common/src/main/java/com/ultreon/devices/programs/gitweb/component/container/ContainerBox.java index a24fbb735..4c7c8499c 100644 --- a/common/src/main/java/com/ultreon/devices/programs/gitweb/component/container/ContainerBox.java +++ b/common/src/main/java/com/ultreon/devices/programs/gitweb/component/container/ContainerBox.java @@ -1,15 +1,15 @@ package com.ultreon.devices.programs.gitweb.component.container; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.Reference; import com.ultreon.devices.api.app.Component; import com.ultreon.devices.api.utils.RenderUtil; import com.ultreon.devices.core.Laptop; import com.ultreon.devices.util.GuiHelper; import net.minecraft.client.Minecraft; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraft.item.ItemStack; import java.awt.*; import java.util.ArrayList; @@ -38,8 +38,8 @@ public ContainerBox(int left, int top, int boxU, int boxV, int height, ItemStack } @Override - protected void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { - RenderSystem.setShaderTexture(0, CONTAINER_BOXES_TEXTURE); + protected void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + mc.textureManager.bind(CONTAINER_BOXES_TEXTURE); RenderUtil.drawRectWithTexture(pose, x, y + 12, boxU, boxV, WIDTH, height, WIDTH, height, 256, 256); //Gui.blit(pose, x, y + 12, WIDTH, height, boxU, boxV, 256, 256, WIDTH, height); @@ -58,7 +58,7 @@ protected void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, } @Override - protected void renderOverlay(PoseStack pose, Laptop laptop, Minecraft mc, int mouseX, int mouseY, boolean windowActive) { + protected void renderOverlay(MatrixStack pose, Laptop laptop, Minecraft mc, int mouseX, int mouseY, boolean windowActive) { slots.forEach(slot -> slot.renderOverlay(pose, laptop, xPosition, yPosition + 12, mouseX, mouseY)); } @@ -77,7 +77,7 @@ public void render(int x, int y) { RenderUtil.renderItem(x + slotX, y + slotY, stack, true); } - public void renderOverlay(PoseStack pose, Laptop laptop, int x, int y, int mouseX, int mouseY) { + public void renderOverlay(MatrixStack pose, Laptop laptop, int x, int y, int mouseX, int mouseY) { if (GuiHelper.isMouseWithin(mouseX, mouseY, x + slotX, y + slotY, 16, 16)) { if (!stack.isEmpty()) { laptop.renderTooltip(pose, laptop.getTooltipFromItem(stack), Optional.empty(), mouseX, mouseY/*, stack*/); diff --git a/common/src/main/java/com/ultreon/devices/programs/gitweb/component/container/CraftingBox.java b/common/src/main/java/com/ultreon/devices/programs/gitweb/component/container/CraftingBox.java index c274e1116..7918e41b9 100644 --- a/common/src/main/java/com/ultreon/devices/programs/gitweb/component/container/CraftingBox.java +++ b/common/src/main/java/com/ultreon/devices/programs/gitweb/component/container/CraftingBox.java @@ -1,7 +1,7 @@ package com.ultreon.devices.programs.gitweb.component.container; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.block.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.block.Blocks; /** * @author MrCrayfish diff --git a/common/src/main/java/com/ultreon/devices/programs/gitweb/component/container/FurnaceBox.java b/common/src/main/java/com/ultreon/devices/programs/gitweb/component/container/FurnaceBox.java index e18e6f502..9ea049c30 100644 --- a/common/src/main/java/com/ultreon/devices/programs/gitweb/component/container/FurnaceBox.java +++ b/common/src/main/java/com/ultreon/devices/programs/gitweb/component/container/FurnaceBox.java @@ -1,13 +1,13 @@ package com.ultreon.devices.programs.gitweb.component.container; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import com.ultreon.devices.core.Laptop; import dev.architectury.injectables.annotations.ExpectPlatform; import net.minecraft.client.Minecraft; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.RecipeType; -import net.minecraft.world.level.block.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.RecipeType; +import net.minecraft.block.Blocks; /** * @author MrCrayfish @@ -43,10 +43,10 @@ protected void handleTick() { } @Override - protected void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + protected void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { super.render(pose, laptop, mc, x, y, mouseX, mouseY, windowActive, partialTicks); - RenderSystem.setShaderTexture(0, CONTAINER_BOXES_TEXTURE); + mc.textureManager.bind(CONTAINER_BOXES_TEXTURE); int burnProgress = this.getBurnLeftScaled(13); this.blit(pose, x + 26, y + 52 - burnProgress, 128, 238 - burnProgress, 14, burnProgress + 1); diff --git a/common/src/main/java/com/ultreon/devices/programs/gitweb/component/container/LoomBox.java b/common/src/main/java/com/ultreon/devices/programs/gitweb/component/container/LoomBox.java index bb8824b8c..3639eaccd 100644 --- a/common/src/main/java/com/ultreon/devices/programs/gitweb/component/container/LoomBox.java +++ b/common/src/main/java/com/ultreon/devices/programs/gitweb/component/container/LoomBox.java @@ -1,22 +1,22 @@ package com.ultreon.devices.programs.gitweb.component.container; -import com.mojang.blaze3d.platform.Lighting; -import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.renderer.RenderHelper; +import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.datafixers.util.Pair; import com.ultreon.devices.core.Laptop; import net.minecraft.client.Minecraft; import net.minecraft.client.model.geom.ModelLayers; -import net.minecraft.client.model.geom.ModelPart; -import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.blockentity.BannerRenderer; +import net.minecraft.client.model.geom.ModelRenderer; +import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.tileentity.BannerRenderer; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.resources.model.ModelBakery; -import net.minecraft.world.item.BannerItem; -import net.minecraft.world.item.DyeColor; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.entity.BannerBlockEntity; -import net.minecraft.world.level.block.entity.BannerPattern; +import net.minecraft.item.BannerItem; +import net.minecraft.item.DyeColor; +import net.minecraft.item.ItemStack; +import net.minecraft.block.Blocks; +import net.minecraft.tileentity.BannerBlockEntity; +import net.minecraft.tileentity.BannerPattern; import java.util.ArrayList; import java.util.List; @@ -28,7 +28,7 @@ public class LoomBox extends ContainerBox { private final ItemStack pattern; private final ItemStack result; private final List> resultBannerPatterns; - private final ModelPart flag; + private final ModelRenderer flag; public LoomBox(ItemStack banner, ItemStack dye, ItemStack pattern, ItemStack result) { super(0, 0, 128, 72, HEIGHT, new ItemStack(Blocks.LOOM), "Loom"); @@ -49,13 +49,13 @@ public LoomBox(ItemStack banner, ItemStack dye, ItemStack pattern, ItemStack res } @Override - protected void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + protected void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { super.render(pose, laptop, mc, x, y, mouseX, mouseY, windowActive, partialTicks); int i = x;//this.leftPos; int j = y+12;//this.topPos; if (result.isEmpty())return; - Lighting.setupForFlatItems(); - MultiBufferSource.BufferSource bufferSource = mc.renderBuffers().bufferSource(); + RenderHelper.setupForFlatItems(); + IRenderTypeBuffer.BufferSource bufferSource = mc.renderBuffers().bufferSource(); pose.pushPose(); //pose.translate((double)(i + 139), (double)(j + 52), 0.0D); pose.translate(i+90d,j+52d,0.0D); diff --git a/common/src/main/java/com/ultreon/devices/programs/gitweb/module/AnvilModule.java b/common/src/main/java/com/ultreon/devices/programs/gitweb/module/AnvilModule.java index b341b563c..3dca5dca2 100644 --- a/common/src/main/java/com/ultreon/devices/programs/gitweb/module/AnvilModule.java +++ b/common/src/main/java/com/ultreon/devices/programs/gitweb/module/AnvilModule.java @@ -2,7 +2,7 @@ import com.ultreon.devices.programs.gitweb.component.container.AnvilBox; import com.ultreon.devices.programs.gitweb.component.container.ContainerBox; -import net.minecraft.world.item.ItemStack; +import net.minecraft.item.ItemStack; import java.util.ArrayList; import java.util.Arrays; diff --git a/common/src/main/java/com/ultreon/devices/programs/gitweb/module/BannerIIModule.java b/common/src/main/java/com/ultreon/devices/programs/gitweb/module/BannerIIModule.java index 131beafeb..4f0b7a2d8 100644 --- a/common/src/main/java/com/ultreon/devices/programs/gitweb/module/BannerIIModule.java +++ b/common/src/main/java/com/ultreon/devices/programs/gitweb/module/BannerIIModule.java @@ -1,7 +1,7 @@ package com.ultreon.devices.programs.gitweb.module; -import com.mojang.blaze3d.platform.Lighting; -import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.renderer.RenderHelper; +import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.datafixers.util.Pair; import com.ultreon.devices.api.app.Component; import com.ultreon.devices.api.app.Layout; @@ -11,18 +11,18 @@ import com.ultreon.devices.programs.gitweb.component.container.LoomBox; import net.minecraft.client.Minecraft; import net.minecraft.client.model.geom.ModelLayers; -import net.minecraft.client.model.geom.ModelPart; -import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.blockentity.BannerRenderer; +import net.minecraft.client.model.geom.ModelRenderer; +import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.tileentity.BannerRenderer; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.resources.model.ModelBakery; -import net.minecraft.util.Mth; -import net.minecraft.world.item.BannerItem; -import net.minecraft.world.item.DyeColor; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.entity.BannerBlockEntity; -import net.minecraft.world.level.block.entity.BannerPattern; +import net.minecraft.util.math.MathHelper; +import net.minecraft.item.BannerItem; +import net.minecraft.item.DyeColor; +import net.minecraft.item.ItemStack; +import net.minecraft.block.Blocks; +import net.minecraft.tileentity.BannerBlockEntity; +import net.minecraft.tileentity.BannerPattern; import java.util.ArrayList; import java.util.List; @@ -58,7 +58,7 @@ public LoomBox createContainer(Map data) { public static class LoomBox extends Component { public static final int HEIGHT = 84; private final ItemStack banner; - private final ModelPart flag; + private final ModelRenderer flag; private final List> resultBannerPatterns; public LoomBox(ItemStack banner, boolean waving) { @@ -73,13 +73,13 @@ public LoomBox(ItemStack banner, boolean waving) { } @Override - protected void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { + protected void render(MatrixStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) { super.render(pose, laptop, mc, x, y, mouseX, mouseY, windowActive, partialTicks); int i = x;//this.leftPos; int j = y;//this.topPos; if (banner.isEmpty())return; - Lighting.setupForFlatItems(); - MultiBufferSource.BufferSource bufferSource = mc.renderBuffers().bufferSource(); + RenderHelper.setupForFlatItems(); + IRenderTypeBuffer.BufferSource bufferSource = mc.renderBuffers().bufferSource(); pose.pushPose(); //pose.translate((double)(i + 139), (double)(j + 52), 0.0D); pose.translate(i+139,j+90,0.0D); @@ -93,7 +93,7 @@ protected void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, float h = ((float)Math.floorMod(l, 100L) + partialTicks) / 100.0f; this.flag.yRot = (float) Math.toRadians(30); - this.flag.xRot = (-0.0125f + 0.01f * Mth.cos((float)Math.PI * 2 * h)) * (float)Math.PI; + this.flag.xRot = (-0.0125f + 0.01f * MathHelper.cos((float)Math.PI * 2 * h)) * (float)Math.PI; // this.flag.xRot = 0.0F; this.flag.y = -32.0F; BannerRenderer.renderPatterns(pose, bufferSource, 15728880, OverlayTexture.NO_OVERLAY, this.flag, ModelBakery.BANNER_BASE, true, this.resultBannerPatterns); diff --git a/common/src/main/java/com/ultreon/devices/programs/gitweb/module/BrewingModule.java b/common/src/main/java/com/ultreon/devices/programs/gitweb/module/BrewingModule.java index 0450ba623..e56f4bd1b 100644 --- a/common/src/main/java/com/ultreon/devices/programs/gitweb/module/BrewingModule.java +++ b/common/src/main/java/com/ultreon/devices/programs/gitweb/module/BrewingModule.java @@ -2,7 +2,7 @@ import com.ultreon.devices.programs.gitweb.component.container.BrewingBox; import com.ultreon.devices.programs.gitweb.component.container.ContainerBox; -import net.minecraft.world.item.ItemStack; +import net.minecraft.item.ItemStack; import java.util.ArrayList; import java.util.Arrays; diff --git a/common/src/main/java/com/ultreon/devices/programs/gitweb/module/ContainerModule.java b/common/src/main/java/com/ultreon/devices/programs/gitweb/module/ContainerModule.java index 948526bb8..b720ae7d5 100644 --- a/common/src/main/java/com/ultreon/devices/programs/gitweb/module/ContainerModule.java +++ b/common/src/main/java/com/ultreon/devices/programs/gitweb/module/ContainerModule.java @@ -7,9 +7,9 @@ import com.ultreon.devices.programs.gitweb.component.GitWebFrame; import com.ultreon.devices.programs.gitweb.component.container.ContainerBox; import com.ultreon.devices.programs.gitweb.component.container.CraftingBox; -import net.minecraft.ChatFormatting; -import net.minecraft.nbt.TagParser; -import net.minecraft.world.item.ItemStack; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.nbt.INBTParser; +import net.minecraft.item.ItemStack; import java.util.Map; @@ -47,7 +47,7 @@ public final void generate(GitWebFrame frame, Layout layout, int width, Map - Gui.fill(pose, x, y, x + width1, y + height, color)); + IngameGui.fill(pose, x, y, x + width1, y + height, color)); } } } diff --git a/common/src/main/java/com/ultreon/devices/programs/gitweb/module/DownloadModule.java b/common/src/main/java/com/ultreon/devices/programs/gitweb/module/DownloadModule.java index 727677ea3..7d537797c 100644 --- a/common/src/main/java/com/ultreon/devices/programs/gitweb/module/DownloadModule.java +++ b/common/src/main/java/com/ultreon/devices/programs/gitweb/module/DownloadModule.java @@ -12,9 +12,9 @@ import com.ultreon.devices.core.Laptop; import com.ultreon.devices.object.AppInfo; import com.ultreon.devices.programs.gitweb.component.GitWebFrame; -import net.minecraft.client.gui.Gui; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.TagParser; +import net.minecraft.client.gui.IngameGui; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.INBTParser; import java.awt.*; import java.util.Map; @@ -47,11 +47,11 @@ public void generate(GitWebFrame frame, Layout layout, int width, Map { try { - CompoundTag tag = TagParser.parseTag(data.get("file-data")); + CompoundNBT tag = TagParser.parseTag(data.get("file-data")); File file = new File(data.getOrDefault("file-name", ""), data.get("file-app"), tag); Dialog dialog = new Dialog.SaveFile(frame.getApp(), file); frame.getApp().openDialog(dialog); diff --git a/common/src/main/java/com/ultreon/devices/programs/gitweb/module/FooterModule.java b/common/src/main/java/com/ultreon/devices/programs/gitweb/module/FooterModule.java index a7b11fbaa..5897dce42 100644 --- a/common/src/main/java/com/ultreon/devices/programs/gitweb/module/FooterModule.java +++ b/common/src/main/java/com/ultreon/devices/programs/gitweb/module/FooterModule.java @@ -5,7 +5,7 @@ import com.ultreon.devices.api.app.component.Button; import com.ultreon.devices.api.utils.RenderUtil; import com.ultreon.devices.programs.gitweb.component.GitWebFrame; -import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.IngameGui; import java.awt.*; import java.util.Map; @@ -60,7 +60,7 @@ public void generate(GitWebFrame frame, Layout layout, int width, Map { - Gui.fill(pose, x, y, x + width1, y + height, finalColor); + IngameGui.fill(pose, x, y, x + width1, y + height, finalColor); RenderUtil.drawStringClipped(pose, title, x + 5, y + 5, buttonHome.left - 10, -1, true); RenderUtil.drawStringClipped(pose, subTitle, x + 5, y + 16, buttonHome.left - 10, Color.LIGHT_GRAY.getRGB(), false); diff --git a/common/src/main/java/com/ultreon/devices/programs/gitweb/module/FurnaceModule.java b/common/src/main/java/com/ultreon/devices/programs/gitweb/module/FurnaceModule.java index b49fca683..387aadac8 100644 --- a/common/src/main/java/com/ultreon/devices/programs/gitweb/module/FurnaceModule.java +++ b/common/src/main/java/com/ultreon/devices/programs/gitweb/module/FurnaceModule.java @@ -2,7 +2,7 @@ import com.ultreon.devices.programs.gitweb.component.container.ContainerBox; import com.ultreon.devices.programs.gitweb.component.container.FurnaceBox; -import net.minecraft.world.item.ItemStack; +import net.minecraft.item.ItemStack; import java.util.ArrayList; import java.util.Arrays; diff --git a/common/src/main/java/com/ultreon/devices/programs/gitweb/module/NavigationModule.java b/common/src/main/java/com/ultreon/devices/programs/gitweb/module/NavigationModule.java index 643a0d11f..5a9cfbf06 100644 --- a/common/src/main/java/com/ultreon/devices/programs/gitweb/module/NavigationModule.java +++ b/common/src/main/java/com/ultreon/devices/programs/gitweb/module/NavigationModule.java @@ -4,7 +4,7 @@ import com.ultreon.devices.api.app.Layout; import com.ultreon.devices.api.app.component.Button; import com.ultreon.devices.programs.gitweb.component.GitWebFrame; -import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.IngameGui; import javax.annotation.Nullable; import java.awt.*; @@ -63,7 +63,7 @@ public void generate(GitWebFrame frame, Layout layout, int width, Map - Gui.fill(pose, x, y, x + width1, y + height, finalColor)); + IngameGui.fill(pose, x, y, x + width1, y + height, finalColor)); List