[ci-skip] [DEV] Add 1.21.5 to LTS
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package com.hypherionmc.craterlib;
|
||||
|
||||
import com.hypherionmc.craterlib.api.events.server.CraterRegisterCommandEvent;
|
||||
import com.hypherionmc.craterlib.api.events.server.CraterServerLifecycleEvent;
|
||||
import com.hypherionmc.craterlib.common.FabricCommonPlatform;
|
||||
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.CraterFabricNetworkHandler;
|
||||
import com.hypherionmc.craterlib.nojang.server.BridgedMinecraftServer;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
|
||||
public class CraterLibInitializer implements ModInitializer {
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
new CraterPacketNetwork(new CraterFabricNetworkHandler(PacketSide.SERVER));
|
||||
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
|
||||
CraterEventBus.INSTANCE.postEvent(new CraterRegisterCommandEvent(dispatcher));
|
||||
});
|
||||
|
||||
|
||||
ServerLifecycleEvents.SERVER_STARTING.register(server -> {
|
||||
FabricCommonPlatform.server = server;
|
||||
CraterEventBus.INSTANCE.postEvent(new CraterServerLifecycleEvent.Starting(BridgedMinecraftServer.of(server)));
|
||||
});
|
||||
|
||||
ServerLifecycleEvents.SERVER_STARTED.register(li -> CraterEventBus.INSTANCE.postEvent(new CraterServerLifecycleEvent.Started(BridgedMinecraftServer.of(li))));
|
||||
ServerLifecycleEvents.SERVER_STOPPING.register(server -> CraterEventBus.INSTANCE.postEvent(new CraterServerLifecycleEvent.Stopping(BridgedMinecraftServer.of(server))));
|
||||
ServerLifecycleEvents.SERVER_STOPPED.register(server -> CraterEventBus.INSTANCE.postEvent(new CraterServerLifecycleEvent.Stopped(BridgedMinecraftServer.of(server))));
|
||||
|
||||
if (ModloaderEnvironment.INSTANCE.isModLoaded("melius-vanish")) {
|
||||
Vanish.register();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
package com.hypherionmc.craterlib;
|
||||
|
||||
import com.hypherionmc.craterlib.client.gui.config.ClothConfigScreenBuilder;
|
||||
import com.hypherionmc.craterlib.core.config.ConfigController;
|
||||
import com.hypherionmc.craterlib.core.config.annotations.ClothScreen;
|
||||
import com.hypherionmc.craterlib.core.config.annotations.NoConfigScreen;
|
||||
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
|
||||
import com.hypherionmc.craterlib.nojang.client.BridgedMinecraft;
|
||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.Style;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
*/
|
||||
public class CraterLibModMenuIntegration implements ModMenuApi {
|
||||
|
||||
@Override
|
||||
public Map<String, ConfigScreenFactory<?>> getProvidedConfigScreenFactories() {
|
||||
Map<String, ConfigScreenFactory<?>> configScreens = new HashMap<>();
|
||||
|
||||
ConfigController.getWatchedConfigs().forEach((conf, config) -> {
|
||||
if (config.getClass().isAnnotationPresent(NoConfigScreen.class))
|
||||
return;
|
||||
|
||||
if (config.getClass().isAnnotationPresent(ClothScreen.class) && (ModloaderEnvironment.INSTANCE.isModLoaded("cloth_config") || ModloaderEnvironment.INSTANCE.isModLoaded("cloth-config") || ModloaderEnvironment.INSTANCE.isModLoaded("clothconfig"))) {
|
||||
configScreens.put(config.getModId(), screen -> ClothConfigScreenBuilder.buildConfigScreen(config, screen));
|
||||
} else {
|
||||
configScreens.put(config.getModId(), screen -> BridgedMinecraft.getInstance().buildWarningScreen(
|
||||
Component.text("Notice").style(Style.style(NamedTextColor.YELLOW).decorate(TextDecoration.BOLD)),
|
||||
Component.text("This mod does not have a config screen, or Cloth Config is not installed"),
|
||||
screen
|
||||
));
|
||||
}
|
||||
});
|
||||
|
||||
return configScreens;
|
||||
}
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
package com.hypherionmc.craterlib.client;
|
||||
|
||||
import com.hypherionmc.craterlib.api.events.client.CraterClientTickEvent;
|
||||
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.network.CraterFabricNetworkHandler;
|
||||
import com.hypherionmc.craterlib.nojang.client.multiplayer.BridgedClientLevel;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
|
||||
public class CraterLibClientInitializer implements ClientModInitializer {
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
new CraterPacketNetwork(new CraterFabricNetworkHandler(PacketSide.CLIENT));
|
||||
ClientTickEvents.START_CLIENT_TICK.register((listener) -> {
|
||||
if (listener.level == null)
|
||||
return;
|
||||
|
||||
CraterClientTickEvent event = new CraterClientTickEvent(BridgedClientLevel.of(listener.level));
|
||||
CraterEventBus.INSTANCE.postEvent(event);
|
||||
});
|
||||
|
||||
CraterEventBus.INSTANCE.registerEventListener(CraterLibClientInitializer.class);
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
*/
|
||||
public class FabricClientPlatform implements ClientPlatform {
|
||||
|
||||
@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() {
|
||||
return Minecraft.getInstance().getConnection().getConnection();
|
||||
}
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
package com.hypherionmc.craterlib.common;
|
||||
|
||||
import com.hypherionmc.craterlib.core.platform.CommonPlatform;
|
||||
import com.hypherionmc.craterlib.nojang.server.BridgedMinecraftServer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
*/
|
||||
public class FabricCommonPlatform implements CommonPlatform {
|
||||
|
||||
public static MinecraftServer server;
|
||||
|
||||
@Override
|
||||
public BridgedMinecraftServer getMCServer() {
|
||||
return BridgedMinecraftServer.of(server);
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
package com.hypherionmc.craterlib.common;
|
||||
|
||||
import com.hypherionmc.craterlib.compat.FabricTailor;
|
||||
import com.hypherionmc.craterlib.compat.Vanish;
|
||||
import com.hypherionmc.craterlib.core.platform.CompatUtils;
|
||||
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
|
||||
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
|
||||
|
||||
public class FabricCompatHelper implements CompatUtils {
|
||||
|
||||
@Override
|
||||
public boolean isPlayerActive(BridgedPlayer player) {
|
||||
if (!ModloaderEnvironment.INSTANCE.isModLoaded("melius-vanish"))
|
||||
return true;
|
||||
|
||||
return !Vanish.isPlayerVanished(player.toMojangServerPlayer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSkinUUID(BridgedPlayer player) {
|
||||
return FabricTailor.getTailorSkin(player.toMojangServerPlayer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerBleeding(BridgedPlayer player) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerBledOut(BridgedPlayer player) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRevived(BridgedPlayer player) {
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,75 @@
|
||||
package com.hypherionmc.craterlib.common;
|
||||
|
||||
import com.hypherionmc.craterlib.core.platform.Environment;
|
||||
import com.hypherionmc.craterlib.core.platform.LoaderType;
|
||||
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 07/08/2022
|
||||
*/
|
||||
public class FabricLoaderHelper implements ModloaderEnvironment {
|
||||
|
||||
@Override
|
||||
public boolean isFabric() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoaderType getLoaderType() {
|
||||
return LoaderType.FABRIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGameVersion() {
|
||||
return SharedConstants.VERSION_STRING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getGameFolder() {
|
||||
return Minecraft.getInstance().gameDirectory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getConfigFolder() {
|
||||
return FabricLoader.getInstance().getConfigDir().toFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getModsFolder() {
|
||||
return new File(FabricLoader.getInstance().getGameDir().toString() + File.separator + "mods");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Environment getEnvironment() {
|
||||
switch (FabricLoader.getInstance().getEnvironmentType()) {
|
||||
case SERVER -> {
|
||||
return Environment.SERVER;
|
||||
}
|
||||
case CLIENT -> {
|
||||
return Environment.CLIENT;
|
||||
}
|
||||
}
|
||||
return Environment.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModLoaded(String modid) {
|
||||
return FabricLoader.getInstance().isModLoaded(modid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDevEnv() {
|
||||
return FabricLoader.getInstance().isDevelopmentEnvironment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getModCount() {
|
||||
return FabricLoader.getInstance().getAllMods().size();
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package com.hypherionmc.craterlib.compat;
|
||||
|
||||
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.samo_lego.fabrictailor.casts.TailoredPlayer;
|
||||
public class FabricTailor {
|
||||
|
||||
public static String getTailorSkin(ServerPlayer player) {
|
||||
if (!ModloaderEnvironment.INSTANCE.isModLoaded("fabrictailor"))
|
||||
return player.getStringUUID();
|
||||
|
||||
try {
|
||||
if (player instanceof TailoredPlayer tp) {
|
||||
return tp.getSkinId();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return player.getStringUUID();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
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 me.drex.vanish.api.VanishAPI;
|
||||
import me.drex.vanish.api.VanishEvents;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class Vanish {
|
||||
|
||||
public static void register() {
|
||||
VanishEvents.VANISH_EVENT.register((serverPlayer, b) -> {
|
||||
if (b) {
|
||||
CraterEventBus.INSTANCE.postEvent(new CraterPlayerEvent.PlayerLoggedOut(BridgedPlayer.of(serverPlayer), true));
|
||||
} else {
|
||||
CraterEventBus.INSTANCE.postEvent(new CraterPlayerEvent.PlayerLoggedIn(BridgedPlayer.of(serverPlayer), true));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean isPlayerVanished(ServerPlayer player) {
|
||||
return VanishAPI.isVanished(player);
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
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$6",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true
|
||||
)
|
||||
private void injectChatEvent(PlayerChatMessage arg, Component arg2, FilteredText arg3, CallbackInfo ci) {
|
||||
Component finalcomp = arg2 == null ? arg.decoratedContent() : arg2;
|
||||
CraterServerChatEvent event = new CraterServerChatEvent(BridgedPlayer.of(this.player), finalcomp.getString(), ChatUtils.mojangToAdventure(finalcomp));
|
||||
CraterEventBus.INSTANCE.postEvent(event);
|
||||
if (event.wasCancelled())
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
package com.hypherionmc.craterlib.mixin;
|
||||
|
||||
import com.hypherionmc.craterlib.api.events.server.ServerStatusEvent;
|
||||
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||
import com.hypherionmc.craterlib.utils.ChatUtils;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.status.ClientboundStatusResponsePacket;
|
||||
import net.minecraft.network.protocol.status.ServerStatus;
|
||||
import net.minecraft.network.protocol.status.ServerboundStatusRequestPacket;
|
||||
import net.minecraft.server.network.ServerStatusPacketListenerImpl;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
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(ServerStatusPacketListenerImpl.class)
|
||||
public class ServerStatusPacketListenerMixin {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private ServerStatus status;
|
||||
|
||||
@Shadow @Final private Connection connection;
|
||||
|
||||
@Inject(method = "handleStatusRequest",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/Connection;send(Lnet/minecraft/network/protocol/Packet;)V",
|
||||
shift = At.Shift.BEFORE),
|
||||
cancellable = true
|
||||
)
|
||||
private void injectHandleStatusRequest(ServerboundStatusRequestPacket arg, CallbackInfo ci) {
|
||||
ServerStatusEvent.StatusRequestEvent event = new ServerStatusEvent.StatusRequestEvent(ChatUtils.mojangToAdventure(status.description()));
|
||||
CraterEventBus.INSTANCE.postEvent(event);
|
||||
|
||||
if (event.getNewStatus() != null) {
|
||||
ci.cancel();
|
||||
this.connection.send(new ClientboundStatusResponsePacket(
|
||||
new ServerStatus(ChatUtils.adventureToMojang(
|
||||
event.getNewStatus()),
|
||||
status.players(),
|
||||
status.version(),
|
||||
status.favicon(),
|
||||
status.enforcesSecureChat()
|
||||
)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
package com.hypherionmc.craterlib.mixin;
|
||||
|
||||
import com.hypherionmc.craterlib.api.events.client.LateInitEvent;
|
||||
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||
import com.hypherionmc.craterlib.nojang.client.BridgedMinecraft;
|
||||
import com.hypherionmc.craterlib.nojang.client.BridgedOptions;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.Options;
|
||||
import net.minecraft.client.tutorial.Tutorial;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(Tutorial.class)
|
||||
public class TutorialMixin {
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void injectEarlyInitEvent(Minecraft minecraft, Options options, CallbackInfo ci) {
|
||||
LateInitEvent event = new LateInitEvent(new BridgedMinecraft(), BridgedOptions.of(options));
|
||||
CraterEventBus.INSTANCE.postEvent(event);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,68 @@
|
||||
package com.hypherionmc.craterlib.network;
|
||||
|
||||
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.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||
|
||||
/**
|
||||
* Based on https://github.com/mysticdrew/common-networking/tree/1.20.4
|
||||
*/
|
||||
public class CraterFabricNetworkHandler extends PacketRegistry {
|
||||
|
||||
public CraterFabricNetworkHandler(PacketSide side) {
|
||||
super(side);
|
||||
}
|
||||
|
||||
protected <T> void registerPacket(PacketHolder<T> holder) {
|
||||
try
|
||||
{
|
||||
PayloadTypeRegistry.playC2S().register(holder.getType(), holder.getCodec());
|
||||
PayloadTypeRegistry.playS2C().register(holder.getType(), holder.getCodec());
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
if (PacketSide.CLIENT.equals(this.side)) {
|
||||
ClientPlayNetworking.registerGlobalReceiver(holder.getType(),
|
||||
(ClientPlayNetworking.PlayPayloadHandler<CommonPacketWrapper<T>>) (payload, context) -> context.client().execute(() ->
|
||||
holder.handler().accept(
|
||||
new PacketContext<>(payload.packet(), side))));
|
||||
}
|
||||
|
||||
ServerPlayNetworking.registerGlobalReceiver(holder.getType(),
|
||||
(ServerPlayNetworking.PlayPayloadHandler<CommonPacketWrapper<T>>) (payload, context) -> context.player().server.execute(() ->
|
||||
holder.handler().accept(
|
||||
new PacketContext<>(BridgedPlayer.of(context.player()), payload.packet(), side))));
|
||||
}
|
||||
|
||||
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) {
|
||||
if (ignoreCheck || ClientPlayNetworking.canSend(container.type().id())) {
|
||||
ClientPlayNetworking.send(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 (ServerPlayNetworking.canSend(player.toMojangServerPlayer(), container.type().id())) {
|
||||
ServerPlayNetworking.send(player.toMojangServerPlayer(), new CommonPacketWrapper<>(container, packet));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1 @@
|
||||
com.hypherionmc.craterlib.client.FabricClientPlatform
|
@@ -0,0 +1 @@
|
||||
com.hypherionmc.craterlib.common.FabricCommonPlatform
|
@@ -0,0 +1 @@
|
||||
com.hypherionmc.craterlib.common.FabricCompatHelper
|
@@ -0,0 +1 @@
|
||||
com.hypherionmc.craterlib.common.FabricLoaderHelper
|
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "com.hypherionmc.craterlib.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
],
|
||||
"client": [
|
||||
"TutorialMixin"
|
||||
],
|
||||
"server": [
|
||||
"ServerGamePacketListenerImplMixin",
|
||||
"ServerStatusPacketListenerMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
39
1.21.5/Fabric/src/main/resources/fabric.mod.json
Normal file
39
1.21.5/Fabric/src/main/resources/fabric.mod.json
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "${mod_id}",
|
||||
"version": "${version}",
|
||||
"name": "${mod_name}",
|
||||
"description": "A library mod used by First Dark Development and HypherionSA Mods",
|
||||
"authors": [
|
||||
"${mod_author}",
|
||||
"Misha"
|
||||
],
|
||||
"contact": {
|
||||
"homepage": "https://modrinth.com/mod/craterlib",
|
||||
"sources": "https://github.com/firstdarkdev/craterLib/"
|
||||
},
|
||||
"license": "MIT",
|
||||
"icon": "assets/craterlib/craterlib_logo.png",
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"main": [
|
||||
"com.hypherionmc.craterlib.CraterLibInitializer"
|
||||
],
|
||||
"client": [
|
||||
"com.hypherionmc.craterlib.client.CraterLibClientInitializer"
|
||||
],
|
||||
"modmenu": [
|
||||
"com.hypherionmc.craterlib.CraterLibModMenuIntegration"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
"${mod_id}.mixins.json",
|
||||
"${mod_id}.fabric.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.16.7",
|
||||
"fabric-api": "*",
|
||||
"minecraft": ">=1.21.5",
|
||||
"java": ">=21"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user