Search in sources :

Example 1 with PacketGivePotionEffect

use of net.geforcemods.securitycraft.network.packets.PacketGivePotionEffect in project SecurityCraft by Geforce132.

the class EntitySecurityCamera method onUpdate.

@Override
public void onUpdate() {
    if (this.worldObj.isRemote && getRidingEntity() != null) {
        if (this.screenshotCooldown > 0) {
            this.screenshotCooldown -= 1;
        }
        if (this.redstoneCooldown > 0) {
            this.redstoneCooldown -= 1;
        }
        if (this.toggleNightVisionCooldown > 0) {
            this.toggleNightVisionCooldown -= 1;
        }
        if (this.toggleLightCooldown > 0) {
            this.toggleLightCooldown -= 1;
        }
        if (((EntityPlayer) getRidingEntity()).rotationYaw != this.rotationYaw) {
            ((EntityPlayer) getRidingEntity()).setPositionAndRotation(getRidingEntity().posX, getRidingEntity().posY, getRidingEntity().posZ, this.rotationYaw, this.rotationPitch);
            ((EntityPlayer) getRidingEntity()).rotationYaw = this.rotationYaw;
        }
        if (((EntityPlayer) getRidingEntity()).rotationPitch != this.rotationPitch) {
            ((EntityPlayer) getRidingEntity()).setPositionAndRotation(getRidingEntity().posX, getRidingEntity().posY, getRidingEntity().posZ, this.rotationYaw, this.rotationPitch);
        }
        this.checkKeysPressed();
        if (Mouse.hasWheel() && Mouse.isButtonDown(2) && this.screenshotCooldown == 0) {
            this.screenshotCooldown = 30;
            ClientUtils.takeScreenshot();
            Minecraft.getMinecraft().theWorld.playSound(new BlockPos(posX, posY, posZ), SoundEvent.REGISTRY.getObject(SCSounds.CAMERASNAP.path), SoundCategory.BLOCKS, 1.0F, 1.0F, true);
        }
        if (getRidingEntity() != null && this.shouldProvideNightVision) {
            mod_SecurityCraft.network.sendToServer(new PacketGivePotionEffect(Potion.getIdFromPotion(Potion.getPotionFromResourceLocation("night_vision")), 3, -1));
        }
    }
    if (!this.worldObj.isRemote) {
        if (getRidingEntity() == null | BlockUtils.getBlock(worldObj, blockPosX, blockPosY, blockPosZ) != mod_SecurityCraft.securityCamera) {
            this.setDead();
            return;
        }
    }
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) PacketGivePotionEffect(net.geforcemods.securitycraft.network.packets.PacketGivePotionEffect) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

PacketGivePotionEffect (net.geforcemods.securitycraft.network.packets.PacketGivePotionEffect)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 BlockPos (net.minecraft.util.math.BlockPos)1