Search in sources :

Example 1 with CustomPayloadS2CPacket

use of net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket in project MasaGadget by plusls.

the class MixinCustomPayloadS2CPacket method onApply.

@Inject(method = "apply*", at = @At(value = "HEAD"), cancellable = true)
private void onApply(ClientPlayPacketListener clientPlayPacketListener, CallbackInfo info) {
    if (MinecraftClient.getInstance().isIntegratedServerRunning()) {
        return;
    }
    CustomPayloadS2CPacket packet = (CustomPayloadS2CPacket) (Object) this;
    if (channel.getNamespace().equals(BborProtocol.NAMESPACE)) {
        // 因为 mod 会吞掉包,因此需要手动 mixin 在 mod 处理包之前做处理
        BborProtocol.bborProtocolHandler((ClientPlayNetworkHandler) clientPlayPacketListener, channel, packet.getData());
        // 兼容 bbor
        if (!ModInfo.isModLoaded(ModInfo.BBOR_MOD_ID)) {
            info.cancel();
        }
    } else if (channel.toString().equals("carpet:structures")) {
        BborProtocol.carpetOrServux = true;
        BborProtocol.enable = false;
    } else if (channel.toString().equals("servux:structures")) {
        BborProtocol.carpetOrServux = true;
        BborProtocol.enable = false;
    }
}
Also used : CustomPayloadS2CPacket(net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with CustomPayloadS2CPacket

use of net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket in project SpeedRunIGT by RedLime.

the class TimerPacketHandler method sendInitS2C.

public static void sendInitS2C(List<ServerPlayerEntity> players, long startTime, RunCategory category) {
    PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
    passedData.writeLong(startTime);
    passedData.writeString(category.getID());
    CustomPayloadS2CPacket s2CPacket = new CustomPayloadS2CPacket(PACKET_TIMER_INIT_ID, passedData);
    for (ServerPlayerEntity player : players) {
        player.networkHandler.sendPacket(s2CPacket);
    }
}
Also used : CustomPayloadS2CPacket(net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket) PacketByteBuf(net.minecraft.network.PacketByteBuf) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity)

Example 3 with CustomPayloadS2CPacket

use of net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket in project SpeedRunIGT by RedLime.

the class TimerPacketHandler method sendCompleteS2C.

public static void sendCompleteS2C(List<ServerPlayerEntity> players, long endTime) {
    PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
    passedData.writeLong(endTime);
    CustomPayloadS2CPacket s2CPacket = new CustomPayloadS2CPacket(PACKET_TIMER_COMPLETE_ID, passedData);
    for (ServerPlayerEntity player : players) {
        player.networkHandler.sendPacket(s2CPacket);
    }
}
Also used : CustomPayloadS2CPacket(net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket) PacketByteBuf(net.minecraft.network.PacketByteBuf) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity)

Example 4 with CustomPayloadS2CPacket

use of net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket in project meteor-rejects by AntiCope.

the class CustomPayloadS2CPacketMixin method onApply.

@Inject(method = "apply(Lnet/minecraft/network/listener/ClientPlayPacketListener;)V", at = @At(value = "HEAD"), cancellable = true)
private void onApply(ClientPlayPacketListener clientPlayPacketListener, CallbackInfo info) {
    CustomPayloadS2CPacket packet = (CustomPayloadS2CPacket) (Object) this;
    CustomPayloadEvent event = MeteorClient.EVENT_BUS.post(CustomPayloadEvent.get(packet));
    if (event.isCancelled()) {
        info.cancel();
    }
}
Also used : CustomPayloadEvent(anticope.rejects.events.CustomPayloadEvent) CustomPayloadS2CPacket(net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 5 with CustomPayloadS2CPacket

use of net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket in project FallingAttackFabric by hamusuke0323.

the class ServerPlayerEntityMixin method sendFallingAttackPacket.

public void sendFallingAttackPacket(boolean start) {
    PacketByteBuf packetByteBuf = PacketByteBufs.create();
    packetByteBuf.writeVarInt(this.getId());
    packetByteBuf.writeBoolean(start);
    this.server.getPlayerManager().getPlayerList().forEach(serverPlayerEntity -> {
        serverPlayerEntity.networkHandler.sendPacket(new CustomPayloadS2CPacket(NetworkManager.FALLING_ATTACK_S2C_PACKET_ID, packetByteBuf));
    });
}
Also used : CustomPayloadS2CPacket(net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket) PacketByteBuf(net.minecraft.network.PacketByteBuf)

Aggregations

CustomPayloadS2CPacket (net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket)6 PacketByteBuf (net.minecraft.network.PacketByteBuf)4 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)2 Inject (org.spongepowered.asm.mixin.injection.Inject)2 CustomPayloadEvent (anticope.rejects.events.CustomPayloadEvent)1