Refactor to use infrastructury

This commit is contained in:
Melon 2024-04-24 00:03:33 +01:00
parent 2d2bb36df5
commit fde15f5a74
Signed by: melon
GPG Key ID: 6C9D970C50D26A25
53 changed files with 790 additions and 191 deletions

View File

@ -3,20 +3,57 @@ name: Java CI
on: [ push ]
jobs:
build:
resolve-versions:
name: "Resolve Versions"
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- run: sudo apt-get update && sudo apt-get install -y jo
- uses: actions/checkout@v4
- id: set-matrix
run: ./resolveversions.sh >> $GITHUB_OUTPUT
build:
needs: resolve-versions
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.resolve-versions.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "adopt"
distribution: "temurin"
- name: Build
run: ./gradlew build
run: ./buildsingle.sh "${{ matrix.mc }}"
- uses: actions/upload-artifact@v4
with:
name: "buildAllJars-${{matrix.mc}}"
path: buildAllJars/*.jar
if-no-files-found: error
- name: Deploy
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download All Artifacts
uses: actions/download-artifact@v4
with:
path: buildAllJars
pattern: buildAllJars-*
merge-multiple: true
- name: Files
run: |
#!/bin/bash
ls -1 ./buildAllJars/*.jar
- name: Publish
if: startsWith(github.ref, 'refs/tags/v')
run: 'curl --fail -X POST -H "Authorization: Bearer ${{ secrets.DEPLOY }}" -F "upload=@$(ls -1 build/libs/merged/*.jar)" https://api.mrmelon54.com/v1/mc-upload/upload/wireless-redstone'
run: |
#!/bin/bash
while read -r filename; do
curl --fail -X POST -H "Authorization: Bearer ${{ secrets.DEPLOY }}" -F "upload=@$filename" https://api.mrmelon54.com/v1/mc-upload/upload/wireless-redstone
done < <(find ./buildAllJars/ -name '*.jar' -type f)

5
.gitignore vendored
View File

@ -27,3 +27,8 @@ bin/
# fabric
run/
build.properties
mcver.properties
*.build.log
.architectury-transformer/
buildAllJars/

View File

@ -1,18 +1,11 @@
# Melon Wireless Redstone
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/W7W1607S8)
In the latest version cardinal components is replaced with vanilla functionality.
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/mrmelon54)
## Setup
- Drop the mod in the mods folder
## Details
My version of a simple wireless redstone transmitter and receiver.
The crafting recipes are in the images tab/folder.
- Requires [Infrastructury](https://modrinth.com/mod/infrastructury) and [Architectury API](https://modrinth.com/mod/architectury-api)
## Usage

View File

@ -1,31 +1,126 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.5-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false
id "io.github.pacifistmc.forgix" version "1.2.6"
id "org.ajoberstar.grgit" version "4.1.0"
id "systems.manifold.manifold-gradle-plugin" version "0.0.2-alpha"
}
import groovy.json.JsonSlurper
def writeBuildGradlePredefine(List<String> mcVers, int mcIndex) {
// Build the list of preprocessors to use
StringBuilder sb = new StringBuilder();
sb.append("# DON'T TOUCH THIS FILE, This is handled by the build script\n");
for (int i = 0; i < mcVers.size(); i++) {
String verStr = mcVers[i].replace(".", "_");
sb.append("MC_" + verStr + "=" + i.toString() + "\n");
if (mcIndex == i)
sb.append("MC_VER=" + i.toString() + "\n");
}
new File(projectDir, "build.properties").text = sb.toString()
}
static def generateForgeVersions(mc_versions) {
def json = new JsonSlurper().parseText(mc_versions) as List<String>
if (json.size() == 0) {
return "error"
}
return "[" + json[0] + "," + json[json.size() - 1] + "]"
}
project.gradle.ext.getProperties().each { prop ->
rootProject.ext.set(prop.key, prop.value)
}
writeBuildGradlePredefine(rootProject.mcVers, rootProject.mcIndex)
rootProject.versionStr = "${rootProject.mod_version}-mc${rootProject.minecraft_version}"
rootProject.compatible_forge_versions = generateForgeVersions(rootProject.compatible_minecraft_versions)
rootProject.forgix_merged_jar = "${project.archives_base_name}-${rootProject.versionStr}-${getVersionMetadata()}.jar"
compileJava {
sourceCompatibility = rootProject.java_version
targetCompatibility = rootProject.java_version
}
architectury {
minecraft = rootProject.minecraft_version
}
subprojects {
subprojects { p ->
apply plugin: "java"
apply plugin: "dev.architectury.loom"
apply plugin: "systems.manifold.manifold-gradle-plugin"
loom {
silentMojangMappingsLicense()
}
dependencies {
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
// The following line declares the mojmap mappings, you may use other mappings as well
mappings loom.officialMojangMappings()
// The following line declares the yarn mappings you may select this one as well.
// mappings "net.fabricmc:yarn:1.19.4+build.2:v2"
// set up custom configurations (configurations are a way to handle dependencies)
configurations {
compile
mappings
// extends the shadowJar configuration
shadowMe
// have implemented dependencies automatically embedded in the final jar
implementation.extendsFrom(shadowMe)
forgeShadowMe
implementation.extendsFrom(forgeShadowMe)
shadowMe.extendsFrom(forgeShadowMe)
forgeRuntimeLibrary.extendsFrom(forgeShadowMe)
if (p != project(":common")) {
// Shadow common
common
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
if (findProject(":forge"))
developmentForge.extendsFrom common
if (findProject(":neoforge"))
developmentNeoForge.extendsFrom common
compileClasspath.extendsFrom coreProjects
runtimeClasspath.extendsFrom coreProjects
if (findProject(":forge"))
developmentForge.extendsFrom coreProjects
if (findProject(":neoforge"))
developmentNeoForge.extendsFrom coreProjects
}
}
build.finalizedBy(mergeJars)
assemble.finalizedBy(mergeJars)
String platformStr = ""
if (findProject(":common") && p != project(":common")) {
if (findProject(":quilt") && p == project(":quilt")) platformStr = "-fabric"
else platformStr = "-${p.name}"
}
dependencies {
annotationProcessor("systems.manifold:manifold-preprocessor:${rootProject.manifold_version}")
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
mappings loom.layered() {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${rootProject.parchment_version}@zip")
}
modApi "com.mrmelon54.infrastructury:infrastructury${platformStr}:${rootProject.infrastructury_version}-mc${rootProject.minecraft_version}"
if (p != project(":common")) {
common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProduction${capitalProject(p.name)}")) { transitive false }
}
}
}
static def capitalProject(String value) {
if (value == "neoforge") return "NeoForge"
return value[0].toUpperCase() + value.substring(1)
}
allprojects {
@ -33,8 +128,8 @@ allprojects {
apply plugin: "architectury-plugin"
apply plugin: "maven-publish"
archivesBaseName = rootProject.archives_base_name
version = rootProject.mod_version
archivesBaseName = "${rootProject.archives_base_name}-${project.name}"
version = rootProject.versionStr
group = rootProject.maven_group
repositories {
@ -43,15 +138,30 @@ allprojects {
// 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.shedaniel.me/" }
maven { url "https://maven.terraformersmc.com/releases/" }
maven { url "https://maven.parchmentmc.org" }
maven { url "https://maven.mrmelon54.com/releases/" }
maven {
name = 'CottonMC'
url = 'https://server.bbkr.space/artifactory/libs-release'
name = "CottonMC"
url "https://server.bbkr.space/artifactory/libs-release"
}
mavenLocal()
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.release = 17
options.release = rootProject.java_version as Integer
options.compilerArgs += ["-Xplugin:Manifold"]
}
processResources {
exclude { file ->
if (file.name.contains(".${mod_id}.accesswidener") && file.name != "${accessWidenerVersion}.${mod_id}.accesswidener") {
return true
}
return false
}
}
java {
@ -61,8 +171,30 @@ allprojects {
forgix {
group = "com.mrmelon54.WirelessRedstone"
mergedJarName = "${project.archivesBaseName}-mc${project.minecraft_version}-${project.mod_version}-${getVersionMetadata()}.jar"
outputDir = "build/libs/merged"
mergedJarName = rootProject.forgix_merged_jar
if (findProject(":fabric"))
fabric {
jarLocation = "build/libs/${project.archives_base_name}-fabric-${rootProject.versionStr}.jar"
}
if (findProject(":quilt"))
quilt {
jarLocation = "build/libs/${project.archives_base_name}-quilt-${rootProject.versionStr}.jar"
}
if (findProject(":forge"))
forge {
jarLocation = "build/libs/${project.archives_base_name}-forge-${rootProject.versionStr}.jar"
}
if (findProject(":neoforge"))
custom {
projectName = "neoforge"
jarLocation = "build/libs/${project.archives_base_name}-neoforge-${rootProject.versionStr}.jar"
}
removeDuplicate "com.mrmelon54.WirelessRedstone"
}
def getVersionMetadata() {
@ -88,3 +220,13 @@ def getVersionMetadata() {
// No tracking information could be found about the build
return "unknown"
}
// Delete the merged folder when running clean
task cleanMergedJars() {
def mergedFolder = file("Merged")
if (mergedFolder.exists()) {
delete(mergedFolder)
}
}
// add cleanMergedJars to the end of the "clean" task
tasks["clean"].finalizedBy(cleanMergedJars)

13
buildall.sh Normal file
View File

@ -0,0 +1,13 @@
#!/bin/sh
echo "==================== Note: All build jars will be in the folder called 'buildAllJars' ===================="
mkdir -p buildAllJars | true
# Loop trough everything in the version properties folder
for d in versionProperties/*; do
# Get the name of the version that is going to be compiled
version=$(echo "$d" | sed "s/versionProperties\///" | sed "s/.properties//")
sh buildsingle.sh "$version" || true
# The "| true" at the end of those are just to make sure the script continues even if a build fails
done

16
buildsingle.sh Normal file
View File

@ -0,0 +1,16 @@
#!/bin/sh
echo "==================== Note: All build jars will be in the folder called 'buildAllJars' ===================="
mkdir -p buildAllJars || true
version="$1"
# Clean out the folders, build it, and merge it
echo "==================== Cleaning workspace to build $version ===================="
sh gradlew clean -PmcVer="$version" --no-daemon
echo "====================Building $version ===================="
sh gradlew build -PmcVer="$version" --no-daemon
echo "==================== Merging $version ===================="
sh gradlew mergeJars -PmcVer="$version" --no-daemon
echo "==================== Moving jar ===================="
mv Merged/*.jar buildAllJars/

View File

@ -1,5 +1,5 @@
architectury {
common(rootProject.enabled_platforms.split(","))
common(rootProject.builds_for.split(","))
}
loom {
@ -10,8 +10,13 @@ dependencies {
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
// Do NOT use other classes from fabric loader
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
// Remove the next line if you don't want to depend on the API
modApi "dev.architectury:architectury:${rootProject.architectury_version}"
modApi("me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_config_version}") {
exclude(group: "net.fabricmc.fabric-api")
}
modApi("com.terraformersmc:modmenu:${rootProject.modmenu_version}") {
exclude(group: "net.fabricmc.fabric-api")
}
}
publishing {

View File

@ -0,0 +1,10 @@
package com.mrmelon54.WirelessRedstone;
import me.shedaniel.autoconfig.ConfigData;
import me.shedaniel.autoconfig.annotation.Config;
@Config(name = "wireless_redstone")
@Config.Gui.Background("minecraft:textures/block/dirt.png")
public class ConfigStructure implements ConfigData {
public boolean modeEnabled = true;
}

View File

@ -0,0 +1,14 @@
package com.mrmelon54.WirelessRedstone;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
@Environment(EnvType.CLIENT)
public class ModMenuIntegration implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return parent -> WirelessRedstone.createConfigScreen(parent).get();
}
}

View File

@ -13,16 +13,17 @@ import com.mrmelon54.WirelessRedstone.packet.HandheldFrequencyChangeC2SPacket;
import com.mrmelon54.WirelessRedstone.screen.WirelessFrequencyScreen;
import com.mrmelon54.WirelessRedstone.util.HandheldItemUtils;
import com.mrmelon54.WirelessRedstone.util.NetworkingConstants;
import dev.architectury.event.events.client.ClientLifecycleEvent;
import dev.architectury.event.events.common.ChunkEvent;
import dev.architectury.event.events.common.LifecycleEvent;
import dev.architectury.event.events.common.PlayerEvent;
import dev.architectury.registry.CreativeTabRegistry;
import dev.architectury.registry.item.ItemPropertiesRegistry;
import dev.architectury.registry.menu.MenuRegistry;
import dev.architectury.registry.registries.Registrar;
import dev.architectury.registry.registries.RegistrarManager;
import dev.architectury.registry.registries.RegistrySupplier;
import com.mrmelon54.infrastructury.Infrastructury;
import com.mrmelon54.infrastructury.event.events.client.ClientLifecycleEvent;
import com.mrmelon54.infrastructury.event.events.common.ChunkEvent;
import com.mrmelon54.infrastructury.event.events.common.LifecycleEvent;
import com.mrmelon54.infrastructury.event.events.common.PlayerEvent;
import com.mrmelon54.infrastructury.registry.CreativeTabRegistry;
import com.mrmelon54.infrastructury.registry.item.ItemPropertiesRegistry;
import com.mrmelon54.infrastructury.registry.menu.MenuRegistry;
import com.mrmelon54.infrastructury.registry.registries.Registrar;
import com.mrmelon54.infrastructury.registry.registries.RegistrarManager;
import com.mrmelon54.infrastructury.registry.registries.RegistrySupplier;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.core.registries.Registries;
@ -48,9 +49,13 @@ import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;
import java.util.function.ToIntFunction;
import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.serializer.JanksonConfigSerializer;
import net.minecraft.client.gui.screens.Screen;
public class WirelessRedstone {
public static final String MOD_ID = "wireless_redstone";
public static ConfigStructure CONFIG = AutoConfig.register(ConfigStructure.class, JanksonConfigSerializer::new).get();
public static final Logger LOGGER = LoggerFactory.getLogger(WirelessRedstone.class);
public static final Block WIRELESS_TRANSMITTER = new WirelessTransmitterBlock(BlockBehaviour.Properties.of().strength(0).lightLevel(litFrequencyBlockEmission()).sound(SoundType.METAL));
@ -81,7 +86,6 @@ public class WirelessRedstone {
HandheldItemUtils.addHandheldFromPlayer(player, player.server.getLevel(newLevel));
});
//noinspection UnstableApiUsage
CreativeTabRegistry.append(CreativeModeTabs.REDSTONE_BLOCKS, WIRELESS_RECEIVER_ITEM, WIRELESS_TRANSMITTER_ITEM, WIRELESS_HANDHELD);
Registrar<MenuType<?>> menuReg = MANAGER.get().get(Registries.MENU);
@ -112,7 +116,7 @@ public class WirelessRedstone {
levelData.put(world.dimension(), savedData);
dataStorage.set(MOD_ID, savedData);
});
ClientLifecycleEvent.CLIENT_SETUP.register(instance -> MenuRegistry.registerScreenFactory(WIRELESS_FREQUENCY_MENU.get(), WirelessFrequencyScreen::new));
ClientLifecycleEvent.CLIENT_SETUP.register(instance -> MenuRegistry.registerScreenFactory(WIRELESS_FREQUENCY_MENU.get(), (containerMenu, inventory, component) -> new WirelessFrequencyScreen(containerMenu)));
clientInit();
}
@ -120,6 +124,7 @@ public class WirelessRedstone {
@Environment(EnvType.CLIENT)
public static void clientInit() {
ItemPropertiesRegistry.register(WirelessRedstone.WIRELESS_HANDHELD, new ResourceLocation("wireless_redstone_handheld_enabled"), new HandheldModelProvider());
Infrastructury.registerConfigScreen((mc,screen)->createConfigScreen(screen).get());
}
public static void sendTickScheduleToReceivers(Level level) {
@ -134,4 +139,8 @@ public class WirelessRedstone {
private static ToIntFunction<BlockState> litFrequencyBlockEmission() {
return (blockState) -> blockState.getValue(BlockStateProperties.LIT) ? 7 : 0;
}
public static Supplier<Screen> createConfigScreen(Screen screen) {
return AutoConfig.getConfigScreen(ConfigStructure.class, screen);
}
}

View File

@ -1,8 +1,8 @@
package com.mrmelon54.WirelessRedstone.block;
import com.mrmelon54.WirelessRedstone.WirelessRedstone;
import dev.architectury.registry.menu.ExtendedMenuProvider;
import dev.architectury.registry.menu.MenuRegistry;
import com.mrmelon54.infrastructury.registry.menu.ExtendedMenuProvider;
import com.mrmelon54.infrastructury.registry.menu.MenuRegistry;
import net.minecraft.core.BlockPos;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
@ -46,7 +46,7 @@ public abstract class WirelessFrequencyBlock extends BaseEntityBlock {
}
@Override
public Component getDisplayName() {
public @NotNull Component getDisplayName() {
return Component.translatable("screen.wireless_redstone.set_frequency");
}

View File

@ -3,8 +3,8 @@ package com.mrmelon54.WirelessRedstone.item;
import com.mrmelon54.WirelessRedstone.WirelessFrequencySavedData;
import com.mrmelon54.WirelessRedstone.WirelessRedstone;
import com.mrmelon54.WirelessRedstone.util.TransmittingHandheldEntry;
import dev.architectury.registry.menu.ExtendedMenuProvider;
import dev.architectury.registry.menu.MenuRegistry;
import com.mrmelon54.infrastructury.registry.menu.ExtendedMenuProvider;
import com.mrmelon54.infrastructury.registry.menu.MenuRegistry;
import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;
@ -61,7 +61,7 @@ public class WirelessHandheldItem extends Item {
}
@Override
public Component getDisplayName() {
public @NotNull Component getDisplayName() {
return Component.translatable("screen.wireless_redstone.set_frequency");
}

View File

@ -1,15 +0,0 @@
package com.mrmelon54.WirelessRedstone.mixin;
import net.minecraft.client.gui.screens.TitleScreen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(TitleScreen.class)
public class MixinTitleScreen {
@Inject(at = @At("HEAD"), method = "init()V")
private void init(CallbackInfo info) {
}
}

View File

@ -3,16 +3,12 @@ package com.mrmelon54.WirelessRedstone.packet;
import com.mrmelon54.WirelessRedstone.WirelessRedstone;
import com.mrmelon54.WirelessRedstone.block.entity.WirelessReceiverBlockEntity;
import com.mrmelon54.WirelessRedstone.block.entity.WirelessTransmitterBlockEntity;
import dev.architectury.networking.NetworkManager;
import com.mrmelon54.infrastructury.networking.NetworkManager;
import net.minecraft.core.BlockPos;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import org.apache.logging.log4j.core.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.Optional;
import java.util.function.Supplier;
@ -34,10 +30,10 @@ public record BlockFrequencyChangeC2SPacket(boolean isReceiver, BlockPos blockPo
Level level = player.level();
if (isReceiver) {
Optional<WirelessReceiverBlockEntity> blockEntity = level.getBlockEntity(blockPos, WirelessRedstone.WIRELESS_RECEIVER_BLOCK_ENTITY);
blockEntity.ifPresentOrElse(x -> x.setFrequency(freq), () -> WirelessRedstone.LOGGER.warn("Failed to apply BlockFrequencyChangeC2SPacket(true, {" + blockPos.toShortString() + "}, " + freq + ")"));
blockEntity.ifPresentOrElse(x -> x.setFrequency(freq), () -> WirelessRedstone.LOGGER.warn("Failed to apply BlockFrequencyChangeC2SPacket(true, {" + blockPos.toShortString() + "}, " + freq + ") to WirelessReceiverBlockEntity"));
} else {
Optional<WirelessTransmitterBlockEntity> blockEntity = level.getBlockEntity(blockPos, WirelessRedstone.WIRELESS_TRANSMITTER_BLOCK_ENTITY);
blockEntity.ifPresentOrElse(x -> x.setFrequency(freq), () -> WirelessRedstone.LOGGER.warn("Failed to apply BlockFrequencyChangeC2SPacket(true, {" + blockPos.toShortString() + "}, " + freq + ")"));
blockEntity.ifPresentOrElse(x -> x.setFrequency(freq), () -> WirelessRedstone.LOGGER.warn("Failed to apply BlockFrequencyChangeC2SPacket(true, {" + blockPos.toShortString() + "}, " + freq + ") to WirelessTransmitterBlockEntity"));
}
level.scheduleTick(blockPos, isReceiver ? WirelessRedstone.WIRELESS_RECEIVER : WirelessRedstone.WIRELESS_TRANSMITTER, 0);
}

View File

@ -3,7 +3,7 @@ package com.mrmelon54.WirelessRedstone.packet;
import com.mrmelon54.WirelessRedstone.WirelessRedstone;
import com.mrmelon54.WirelessRedstone.item.WirelessHandheldItem;
import com.mrmelon54.WirelessRedstone.util.TransmittingHandheldEntry;
import dev.architectury.networking.NetworkManager;
import com.mrmelon54.infrastructury.networking.NetworkManager;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.entity.player.Player;

View File

@ -9,7 +9,6 @@ import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.FormattedCharSequence;
import net.minecraft.world.entity.player.Inventory;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
@ -17,13 +16,11 @@ import java.util.Objects;
public class WirelessFrequencyScreen extends Screen implements MenuAccess<WirelessFrequencyMenu> {
private static final ResourceLocation MENU_LOCATION = new ResourceLocation("wireless_redstone:textures/gui/frequency.png");
private final WirelessFrequencyMenu containerMenu;
private final Inventory inventory;
private EditBox freqBox;
public WirelessFrequencyScreen(WirelessFrequencyMenu containerMenu, Inventory inventory, Component component) {
public WirelessFrequencyScreen(WirelessFrequencyMenu containerMenu) {
super(Component.translatable("screen.wireless_redstone.set_frequency"));
this.containerMenu = containerMenu;
this.inventory = inventory;
init();
}

View File

@ -1,12 +1,9 @@
package com.mrmelon54.WirelessRedstone.util;
import com.mrmelon54.WirelessRedstone.WirelessRedstone;
import dev.architectury.networking.NetworkChannel;
import com.mrmelon54.infrastructury.networking.NetworkChannel;
import net.minecraft.resources.ResourceLocation;
public class NetworkingConstants {
public static final NetworkChannel CHANNEL = NetworkChannel.create(new ResourceLocation(WirelessRedstone.MOD_ID, "networking_channel"));
// Packet IDs
public static final ResourceLocation WIRELESS_FREQUENCY_CHANGE_PACKET_ID = new ResourceLocation(WirelessRedstone.MOD_ID, "wireless_frequency_change");
}

View File

@ -1,10 +1,8 @@
{
"required": true,
"package": "com.mrmelon54.WirelessRedstone.mixin",
"compatibilityLevel": "JAVA_17",
"minVersion": "0.8",
"client": [
"MixinTitleScreen"
],
"mixins": [
],

View File

@ -1 +1 @@
accessWidener v2 named
accessWidener v2 named

View File

@ -1,16 +0,0 @@
architectury {
common(rootProject.enabled_platforms.split(","))
}
loom {
accessWidenerPath = project(":common").loom.accessWidenerPath
}
dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
// Remove the next line if you don't want to depend on the API
modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}"
compileOnly(project(path: ":common", configuration: "namedElements")) { transitive false }
}

View File

@ -1,9 +0,0 @@
package com.mrmelon54.WirelessRedstone.fabriclike;
import com.mrmelon54.WirelessRedstone.WirelessRedstone;
public class WirelessRedstoneFabricLike {
public static void init() {
WirelessRedstone.init();
}
}

View File

@ -22,13 +22,13 @@ configurations {
dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
// Remove the next line if you don't want to depend on the API
modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}"
common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
common(project(path: ":fabric-like", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":fabric-like", configuration: "transformProductionFabric")) { transitive false }
modApi("me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_config_version}") {
exclude(group: "net.fabricmc.fabric-api")
}
modApi("com.terraformersmc:modmenu:${rootProject.modmenu_version}") {
exclude(group: "net.fabricmc.fabric-api")
}
}
processResources {
@ -37,9 +37,11 @@ processResources {
filesMatching("fabric.mod.json") {
expand "version": project.version,
"description": rootProject.mod_description,
"minecraft_version": rootProject.minecraft_version,
"architectury_version": rootProject.architectury_version
}
"compatible_minecraft_versions": rootProject.compatible_minecraft_versions,
"infrastructury_version": rootProject.infrastructury_version,
"cloth_config_version": rootProject.cloth_config_version,
"cloth_config_old": (rootProject.mcVer == "1.16.5" || rootProject.mcVer == "1.17.1") ? "2" : ""
}
}
shadowJar {

View File

@ -1,11 +1,11 @@
package com.mrmelon54.WirelessRedstone.fabric;
import com.mrmelon54.WirelessRedstone.fabriclike.WirelessRedstoneFabricLike;
import com.mrmelon54.WirelessRedstone.WirelessRedstone;
import net.fabricmc.api.ModInitializer;
public class WirelessRedstoneFabric implements ModInitializer {
@Override
public void onInitialize() {
WirelessRedstoneFabricLike.init();
WirelessRedstone.init();
}
}

View File

@ -18,6 +18,9 @@
"entrypoints": {
"main": [
"com.mrmelon54.WirelessRedstone.fabric.WirelessRedstoneFabric"
],
"modmenu": [
"com.mrmelon54.WirelessRedstone.ModMenuIntegration"
]
},
"mixins": [
@ -26,7 +29,8 @@
],
"depends": {
"fabric": "*",
"minecraft": "${minecraft_version}",
"architectury": ">=${architectury_version}"
"minecraft": $compatible_minecraft_versions,
"infrastructury": ">=${infrastructury_version}",
"cloth-config${cloth_config_old}": ">=${cloth_config_version}"
}
}

View File

@ -1,7 +1,6 @@
{
"required": true,
"package": "com.mrmelon54.WirelessRedstone.mixin.fabric",
"compatibilityLevel": "JAVA_17",
"minVersion": "0.8",
"client": [
],

View File

@ -29,11 +29,8 @@ configurations {
dependencies {
forge "net.minecraftforge:forge:${rootProject.forge_version}"
// Remove the next line if you don't want to depend on the API
modApi "dev.architectury:architectury-forge:${rootProject.architectury_version}"
common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false }
modApi "me.shedaniel.cloth:cloth-config-forge:${rootProject.cloth_config_version}"
}
processResources {
@ -42,9 +39,10 @@ processResources {
filesMatching("META-INF/mods.toml") {
expand "version": project.version,
"description": rootProject.mod_description,
"minecraft_version": rootProject.minecraft_version,
"architectury_version": rootProject.architectury_version
}
"compatible_minecraft_versions": rootProject.compatible_forge_versions,
"infrastructury_version": rootProject.infrastructury_version,
"cloth_config_version": rootProject.cloth_config_version
}
}
shadowJar {

View File

@ -1,14 +1,12 @@
package com.mrmelon54.WirelessRedstone.forge;
import com.mrmelon54.WirelessRedstone.WirelessRedstone;
import dev.architectury.platform.forge.EventBuses;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
@Mod(WirelessRedstone.MOD_ID)
public class WirelessRedstoneForge {
public WirelessRedstoneForge() {
// Submit our event bus to let architectury register our content on the right time
EventBuses.registerModEventBus(WirelessRedstone.MOD_ID, FMLJavaModLoadingContext.get().getModEventBus());
WirelessRedstone.init();
}

View File

@ -9,18 +9,26 @@ version = "${version}"
displayName = "Wireless Redstone"
authors = "MrMelon54"
description = "${description}"
logoFile = "/icon.png"
logoFile = "icon.png"
displayURL = "https://mrmelon54.com/minecraft/wireless-redstone"
[[dependencies.wireless_redstone]]
modId = "minecraft"
mandatory = true
versionRange = "${minecraft_version}"
versionRange = "${compatible_minecraft_versions}"
ordering = "NONE"
side = "BOTH"
[[dependencies.wireless_redstone]]
modId = "architectury"
modId = "infrastructury"
mandatory = true
versionRange = "[${architectury_version},)"
versionRange = "[${infrastructury_version},)"
ordering = "NONE"
side = "BOTH"
[[dependencies.wireless_redstone]]
modId = "cloth_config"
mandatory = true
versionRange = "[${cloth_config_version},)"
ordering = "AFTER"
side = "BOTH"

View File

@ -1,7 +1,6 @@
{
"required": true,
"package": "com.mrmelon54.WirelessRedstone.mixin.forge",
"compatibilityLevel": "JAVA_17",
"minVersion": "0.8",
"client": [
],

View File

@ -1,23 +1,13 @@
org.gradle.jvmargs=-Xmx4096M
minecraft_version=1.20.4
enabled_platforms=quilt,fabric,forge
archives_base_name=wireless_redstone
mod_id=wireless_redstone
mod_name=Wireless Redstone
mod_version=1.0.2
mod_version=0.0.1
mod_description=Wireless Redstone, what more can I say?
maven_group=com.mrmelon54.WirelessRedstone
architectury_version=11.0.11
infrastructury_version=0.1.6+11
fabric_loader_version=0.15.6
fabric_api_version=0.95.4+1.20.4
forge_version=1.20.4-49.0.26
quilt_loader_version=0.23.1
quilt_fabric_api_version=7.4.0+0.90.0-1.20.1
libgui_version=9.2.2+1.20.2
# Plugin versions
manifold_version=2024.1.+

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -1,10 +0,0 @@
{
"modid": "wireless_redstone",
"modname": "Wireless Redstone",
"modclass": "WirelessRedstone",
"modgroup": "com.mrmelon54.WirelessRedstone",
"moddesc": "Wireless Redstone, what more can I say?",
"modwebsite": "https://mrmelon54.com/minecraft/wireless-redstone",
"modsource": "https://github.com/mrmelon54/wireless_redstone",
"modissue": "https://github.com/mrmelon54/wireless_redstone/issues"
}

86
neoforge/build.gradle Normal file
View File

@ -0,0 +1,86 @@
plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
}
repositories {
maven { url "https://maven.neoforged.net/releases/" }
}
architectury {
platformSetupLoomIde()
neoForge()
}
loom {
accessWidenerPath = project(":common").loom.accessWidenerPath
}
configurations {
common
shadowCommon // Don't use shadow from the shadow plugin since it *excludes* files.
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
developmentNeoForge.extendsFrom common
}
dependencies {
neoForge "net.neoforged:neoforge:${rootProject.neoforge_version}"
modApi "me.shedaniel.cloth:cloth-config-neoforge:${rootProject.cloth_config_version}"
}
processResources {
inputs.property "version", project.version
filesMatching("META-INF/mods.toml") {
expand "version": project.version,
"description": rootProject.mod_description,
"compatible_minecraft_versions": rootProject.compatible_forge_versions,
"infrastructury_version": rootProject.infrastructury_version,
"cloth_config_version": rootProject.cloth_config_version
}
}
shadowJar {
exclude "fabric.mod.json"
exclude "architectury.common.json"
configurations = [project.configurations.shadowCommon]
archiveClassifier.set "dev-shadow"
}
remapJar {
input.set shadowJar.archiveFile
dependsOn shadowJar
archiveClassifier.set null
}
jar {
archiveClassifier.set "dev"
}
sourcesJar {
def commonSources = project(":common").sourcesJar
dependsOn commonSources
from commonSources.archiveFile.map { zipTree(it) }
}
components.java {
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
skip()
}
}
publishing {
publications {
mavenNeoForge(MavenPublication) {
artifactId = rootProject.archives_base_name + "-" + project.name
from components.java
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
}
}

View File

@ -0,0 +1 @@
loom.platform=neoforge

View File

@ -0,0 +1,11 @@
package com.mrmelon54.WirelessRedstone.neoforge;
import com.mrmelon54.WirelessRedstone.WirelessRedstone;
import net.neoforged.fml.common.Mod;
@Mod(WirelessRedstone.MOD_ID)
public class WirelessRedstoneNeoForge {
public WirelessRedstoneNeoForge() {
WirelessRedstone.init();
}
}

View File

@ -0,0 +1,34 @@
modLoader = "javafml"
loaderVersion = "*"
issueTrackerURL = "https://github.com/mrmelon54/wireless_redstone/issues"
license = "GPL-3.0-only"
[[mods]]
modId = "wireless_redstone"
version = "${version}"
displayName = "Wireless Redstone"
authors = "MrMelon54"
description = "${description}"
logoFile = "icon.png"
displayURL = "https://mrmelon54.com/minecraft/wireless-redstone"
[[dependencies.wireless_redstone]]
modId = "minecraft"
mandatory = true
versionRange = "${compatible_minecraft_versions}"
ordering = "NONE"
side = "BOTH"
[[dependencies.wireless_redstone]]
modId = "infrastructury"
mandatory = true
versionRange = "[${infrastructury_version},)"
ordering = "NONE"
side = "BOTH"
[[dependencies.wireless_redstone]]
modId = "cloth_config"
mandatory = true
versionRange = "[${cloth_config_version},)"
ordering = "AFTER"
side = "BOTH"

View File

@ -0,0 +1,6 @@
{
"pack": {
"description": "Wireless Redstone",
"pack_format": 15
}
}

View File

@ -0,0 +1,12 @@
{
"required": true,
"package": "com.mrmelon54.WirelessRedstone.mixin.neoforge",
"minVersion": "0.8",
"client": [
],
"mixins": [
],
"injectors": {
"defaultRequire": 1
}
}

View File

@ -25,18 +25,18 @@ configurations {
dependencies {
modImplementation "org.quiltmc:quilt-loader:${rootProject.quilt_loader_version}"
modApi "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${rootProject.quilt_fabric_api_version}"
// Remove the next few lines if you don't want to depend on the API
modApi("dev.architectury:architectury-fabric:${rootProject.architectury_version}") {
// We must not pull Fabric Loader from Architectury Fabric
exclude group: "net.fabricmc"
modApi("org.quiltmc.quilted-fabric-api:quilted-fabric-api:${rootProject.quilt_fabric_api_version}") {
exclude group: "net.fabricmc.fabric-api"
}
common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionQuilt")) { transitive false }
common(project(path: ":fabric-like", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":fabric-like", configuration: "transformProductionQuilt")) { transitive false }
modApi("me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_config_version}") {
exclude(group: "net.fabricmc")
exclude(group: "net.fabricmc.fabric-api")
}
modApi("com.terraformersmc:modmenu:${rootProject.modmenu_version}") {
exclude(group: "net.fabricmc")
exclude(group: "net.fabricmc.fabric-api")
}
}
processResources {
@ -47,8 +47,9 @@ processResources {
expand "group": rootProject.maven_group,
"version": project.version,
"description": rootProject.mod_description,
"minecraft_version": rootProject.minecraft_version,
"architectury_version": rootProject.architectury_version
"compatible_minecraft_versions": rootProject.compatible_minecraft_versions,
"infrastructury_version": rootProject.infrastructury_version,
"cloth_config_version": rootProject.cloth_config_version
}
}

View File

@ -1,12 +1,12 @@
package com.mrmelon54.WirelessRedstone.quilt;
import com.mrmelon54.WirelessRedstone.fabriclike.WirelessRedstoneFabricLike;
import com.mrmelon54.WirelessRedstone.WirelessRedstone;
import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.qsl.base.api.entrypoint.ModInitializer;
public class WirelessRedstoneQuilt implements ModInitializer {
@Override
public void onInitialize(ModContainer mod) {
WirelessRedstoneFabricLike.init();
WirelessRedstone.init();
}
}

View File

@ -26,6 +26,9 @@
"entrypoints": {
"init": [
"com.mrmelon54.WirelessRedstone.quilt.WirelessRedstoneQuilt"
],
"modmenu": [
"com.mrmelon54.WirelessRedstone.ModMenuIntegration"
]
},
"depends": [
@ -39,15 +42,19 @@
},
{
"id": "minecraft",
"version": "${minecraft_version}"
"version": $compatible_minecraft_versions
},
{
"id": "architectury",
"version": ">=${architectury_version}"
"id": "infrastructury",
"version": ">=${infrastructury_version}"
},
{
"id": "cloth-config",
"version": ">=${cloth_config_version}"
}
]
},
"minecraft": {
"environment": "*"
"environment": "client"
}
}

View File

@ -1,7 +1,6 @@
{
"required": true,
"package": "com.mrmelon54.WirelessRedstone.mixin.fabric",
"compatibilityLevel": "JAVA_17",
"package": "com.mrmelon54.WirelessRedstone.mixin.quilt",
"minVersion": "0.8",
"client": [
],

14
resolveversions.sh Normal file
View File

@ -0,0 +1,14 @@
#!/bin/bash
versions=()
# Loop trough everything in the version properties folder
for d in versionProperties/*; do
# Get the name of the version that is going to be compiled
version=$(echo "$d" | sed "s/versionProperties\///" | sed "s/.properties//")
versions+=("{\"mc\":\"$version\"}")
done
versionsJson=$(jo -a -- "${versions[@]}")
echo "matrix={\"include\":${versionsJson}}"

View File

@ -3,14 +3,78 @@ pluginManagement {
maven { url "https://maven.fabricmc.net/" }
maven { url "https://maven.architectury.dev/" }
maven { url "https://maven.minecraftforge.net/" }
maven { url "https://maven.neoforged.net/releases/" }
maven { url "https://maven.parchmentmc.org" }
gradlePluginPortal()
}
}
gradle.ext.set("versionStr", "")
gradle.ext.set("compatible_forge_versions", "")
gradle.ext.set("forgix_merged_jar", "")
// Loads the version.properties
def loadProperties() {
def defaultMcVersion = ""
def mcVersion = ""
def mcVers = fileTree("versionProperties").files.name // Get all the files in "versionProperties"
for (int i = 0; i < mcVers.size(); i++) {
mcVers[i] = mcVers[i].replaceAll("\\.properties", "") // As we are getting the file names, we should remove the ".properties" at the end to get the versions
}
assert mcVers.size > 0
mcVers.sort() // Sort so it always goes from oldest to newest
defaultMcVersion = mcVers[mcVers.size - 1]
File mcVerPropsFile = file("mcver.properties")
if (!mcVerPropsFile.exists()) {
mcVerPropsFile.text = "# Modify this property to edit the local Minecraft version to use when compiling\nmcVer=" + defaultMcVersion + "\n"
}
println "Avalible MC versions: ${mcVers}"
if (hasProperty("mcVer")) {
println "Using mcVer command line argument"
mcVersion = mcVer
} else {
println "Using mcver.properties file"
def mcVerProps = new Properties()
mcVerProps.load(new FileInputStream(mcVerPropsFile))
mcVersion = mcVerProps.get("mcVer")
}
int mcIndex = mcVers.indexOf(mcVersion)
if (mcIndex == -1) {
println "No mcVer set or the set mcVer is invalid! Defaulting to ${defaultMcVersion}."
println "Tip: Use -PmcVer=\"${defaultMcVersion}\" in cmd arg to set mcVer."
mcVersion = defaultMcVersion
mcIndex = mcVers.indexOf(defaultMcVersion)
assert mcIndex != -1
}
println "Loading properties file at " + mcVersion + ".properties"
def props = new Properties()
props.load(new FileInputStream("$rootDir/versionProperties/" + "$mcVersion" + ".properties"))
props.each { prop ->
gradle.ext.set(prop.key, prop.value)
// println "Added prop [key:" + prop.key + ", value:" + prop.value + "]"
}
gradle.ext.mcVers = mcVers
gradle.ext.mcIndex = mcIndex
}
loadProperties()
// include projects
include("common")
include("fabric-like")
include("fabric")
include("quilt")
include("forge")
var builds_for = ((String) gradle.builds_for).split(",")
for (loader in builds_for) {
def l = loader.strip()
println "Adding loader " + l
include(l)
}
rootProject.name = "wireless_redstone"