[NO-ORBIT] Unified Porting Branch
This commit is contained in:
114
patches/1.19.2/NeoForge/build.gradle.patch
Normal file
114
patches/1.19.2/NeoForge/build.gradle.patch
Normal file
@@ -0,0 +1,114 @@
|
||||
--- a/NeoForge/build.gradle
|
||||
+++ /dev/null
|
||||
@@ -1,111 +1,0 @@
|
||||
-archivesBaseName = "${mod_name.replace(" ", "")}-NeoForge-${minecraft_version}"
|
||||
-
|
||||
-dependencies {
|
||||
- // Compat
|
||||
- modImplementation("maven.modrinth:vanishmod:${vanishmod_neo}")
|
||||
-
|
||||
- // Do not edit or remove
|
||||
- implementation project(":Common")
|
||||
-}
|
||||
-
|
||||
-shadowJar {
|
||||
- from sourceSets.main.output
|
||||
- configurations = [project.configurations.shade]
|
||||
-
|
||||
- dependencies {
|
||||
- exclude(dependency('com.google.code.gson:.*'))
|
||||
-
|
||||
- relocate 'me.hypherionmc.moonconfig', 'shadow.hypherionmc.moonconfig'
|
||||
- relocate 'me.hypherionmc.mcdiscordformatter', 'shadow.hypherionmc.mcdiscordformatter'
|
||||
- relocate 'net.kyori', 'shadow.kyori'
|
||||
- }
|
||||
-
|
||||
- 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/neoforge.mods.toml") {
|
||||
- expand buildProps
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-compileTestJava.enabled = false
|
||||
-
|
||||
-tasks.withType(JavaCompile).configureEach {
|
||||
- source(project(":Common").sourceSets.main.allSource)
|
||||
-}
|
||||
-
|
||||
-/**
|
||||
- * Publishing Config
|
||||
- */
|
||||
-publishing {
|
||||
- publications {
|
||||
- mavenJava(MavenPublication) {
|
||||
- artifactId project.archivesBaseName
|
||||
- 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 rootProject.orion.getPublishingMaven()
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-publisher {
|
||||
- apiKeys {
|
||||
- modrinth(System.getenv("MODRINTH_TOKEN"))
|
||||
- curseforge(System.getenv("CURSE_TOKEN"))
|
||||
- }
|
||||
-
|
||||
- setCurseID(curse_id)
|
||||
- setModrinthID(modrinth_id)
|
||||
- setVersionType("release")
|
||||
- setChangelog("https://raw.githubusercontent.com/hypherionmc/changelogs/main/craterlib/changelog-forge.md")
|
||||
- setProjectVersion("${minecraft_version}-${project.version}")
|
||||
- setDisplayName("[NeoForge 1.20.6] CraterLib - ${project.version}")
|
||||
- setGameVersions("1.20.6")
|
||||
- setLoaders("neoforge")
|
||||
- setArtifact(remapJar)
|
||||
- setCurseEnvironment("both")
|
||||
-}
|
@@ -0,0 +1,62 @@
|
||||
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/CraterLib.java
|
||||
+++ /dev/null
|
||||
@@ -1,59 +1,0 @@
|
||||
-package com.hypherionmc.craterlib;
|
||||
-
|
||||
-import com.hypherionmc.craterlib.api.events.client.LateInitEvent;
|
||||
-import com.hypherionmc.craterlib.client.gui.config.CraterConfigScreen;
|
||||
-import com.hypherionmc.craterlib.common.NeoForgeServerEvents;
|
||||
-import com.hypherionmc.craterlib.compat.Vanish;
|
||||
-import com.hypherionmc.craterlib.core.config.ConfigController;
|
||||
-import com.hypherionmc.craterlib.core.config.ModuleConfig;
|
||||
-import com.hypherionmc.craterlib.core.config.annotations.NoConfigScreen;
|
||||
-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.core.platform.ModloaderEnvironment;
|
||||
-import com.hypherionmc.craterlib.network.CraterNeoForgeNetworkHandler;
|
||||
-import com.hypherionmc.craterlib.nojang.client.BridgedMinecraft;
|
||||
-import com.hypherionmc.craterlib.nojang.client.BridgedOptions;
|
||||
-import net.minecraft.client.Minecraft;
|
||||
-import net.neoforged.bus.api.IEventBus;
|
||||
-import net.neoforged.fml.ModList;
|
||||
-import net.neoforged.fml.common.Mod;
|
||||
-import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
-import net.neoforged.fml.loading.FMLEnvironment;
|
||||
-import net.neoforged.fml.loading.FMLLoader;
|
||||
-import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
|
||||
-import net.neoforged.neoforge.common.NeoForge;
|
||||
-
|
||||
-import java.util.Optional;
|
||||
-
|
||||
-@Mod(CraterConstants.MOD_ID)
|
||||
-public class CraterLib {
|
||||
-
|
||||
- private final PacketRegistry handler;
|
||||
-
|
||||
- public CraterLib(IEventBus eventBus) {
|
||||
- NeoForge.EVENT_BUS.register(new NeoForgeServerEvents());
|
||||
- eventBus.addListener(this::commonSetup);
|
||||
- handler = new CraterNeoForgeNetworkHandler(FMLLoader.getDist().isClient() ? PacketSide.CLIENT : PacketSide.SERVER);
|
||||
-
|
||||
- if (ModloaderEnvironment.INSTANCE.isModLoaded("vmod")) {
|
||||
- eventBus.register(new Vanish());
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- public void commonSetup(FMLCommonSetupEvent evt) {
|
||||
- new CraterPacketNetwork(handler);
|
||||
- if (FMLEnvironment.dist.isClient()) {
|
||||
- LateInitEvent event = new LateInitEvent(new BridgedMinecraft(), BridgedOptions.of(Minecraft.getInstance().options));
|
||||
- CraterEventBus.INSTANCE.postEvent(event);
|
||||
-
|
||||
- ConfigController.getMonitoredConfigs().forEach((conf, watcher) -> {
|
||||
- if (!conf.getClass().isAnnotationPresent(NoConfigScreen.class)) {
|
||||
- ModuleConfig config = (ModuleConfig) conf;
|
||||
- ModList.get().getModContainerById(config.getModId()).ifPresent(c -> c.registerExtensionPoint(IConfigScreenFactory.class, ((minecraft, screen) -> new CraterConfigScreen(config, screen))));
|
||||
- }
|
||||
- });
|
||||
- }
|
||||
- }
|
||||
-}
|
@@ -0,0 +1,28 @@
|
||||
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/client/NeoForgeClientEvents.java
|
||||
+++ /dev/null
|
||||
@@ -1,25 +1,0 @@
|
||||
-package com.hypherionmc.craterlib.client;
|
||||
-
|
||||
-import com.hypherionmc.craterlib.CraterConstants;
|
||||
-import com.hypherionmc.craterlib.api.events.client.CraterClientTickEvent;
|
||||
-import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||
-import com.hypherionmc.craterlib.nojang.client.multiplayer.BridgedClientLevel;
|
||||
-import net.minecraft.client.Minecraft;
|
||||
-import net.neoforged.api.distmarker.Dist;
|
||||
-import net.neoforged.bus.api.SubscribeEvent;
|
||||
-import net.neoforged.fml.common.EventBusSubscriber;
|
||||
-import net.neoforged.neoforge.event.tick.LevelTickEvent;
|
||||
-
|
||||
-@EventBusSubscriber(modid = CraterConstants.MOD_ID, value = Dist.CLIENT)
|
||||
-public class NeoForgeClientEvents {
|
||||
-
|
||||
- @SubscribeEvent
|
||||
- public static void clientTick(LevelTickEvent.Pre event) {
|
||||
- if (Minecraft.getInstance().level == null)
|
||||
- return;
|
||||
-
|
||||
- CraterClientTickEvent craterClientTickEvent = new CraterClientTickEvent(BridgedClientLevel.of(Minecraft.getInstance().level));
|
||||
- CraterEventBus.INSTANCE.postEvent(craterClientTickEvent);
|
||||
- }
|
||||
-
|
||||
-}
|
@@ -0,0 +1,43 @@
|
||||
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/client/NeoForgeClientHelper.java
|
||||
+++ /dev/null
|
||||
@@ -1,40 +1,0 @@
|
||||
-package com.hypherionmc.craterlib.client;
|
||||
-
|
||||
-import com.hypherionmc.craterlib.core.platform.ClientPlatform;
|
||||
-import com.hypherionmc.craterlib.nojang.client.BridgedMinecraft;
|
||||
-import com.hypherionmc.craterlib.nojang.client.multiplayer.BridgedClientLevel;
|
||||
-import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
|
||||
-import net.minecraft.client.Minecraft;
|
||||
-import net.minecraft.network.Connection;
|
||||
-
|
||||
-import java.util.Objects;
|
||||
-
|
||||
-/**
|
||||
- * @author HypherionSA
|
||||
- */
|
||||
-public class NeoForgeClientHelper implements ClientPlatform {
|
||||
-
|
||||
- public NeoForgeClientHelper() {
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- public BridgedMinecraft getClientInstance() {
|
||||
- return new BridgedMinecraft();
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- public BridgedPlayer getClientPlayer() {
|
||||
- return BridgedPlayer.of(Minecraft.getInstance().player);
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- public BridgedClientLevel getClientLevel() {
|
||||
- return BridgedClientLevel.of(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,22 @@
|
||||
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/common/NeoForgeCommonHelper.java
|
||||
+++ /dev/null
|
||||
@@ -1,19 +1,0 @@
|
||||
-package com.hypherionmc.craterlib.common;
|
||||
-
|
||||
-import com.hypherionmc.craterlib.core.platform.CommonPlatform;
|
||||
-import com.hypherionmc.craterlib.nojang.server.BridgedMinecraftServer;
|
||||
-import net.neoforged.neoforge.server.ServerLifecycleHooks;
|
||||
-
|
||||
-/**
|
||||
- * @author HypherionSA
|
||||
- */
|
||||
-public class NeoForgeCommonHelper implements CommonPlatform {
|
||||
-
|
||||
- public NeoForgeCommonHelper() {
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- public BridgedMinecraftServer getMCServer() {
|
||||
- return BridgedMinecraftServer.of(ServerLifecycleHooks.getCurrentServer());
|
||||
- }
|
||||
-}
|
@@ -0,0 +1,25 @@
|
||||
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/common/NeoForgeCompatHelper.java
|
||||
+++ /dev/null
|
||||
@@ -1,22 +1,0 @@
|
||||
-package com.hypherionmc.craterlib.common;
|
||||
-
|
||||
-import com.hypherionmc.craterlib.core.platform.CompatUtils;
|
||||
-import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
|
||||
-import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
|
||||
-import redstonedubstep.mods.vanishmod.VanishUtil;
|
||||
-
|
||||
-public class NeoForgeCompatHelper implements CompatUtils {
|
||||
-
|
||||
- @Override
|
||||
- public boolean isPlayerActive(BridgedPlayer player) {
|
||||
- if (!ModloaderEnvironment.INSTANCE.isModLoaded("vmod"))
|
||||
- return true;
|
||||
-
|
||||
- return VanishUtil.isVanished(player.toMojangServerPlayer());
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- public String getSkinUUID(BridgedPlayer player) {
|
||||
- return player.getStringUUID();
|
||||
- }
|
||||
-}
|
@@ -0,0 +1,76 @@
|
||||
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/common/NeoForgeLoaderHelper.java
|
||||
+++ /dev/null
|
||||
@@ -1,73 +1,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();
|
||||
- }
|
||||
-}
|
@@ -0,0 +1,46 @@
|
||||
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/common/NeoForgeServerEvents.java
|
||||
+++ /dev/null
|
||||
@@ -1,43 +1,0 @@
|
||||
-package com.hypherionmc.craterlib.common;
|
||||
-
|
||||
-import com.hypherionmc.craterlib.api.events.server.CraterRegisterCommandEvent;
|
||||
-import com.hypherionmc.craterlib.api.events.server.CraterServerLifecycleEvent;
|
||||
-import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||
-import com.hypherionmc.craterlib.nojang.commands.CommandsRegistry;
|
||||
-import com.hypherionmc.craterlib.nojang.server.BridgedMinecraftServer;
|
||||
-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(BridgedMinecraftServer.of(event.getServer())));
|
||||
- }
|
||||
-
|
||||
- @SubscribeEvent
|
||||
- public void serverStarted(ServerStartedEvent event) {
|
||||
- CraterEventBus.INSTANCE.postEvent(new CraterServerLifecycleEvent.Started(BridgedMinecraftServer.of(event.getServer())));
|
||||
- }
|
||||
-
|
||||
- @SubscribeEvent
|
||||
- public void serverStopping(ServerStoppingEvent event) {
|
||||
- CraterEventBus.INSTANCE.postEvent(new CraterServerLifecycleEvent.Stopping(BridgedMinecraftServer.of(event.getServer())));
|
||||
- }
|
||||
-
|
||||
- @SubscribeEvent
|
||||
- public void serverStopped(ServerStoppedEvent event) {
|
||||
- CraterEventBus.INSTANCE.postEvent(new CraterServerLifecycleEvent.Stopped(BridgedMinecraftServer.of(event.getServer())));
|
||||
- }
|
||||
-
|
||||
- @SubscribeEvent
|
||||
- public void onCommandRegister(RegisterCommandsEvent event) {
|
||||
- CraterEventBus.INSTANCE.postEvent(new CraterRegisterCommandEvent());
|
||||
- CommandsRegistry.INSTANCE.registerCommands(event.getDispatcher());
|
||||
- }
|
||||
-
|
||||
-}
|
@@ -0,0 +1,27 @@
|
||||
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/compat/Vanish.java
|
||||
+++ /dev/null
|
||||
@@ -1,24 +1,0 @@
|
||||
-package com.hypherionmc.craterlib.compat;
|
||||
-
|
||||
-import com.hypherionmc.craterlib.api.events.server.CraterPlayerEvent;
|
||||
-import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||
-import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
|
||||
-import net.neoforged.bus.api.SubscribeEvent;
|
||||
-import redstonedubstep.mods.vanishmod.api.PlayerVanishEvent;
|
||||
-
|
||||
-public class Vanish {
|
||||
-
|
||||
- public Vanish() {
|
||||
-
|
||||
- }
|
||||
-
|
||||
- @SubscribeEvent
|
||||
- public void vanishevent(PlayerVanishEvent event) {
|
||||
- if (event.isVanished()) {
|
||||
- CraterEventBus.INSTANCE.postEvent(new CraterPlayerEvent.PlayerLoggedOut(BridgedPlayer.of(event.getEntity())));
|
||||
- } else {
|
||||
- CraterEventBus.INSTANCE.postEvent(new CraterPlayerEvent.PlayerLoggedIn(BridgedPlayer.of(event.getEntity())));
|
||||
- }
|
||||
- }
|
||||
-
|
||||
-}
|
@@ -0,0 +1,39 @@
|
||||
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/mixin/ServerGamePacketListenerImplMixin.java
|
||||
+++ /dev/null
|
||||
@@ -1,36 +1,0 @@
|
||||
-package com.hypherionmc.craterlib.mixin;
|
||||
-
|
||||
-import com.hypherionmc.craterlib.api.events.server.CraterServerChatEvent;
|
||||
-import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||
-import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
|
||||
-import com.hypherionmc.craterlib.utils.ChatUtils;
|
||||
-import net.minecraft.network.chat.Component;
|
||||
-import net.minecraft.network.chat.PlayerChatMessage;
|
||||
-import net.minecraft.server.level.ServerPlayer;
|
||||
-import net.minecraft.server.network.FilteredText;
|
||||
-import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
-import org.spongepowered.asm.mixin.Mixin;
|
||||
-import org.spongepowered.asm.mixin.Shadow;
|
||||
-import org.spongepowered.asm.mixin.injection.At;
|
||||
-import org.spongepowered.asm.mixin.injection.Inject;
|
||||
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
-
|
||||
-@Mixin(value = ServerGamePacketListenerImpl.class, priority = Integer.MIN_VALUE)
|
||||
-public class ServerGamePacketListenerImplMixin {
|
||||
-
|
||||
- @Shadow
|
||||
- public ServerPlayer player;
|
||||
-
|
||||
- @Inject(
|
||||
- method = "lambda$handleChat$5",
|
||||
- at = @At("HEAD"),
|
||||
- cancellable = true
|
||||
- )
|
||||
- private void injectChatEvent(Component component, PlayerChatMessage arg, FilteredText p_296589_, CallbackInfo ci) {
|
||||
- CraterServerChatEvent event = new CraterServerChatEvent(BridgedPlayer.of(this.player), arg.decoratedContent().getString(), ChatUtils.mojangToAdventure(arg.decoratedContent()));
|
||||
- CraterEventBus.INSTANCE.postEvent(event);
|
||||
- if (event.wasCancelled())
|
||||
- ci.cancel();
|
||||
- }
|
||||
-
|
||||
-}
|
@@ -0,0 +1,80 @@
|
||||
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/network/CraterNeoForgeNetworkHandler.java
|
||||
+++ /dev/null
|
||||
@@ -1,77 +1,0 @@
|
||||
-package com.hypherionmc.craterlib.network;
|
||||
-
|
||||
-import com.hypherionmc.craterlib.CraterConstants;
|
||||
-import com.hypherionmc.craterlib.api.networking.CommonPacketWrapper;
|
||||
-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 com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
|
||||
-import net.neoforged.bus.api.SubscribeEvent;
|
||||
-import net.neoforged.fml.LogicalSide;
|
||||
-import net.neoforged.neoforge.network.PacketDistributor;
|
||||
-import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
|
||||
-import net.neoforged.neoforge.network.handling.IPayloadHandler;
|
||||
-
|
||||
-import java.util.function.Consumer;
|
||||
-
|
||||
-/**
|
||||
- * Based on https://github.com/mysticdrew/common-networking/tree/1.20.4
|
||||
- */
|
||||
-public class CraterNeoForgeNetworkHandler extends PacketRegistry {
|
||||
-
|
||||
- public CraterNeoForgeNetworkHandler(PacketSide side) {
|
||||
- super(side);
|
||||
- }
|
||||
-
|
||||
- @SubscribeEvent
|
||||
- public void register(final RegisterPayloadHandlersEvent event) {
|
||||
- if (!PACKET_MAP.isEmpty()) {
|
||||
- PACKET_MAP.forEach((type, container) -> event.registrar(container.getType().id().getNamespace())
|
||||
- .optional().commonBidirectional(container.getType(), container.getCodec(), buildHandler(container.handler())));
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- protected <T> void registerPacket(PacketHolder<T> container) {
|
||||
-
|
||||
- }
|
||||
-
|
||||
- public <T> void sendToServer(T packet) {
|
||||
- this.sendToServer(packet, false);
|
||||
- }
|
||||
-
|
||||
- public <T> void sendToServer(T packet, boolean ignoreCheck) {
|
||||
- PacketHolder<T> container = (PacketHolder<T>) PACKET_MAP.get(packet.getClass());
|
||||
- if (container != null) {
|
||||
- PacketDistributor.sendToServer(new CommonPacketWrapper<>(container, packet));
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- public <T> void sendToClient(T packet, BridgedPlayer player) {
|
||||
- PacketHolder<T> container = (PacketHolder<T>) PACKET_MAP.get(packet.getClass());
|
||||
- if (container != null) {
|
||||
- if (player.getConnection().hasChannel(container.type())) {
|
||||
- PacketDistributor.sendToPlayer(player.toMojangServerPlayer(), new CommonPacketWrapper<>(container, packet));
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- private <T, K extends CommonPacketWrapper<T>> IPayloadHandler<K> buildHandler(Consumer<PacketContext<T>> handler) {
|
||||
- return (payload, ctx) -> {
|
||||
- try
|
||||
- {
|
||||
- PacketSide side = ctx.flow().getReceptionSide().equals(LogicalSide.SERVER) ? PacketSide.SERVER : PacketSide.CLIENT;
|
||||
- if (PacketSide.SERVER.equals(side)) {
|
||||
- handler.accept(new PacketContext<>(BridgedPlayer.of(ctx.player()), payload.packet(), side));
|
||||
- } else {
|
||||
- handler.accept(new PacketContext<>(payload.packet(), side));
|
||||
- }
|
||||
-
|
||||
- }
|
||||
- catch (Throwable t) {
|
||||
- CraterConstants.LOG.error("Error handling packet: {} -> ", payload.packet().getClass(), t);
|
||||
- }
|
||||
- };
|
||||
- }
|
||||
-}
|
@@ -0,0 +1,34 @@
|
||||
--- a/NeoForge/src/main/resources/META-INF/neoforge.mods.toml
|
||||
+++ /dev/null
|
||||
@@ -1,31 +1,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 = "NONE"
|
||||
-
|
||||
-[[dependencies.${ mod_id }]]
|
||||
- modId = "neoforge"
|
||||
- type="required"
|
||||
- versionRange = "[20.6,)"
|
||||
- ordering = "NONE"
|
||||
- side = "BOTH"
|
||||
-
|
||||
-[[dependencies.${ mod_id }]]
|
||||
- modId = "minecraft"
|
||||
- type="required"
|
||||
- versionRange = "[1.20.6,1.21)"
|
||||
- ordering = "NONE"
|
||||
- side = "BOTH"
|
@@ -0,0 +1,4 @@
|
||||
--- a/NeoForge/src/main/resources/META-INF/services/com.hypherionmc.craterlib.core.platform.ClientPlatform
|
||||
+++ /dev/null
|
||||
@@ -1,1 +1,0 @@
|
||||
-com.hypherionmc.craterlib.client.NeoForgeClientHelper
|
@@ -0,0 +1,4 @@
|
||||
--- a/NeoForge/src/main/resources/META-INF/services/com.hypherionmc.craterlib.core.platform.CommonPlatform
|
||||
+++ /dev/null
|
||||
@@ -1,1 +1,0 @@
|
||||
-com.hypherionmc.craterlib.common.NeoForgeCommonHelper
|
@@ -0,0 +1,4 @@
|
||||
--- a/NeoForge/src/main/resources/META-INF/services/com.hypherionmc.craterlib.core.platform.CompatUtils
|
||||
+++ /dev/null
|
||||
@@ -1,1 +1,0 @@
|
||||
-com.hypherionmc.craterlib.common.NeoForgeCompatHelper
|
@@ -0,0 +1,4 @@
|
||||
--- a/NeoForge/src/main/resources/META-INF/services/com.hypherionmc.craterlib.core.platform.ModloaderEnvironment
|
||||
+++ /dev/null
|
||||
@@ -1,1 +1,0 @@
|
||||
-com.hypherionmc.craterlib.common.NeoForgeLoaderHelper
|
@@ -0,0 +1,18 @@
|
||||
--- a/NeoForge/src/main/resources/craterlib.neoforge.mixins.json
|
||||
+++ /dev/null
|
||||
@@ -1,15 +1,0 @@
|
||||
-{
|
||||
- "required": true,
|
||||
- "minVersion": "0.8",
|
||||
- "package": "com.hypherionmc.craterlib.mixin",
|
||||
- "compatibilityLevel": "JAVA_17",
|
||||
- "mixins": [
|
||||
- ],
|
||||
- "client": [],
|
||||
- "server": [
|
||||
- "ServerGamePacketListenerImplMixin"
|
||||
- ],
|
||||
- "injectors": {
|
||||
- "defaultRequire": 1
|
||||
- }
|
||||
-}
|
Reference in New Issue
Block a user