Skip to content

Commit

Permalink
🔄️ Backport in progress!
Browse files Browse the repository at this point in the history
  • Loading branch information
XyperCode committed Jun 23, 2024
1 parent f953559 commit 93df7d3
Show file tree
Hide file tree
Showing 522 changed files with 33,419 additions and 2,892 deletions.
240 changes: 167 additions & 73 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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
jar.finalizedBy('reobfJar')

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}
26 changes: 13 additions & 13 deletions common/src/main/java/com/ultreon/devices/ClientModEvents.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -70,7 +70,7 @@ public static void clientSetup() {
public static class ReloaderListener implements PreparableReloadListener {
@NotNull
@Override
public CompletableFuture<Void> reload(@NotNull PreparableReloadListener.PreparationBarrier preparationBarrier, @NotNull ResourceManager resourceManager, @NotNull ProfilerFiller preparationsProfiler, @NotNull ProfilerFiller reloadProfiler, @NotNull Executor backgroundExecutor, @NotNull Executor gameExecutor) {
public CompletableFuture<Void> 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(() -> {
Expand Down Expand Up @@ -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() {
Expand Down
16 changes: 8 additions & 8 deletions common/src/main/java/com/ultreon/devices/DeviceConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions common/src/main/java/com/ultreon/devices/DeviceTab.java
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
Loading

0 comments on commit 93df7d3

Please sign in to comment.