Search in sources :

Example 36 with AxisAlignedBB

use of net.minecraft.util.AxisAlignedBB in project SecurityCraft by Geforce132.

the class TileEntitySecurityCamera method updateEntity.

public void updateEntity() {
    if (this.worldObj.isRemote) {
        return;
    } else {
        double d0 = 1;
        AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox((double) this.xCoord, (double) this.yCoord, (double) this.zCoord, (double) (this.xCoord + 1), (double) (this.yCoord + 1), (double) (this.zCoord + 1)).expand(d0, d0, d0);
        //System.out.println((int)axisalignedbb.minX + " | " + (int)axisalignedbb.minY + " | " + (int)axisalignedbb.minZ + " | " + (int)axisalignedbb.maxX + " | " + (int)axisalignedbb.maxY + " | " + (int)axisalignedbb.maxZ);
        //axisalignedbb.maxY = (double)this.worldObj.getHeight();
        List list = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, axisalignedbb);
        Iterator iterator = list.iterator();
        EntityPlayer entityplayer;
        if (id1 != "") {
            if (iterator.hasNext()) {
                if (!detectingPlayer && !isPlayerAllowed(((EntityPlayer) iterator.next()).getCommandSenderName())) {
                    detectingPlayer = true;
                }
                HelpfulMethods.updateAndNotify(worldObj, xCoord, yCoord, zCoord, mod_SecurityCraft.securityCamera, 1, true);
            } else {
                if (detectingPlayer) {
                    detectingPlayer = false;
                }
                HelpfulMethods.updateAndNotify(worldObj, xCoord, yCoord, zCoord, mod_SecurityCraft.securityCamera, 1, true);
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) Iterator(java.util.Iterator) EntityPlayer(net.minecraft.entity.player.EntityPlayer) List(java.util.List)

Example 37 with AxisAlignedBB

use of net.minecraft.util.AxisAlignedBB in project SecurityCraft by Geforce132.

the class TileEntityLogger method logPlayers.

public void logPlayers() {
    if (this.worldObj.isRemote) {
        return;
    } else {
        double d0 = (double) (mod_SecurityCraft.configHandler.usernameLoggerSearchRadius);
        AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox((double) this.xCoord, (double) this.yCoord, (double) this.zCoord, (double) (this.xCoord + 1), (double) (this.yCoord + 1), (double) (this.zCoord + 1)).expand(d0, d0, d0);
        List list = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, axisalignedbb);
        Iterator iterator = list.iterator();
        EntityPlayer entityplayer;
        while (iterator.hasNext()) {
            addPlayerName(((EntityPlayer) iterator.next()).getCommandSenderName());
        }
        sendChangeToClient();
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) Iterator(java.util.Iterator) EntityPlayer(net.minecraft.entity.player.EntityPlayer) List(java.util.List)

Example 38 with AxisAlignedBB

use of net.minecraft.util.AxisAlignedBB in project BetterStorage by copygirl.

the class Attachments method rayTrace.

// Called in Block.collisionRayTrace.
public MovingObjectPosition rayTrace(World world, int x, int y, int z, Vec3 start, Vec3 end) {
    AxisAlignedBB aabb = tileEntity.getBlockType().getCollisionBoundingBoxFromPool(world, x, y, z);
    MovingObjectPosition target = aabb.calculateIntercept(start, end);
    EntityPlayer player = playerLocal.get();
    double distance = ((target != null) ? start.distanceTo(target.hitVec) : Double.MAX_VALUE);
    for (Attachment attachment : this) {
        if (!attachment.boxVisible(player))
            continue;
        AxisAlignedBB attachmentBox = attachment.getHighlightBox();
        MovingObjectPosition attachmentTarget = attachmentBox.calculateIntercept(start, end);
        if (attachmentTarget == null)
            continue;
        double attachmentDistance = start.distanceTo(attachmentTarget.hitVec);
        if (attachmentDistance >= distance)
            continue;
        distance = attachmentDistance;
        target = attachmentTarget;
        target.subHit = attachment.subId;
    }
    if (target != null) {
        target.blockX = x;
        target.blockY = y;
        target.blockZ = z;
    }
    return target;
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 39 with AxisAlignedBB

use of net.minecraft.util.AxisAlignedBB in project BetterStorage by copygirl.

the class LockAttachment method attack.

private boolean attack(EntityPlayer player, ItemStack holding) {
    ILockable lockable = (ILockable) tileEntity;
    ItemStack lock = lockable.getLock();
    if (lock == null)
        return false;
    boolean canHurt = ((hit <= 0) && canHurtLock(holding));
    if (canHurt) {
        holding.damageItem(2, player);
        if (holding.stackSize <= 0)
            player.destroyCurrentEquippedItem();
    }
    if (!player.worldObj.isRemote) {
        if (canHurt) {
            hit = 10;
            int damage = (int) ((AttributeModifier) holding.getAttributeModifiers().get(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName()).iterator().next()).getAmount();
            int sharpness = EnchantmentHelper.getEnchantmentLevel(Enchantment.sharpness.effectId, holding);
            int efficiency = EnchantmentHelper.getEnchantmentLevel(Enchantment.efficiency.effectId, holding);
            breakProgress += Math.min(damage, 10) / 2 + Math.min(Math.max(sharpness, efficiency), 5);
            int persistance = BetterStorageEnchantment.getLevel(lock, "persistance");
            if (breakProgress > 100 * (1 + persistance)) {
                int unbreaking = EnchantmentHelper.getEnchantmentLevel(Enchantment.unbreaking.effectId, lock);
                lock.setItemDamage(lock.getItemDamage() + 10 / (1 + unbreaking));
                if (lock.getItemDamage() < lock.getMaxDamage()) {
                    AxisAlignedBB box = getHighlightBox();
                    double x = (box.minX + box.maxX) / 2;
                    double y = (box.minY + box.maxY) / 2;
                    double z = (box.minZ + box.maxZ) / 2;
                    EntityItem item = WorldUtils.spawnItem(tileEntity.getWorldObj(), x, y, z, lock);
                }
                lockable.setLock(null);
                breakProgress = 0;
            }
            ((ILock) lock.getItem()).applyEffects(lock, lockable, player, EnumLockInteraction.ATTACK);
        }
        BetterStorage.networkChannel.sendToAllAround(new PacketLockHit(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, canHurt), tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, 32);
    } else
        hit(canHurt);
    return true;
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) PacketLockHit(net.mcft.copy.betterstorage.network.packet.PacketLockHit) ItemStack(net.minecraft.item.ItemStack) ILock(net.mcft.copy.betterstorage.api.lock.ILock) EntityItem(net.minecraft.entity.item.EntityItem) ILockable(net.mcft.copy.betterstorage.api.lock.ILockable)

Example 40 with AxisAlignedBB

use of net.minecraft.util.AxisAlignedBB in project BetterStorage by copygirl.

the class LockAttachment method hit.

@SideOnly(Side.CLIENT)
public void hit(boolean damage) {
    wiggleStrength = Math.min(20.0F, wiggleStrength + 12.0F);
    if (damage) {
        hit = 10;
        AxisAlignedBB box = getHighlightBox();
        double x = (box.minX + box.maxX) / 2;
        double y = (box.minY + box.maxY) / 2;
        double z = (box.minZ + box.maxZ) / 2;
        tileEntity.getWorldObj().playSound(x, y, z, "random.break", 0.5F, 2.5F, false);
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Aggregations

AxisAlignedBB (net.minecraft.util.AxisAlignedBB)74 Entity (net.minecraft.entity.Entity)24 EntityPlayer (net.minecraft.entity.player.EntityPlayer)20 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)18 ItemStack (net.minecraft.item.ItemStack)15 TileEntity (net.minecraft.tileentity.TileEntity)14 ArrayList (java.util.ArrayList)13 Vec3 (net.minecraft.util.Vec3)13 List (java.util.List)11 EntityItem (net.minecraft.entity.item.EntityItem)11 Block (net.minecraft.block.Block)10 EntityLivingBase (net.minecraft.entity.EntityLivingBase)9 Pos (com.builtbroken.mc.imp.transform.vector.Pos)7 SideOnly (cpw.mods.fml.relauncher.SideOnly)7 Iterator (java.util.Iterator)4 LPPositionSet (logisticspipes.utils.LPPositionSet)4 World (net.minecraft.world.World)4 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)4 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)4 EntityFlyingBlock (icbm.classic.content.entity.EntityFlyingBlock)3