[CHORE] Backport from 1.20.3
This commit is contained in:
@@ -9,7 +9,7 @@ pipeline {
|
||||
stage("Notify Discord") {
|
||||
steps {
|
||||
discordSend webhookURL: env.FDD_WH_ADMIN,
|
||||
title: "Deploy Started: CraterLib 1.20.3 Deploy #${BUILD_NUMBER}",
|
||||
title: "Deploy Started: CraterLib 1.20.2 Deploy #${BUILD_NUMBER}",
|
||||
link: env.BUILD_URL,
|
||||
result: 'SUCCESS',
|
||||
description: "Build: [${BUILD_NUMBER}](${env.BUILD_URL})"
|
||||
@@ -38,7 +38,7 @@ pipeline {
|
||||
deleteDir()
|
||||
|
||||
discordSend webhookURL: env.FDD_WH_ADMIN,
|
||||
title: "CraterLib 1.20.3 Deploy #${BUILD_NUMBER}",
|
||||
title: "CraterLib 1.20.2 Deploy #${BUILD_NUMBER}",
|
||||
link: env.BUILD_URL,
|
||||
result: currentBuild.currentResult,
|
||||
description: "Build: [${BUILD_NUMBER}](${env.BUILD_URL})\nStatus: ${currentBuild.currentResult}"
|
||||
|
@@ -13,7 +13,7 @@ pipeline {
|
||||
stage("Notify Discord") {
|
||||
steps {
|
||||
discordSend webhookURL: env.SSS_WEBHOOK,
|
||||
title: "Deploy Started: ${projectName} 1.20.3 Deploy #${BUILD_NUMBER}",
|
||||
title: "Deploy Started: ${projectName} 1.20.2 Deploy #${BUILD_NUMBER}",
|
||||
link: env.BUILD_URL,
|
||||
result: 'SUCCESS',
|
||||
description: "Build: [${BUILD_NUMBER}](${env.BUILD_URL})"
|
||||
@@ -54,7 +54,7 @@ pipeline {
|
||||
versionName: "Snapshot 1.0.${BUILD_NUMBER}",
|
||||
version: "1.0.${BUILD_NUMBER}",
|
||||
modLoaders: "forge|neoforge|fabric|quilt",
|
||||
minecraftVersions: "1.20.3",
|
||||
minecraftVersions: "1.20.2",
|
||||
failWebhook: env.SSS_WEBHOOK,
|
||||
publishWebhooks: "${env.SSS_WEBHOOK}|${env.FDD_WH}"
|
||||
|
||||
|
@@ -2,7 +2,7 @@ archivesBaseName = "${mod_name.replace(" ", "")}-Common-${minecraft_version}"
|
||||
|
||||
dependencies {
|
||||
implementation "com.hypherionmc:rpcsdk:1.0"
|
||||
implementation("me.hypherionmc.sdlink:mcdiscordformatter-1.20.3:2.0.0")
|
||||
implementation("me.hypherionmc.sdlink:mcdiscordformatter-1.19.1:2.0.0")
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
@@ -10,7 +10,7 @@ shadowJar {
|
||||
dependencies {
|
||||
include(dependency("me.hypherionmc.moon-config:core:${moon_config}"))
|
||||
include(dependency("me.hypherionmc.moon-config:toml:${moon_config}"))
|
||||
include(dependency("me.hypherionmc.sdlink:mcdiscordformatter-1.20.3:2.0.0"))
|
||||
include(dependency("me.hypherionmc.sdlink:mcdiscordformatter-1.19.1:2.0.0"))
|
||||
|
||||
relocate 'me.hypherionmc.moonconfig', 'shadow.hypherionmc.moonconfig'
|
||||
relocate 'me.hypherionmc.mcdiscordformatter', 'shadow.hypherionmc.mcdiscordformatter'
|
||||
|
@@ -6,6 +6,7 @@ import net.minecraft.client.gui.components.AbstractButton;
|
||||
import net.minecraft.client.gui.narration.NarratedElementType;
|
||||
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
@@ -22,7 +23,7 @@ public class InternalConfigButton extends AbstractButton {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderWidget(GuiGraphics arg, int i, int j, float f) {
|
||||
public void render(@NotNull GuiGraphics poseStack, int i, int j, float f) {
|
||||
if (cancel) {
|
||||
setMessage(Component.translatable(screen.isEdited() ? "t.clc.cancel_discard" : "gui.cancel"));
|
||||
} else {
|
||||
@@ -30,7 +31,7 @@ public class InternalConfigButton extends AbstractButton {
|
||||
active = screen.isEdited() && !hasErrors;
|
||||
setMessage(Component.translatable(hasErrors ? "t.clc.error" : "t.clc.save"));
|
||||
}
|
||||
super.renderWidget(arg, i, j, f);
|
||||
super.render(poseStack, i, j, f);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -9,28 +9,28 @@ import net.minecraft.commands.Commands;
|
||||
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;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Commands.class)
|
||||
public class CommandMixin {
|
||||
|
||||
@Inject(method = "performCommand",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/commands/Commands;finishParsing(Lcom/mojang/brigadier/ParseResults;Ljava/lang/String;Lnet/minecraft/commands/CommandSourceStack;)Lcom/mojang/brigadier/context/ContextChain;",
|
||||
target = "Lcom/mojang/brigadier/CommandDispatcher;execute(Lcom/mojang/brigadier/ParseResults;)I",
|
||||
shift = At.Shift.BEFORE
|
||||
), cancellable = true
|
||||
)
|
||||
private void injectCommandEvent(ParseResults<CommandSourceStack> stackParseResults, String command, CallbackInfo ci) {
|
||||
private void injectCommandEvent(ParseResults<CommandSourceStack> stackParseResults, String command, CallbackInfoReturnable<Integer> cir) {
|
||||
CraterCommandEvent commandEvent = new CraterCommandEvent(stackParseResults, command);
|
||||
CraterEventBus.INSTANCE.postEvent(commandEvent);
|
||||
if (commandEvent.wasCancelled()) {
|
||||
ci.cancel();
|
||||
cir.setReturnValue(1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (commandEvent.getException() != null) {
|
||||
Throwables.throwIfUnchecked(commandEvent.getException());
|
||||
ci.cancel();
|
||||
cir.setReturnValue(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -7,7 +7,7 @@ dependencies {
|
||||
shade "me.hypherionmc.moon-config:core:${moon_config}"
|
||||
shade "me.hypherionmc.moon-config:toml:${moon_config}"
|
||||
shade "com.hypherionmc:rpcsdk:1.0"
|
||||
shade ("me.hypherionmc.sdlink:mcdiscordformatter-1.20.3:2.0.0")
|
||||
shade ("me.hypherionmc.sdlink:mcdiscordformatter-1.19.1:2.0.0")
|
||||
|
||||
modImplementation("com.terraformersmc:modmenu:${mod_menu_version}") {
|
||||
exclude(group: "net.fabricmc.fabric-api")
|
||||
|
@@ -33,7 +33,7 @@
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.21",
|
||||
"fabric-api": "*",
|
||||
"minecraft": ">=1.20.3",
|
||||
"minecraft": ">=1.20.2",
|
||||
"java": ">=17"
|
||||
}
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ dependencies {
|
||||
shade "me.hypherionmc.moon-config:core:${moon_config}"
|
||||
shade "me.hypherionmc.moon-config:toml:${moon_config}"
|
||||
shade "com.hypherionmc:rpcsdk:1.0"
|
||||
shade ("me.hypherionmc.sdlink:mcdiscordformatter-1.20.3:2.0.0")
|
||||
shade ("me.hypherionmc.sdlink:mcdiscordformatter-1.19.1:2.0.0")
|
||||
|
||||
// Do not edit or remove
|
||||
implementation project(":Common")
|
||||
|
@@ -1,5 +1,5 @@
|
||||
modLoader = "javafml"
|
||||
loaderVersion = "[49,)"
|
||||
loaderVersion = "[48,)"
|
||||
license = "MIT"
|
||||
issueTrackerURL = "https://github.com/firstdarkdev/craterLib/issues"
|
||||
|
||||
@@ -16,16 +16,16 @@ A library mod used by First Dark Development and HypherionSA Mods
|
||||
'''
|
||||
displayTest = "MATCH_VERSION"
|
||||
|
||||
[[dependencies.${ mod_id }]]
|
||||
[[dependencies.${mod_id}]]
|
||||
modId = "forge"
|
||||
mandatory = true
|
||||
versionRange = "[49,)"
|
||||
versionRange = "[48,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies.${ mod_id }]]
|
||||
[[dependencies.${mod_id}]]
|
||||
modId = "minecraft"
|
||||
mandatory = true
|
||||
versionRange = "[1.20.3,1.21)"
|
||||
versionRange = "[1.20.2,1.20.3)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
@@ -1,121 +0,0 @@
|
||||
// Adjust the output jar name here
|
||||
archivesBaseName = "${mod_name.replace(" ", "")}-NeoForge-${minecraft_version}"
|
||||
|
||||
dependencies {
|
||||
shade "me.hypherionmc.moon-config:core:${moon_config}"
|
||||
shade "me.hypherionmc.moon-config:toml:${moon_config}"
|
||||
shade "com.hypherionmc:rpcsdk:1.0"
|
||||
shade ("me.hypherionmc.sdlink:mcdiscordformatter-1.20.3:2.0.0")
|
||||
|
||||
// Do not edit or remove
|
||||
implementation project(":Common")
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
from sourceSets.main.output
|
||||
configurations = [project.configurations.shade]
|
||||
|
||||
dependencies {
|
||||
relocate 'me.hypherionmc.moonconfig', 'shadow.hypherionmc.moonconfig'
|
||||
relocate 'me.hypherionmc.mcdiscordformatter', 'shadow.hypherionmc.mcdiscordformatter'
|
||||
}
|
||||
|
||||
setArchiveClassifier('dev-shadow')
|
||||
}
|
||||
|
||||
/**
|
||||
* ===============================================================================
|
||||
* = DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING =
|
||||
* ===============================================================================
|
||||
*/
|
||||
|
||||
unimined.minecraft {
|
||||
neoForged {
|
||||
loader neoforge_version
|
||||
mixinConfig("${mod_id}.mixins.json", "${mod_id}.neoforge.mixins.json")
|
||||
}
|
||||
}
|
||||
|
||||
remapJar {
|
||||
inputFile.set shadowJar.archiveFile
|
||||
dependsOn shadowJar
|
||||
archiveClassifier.set null
|
||||
}
|
||||
|
||||
jar {
|
||||
archiveClassifier.set "dev"
|
||||
}
|
||||
|
||||
processResources {
|
||||
from project(":Common").sourceSets.main.resources
|
||||
def buildProps = project.properties.clone()
|
||||
|
||||
filesMatching("META-INF/mods.toml") {
|
||||
expand buildProps
|
||||
}
|
||||
}
|
||||
|
||||
compileTestJava.enabled = false
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
source(project(":Common").sourceSets.main.allSource)
|
||||
}
|
||||
|
||||
/**
|
||||
* Publishing Config
|
||||
*/
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
groupId project.group
|
||||
artifactId project.archivesBaseName
|
||||
version project.version
|
||||
from components.java
|
||||
|
||||
artifact(remapJar) {
|
||||
builtBy remapJar
|
||||
}
|
||||
|
||||
pom.withXml {
|
||||
Node pomNode = asNode()
|
||||
pomNode.dependencies.'*'.findAll() {
|
||||
it.artifactId.text() == 'regutils-joined-fabric' ||
|
||||
it.artifactId.text() == 'core' ||
|
||||
it.artifactId.text() == 'toml'
|
||||
}.each() {
|
||||
it.parent().remove(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url "https://maven.firstdark.dev/" + (project.release ? "releases" : "snapshots")
|
||||
credentials {
|
||||
username System.getenv("MAVEN_USER")
|
||||
password System.getenv("MAVEN_PASS")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*publisher {
|
||||
apiKeys {
|
||||
modrinth = System.getenv("MODRINTH_TOKEN")
|
||||
curseforge = System.getenv("CURSE_TOKEN")
|
||||
}
|
||||
|
||||
curseID = curse_id
|
||||
modrinthID = modrinth_id
|
||||
versionType = "release"
|
||||
changelog = rootProject.file("changelog-forge.md")
|
||||
version = "${minecraft_version}-${project.version}"
|
||||
displayName = "[NEOFORGE 1.20.2] CraterLib - ${project.version}"
|
||||
gameVersions = ["1.20.2"]
|
||||
loaders = ["neoforge"]
|
||||
artifact = remapJar
|
||||
}
|
||||
|
||||
publishCurseforge.dependsOn(remapJar)
|
||||
publishModrinth.dependsOn(remapJar)*/
|
@@ -1,28 +0,0 @@
|
||||
package com.hypherionmc.craterlib;
|
||||
|
||||
import com.hypherionmc.craterlib.api.event.client.LateInitEvent;
|
||||
import com.hypherionmc.craterlib.common.NeoForgeServerEvents;
|
||||
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.neoforged.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.neoforged.fml.loading.FMLEnvironment;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
|
||||
@Mod(CraterConstants.MOD_ID)
|
||||
public class CraterLib {
|
||||
|
||||
public CraterLib(IEventBus eventBus) {
|
||||
NeoForge.EVENT_BUS.register(new NeoForgeServerEvents());
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::commonSetup);
|
||||
}
|
||||
|
||||
public void commonSetup(FMLCommonSetupEvent evt) {
|
||||
if (FMLEnvironment.dist.isClient()) {
|
||||
LateInitEvent event = new LateInitEvent(Minecraft.getInstance(), Minecraft.getInstance().options);
|
||||
CraterEventBus.INSTANCE.postEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
package com.hypherionmc.craterlib.client;
|
||||
|
||||
import com.hypherionmc.craterlib.CraterConstants;
|
||||
import com.hypherionmc.craterlib.api.event.client.CraterClientTickEvent;
|
||||
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.neoforge.event.TickEvent;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = CraterConstants.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
|
||||
public class NeoForgeClientEvents {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void clientTick(TickEvent.LevelTickEvent event) {
|
||||
CraterClientTickEvent craterClientTickEvent = new CraterClientTickEvent(Minecraft.getInstance().level);
|
||||
CraterEventBus.INSTANCE.postEvent(craterClientTickEvent);
|
||||
}
|
||||
|
||||
}
|
@@ -1,40 +0,0 @@
|
||||
package com.hypherionmc.craterlib.client;
|
||||
|
||||
import com.hypherionmc.craterlib.core.platform.ClientPlatform;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 16/06/2022
|
||||
*/
|
||||
public class NeoForgeClientHelper implements ClientPlatform {
|
||||
|
||||
public NeoForgeClientHelper() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Minecraft getClientInstance() {
|
||||
return Minecraft.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getClientPlayer() {
|
||||
return Minecraft.getInstance().player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Level getClientLevel() {
|
||||
return Minecraft.getInstance().level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection getClientConnection() {
|
||||
Objects.requireNonNull(Minecraft.getInstance().getConnection(), "Cannot send packets when not in game!");
|
||||
return Minecraft.getInstance().getConnection().getConnection();
|
||||
}
|
||||
}
|
@@ -1,33 +0,0 @@
|
||||
package com.hypherionmc.craterlib.common;
|
||||
|
||||
import com.hypherionmc.craterlib.core.network.CraterNetworkHandler;
|
||||
import com.hypherionmc.craterlib.core.platform.CommonPlatform;
|
||||
import com.hypherionmc.craterlib.network.NeoForgeNetworkHandler;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.neoforged.neoforge.server.ServerLifecycleHooks;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
*/
|
||||
public class NeoForgeCommonHelper implements CommonPlatform {
|
||||
|
||||
public static Map<ResourceLocation, CreativeModeTab> TABS = new HashMap<>();
|
||||
|
||||
public NeoForgeCommonHelper() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraterNetworkHandler createPacketHandler(String modid, boolean requiredClient, boolean requiredServer) {
|
||||
return NeoForgeNetworkHandler.of(modid, requiredClient, requiredServer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MinecraftServer getMCServer() {
|
||||
return ServerLifecycleHooks.getCurrentServer();
|
||||
}
|
||||
}
|
@@ -1,73 +0,0 @@
|
||||
package com.hypherionmc.craterlib.common;
|
||||
|
||||
import com.hypherionmc.craterlib.core.platform.Environment;
|
||||
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.neoforged.fml.ModList;
|
||||
import net.neoforged.fml.loading.FMLLoader;
|
||||
import net.neoforged.fml.loading.FMLPaths;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
*/
|
||||
public class NeoForgeLoaderHelper implements ModloaderEnvironment {
|
||||
|
||||
public NeoForgeLoaderHelper() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFabric() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGameVersion() {
|
||||
return SharedConstants.VERSION_STRING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getGameFolder() {
|
||||
return Minecraft.getInstance().gameDirectory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getConfigFolder() {
|
||||
return FMLPaths.CONFIGDIR.get().toFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getModsFolder() {
|
||||
return FMLPaths.MODSDIR.get().toFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Environment getEnvironment() {
|
||||
switch (FMLLoader.getDist()) {
|
||||
case CLIENT -> {
|
||||
return Environment.CLIENT;
|
||||
}
|
||||
case DEDICATED_SERVER -> {
|
||||
return Environment.SERVER;
|
||||
}
|
||||
}
|
||||
return Environment.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModLoaded(String modid) {
|
||||
return ModList.get().isLoaded(modid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDevEnv() {
|
||||
return !FMLLoader.isProduction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getModCount() {
|
||||
return ModList.get().size();
|
||||
}
|
||||
}
|
@@ -1,40 +0,0 @@
|
||||
package com.hypherionmc.craterlib.common;
|
||||
|
||||
import com.hypherionmc.craterlib.api.event.server.CraterRegisterCommandEvent;
|
||||
import com.hypherionmc.craterlib.api.event.server.CraterServerLifecycleEvent;
|
||||
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStartedEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStartingEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStoppedEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStoppingEvent;
|
||||
|
||||
public class NeoForgeServerEvents {
|
||||
|
||||
@SubscribeEvent
|
||||
public void serverStarting(ServerStartingEvent event) {
|
||||
CraterEventBus.INSTANCE.postEvent(new CraterServerLifecycleEvent.Starting(event.getServer()));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void serverStarted(ServerStartedEvent event) {
|
||||
CraterEventBus.INSTANCE.postEvent(new CraterServerLifecycleEvent.Started());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void serverStopping(ServerStoppingEvent event) {
|
||||
CraterEventBus.INSTANCE.postEvent(new CraterServerLifecycleEvent.Stopping());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void serverStopped(ServerStoppedEvent event) {
|
||||
CraterEventBus.INSTANCE.postEvent(new CraterServerLifecycleEvent.Stopped());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onCommandRegister(RegisterCommandsEvent event) {
|
||||
CraterEventBus.INSTANCE.postEvent(new CraterRegisterCommandEvent(event.getDispatcher()));
|
||||
}
|
||||
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
package com.hypherionmc.craterlib.mixin;
|
||||
|
||||
import com.hypherionmc.craterlib.client.gui.config.CraterConfigScreen;
|
||||
import com.hypherionmc.craterlib.core.config.ConfigController;
|
||||
import com.hypherionmc.craterlib.core.config.ModuleConfig;
|
||||
import com.hypherionmc.craterlib.core.config.annotations.NoConfigScreen;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.neoforged.neoforge.client.ConfigScreenHandler;
|
||||
import net.neoforged.neoforgespi.language.IModInfo;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
*/
|
||||
@Mixin(ConfigScreenHandler.class)
|
||||
public class ConfigScreenHandlerMixin {
|
||||
|
||||
/**
|
||||
* Inject Auto Generated config Screens into forge
|
||||
*
|
||||
* @param selectedMod
|
||||
* @param cir
|
||||
*/
|
||||
@Inject(at = @At("RETURN"), method = "getScreenFactoryFor", cancellable = true, remap = false)
|
||||
private static void injectConfigScreen(IModInfo selectedMod, CallbackInfoReturnable<Optional<BiFunction<Minecraft, Screen, Screen>>> cir) {
|
||||
ConfigController.getMonitoredConfigs().forEach((conf, watcher) -> {
|
||||
if (!conf.getClass().isAnnotationPresent(NoConfigScreen.class)) {
|
||||
ModuleConfig config = (ModuleConfig) conf;
|
||||
if (config.getModId().equals(selectedMod.getModId())) {
|
||||
cir.setReturnValue(
|
||||
Optional.of((minecraft, screen) -> new CraterConfigScreen(config, screen))
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@@ -1,129 +0,0 @@
|
||||
package com.hypherionmc.craterlib.network;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.hypherionmc.craterlib.core.network.CraterNetworkHandler;
|
||||
import com.hypherionmc.craterlib.core.network.CraterPacket;
|
||||
import com.hypherionmc.craterlib.core.network.PacketDirection;
|
||||
import com.hypherionmc.craterlib.core.platform.ClientPlatform;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.neoforged.fml.LogicalSide;
|
||||
import net.neoforged.neoforge.common.util.LogicalSidedProvider;
|
||||
import net.neoforged.neoforge.network.NetworkEvent;
|
||||
import net.neoforged.neoforge.network.NetworkRegistry;
|
||||
import net.neoforged.neoforge.network.PlayNetworkDirection;
|
||||
import net.neoforged.neoforge.network.simple.MessageFunctions;
|
||||
import net.neoforged.neoforge.network.simple.SimpleChannel;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* Partly inspired by and based on <a href="https://github.com/Fuzss/puzzleslib/blob/1.19/Forge/src/main/java/fuzs/puzzleslib/network/ForgeNetworkHandler.java">...</a>
|
||||
*/
|
||||
public class NeoForgeNetworkHandler implements CraterNetworkHandler {
|
||||
|
||||
private static final Map<String, NeoForgeNetworkHandler> NETWORK_HANDLERS = Maps.newConcurrentMap();
|
||||
private static final String PROTOCOL = Integer.toString(1);
|
||||
|
||||
private final SimpleChannel channel;
|
||||
|
||||
private final boolean clientRequired;
|
||||
|
||||
private final boolean serverRequired;
|
||||
|
||||
private final AtomicInteger packetID = new AtomicInteger();
|
||||
|
||||
private NeoForgeNetworkHandler(SimpleChannel channel, boolean clientRequired, boolean serverRequired) {
|
||||
this.channel = channel;
|
||||
this.clientRequired = clientRequired;
|
||||
this.serverRequired = serverRequired;
|
||||
}
|
||||
|
||||
public synchronized static CraterNetworkHandler of(String modId, boolean clientRequired, boolean serverRequired) {
|
||||
NeoForgeNetworkHandler handler = NETWORK_HANDLERS.computeIfAbsent(modId, modId1 -> new NeoForgeNetworkHandler(buildSimpleChannel(modId1, clientRequired, serverRequired), clientRequired, serverRequired));
|
||||
if (handler.clientRequired != clientRequired)
|
||||
throw new IllegalArgumentException("client channel settings mismatch, expected %s, but was %s".formatted(handler.clientRequired, clientRequired));
|
||||
if (handler.serverRequired != serverRequired)
|
||||
throw new IllegalArgumentException("server channel settings mismatch, expected %s, but was %s".formatted(handler.serverRequired, serverRequired));
|
||||
return handler;
|
||||
}
|
||||
|
||||
private static SimpleChannel buildSimpleChannel(String modId, boolean clientAcceptsVanillaOrMissing, boolean serverAcceptsVanillaOrMissing) {
|
||||
return NetworkRegistry.ChannelBuilder
|
||||
.named(new ResourceLocation(modId, "crater_network"))
|
||||
.networkProtocolVersion(() -> PROTOCOL)
|
||||
.clientAcceptedVersions(clientAcceptsVanillaOrMissing ? NetworkRegistry.acceptMissingOr(PROTOCOL) : PROTOCOL::equals)
|
||||
.serverAcceptedVersions(serverAcceptsVanillaOrMissing ? NetworkRegistry.acceptMissingOr(PROTOCOL) : PROTOCOL::equals)
|
||||
.simpleChannel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends CraterPacket<T>> void registerPacket(Class<T> clazz, Supplier<T> supplier, PacketDirection packetDirection) {
|
||||
BiConsumer<T, FriendlyByteBuf> encoder = CraterPacket::write;
|
||||
Function<FriendlyByteBuf, T> decoder = buf -> {
|
||||
T packet = supplier.get();
|
||||
packet.read(buf);
|
||||
return packet;
|
||||
};
|
||||
|
||||
BiConsumer<T, NetworkEvent.Context> handler = (packet, ctx) -> {
|
||||
LogicalSide expectedSide = getSideFromDirection(packetDirection);
|
||||
LogicalSide currentSide = ctx.getDirection().getReceptionSide();
|
||||
|
||||
if (expectedSide != currentSide) {
|
||||
throw new IllegalStateException(String.format("Received message on wrong side, expected %s, was %s", expectedSide, currentSide));
|
||||
}
|
||||
|
||||
ctx.enqueueWork(() -> {
|
||||
Player player;
|
||||
if (packetDirection == PacketDirection.TO_CLIENT) {
|
||||
player = ClientPlatform.INSTANCE.getClientPlayer();
|
||||
} else {
|
||||
player = ctx.getSender();
|
||||
}
|
||||
packet.handle(player, LogicalSidedProvider.WORKQUEUE.get(expectedSide));
|
||||
});
|
||||
ctx.setPacketHandled(true);
|
||||
};
|
||||
|
||||
this.channel.registerMessage(this.packetID.getAndIncrement(), clazz, encoder(encoder), decoder(decoder), buildHandler(handler));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet<?> toServerBound(CraterPacket<?> packet) {
|
||||
return this.channel.toVanillaPacket(packet, PlayNetworkDirection.PLAY_TO_SERVER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet<?> toClientBound(CraterPacket<?> packet) {
|
||||
return this.channel.toVanillaPacket(packet, PlayNetworkDirection.PLAY_TO_CLIENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendToServer(CraterPacket<?> packet) {
|
||||
CraterNetworkHandler.super.sendToServer(packet);
|
||||
}
|
||||
|
||||
private LogicalSide getSideFromDirection(PacketDirection direction) {
|
||||
return direction == PacketDirection.TO_CLIENT ? LogicalSide.CLIENT : LogicalSide.SERVER;
|
||||
}
|
||||
|
||||
private <T> MessageFunctions.MessageEncoder<T> encoder(BiConsumer<T, FriendlyByteBuf> encoder) {
|
||||
return encoder::accept;
|
||||
}
|
||||
|
||||
private <T> MessageFunctions.MessageDecoder<T> decoder(Function<FriendlyByteBuf, T> decoder) {
|
||||
return decoder::apply;
|
||||
}
|
||||
|
||||
private <T> MessageFunctions.MessageConsumer<T> buildHandler(BiConsumer<T, NetworkEvent.Context> handler) {
|
||||
return (message, ctx) -> handler.accept(message, ctx);
|
||||
}
|
||||
}
|
@@ -1,31 +0,0 @@
|
||||
modLoader = "javafml"
|
||||
loaderVersion = "[1,)"
|
||||
license = "MIT"
|
||||
issueTrackerURL = "https://github.com/firstdarkdev/craterLib/issues"
|
||||
|
||||
[[mods]]
|
||||
modId = "${mod_id}"
|
||||
version = "${version}"
|
||||
displayName = "${mod_name}"
|
||||
displayURL = "https://modrinth.com/mod/craterlib"
|
||||
logoFile = "craterlib_logo.png"
|
||||
#credits="Thanks for this example mod goes to Java"
|
||||
authors = "${mod_author}, Zenith"
|
||||
description = '''
|
||||
A library mod used by First Dark Development and HypherionSA Mods
|
||||
'''
|
||||
displayTest = "MATCH_VERSION"
|
||||
|
||||
[[dependencies.${ mod_id }]]
|
||||
modId = "neoforge"
|
||||
mandatory = true
|
||||
versionRange = "[20.3,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies.${ mod_id }]]
|
||||
modId = "minecraft"
|
||||
mandatory = true
|
||||
versionRange = "[1.20.3,1.21)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
@@ -1 +0,0 @@
|
||||
com.hypherionmc.craterlib.client.NeoForgeClientHelper
|
@@ -1 +0,0 @@
|
||||
com.hypherionmc.craterlib.common.NeoForgeCommonHelper
|
@@ -1 +0,0 @@
|
||||
com.hypherionmc.craterlib.common.NeoForgeLoaderHelper
|
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "com.hypherionmc.craterlib.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
],
|
||||
"client": [
|
||||
"ConfigScreenHandlerMixin"
|
||||
],
|
||||
"server": [
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 48 KiB |
@@ -7,7 +7,7 @@ plugins {
|
||||
}
|
||||
|
||||
ext {
|
||||
release = project.properties['release'] ?: false
|
||||
release=project.properties['release'] ?: false
|
||||
}
|
||||
|
||||
var base_version = "${version_major}.${version_minor}"
|
||||
@@ -68,7 +68,7 @@ subprojects {
|
||||
'Implementation-Version' : project.jar.archiveVersion,
|
||||
'Implementation-Vendor' : mod_author,
|
||||
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
||||
'Timestamp' : System.currentTimeMillis(),
|
||||
'Timestamp' : System.currentTimeMillis(),
|
||||
'Built-On-Java' : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})",
|
||||
'Build-On-Minecraft' : minecraft_version
|
||||
])
|
||||
|
@@ -3,25 +3,33 @@ version_major=1
|
||||
version_minor=1
|
||||
version_patch=0
|
||||
project_group=com.hypherionmc.craterlib
|
||||
|
||||
#Mod
|
||||
mod_author=HypherionSA
|
||||
mod_id=craterlib
|
||||
mod_name=CraterLib
|
||||
|
||||
# Shared
|
||||
minecraft_version=1.20.3
|
||||
minecraft_version=1.20.2
|
||||
|
||||
# Fabric
|
||||
fabric_loader=0.15.0
|
||||
fabric_api=0.91.1+1.20.3
|
||||
fabric_loader=0.14.22
|
||||
fabric_api=0.89.0+1.20.2
|
||||
|
||||
# Forge
|
||||
forge_version=49.0.2
|
||||
forge_version=48.0.6
|
||||
|
||||
# NeoForged
|
||||
neoforge_version=8-beta
|
||||
neoforge_version=64-beta
|
||||
|
||||
# Dependencies
|
||||
mod_menu_version=8.0.0-beta.2
|
||||
moon_config=1.0.9
|
||||
|
||||
# Publishing
|
||||
curse_id=867099
|
||||
modrinth_id=Nn8Wasaq
|
||||
|
||||
# Gradle
|
||||
org.gradle.jvmargs=-Xmx3G
|
||||
org.gradle.daemon=false
|
@@ -11,5 +11,4 @@ pluginManagement {
|
||||
}
|
||||
|
||||
rootProject.name = 'CraterLib'
|
||||
include("Common", "Fabric", "Forge")
|
||||
include 'NeoForge'
|
||||
include("Common", "Fabric", "Forge")
|
Reference in New Issue
Block a user