Search in sources :

Example 81 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project MCDoom by AzureDoom.

the class Chainsaw method inventoryTick.

@Override
public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
    LivingEntity user = (LivingEntity) entityIn;
    PlayerEntity player = (PlayerEntity) entityIn;
    if (player.getMainHandStack().isItemEqualIgnoreDamage(stack) && stack.getDamage() < (stack.getMaxDamage() - 1)) {
        final Box aabb = new Box(entityIn.getBlockPos().up()).expand(1D, 1D, 1D);
        entityIn.getEntityWorld().getOtherEntities(user, aabb).forEach(e -> doDamage(user, e));
        entityIn.getEntityWorld().getOtherEntities(user, aabb).forEach(e -> doDeathCheck(user, e, stack));
        entityIn.getEntityWorld().getOtherEntities(user, aabb).forEach(e -> damageItem(user, stack));
        entityIn.getEntityWorld().getOtherEntities(user, aabb).forEach(e -> addParticle(e));
    }
    if (isSelected && stack.getDamage() < (stack.getMaxDamage() - 1)) {
        worldIn.playSound((PlayerEntity) null, user.getX(), user.getY(), user.getZ(), ModSoundEvents.CHAINSAW_IDLE, SoundCategory.PLAYERS, 0.05F, 1.0F / (worldIn.random.nextFloat() * 0.4F + 1.2F) + 0.25F * 0.5F);
    }
    if (worldIn.isClient) {
        if (player.getMainHandStack().getItem() instanceof Chainsaw && ClientInit.reload.isPressed() && isSelected) {
            PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
            passedData.writeBoolean(true);
            ClientPlayNetworking.send(DoomMod.CHAINSAW, passedData);
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) PacketByteBuf(net.minecraft.network.PacketByteBuf) Box(net.minecraft.util.math.Box) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 82 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project MCDoom by AzureDoom.

the class DGauss 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 DGauss && ClientInit.reload.isPressed() && selected) {
            PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
            passedData.writeBoolean(true);
            ClientPlayNetworking.send(DoomMod.DGAUSS, passedData);
        }
    }
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 83 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project MCDoom by AzureDoom.

the class Shotgun 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 Shotgun && ClientInit.reload.isPressed() && selected) {
            PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
            passedData.writeBoolean(true);
            ClientPlayNetworking.send(DoomMod.SHOTGUN, passedData);
        }
    }
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 84 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project MCDoom by AzureDoom.

the class SuperShotgun 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 SuperShotgun && ClientInit.reload.isPressed() && selected) {
            PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
            passedData.writeBoolean(true);
            ClientPlayNetworking.send(DoomMod.SUPERSHOTGUN, passedData);
        }
    }
    if (((PlayerEntity) entity).getMainHandStack().getItem() instanceof SuperShotgun && selected && ((PlayerProperties) entity).hasMeatHook()) {
        ((PlayerProperties) entity).setHasMeatHook(false);
    }
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf) PlayerProperties(mod.azure.doom.util.PlayerProperties) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 85 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project MCDoom by AzureDoom.

the class Unmaykr 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 Unmaykr && ClientInit.reload.isPressed() && selected) {
            PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
            passedData.writeBoolean(true);
            ClientPlayNetworking.send(DoomMod.UNMAYKR, passedData);
        }
    }
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Aggregations

PacketByteBuf (net.minecraft.network.PacketByteBuf)117 PlayerEntity (net.minecraft.entity.player.PlayerEntity)21 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)14 Identifier (net.minecraft.util.Identifier)8 NbtCompound (net.minecraft.nbt.NbtCompound)7 Environment (net.fabricmc.api.Environment)5 CustomPayloadC2SPacket (net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket)5 CustomPayloadS2CPacket (net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket)4 Nullable (org.jetbrains.annotations.Nullable)4 Inject (org.spongepowered.asm.mixin.injection.Inject)4 ArrayList (java.util.ArrayList)3 UUID (java.util.UUID)3 JSONSource (de.modprog.blockmeter.util.JSONSource)2 Map (java.util.Map)2 ServerPlayNetworking (net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking)2 LivingEntity (net.minecraft.entity.LivingEntity)2 CompoundTag (net.minecraft.nbt.CompoundTag)2 ListTag (net.minecraft.nbt.ListTag)2 ParticleType (net.minecraft.particle.ParticleType)2 LiteralText (net.minecraft.text.LiteralText)2