[FEAT] More Nojang abstractions and compat layers (SDLink)

This commit is contained in:
2024-05-01 18:28:52 +02:00
parent 5166886924
commit 9ffd14d9c1
23 changed files with 292 additions and 10 deletions

View File

@@ -2,6 +2,8 @@
archivesBaseName = "${mod_name.replace(" ", "")}-Forge-${minecraft_version}"
dependencies {
// Compat
modImplementation("maven.modrinth:vanishmod:1.1.12.1")
// Do not edit or remove
implementation project(":Common")
@@ -12,8 +14,11 @@ shadowJar {
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')
@@ -63,9 +68,7 @@ tasks.withType(JavaCompile).configureEach {
publishing {
publications {
mavenJava(MavenPublication) {
groupId project.group
artifactId project.archivesBaseName
version project.version
from components.java
artifact(remapJar) {

View File

@@ -2,9 +2,11 @@ package com.hypherionmc.craterlib;
import com.hypherionmc.craterlib.api.events.client.LateInitEvent;
import com.hypherionmc.craterlib.common.ForgeServerEvents;
import com.hypherionmc.craterlib.compat.Vanish;
import com.hypherionmc.craterlib.core.event.CraterEventBus;
import com.hypherionmc.craterlib.core.networking.CraterPacketNetwork;
import com.hypherionmc.craterlib.core.networking.data.PacketSide;
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
import com.hypherionmc.craterlib.network.CraterForgeNetworkHandler;
import com.hypherionmc.craterlib.nojang.client.BridgedMinecraft;
import com.hypherionmc.craterlib.nojang.client.BridgedOptions;
@@ -31,5 +33,9 @@ public class CraterLib {
LateInitEvent event = new LateInitEvent(new BridgedMinecraft(), BridgedOptions.of(Minecraft.getInstance().options));
CraterEventBus.INSTANCE.postEvent(event);
});
if (ModloaderEnvironment.INSTANCE.isModLoaded("vmod")) {
MinecraftForge.EVENT_BUS.register(new Vanish());
}
}
}

View File

@@ -0,0 +1,22 @@
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 ForgeCompatHelper 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();
}
}

View File

@@ -0,0 +1,24 @@
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.minecraftforge.eventbus.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())));
}
}
}

View File

@@ -0,0 +1 @@
com.hypherionmc.craterlib.common.ForgeCompatHelper