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;
}
}
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);
}
}
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);
}
}
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();
}
}
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));
});
}
Aggregations