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