use of net.minecraft.util.AxisAlignedBB in project SecurityCraft by Geforce132.
the class BlockPortableRadar method addEffectsToPlayers.
public void addEffectsToPlayers(World par1World, int par2, int par3, int par4) {
if (par1World.isRemote) {
return;
} else {
// double d0 = (double)(5 * 10);
double d0 = (double) (mod_SecurityCraft.configHandler.portableRadarSearchRadius);
AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox((double) par2, (double) par3, (double) par4, (double) (par2 + 1), (double) (par3 + 1), (double) (par4 + 1)).expand(d0, d0, d0);
axisalignedbb.maxY = (double) par1World.getHeight();
List list = par1World.getEntitiesWithinAABB(EntityPlayer.class, axisalignedbb);
Iterator iterator = list.iterator();
EntityPlayer entityplayer;
if (list.isEmpty()) {
if (par1World.getTileEntity(par2, par3, par4) != null && par1World.getTileEntity(par2, par3, par4) instanceof TileEntityPortableRadar && ((CustomizableSCTE) par1World.getTileEntity(par2, par3, par4)).hasModule(EnumCustomModules.REDSTONE) && par1World.getBlockMetadata(par2, par3, par4) == 1) {
this.togglePowerOutput(par1World, par2, par3, par4, false);
return;
}
}
while (iterator.hasNext()) {
EntityPlayerMP entityplayermp = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(((TileEntityPortableRadar) par1World.getTileEntity(par2, par3, par4)).getUsername());
entityplayer = (EntityPlayer) iterator.next();
if (this.isOwnerOnline(((TileEntityPortableRadar) par1World.getTileEntity(par2, par3, par4)).getUsername())) {
if (!((TileEntityPortableRadar) par1World.getTileEntity(par2, par3, par4)).isEmped()) {
HelpfulMethods.sendMessageToPlayer(entityplayermp, ((TileEntityPortableRadar) par1World.getTileEntity(par2, par3, par4)).hasCustomName() ? (EnumChatFormatting.ITALIC + entityplayer.getCommandSenderName() + EnumChatFormatting.RESET + " is near your portable radar named " + EnumChatFormatting.ITALIC + ((TileEntityPortableRadar) par1World.getTileEntity(par2, par3, par4)).getCustomName() + EnumChatFormatting.RESET + ".") : (EnumChatFormatting.ITALIC + entityplayer.getCommandSenderName() + EnumChatFormatting.RESET + " is near a portable radar (at X: " + par2 + " Y:" + par3 + " Z:" + par4 + ")."), null);
} else {
HelpfulMethods.sendMessageToPlayer(entityplayermp, "xxxxxxxxxx", EnumChatFormatting.OBFUSCATED);
}
}
if (par1World.getTileEntity(par2, par3, par4) != null && par1World.getTileEntity(par2, par3, par4) instanceof TileEntityPortableRadar && ((CustomizableSCTE) par1World.getTileEntity(par2, par3, par4)).hasModule(EnumCustomModules.REDSTONE)) {
this.togglePowerOutput(par1World, par2, par3, par4, true);
}
}
}
}
use of net.minecraft.util.AxisAlignedBB in project SecurityCraft by Geforce132.
the class TileEntitySCTE method updateEntity.
@Override
public void updateEntity() {
if (viewActivated) {
if (blockPlaceCooldown > 0) {
blockPlaceCooldown--;
return;
}
if (viewCooldown > 0) {
viewCooldown--;
return;
}
int i = xCoord;
int j = yCoord;
int k = zCoord;
AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(i, j, k, i, j, k).expand(5, 5, 5);
List<?> list = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);
Iterator<?> iterator = list.iterator();
EntityLivingBase entity;
while (iterator.hasNext()) {
entity = (EntityLivingBase) iterator.next();
double eyeHeight = entity.getEyeHeight();
boolean isPlayer = (entity instanceof EntityPlayer);
Vec3 lookVec = Vec3.createVectorHelper((entity.posX + (entity.getLookVec().xCoord * 5)), ((eyeHeight + entity.posY) + (entity.getLookVec().yCoord * 5)), (entity.posZ + (entity.getLookVec().zCoord * 5)));
MovingObjectPosition mop = worldObj.rayTraceBlocks(Vec3.createVectorHelper(entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ), lookVec);
if (mop != null && mop.typeOfHit == MovingObjectType.BLOCK)
if (mop.blockX == xCoord && mop.blockY == yCoord && mop.blockZ == zCoord)
if ((isPlayer && activatedOnlyByPlayer()) || !activatedOnlyByPlayer()) {
entityViewed(entity);
viewCooldown = getViewCooldown();
}
}
}
if (attacks) {
if (attackCooldown < getTicksBetweenAttacks()) {
attackCooldown++;
return;
}
if (canAttack()) {
int i = xCoord;
int j = yCoord;
int k = zCoord;
AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(i, j, k, i + 1, j + 1, k + 1).expand(getAttackRange(), getAttackRange(), getAttackRange());
List<?> list = worldObj.getEntitiesWithinAABB(entityTypeToAttack(), axisalignedbb);
Iterator<?> iterator = list.iterator();
if (!worldObj.isRemote) {
boolean attacked = false;
while (iterator.hasNext()) {
Entity mobToAttack = (Entity) iterator.next();
if (mobToAttack == null || mobToAttack instanceof EntityItem || !shouldAttackEntityType(mobToAttack))
continue;
if (attackEntity(mobToAttack))
attacked = true;
}
if (attacked || shouldRefreshAttackCooldown())
attackCooldown = 0;
if (attacked || shouldSyncToClient())
sync();
}
}
}
}
use of net.minecraft.util.AxisAlignedBB in project SecurityCraft by Geforce132.
the class TileEntityClaymore method update.
@Override
public void update() {
if (getWorld().isRemote)
return;
else {
if (((Boolean) getWorld().getBlockState(getPos()).getValue(BlockClaymore.DEACTIVATED)).booleanValue())
return;
if (cooldown > 0) {
cooldown--;
return;
}
if (cooldown == 0) {
BlockUtils.destroyBlock(getWorld(), getPos(), false);
getWorld().createExplosion((Entity) null, entityX, entityY + 0.5F, entityZ, 3.5F, true);
return;
}
EnumFacing dir = BlockUtils.getBlockProperty(getWorld(), getPos(), BlockClaymore.FACING);
AxisAlignedBB axisalignedbb = AxisAlignedBB.fromBounds(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1);
if (dir == EnumFacing.NORTH)
axisalignedbb = axisalignedbb.addCoord(0, 0, -SecurityCraft.config.claymoreRange);
else if (dir == EnumFacing.SOUTH)
axisalignedbb = axisalignedbb.addCoord(0, 0, SecurityCraft.config.claymoreRange);
if (dir == EnumFacing.EAST)
axisalignedbb = axisalignedbb.addCoord(SecurityCraft.config.claymoreRange, 0, 0);
else if (dir == EnumFacing.WEST)
axisalignedbb = axisalignedbb.addCoord(-SecurityCraft.config.claymoreRange, 0, 0);
List<?> list = getWorld().getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);
Iterator<?> iterator = list.iterator();
EntityLivingBase entityliving;
while (iterator.hasNext()) {
entityliving = (EntityLivingBase) iterator.next();
if (PlayerUtils.isPlayerMountedOnCamera(entityliving))
continue;
entityX = entityliving.posX;
entityY = entityliving.posY;
entityZ = entityliving.posZ;
cooldown = 20;
getWorld().playSoundEffect(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, "random.click", 0.3F, 0.6F);
break;
}
}
}
use of net.minecraft.util.AxisAlignedBB in project SecurityCraft by Geforce132.
the class TileEntityIMS method launchMine.
/**
* Create a bounding box around the IMS, and fire a mine if a mob or player is found.
*/
private void launchMine() {
boolean launchedMine = false;
if (bombsRemaining > 0) {
double d0 = SecurityCraft.config.imsRange;
AxisAlignedBB axisalignedbb = AxisAlignedBB.fromBounds(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1).expand(d0, d0, d0);
List<?> list1 = worldObj.getEntitiesWithinAABB(EntityPlayer.class, axisalignedbb);
List<?> list2 = worldObj.getEntitiesWithinAABB(EntityMob.class, axisalignedbb);
Iterator<?> iterator1 = list1.iterator();
Iterator<?> iterator2 = list2.iterator();
while (targetingOption == EnumIMSTargetingMode.PLAYERS_AND_MOBS && iterator2.hasNext()) {
EntityLivingBase entity = (EntityLivingBase) iterator2.next();
int launchHeight = getLaunchHeight();
if (PlayerUtils.isPlayerMountedOnCamera(entity))
continue;
if (WorldUtils.isPathObstructed(worldObj, pos.getX() + 0.5D, pos.getY() + (((launchHeight - 1) / 3) + 0.5D), pos.getZ() + 0.5D, entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ))
continue;
if (hasModule(EnumCustomModules.WHITELIST) && ModuleUtils.getPlayersFromModule(worldObj, pos, EnumCustomModules.WHITELIST).contains(entity.getCommandSenderName().toLowerCase()))
continue;
double d5 = entity.posX - (pos.getX() + 0.5D);
double d6 = entity.getEntityBoundingBox().minY + entity.height / 2.0F - (pos.getY() + 1.25D);
double d7 = entity.posZ - (pos.getZ() + 0.5D);
this.spawnMine(entity, d5, d6, d7, launchHeight);
if (worldObj.isRemote)
SecurityCraft.network.sendToAll(new PacketCPlaySoundAtPos(pos.getX(), pos.getY(), pos.getZ(), "random.bow", 1.0F));
bombsRemaining--;
if (bombsRemaining == 0)
worldObj.scheduleUpdate(pos, BlockUtils.getBlock(worldObj, pos), 140);
launchedMine = true;
updateBombCount = true;
break;
}
while (!launchedMine && iterator1.hasNext()) {
EntityPlayer entity = (EntityPlayer) iterator1.next();
int launchHeight = getLaunchHeight();
if ((entity != null && getOwner().isOwner((entity))) || PlayerUtils.isPlayerMountedOnCamera(entity))
continue;
if (WorldUtils.isPathObstructed(worldObj, pos.getX() + 0.5D, pos.getY() + (((launchHeight - 1) / 3) + 0.5D), pos.getZ() + 0.5D, entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ))
continue;
if (hasModule(EnumCustomModules.WHITELIST) && ModuleUtils.getPlayersFromModule(worldObj, pos, EnumCustomModules.WHITELIST).contains(entity.getCommandSenderName()))
continue;
double d5 = entity.posX - (pos.getX() + 0.5D);
double d6 = entity.getEntityBoundingBox().minY + entity.height / 2.0F - (pos.getY() + 1.25D);
double d7 = entity.posZ - (pos.getZ() + 0.5D);
this.spawnMine(entity, d5, d6, d7, launchHeight);
if (worldObj.isRemote)
SecurityCraft.network.sendToAll(new PacketCPlaySoundAtPos(pos.getX(), pos.getY(), pos.getZ(), "random.bow", 1.0F));
bombsRemaining--;
if (bombsRemaining == 0)
worldObj.scheduleUpdate(pos, BlockUtils.getBlock(worldObj, pos), 140);
updateBombCount = true;
break;
}
}
}
use of net.minecraft.util.AxisAlignedBB in project Galacticraft by micdoodle8.
the class BlockTier1TreasureChest method isOcelotSittingOnChest.
private boolean isOcelotSittingOnChest(World worldIn, BlockPos pos) {
Iterator iterator = worldIn.getEntitiesWithinAABB(EntityOcelot.class, new AxisAlignedBB((double) pos.getX(), (double) (pos.getY() + 1), (double) pos.getZ(), (double) (pos.getX() + 1), (double) (pos.getY() + 2), (double) (pos.getZ() + 1))).iterator();
EntityOcelot entityocelot;
do {
if (!iterator.hasNext()) {
return false;
}
Entity entity = (Entity) iterator.next();
entityocelot = (EntityOcelot) entity;
} while (!entityocelot.isSitting());
return true;
}
Aggregations