mirror of
https://github.com/Coloryr/AllMusic.git
synced 2026-11-13 19:34:12 +00:00
up
This commit is contained in:
1 parent
2fcd9d3053
commit
4858bcb4da
8 files changed
+73
-46
No files matched your search
+1
-1
Submodule client updated: 44179f4e12...cef9b7b64f.
@@ -1,7 +1,7 @@
|
||||
plugins {
|
||||
id 'java-library'
|
||||
id 'maven-publish'
|
||||
id 'net.neoforged.gradle.userdev' version '7.0.189'
|
||||
id 'net.neoforged.gradle.userdev' version '7.0.192'
|
||||
}
|
||||
|
||||
tasks.named('wrapper', Wrapper).configure {
|
||||
@@ -156,7 +156,6 @@ tasks.withType(ProcessResources).configureEach {
|
||||
minecraft_version : minecraft_version,
|
||||
minecraft_version_range: minecraft_version_range,
|
||||
neo_version : neo_version,
|
||||
neo_version_range : neo_version_range,
|
||||
mod_id : mod_id,
|
||||
mod_name : mod_name,
|
||||
mod_license : mod_license,
|
||||
|
||||
@@ -7,8 +7,8 @@ org.gradle.configuration-cache=true
|
||||
|
||||
#read more on this at https://github.com/neoforged/NeoGradle/blob/NG_7.0/README.md#apply-parchment-mappings
|
||||
# you can also find the latest versions at: https://parchmentmc.org/docs/getting-started
|
||||
neogradle.subsystems.parchment.minecraftVersion=1.21.5
|
||||
neogradle.subsystems.parchment.mappingsVersion=2025.06.15
|
||||
neogradle.subsystems.parchment.minecraftVersion=1.21.6
|
||||
neogradle.subsystems.parchment.mappingsVersion=2025.06.29
|
||||
# Environment Properties
|
||||
# You can find the latest versions here: https://projects.neoforged.net/neoforged/neoforge
|
||||
# The Minecraft version must agree with the Neo version to get a valid artifact
|
||||
@@ -20,7 +20,7 @@ minecraft_version_range=[1.21.6]
|
||||
# The Neo version must agree with the Minecraft version to get a valid artifact
|
||||
neo_version=21.6.20-beta
|
||||
# The Neo version range can use any version of Neo as bounds
|
||||
neo_version_range=[21.6.20-beta,)
|
||||
#neo_version_range=[21.6.20-beta,)
|
||||
|
||||
kff_version=5.7.0
|
||||
|
||||
|
||||
@@ -10,4 +10,4 @@ plugins {
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.9.0'
|
||||
}
|
||||
|
||||
rootProject.name = 'AllMusic_Server'
|
||||
rootProject.name = 'AllMusic'
|
||||
+16
-31
@@ -2,7 +2,8 @@ package com.coloryr.allmusic.client;
|
||||
|
||||
import com.coloryr.allmusic.client.core.AllMusicBridge;
|
||||
import com.coloryr.allmusic.client.core.AllMusicCore;
|
||||
import com.coloryr.allmusic.server.core.objs.enums.ComType;
|
||||
import com.coloryr.allmusic.client.core.CommandType;
|
||||
import com.coloryr.allmusic.server.AllMusicForge;
|
||||
import com.coloryr.allmusic.server.side.forge.PackData;
|
||||
import com.mojang.blaze3d.opengl.GlTexture;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
@@ -10,18 +11,18 @@ import com.mojang.blaze3d.textures.FilterMode;
|
||||
import com.mojang.blaze3d.textures.GpuTexture;
|
||||
import com.mojang.blaze3d.textures.GpuTextureView;
|
||||
import com.mojang.blaze3d.textures.TextureFormat;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.renderer.RenderPipelines;
|
||||
import net.minecraft.client.renderer.texture.AbstractTexture;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.neoforged.fml.loading.FMLPaths;
|
||||
@@ -33,14 +34,15 @@ import net.neoforged.neoforge.client.event.sound.PlayStreamingSourceEvent;
|
||||
import net.neoforged.neoforge.client.event.sound.SoundEngineLoadEvent;
|
||||
import net.neoforged.neoforge.client.gui.VanillaGuiLayers;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
||||
import net.neoforged.neoforge.network.handling.IPayloadHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.joml.Matrix3x2fStack;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class AllMusicClient implements IPayloadHandler<PackData>, StreamCodec<RegistryFriendlyByteBuf, PackData>, AllMusicBridge {
|
||||
// This class will not load on dedicated servers. Accessing client side code from here is safe.
|
||||
@Mod(value = AllMusicForge.MODID, dist = Dist.CLIENT)
|
||||
// You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent
|
||||
@EventBusSubscriber(modid = AllMusicForge.MODID, value = Dist.CLIENT)
|
||||
public class AllMusicClient implements AllMusicBridge {
|
||||
private static GuiGraphics gui;
|
||||
|
||||
public static final ResourceLocation channel =
|
||||
@@ -70,21 +72,12 @@ public class AllMusicClient implements IPayloadHandler<PackData>, StreamCodec<Re
|
||||
event.enqueueWork(AllMusicCore::glInit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackData decode(RegistryFriendlyByteBuf pack) {
|
||||
handle(pack);
|
||||
pack.clear();
|
||||
return new PackData(ComType.CLEAR, "", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(RegistryFriendlyByteBuf pack, PackData data) {
|
||||
PackData.CODEC.encode(pack, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(@NotNull PackData payload, IPayloadContext context) {
|
||||
|
||||
public static void decode(PackData pack) {
|
||||
try {
|
||||
AllMusicCore.packDo(AllMusicCore.types[pack.cmd().ordinal()], pack.data(), pack.data1());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -93,14 +86,6 @@ public class AllMusicClient implements IPayloadHandler<PackData>, StreamCodec<Re
|
||||
Minecraft.getInstance().getSoundManager().stop(null, SoundSource.RECORDS);
|
||||
}
|
||||
|
||||
public void handle(ByteBuf buffer) {
|
||||
try {
|
||||
AllMusicCore.packRead(buffer);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void setup1(final FMLCommonSetupEvent event) {
|
||||
AllMusicCore.init(FMLPaths.CONFIGDIR.get(), this);
|
||||
}
|
||||
|
||||
+15
-5
@@ -7,7 +7,9 @@ import com.coloryr.allmusic.server.side.forge.LogForge;
|
||||
import com.coloryr.allmusic.server.side.forge.PackData;
|
||||
import com.coloryr.allmusic.server.side.forge.SideForge;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.network.protocol.PacketFlow;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
@@ -20,7 +22,10 @@ import net.neoforged.neoforge.event.entity.player.PlayerEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStartedEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStoppingEvent;
|
||||
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
|
||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
||||
import net.neoforged.neoforge.network.handling.IPayloadHandler;
|
||||
import net.neoforged.neoforge.network.registration.PayloadRegistrar;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -38,8 +43,6 @@ public class AllMusicForge {
|
||||
public static MinecraftServer server;
|
||||
// Create a Deferred Register to hold Blocks which will all be registered under the "examplemod" namespace
|
||||
|
||||
private static AllMusicClient client;
|
||||
|
||||
public AllMusicForge(IEventBus modEventBus) {
|
||||
// Register the commonSetup method for modloading
|
||||
modEventBus.addListener(this::commonSetup);
|
||||
@@ -47,8 +50,6 @@ public class AllMusicForge {
|
||||
|
||||
// Register ourselves for server and other game events we are interested in
|
||||
NeoForge.EVENT_BUS.register(this);
|
||||
|
||||
client = new AllMusicClient(modEventBus);
|
||||
}
|
||||
|
||||
private void commonSetup(final FMLCommonSetupEvent event) {
|
||||
@@ -63,7 +64,7 @@ public class AllMusicForge {
|
||||
public void register(final RegisterPayloadHandlersEvent event) {
|
||||
LOGGER.info("注册插件信道");
|
||||
final PayloadRegistrar registrar = event.registrar("1.0");
|
||||
registrar.optional().playToClient(PackData.TYPE, client, client);
|
||||
registrar.optional().playToClient(PackData.TYPE, PackData.CODEC, new HandelPack());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -96,4 +97,13 @@ public class AllMusicForge {
|
||||
public void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
|
||||
AllMusic.joinPlay(event.getEntity().getName().getString());
|
||||
}
|
||||
|
||||
private static class HandelPack implements IPayloadHandler<PackData> {
|
||||
@Override
|
||||
public void handle(@NotNull PackData payload, IPayloadContext context) {
|
||||
if (context.flow() == PacketFlow.CLIENTBOUND) {
|
||||
AllMusicClient.decode(payload);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+34
-1
@@ -3,12 +3,17 @@ package com.coloryr.allmusic.server.side.forge;
|
||||
import com.coloryr.allmusic.server.AllMusicForge;
|
||||
import com.coloryr.allmusic.server.codec.PacketCodec;
|
||||
import com.coloryr.allmusic.server.core.objs.enums.ComType;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public record PackData(ComType cmd, String data, int data1) implements CustomPacketPayload {
|
||||
public static final ComType[] types = ComType.values();
|
||||
|
||||
public static final Type<PackData> TYPE = new Type<>(AllMusicForge.channel);
|
||||
public static final StreamCodec<RegistryFriendlyByteBuf, PackData> CODEC = new PackCodec();
|
||||
|
||||
@@ -20,13 +25,41 @@ public record PackData(ComType cmd, String data, int data1) implements CustomPac
|
||||
public static class PackCodec implements StreamCodec<RegistryFriendlyByteBuf, PackData> {
|
||||
@Override
|
||||
public @NotNull PackData decode(RegistryFriendlyByteBuf pack) {
|
||||
byte type = pack.readByte();
|
||||
if (type >= types.length || type < 0) {
|
||||
return new PackData(ComType.CLEAR, "", 0);
|
||||
}
|
||||
ComType type1 = types[type];
|
||||
String data = null;
|
||||
int data1 = 0;
|
||||
switch (type1) {
|
||||
case LYRIC:
|
||||
case INFO:
|
||||
case LIST:
|
||||
case PLAY:
|
||||
case IMG:
|
||||
case HUD:
|
||||
data = readString(pack);
|
||||
break;
|
||||
case POS:
|
||||
data1 = pack.readInt();
|
||||
break;
|
||||
}
|
||||
pack.clear();
|
||||
return new PackData(ComType.CLEAR, "", 0);
|
||||
return new PackData(type1, data, data1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(@NotNull RegistryFriendlyByteBuf pack, PackData buffer) {
|
||||
PacketCodec.pack(pack, buffer.cmd, buffer.data, buffer.data1);
|
||||
}
|
||||
|
||||
private static String readString(ByteBuf buf) {
|
||||
int size = buf.readInt();
|
||||
byte[] temp = new byte[size];
|
||||
buf.readBytes(temp);
|
||||
|
||||
return new String(temp, StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -63,7 +63,7 @@ type="required" #mandatory
|
||||
# Optional field describing why the dependency is required or why it is incompatible
|
||||
# reason="..."
|
||||
# The version range of the dependency
|
||||
versionRange="${neo_version_range}" #mandatory
|
||||
versionRange="[${neo_version},)" #mandatory
|
||||
# An ordering relationship for the dependency.
|
||||
# BEFORE - This mod is loaded BEFORE the dependency
|
||||
# AFTER - This mod is loaded AFTER the dependency
|
||||
@@ -84,4 +84,4 @@ side="BOTH"
|
||||
# that your mod requires GL version 3.2 or higher. Other features will be added. They are side aware so declaring this won't
|
||||
# stop your mod loading on the server for example.
|
||||
#[features.${mod_id}]
|
||||
#openGLVersion="[3.2,)"
|
||||
#openGLVersion="[3.2,)"
|
||||
Reference in new issue
Block a user