use of net.minecraft.util.AxisAlignedBB in project LogisticsPipes by RS485.
the class HSTubeSCurve method addCollisionBoxesToList.
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings({ "unchecked", "rawtypes" })
public void addCollisionBoxesToList(List arraylist, AxisAlignedBB axisalignedbb) {
if (boxes == null || boxes.isEmpty()) {
boxes = new ArrayList<>();
double x = getX();
double y = getY();
double z = getZ();
for (int i = -1; i < 54; i++) {
double xOne = x;
double yOne = y;
double zOne = z;
double xTwo = x;
double yTwo = y + 1;
double zTwo = z;
if (orientation.getRenderOrientation() == TurnSDirection.NORTH_INV || orientation.getRenderOrientation() == TurnSDirection.NORTH) {
zOne += 1;
zTwo += 1;
zOne -= 4.0F * (i - 4) / 50;
zTwo -= 4.0F * (i + 4) / 50;
xOne -= 1;
xTwo += 2;
} else if (orientation.getRenderOrientation() == TurnSDirection.EAST_INV || orientation.getRenderOrientation() == TurnSDirection.EAST) {
xOne += 4;
xTwo += 4;
xOne -= 4.0F * (i - 4) / 50;
xTwo -= 4.0F * (i + 4) / 50;
zOne -= 1;
zTwo += 2;
}
AxisAlignedBB box = SCurveTubeRenderer.getObjectBoundsAt(AxisAlignedBB.getBoundingBox(Math.min(xOne, xTwo), Math.min(yOne, yTwo), Math.min(zOne, zTwo), Math.max(xOne, xTwo), Math.max(yOne, yTwo), Math.max(zOne, zTwo)).getOffsetBoundingBox(-x, -y, -z), orientation);
if (box != null) {
LPPositionSet<DoubleCoordinates> lpBox = new LPPositionSet<>(DoubleCoordinates.class);
lpBox.addFrom(box);
DoubleCoordinates center = lpBox.getCenter();
box = AxisAlignedBB.getBoundingBox(center.getXCoord() - 0.3D, center.getYCoord() - 0.3D, center.getZCoord() - 0.3D, center.getXCoord() + 0.3D, center.getYCoord() + 0.3D, center.getZCoord() + 0.3D);
if (box != null) {
AxisAlignedBB cBox = getCompleteBox();
if (box.minX < cBox.minX) {
box.minX = cBox.minX;
}
if (box.minY < cBox.minY) {
box.minY = cBox.minY;
}
if (box.minZ < cBox.minZ) {
box.minZ = cBox.minZ;
}
if (box.maxX > cBox.maxX) {
box.maxX = cBox.maxX;
}
if (box.maxY > cBox.maxY) {
box.maxY = cBox.maxY;
}
if (box.maxZ > cBox.maxZ) {
box.maxZ = cBox.maxZ;
}
box = box.getOffsetBoundingBox(x, y, z);
boxes.add(box);
}
}
}
}
arraylist.addAll(boxes.stream().filter(box -> box != null && (axisalignedbb == null || axisalignedbb.intersectsWith(box))).collect(Collectors.toList()));
}
use of net.minecraft.util.AxisAlignedBB in project ICBM-Classic by BuiltBrokenModding.
the class BlastChemical method doExplode.
@Override
public void doExplode() {
float radius = this.getRadius();
if (this.world().isRemote) {
for (int i = 0; i < 200; i++) {
Pos diDian = new Pos(Math.random() * radius / 2 - radius / 4, Math.random() * radius / 2 - radius / 4, Math.random() * radius / 2 - radius / 4);
diDian = diDian.multiply(Math.min(radius, callCount) / 10);
if (diDian.magnitude() <= radius) {
diDian = diDian.add(this.position);
ICBMClassic.proxy.spawnParticle("smoke", this.world(), diDian, (Math.random() - 0.5) / 2, (Math.random() - 0.5) / 2, (Math.random() - 0.5) / 2, this.red, this.green, this.blue, 7.0F, 8);
}
}
}
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(position.x() - radius, position.y() - radius, position.z() - radius, position.x() + radius, position.y() + radius, position.z() + radius);
List<EntityLivingBase> allEntities = world().getEntitiesWithinAABB(EntityLivingBase.class, bounds);
for (EntityLivingBase entity : allEntities) {
if (this.isContagious) {
ICBMClassic.contagios_potion.poisonEntity(position.toPos(), entity);
}
if (this.isPoisonous) {
ICBMClassic.poisonous_potion.poisonEntity(position.toPos(), entity);
}
if (this.isConfuse) {
entity.addPotionEffect(new CustomPotionEffect(Potion.confusion.id, 18 * 20, 0));
entity.addPotionEffect(new CustomPotionEffect(Potion.digSlowdown.id, 20 * 60, 0));
entity.addPotionEffect(new CustomPotionEffect(Potion.moveSlowdown.id, 20 * 60, 2));
}
}
if (this.isMutate) {
new BlastMutation(world(), this.exploder, position.x(), position.y(), position.z(), this.getRadius()).explode();
}
if (this.playShortSoundFX) {
world().playSoundEffect(position.x() + 0.5D, position.y() + 0.5D, position.z() + 0.5D, ICBMClassic.PREFIX + "gasleak", 4.0F, (1.0F + (world().rand.nextFloat() - world().rand.nextFloat()) * 0.2F) * 1F);
}
if (this.callCount > this.duration) {
this.controller.endExplosion();
}
}
use of net.minecraft.util.AxisAlignedBB in project ICBM-Classic by BuiltBrokenModding.
the class BlastRedmatter method doPostExplode.
@Override
protected void doPostExplode() {
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(this.explosionX - this.explosionSize, this.explosionY - this.explosionSize, this.explosionZ - this.explosionSize, this.explosionX + this.explosionSize, this.explosionY + this.explosionSize, this.explosionZ + this.explosionSize);
List<?> list = this.world().getEntitiesWithinAABB(EntityExplosion.class, bounds);
for (Object obj : list) {
if (obj instanceof EntityExplosion) {
EntityExplosion explosion = (EntityExplosion) obj;
if (explosion.getBlast() == this) {
explosion.setDead();
}
}
}
}
use of net.minecraft.util.AxisAlignedBB in project Trains-In-Motion-1.7.10 by EternalBlueFlame.
the class ParticleFX method onUpdate.
/**
* <h2>movement calculations</h2>
* call this from the host's onUpdate to update the position of the particle.
* @param host the host entity to get the world object from.
*/
public void onUpdate(Entity host, double x, double y, double z, boolean hostIsRunning) {
posX = (float) x;
posY = (float) y;
posZ = (float) z;
//if the lifespan is out we reset the information, as if we just spawned a new particle.
if (hostIsRunning && this.ticksExisted > this.lifespan) {
colorTint = (rand.nextInt(60) - 30) * 0.005f;
lifespan = rand.nextInt(60) + 100;
ticksExisted = 0;
this.boundingBox.setBounds(posX + offset[0] - 0.1, posY + offset[1] - 0.1, posZ + offset[2] - 0.1, posX + offset[0] + 0.1, posY + offset[1] + 0.1, posZ + offset[2] + 0.1);
motionX = originMotionX;
motionY = originMotionY;
motionZ = originMotionZ;
shouldRender = true;
} else if (this.ticksExisted > this.lifespan) {
//if the transport isn't running and this has finished it's movement, set it' position to the transport and set that it shouldn't render.
this.boundingBox.setBounds(posX, posY, posZ, posX, posY, posZ);
shouldRender = false;
return;
}
//set the old motion values so we can compare them later.
oldX = motionX;
oldY = motionY;
oldZ = motionZ;
//instance a bounding box variable now so we won't have to cast as much later.
AxisAlignedBB box;
list = host.worldObj.getCollidingBoundingBoxes(host, this.boundingBox.addCoord(motionX, motionY, motionZ));
//iterate the list and check for collisions
for (Object obj : list) {
box = ((AxisAlignedBB) obj);
if (motionY < 0.001 || motionY > -0.001) {
motionY = box.calculateYOffset(this.boundingBox, motionY);
}
if (motionX < 0.0001 || motionX > -0.0001) {
motionX = box.calculateXOffset(this.boundingBox, motionX);
}
if (motionZ < 0.0001 || motionZ > -0.0001) {
motionZ = box.calculateZOffset(this.boundingBox, motionZ);
}
}
//check for collisions on the Y vector and apply movement accordingly, also always keep it attempting to float up.
if (motionY < 0.001 || motionY > -0.001) {
this.boundingBox.offset(0.0D, motionY, 0.0D);
if (oldY != motionY) {
motionZ *= 1.5d;
motionZ += rand.nextBoolean() ? oldY : rand.nextBoolean() ? 0 : -oldY;
motionX *= 1.5d;
motionX += rand.nextBoolean() ? oldY : rand.nextBoolean() ? 0 : -oldY;
motionY = oldY * -0.4d;
}
if (motionY < 0.005) {
motionY += 0.00075;
}
} else {
motionY += 0.00005;
}
//check for collisions on the x axis.
if (motionX < 0.0001 || motionX > -0.0001) {
this.boundingBox.offset(motionX, 0.0D, 0.0D);
if (oldX != motionX) {
motionX = this.motionX * 0.75d;
}
motionX *= 0.975;
}
//check for collisions on the Z axis.
if (motionZ < 0.0001 || motionZ > -0.0001) {
this.boundingBox.offset(0.0D, 0.0D, motionZ);
if (oldZ != motionZ) {
motionZ = this.motionZ * 0.75d;
}
motionZ *= 0.975;
}
ticksExisted++;
}
use of net.minecraft.util.AxisAlignedBB in project SecurityCraft by Geforce132.
the class TileEntitySCTE method update.
@Override
public void update() {
if (intersectsEntities) {
int i = pos.getX();
int j = pos.getY();
int k = pos.getZ();
AxisAlignedBB axisalignedbb = (new AxisAlignedBB(i, j, k, i + 1, j + 1, k + 1));
List<?> list = worldObj.getEntitiesWithinAABB(Entity.class, axisalignedbb);
Iterator<?> iterator = list.iterator();
Entity entity;
while (iterator.hasNext()) {
entity = (Entity) iterator.next();
entityIntersecting(entity);
}
}
if (viewActivated) {
if (blockPlaceCooldown > 0) {
blockPlaceCooldown--;
return;
}
if (viewCooldown > 0) {
viewCooldown--;
return;
}
int i = pos.getX();
int j = pos.getY();
int k = pos.getZ();
AxisAlignedBB axisalignedbb = (new AxisAlignedBB(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 = new Vec3((entity.posX + (entity.getLookVec().xCoord * 5)), ((eyeHeight + entity.posY) + (entity.getLookVec().yCoord * 5)), (entity.posZ + (entity.getLookVec().zCoord * 5)));
MovingObjectPosition mop = getWorld().rayTraceBlocks(new Vec3(entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ), lookVec);
if (mop != null && mop.typeOfHit == MovingObjectType.BLOCK)
if (mop.getBlockPos().getX() == getPos().getX() && mop.getBlockPos().getY() == getPos().getY() && mop.getBlockPos().getZ() == getPos().getZ())
if ((isPlayer && activatedOnlyByPlayer()) || !activatedOnlyByPlayer()) {
entityViewed(entity);
viewCooldown = getViewCooldown();
}
}
}
if (attacks) {
if (attackCooldown < getTicksBetweenAttacks()) {
attackCooldown++;
return;
}
if (canAttack()) {
int i = pos.getX();
int j = pos.getY();
int k = pos.getZ();
AxisAlignedBB axisalignedbb = new AxisAlignedBB(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();
}
}
}
}
Aggregations