use of net.minecraft.network.PacketByteBuf in project bewitchment by MoriyaShiine.
the class SpawnSpecterBangleParticlesPacket method send.
public static void send(PlayerEntity player, Entity entity) {
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
buf.writeInt(entity.getId());
ServerPlayNetworking.send((ServerPlayerEntity) player, ID, buf);
}
use of net.minecraft.network.PacketByteBuf in project bewitchment by MoriyaShiine.
the class SyncContractsPacket method handle.
public static void handle(MinecraftClient client, ClientPlayNetworkHandler network, PacketByteBuf buf, PacketSender sender) {
NbtCompound contractsCompound = buf.readNbt();
client.execute(new Runnable() {
@Override
public void run() {
if (client.player != null) {
BWComponents.CONTRACTS_COMPONENT.maybeGet(client.player).ifPresent(contractsComponent -> {
contractsComponent.getContracts().clear();
NbtList contractsList = contractsCompound.getList("Contracts", NbtType.COMPOUND);
for (int i = 0; i < contractsList.size(); i++) {
NbtCompound contractCompound = contractsList.getCompound(i);
contractsComponent.addContract(new Contract.Instance(BWRegistries.CONTRACTS.get(new Identifier(contractCompound.getString("Contract"))), contractCompound.getInt("Duration"), contractCompound.getInt("Cost")));
}
});
}
}
});
}
use of net.minecraft.network.PacketByteBuf in project bewitchment by MoriyaShiine.
the class SyncHornedSpearPacket method send.
public static void send(PlayerEntity player, HornedSpearEntity entity) {
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
buf.writeInt(entity.getId());
buf.writeItemStack(entity.spear);
ServerPlayNetworking.send((ServerPlayerEntity) player, ID, buf);
}
use of net.minecraft.network.PacketByteBuf in project MCDoom by AzureDoom.
the class Ballista method inventoryTick.
@Override
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
if (world.isClient) {
if (((PlayerEntity) entity).getMainHandStack().getItem() instanceof Ballista && ClientInit.reload.isPressed() && selected) {
PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
passedData.writeBoolean(true);
ClientPlayNetworking.send(DoomMod.BALLISTA, passedData);
}
}
}
use of net.minecraft.network.PacketByteBuf in project MCDoom by AzureDoom.
the class Chaingun method inventoryTick.
@Override
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
if (world.isClient) {
if (((PlayerEntity) entity).getMainHandStack().getItem() instanceof Chaingun && ClientInit.reload.isPressed() && selected) {
PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
passedData.writeBoolean(true);
ClientPlayNetworking.send(DoomMod.CHAINGUN, passedData);
}
}
}
Aggregations