Compare commits
9 Commits
old/1.20.2
...
old/1.20.4
Author | SHA1 | Date | |
---|---|---|---|
76bc39ec33 | |||
26a473b013 | |||
62ee369226 | |||
11ec3b84e3 | |||
8b61b45d94 | |||
8e629a674c | |||
0813bc416c | |||
1dad912ec1 | |||
c5cccc3f3b |
@@ -9,7 +9,7 @@ pipeline {
|
||||
stage("Notify Discord") {
|
||||
steps {
|
||||
discordSend webhookURL: env.FDD_WH_ADMIN,
|
||||
title: "Deploy Started: CraterLib 1.20.2 Deploy #${BUILD_NUMBER}",
|
||||
title: "Deploy Started: CraterLib 1.20.4 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.2 Deploy #${BUILD_NUMBER}",
|
||||
title: "CraterLib 1.20.4 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.2 Deploy #${BUILD_NUMBER}",
|
||||
title: "Deploy Started: ${projectName} 1.20.4 Deploy #${BUILD_NUMBER}",
|
||||
link: env.BUILD_URL,
|
||||
result: 'SUCCESS',
|
||||
description: "Build: [${BUILD_NUMBER}](${env.BUILD_URL})"
|
||||
@@ -54,7 +54,7 @@ pipeline {
|
||||
versionName: "Snapshot 1.1.${BUILD_NUMBER}",
|
||||
version: "1.1.${BUILD_NUMBER}",
|
||||
modLoaders: "forge|neoforge|fabric|quilt",
|
||||
minecraftVersions: "1.20.2",
|
||||
minecraftVersions: "1.20.4",
|
||||
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.19.1:2.0.0")
|
||||
implementation("me.hypherionmc.sdlink:mcdiscordformatter-1.20.3: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.19.1:2.0.0"))
|
||||
include(dependency("me.hypherionmc.sdlink:mcdiscordformatter-1.20.3:2.0.0"))
|
||||
|
||||
relocate 'me.hypherionmc.moonconfig', 'shadow.hypherionmc.moonconfig'
|
||||
relocate 'me.hypherionmc.mcdiscordformatter', 'shadow.hypherionmc.mcdiscordformatter'
|
||||
|
@@ -6,7 +6,6 @@ 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
|
||||
@@ -23,7 +22,7 @@ public class InternalConfigButton extends AbstractButton {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(@NotNull GuiGraphics poseStack, int i, int j, float f) {
|
||||
protected void renderWidget(GuiGraphics arg, int i, int j, float f) {
|
||||
if (cancel) {
|
||||
setMessage(Component.translatable(screen.isEdited() ? "t.clc.cancel_discard" : "gui.cancel"));
|
||||
} else {
|
||||
@@ -31,7 +30,7 @@ public class InternalConfigButton extends AbstractButton {
|
||||
active = screen.isEdited() && !hasErrors;
|
||||
setMessage(Component.translatable(hasErrors ? "t.clc.error" : "t.clc.save"));
|
||||
}
|
||||
super.render(poseStack, i, j, f);
|
||||
super.renderWidget(arg, 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.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(Commands.class)
|
||||
public class CommandMixin {
|
||||
|
||||
@Inject(method = "performCommand",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lcom/mojang/brigadier/CommandDispatcher;execute(Lcom/mojang/brigadier/ParseResults;)I",
|
||||
target = "Lnet/minecraft/commands/Commands;finishParsing(Lcom/mojang/brigadier/ParseResults;Ljava/lang/String;Lnet/minecraft/commands/CommandSourceStack;)Lcom/mojang/brigadier/context/ContextChain;",
|
||||
shift = At.Shift.BEFORE
|
||||
), cancellable = true
|
||||
)
|
||||
private void injectCommandEvent(ParseResults<CommandSourceStack> stackParseResults, String command, CallbackInfoReturnable<Integer> cir) {
|
||||
private void injectCommandEvent(ParseResults<CommandSourceStack> stackParseResults, String command, CallbackInfo ci) {
|
||||
CraterCommandEvent commandEvent = new CraterCommandEvent(stackParseResults, command);
|
||||
CraterEventBus.INSTANCE.postEvent(commandEvent);
|
||||
if (commandEvent.wasCancelled()) {
|
||||
cir.setReturnValue(1);
|
||||
ci.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (commandEvent.getException() != null) {
|
||||
Throwables.throwIfUnchecked(commandEvent.getException());
|
||||
cir.setReturnValue(1);
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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.19.1:2.0.0")
|
||||
shade ("me.hypherionmc.sdlink:mcdiscordformatter-1.20.3:2.0.0")
|
||||
|
||||
modImplementation("com.terraformersmc:modmenu:${mod_menu_version}") {
|
||||
exclude(group: "net.fabricmc.fabric-api")
|
||||
@@ -116,8 +116,8 @@ publisher {
|
||||
versionType = "release"
|
||||
changelog = "https://raw.githubusercontent.com/hypherionmc/changelogs/main/craterlib/changelog-fabric.md"
|
||||
version = "${minecraft_version}-${project.version}"
|
||||
displayName = "[FABRIC/QUILT 1.20.2] CraterLib - ${project.version}"
|
||||
gameVersions = ["1.20.2"]
|
||||
displayName = "[FABRIC/QUILT 1.20.4] CraterLib - ${project.version}"
|
||||
gameVersions = ["1.20.4"]
|
||||
loaders = ["fabric", "quilt"]
|
||||
artifact = remapJar
|
||||
|
||||
|
@@ -33,7 +33,7 @@
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.21",
|
||||
"fabric-api": "*",
|
||||
"minecraft": ">=1.20.2",
|
||||
"minecraft": ">=1.20.4",
|
||||
"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.19.1:2.0.0")
|
||||
shade ("me.hypherionmc.sdlink:mcdiscordformatter-1.20.3:2.0.0")
|
||||
|
||||
// Do not edit or remove
|
||||
implementation project(":Common")
|
||||
@@ -111,8 +111,8 @@ publisher {
|
||||
versionType = "release"
|
||||
changelog = "https://raw.githubusercontent.com/hypherionmc/changelogs/main/craterlib/changelog-forge.md"
|
||||
version = "${minecraft_version}-${project.version}"
|
||||
displayName = "[FORGE 1.20.2] CraterLib - ${project.version}"
|
||||
gameVersions = ["1.20.2"]
|
||||
displayName = "[FORGE 1.20.4] CraterLib - ${project.version}"
|
||||
gameVersions = ["1.20.4"]
|
||||
loaders = ["forge"]
|
||||
artifact = remapJar
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
modLoader = "javafml"
|
||||
loaderVersion = "[48,)"
|
||||
loaderVersion = "[49,)"
|
||||
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 = "[48,)"
|
||||
versionRange = "[49,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies.${mod_id}]]
|
||||
[[dependencies.${ mod_id }]]
|
||||
modId = "minecraft"
|
||||
mandatory = true
|
||||
versionRange = "[1.20.2,1.20.3)"
|
||||
versionRange = "[1.20.4,1.21)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
121
NeoForge/build.gradle
Normal file
121
NeoForge/build.gradle
Normal file
@@ -0,0 +1,121 @@
|
||||
// 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.4] CraterLib - ${project.version}"
|
||||
gameVersions = ["1.20.4"]
|
||||
loaders = ["neoforge"]
|
||||
artifact = remapJar
|
||||
}
|
||||
|
||||
publishCurseforge.dependsOn(remapJar)
|
||||
publishModrinth.dependsOn(remapJar)
|
@@ -0,0 +1,37 @@
|
||||
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 com.hypherionmc.craterlib.core.networking.CraterPacketNetwork;
|
||||
import com.hypherionmc.craterlib.core.networking.PacketRegistry;
|
||||
import com.hypherionmc.craterlib.core.networking.data.PacketSide;
|
||||
import com.hypherionmc.craterlib.network.CraterNeoForgeNetworkHandler;
|
||||
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.fml.loading.FMLLoader;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
|
||||
@Mod(CraterConstants.MOD_ID)
|
||||
public class CraterLib {
|
||||
|
||||
private final PacketRegistry handler;
|
||||
|
||||
public CraterLib(IEventBus eventBus) {
|
||||
NeoForge.EVENT_BUS.register(new NeoForgeServerEvents());
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::commonSetup);
|
||||
handler = new CraterNeoForgeNetworkHandler(FMLLoader.getDist().isClient() ? PacketSide.CLIENT : PacketSide.SERVER);
|
||||
}
|
||||
|
||||
public void commonSetup(FMLCommonSetupEvent evt) {
|
||||
new CraterPacketNetwork(handler);
|
||||
if (FMLEnvironment.dist.isClient()) {
|
||||
LateInitEvent event = new LateInitEvent(Minecraft.getInstance(), Minecraft.getInstance().options);
|
||||
CraterEventBus.INSTANCE.postEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
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();
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
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 new NeoForgeNetworkHandler(modid, requiredClient, requiredServer);
|
||||
//return NeoForgeNetworkHandler.of(modid, requiredClient, requiredServer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MinecraftServer getMCServer() {
|
||||
return ServerLifecycleHooks.getCurrentServer();
|
||||
}
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
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();
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
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()));
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
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))
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,103 @@
|
||||
package com.hypherionmc.craterlib.network;
|
||||
|
||||
import com.hypherionmc.craterlib.CraterConstants;
|
||||
import com.hypherionmc.craterlib.core.networking.PacketRegistry;
|
||||
import com.hypherionmc.craterlib.core.networking.data.PacketContext;
|
||||
import com.hypherionmc.craterlib.core.networking.data.PacketHolder;
|
||||
import com.hypherionmc.craterlib.core.networking.data.PacketSide;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.LogicalSide;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import net.neoforged.neoforge.network.event.RegisterPayloadHandlerEvent;
|
||||
import net.neoforged.neoforge.network.handling.IPayloadHandler;
|
||||
import net.neoforged.neoforge.network.registration.IPayloadRegistrar;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Based on https://github.com/mysticdrew/common-networking/tree/1.20.4
|
||||
*/
|
||||
public class CraterNeoForgeNetworkHandler extends PacketRegistry {
|
||||
|
||||
private final Map<Class<?>, NeoForgePacketContainer> PACKETS = new HashMap<>();
|
||||
|
||||
public CraterNeoForgeNetworkHandler(PacketSide side) {
|
||||
super(side);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void register(final RegisterPayloadHandlerEvent event) {
|
||||
if (!PACKETS.isEmpty()) {
|
||||
PACKETS.forEach((type, container) -> {
|
||||
final IPayloadRegistrar registrar = event.registrar(container.packetId().getNamespace());
|
||||
registrar.common(
|
||||
container.packetId(),
|
||||
container.decoder(),
|
||||
container.handler());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected <T> void registerPacket(PacketHolder<T> container) {
|
||||
if (PACKETS.get(container.messageType()) == null) {
|
||||
var packetContainer = new NeoForgePacketContainer<>(
|
||||
container.messageType(),
|
||||
container.packetId(),
|
||||
container.encoder(),
|
||||
decoder(container.decoder()),
|
||||
buildHandler(container.handler())
|
||||
);
|
||||
|
||||
PACKETS.put(container.messageType(), packetContainer);
|
||||
}
|
||||
}
|
||||
|
||||
private <T> FriendlyByteBuf.Reader<NeoForgePacket<T>> decoder(Function<FriendlyByteBuf, T> decoder) {
|
||||
return (buf -> {
|
||||
T packet = decoder.apply(buf);
|
||||
return new NeoForgePacket<T>(PACKETS.get(packet.getClass()), packet);
|
||||
});
|
||||
}
|
||||
|
||||
public <T> void sendToServer(T packet) {
|
||||
this.sendToServer(packet, false);
|
||||
}
|
||||
|
||||
public <T> void sendToServer(T packet, boolean ignoreCheck) {
|
||||
NeoForgePacketContainer<T> container = PACKETS.get(packet.getClass());
|
||||
try {
|
||||
PacketDistributor.SERVER.noArg().send(new NeoForgePacket<>(container, packet));
|
||||
} catch (Throwable t) {
|
||||
CraterConstants.LOG.error("{} packet not registered on the client, this is needed.", packet.getClass(), t);
|
||||
}
|
||||
}
|
||||
|
||||
public <T> void sendToClient(T packet, ServerPlayer player) {
|
||||
NeoForgePacketContainer<T> container = PACKETS.get(packet.getClass());
|
||||
try {
|
||||
if (player.connection.isConnected(container.packetId())) {
|
||||
PacketDistributor.PLAYER.with(player).send(new NeoForgePacket<>(container, packet));
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
CraterConstants.LOG.error("{} packet not registered on the server, this is needed.", packet.getClass(), t);
|
||||
}
|
||||
}
|
||||
|
||||
private <T, K extends NeoForgePacket<T>> IPayloadHandler<K> buildHandler(Consumer<PacketContext<T>> handler) {
|
||||
return (payload, ctx) -> {
|
||||
try {
|
||||
PacketSide side = ctx.flow().getReceptionSide().equals(LogicalSide.SERVER) ? PacketSide.SERVER : PacketSide.CLIENT;
|
||||
Player player = ctx.player().orElse(null);
|
||||
handler.accept(new PacketContext<>(player, payload.packet(), side));
|
||||
} catch (Throwable t) {
|
||||
CraterConstants.LOG.error("Error handling packet: {} -> ", payload.packet().getClass(), t);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
package com.hypherionmc.craterlib.network;
|
||||
|
||||
import com.hypherionmc.craterlib.core.network.CraterNetworkHandler;
|
||||
import com.hypherionmc.craterlib.core.network.CraterPacket;
|
||||
import com.hypherionmc.craterlib.core.network.PacketDirection;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
|
||||
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>
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class NeoForgeNetworkHandler implements CraterNetworkHandler {
|
||||
|
||||
|
||||
public NeoForgeNetworkHandler(String modid, boolean requiredClient, boolean requiredServer) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends CraterPacket<T>> void registerPacket(Class<T> clazz, Supplier<T> supplier, PacketDirection packetDirection) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet<?> toServerBound(CraterPacket<?> packet) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet<?> toClientBound(CraterPacket<?> packet) {
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package com.hypherionmc.craterlib.network;
|
||||
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
/**
|
||||
* Based on https://github.com/mysticdrew/common-networking/tree/1.20.4
|
||||
*/
|
||||
public record NeoForgePacket<T>(NeoForgePacketContainer<T> container, T packet) implements CustomPacketPayload {
|
||||
|
||||
@Override
|
||||
public void write(FriendlyByteBuf buff)
|
||||
{
|
||||
container().encoder().accept(packet(), buff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation id()
|
||||
{
|
||||
return container().packetId();
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package com.hypherionmc.craterlib.network;
|
||||
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.neoforged.neoforge.network.handling.IPayloadHandler;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
/**
|
||||
* Based on https://github.com/mysticdrew/common-networking/tree/1.20.4
|
||||
*/
|
||||
public record NeoForgePacketContainer<T>(Class<T> messageType,
|
||||
ResourceLocation packetId,
|
||||
BiConsumer<T, FriendlyByteBuf> encoder,
|
||||
FriendlyByteBuf.Reader<NeoForgePacket<T>> decoder,
|
||||
IPayloadHandler<NeoForgePacket<T>> handler) { }
|
31
NeoForge/src/main/resources/META-INF/mods.toml
Normal file
31
NeoForge/src/main/resources/META-INF/mods.toml
Normal file
@@ -0,0 +1,31 @@
|
||||
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.4,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies.${ mod_id }]]
|
||||
modId = "minecraft"
|
||||
mandatory = true
|
||||
versionRange = "[1.20.4,1.21)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
@@ -0,0 +1 @@
|
||||
com.hypherionmc.craterlib.client.NeoForgeClientHelper
|
@@ -0,0 +1 @@
|
||||
com.hypherionmc.craterlib.common.NeoForgeCommonHelper
|
@@ -0,0 +1 @@
|
||||
com.hypherionmc.craterlib.common.NeoForgeLoaderHelper
|
16
NeoForge/src/main/resources/craterlib.neoforge.mixins.json
Normal file
16
NeoForge/src/main/resources/craterlib.neoforge.mixins.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "com.hypherionmc.craterlib.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
],
|
||||
"client": [
|
||||
"ConfigScreenHandlerMixin"
|
||||
],
|
||||
"server": [
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
BIN
NeoForge/src/main/resources/craterlib_logo.png
Normal file
BIN
NeoForge/src/main/resources/craterlib_logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
@@ -3,33 +3,25 @@ version_major=1
|
||||
version_minor=1
|
||||
version_patch=2
|
||||
project_group=com.hypherionmc.craterlib
|
||||
|
||||
#Mod
|
||||
mod_author=HypherionSA
|
||||
mod_id=craterlib
|
||||
mod_name=CraterLib
|
||||
|
||||
# Shared
|
||||
minecraft_version=1.20.2
|
||||
|
||||
minecraft_version=1.20.4
|
||||
# Fabric
|
||||
fabric_loader=0.14.22
|
||||
fabric_api=0.89.0+1.20.2
|
||||
|
||||
fabric_loader=0.15.0
|
||||
fabric_api=0.92.0+1.20.4
|
||||
# Forge
|
||||
forge_version=48.0.6
|
||||
|
||||
forge_version=49.0.13
|
||||
# NeoForged
|
||||
neoforge_version=64-beta
|
||||
|
||||
neoforge_version=73-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,4 +11,5 @@ pluginManagement {
|
||||
}
|
||||
|
||||
rootProject.name = 'CraterLib'
|
||||
include("Common", "Fabric", "Forge")
|
||||
include("Common", "Fabric", "Forge")
|
||||
include 'NeoForge'
|
Reference in New Issue
Block a user