net 图标

net

作者:rebot | 分类:模组

价格:0 墨喵币 下载量:0 点赞:0 版本 26.x-2.0.0-26041500-Neo
本资源为搬运资源,原资源地址: https://modrinth.com/mod/net
资源信息

Minecraft 版本: 26.1.1 26.1.2

平台: neoforge

标签: library optimization

资源介绍

Net

Features

  • Simplifies the network communication part in development, making development easier.
  • Will provide network optimization and protection in the future.

How to use

First, insert implementation "dev.anye.mc:net:version" into the dependencies section of the build.gradle file, replacing version with the version you are actually using.
Then create network communication according to the following code

    //Create a DeferredRegister to store your NetHandle
    public static final DeferredRegister<NetHandle> EASY_NET = DeferredRegister.create(NetReg.KEY, YourMod.MOD_ID);
    //Register your NetHandle to the DeferredRegister above
    public static final DeferredHolder<NetHandle, ExampleA> ExampleA = EASY_NET.register("example_a",ExampleA::new);
    public static final DeferredHolder<NetHandle, ExampleB> ExampleB = EASY_NET.register("example_b",ExampleB::new);
    //Create a DeferredRegister registration method and call it in the Mod main class
    public static void reg(IEventBus eventBus){
        EASY_NET.register(eventBus);
    }

    Use the methods in the NetCore class to send data
    NetCore.sendToServer(NetPack.createClientPack(CompoundTag data, NetHandle));
    NetCore.sendToEntity(NetPack.createServerPack(compoundTag,NetHandle), entity);




  public class ExampleA extends NetHandle {
    @Override
    public void client(IPayloadContext context, CompoundTag dat) {
    //Process data sent from the server here
    }

    @Override
    public void server(IPayloadContext context, CompoundTag dat) {
    //Process data sent from the client here
    }
}
下载太慢?试试 墨喵加速站,支持 Modrinth 和外网直链高速下载! 用的人越多,下载的越快!
下载与版本
评论(0)
登录 后发表评论。

暂无评论,抢个沙发吧~

举报此资源

请登录后举报

🔥 相关推荐
Momeow Shader(墨喵光影)

价格:0 墨喵币
下载量:1

查看详情
stars & clouds

价格:0 墨喵币
下载量:0

查看详情
Cobblemon Hostile Spawners

价格:0 墨喵币
下载量:0

查看详情
Shadax Client Automods

价格:0 墨喵币
下载量:0

查看详情