use of net.minecraft.util.AxisAlignedBB in project Galacticraft by micdoodle8.
the class GCPlayerBaseSP method afterUpdateEntityActionState.
@Override
public void afterUpdateEntityActionState() {
if (this.player.worldObj.provider instanceof IZeroGDimension) {
this.player.setJumping(false);
AxisAlignedBB aABB = this.player.getEntityBoundingBox();
if ((aABB.minY % 1D) == 0.5D)
this.player.setEntityBoundingBox(aABB.offset(0D, 0.00001D, 0D));
}
}
use of net.minecraft.util.AxisAlignedBB in project Galacticraft by micdoodle8.
the class TileEntityEmergencyBox method update.
@Override
public void update() {
if (!this.activated) {
this.activated = true;
this.setLightBlocks();
this.thisVec3 = new Vec3(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ());
this.vec3Centre = new Vec3(this.pos.getX() + 0.5D, this.pos.getY() + 0.5D, this.pos.getZ() + 0.5D);
this.mobsAABB = AxisAlignedBB.fromBounds(this.pos.getX() - 14, this.pos.getY() - 7, this.pos.getZ() - 14, this.pos.getX() + 14, this.pos.getY() + 7, this.pos.getZ() + 14);
}
if (this.worldObj.isRemote) {
if (this.openN && this.angleA < 90F) {
this.lastAngleA = this.angleA;
this.angleA += SPEED;
if (this.angleA > 90F)
this.angleA = 90F;
}
if (this.openW && this.angleB < 90F) {
this.lastAngleB = this.angleB;
this.angleB += SPEED;
if (this.angleB > 90F)
this.angleB = 90F;
}
if (this.openS && this.angleC < 90F) {
this.lastAngleC = this.angleC;
this.angleC += SPEED;
if (this.angleC > 90F)
this.angleC = 90F;
}
if (this.openE && this.angleD < 90F) {
this.lastAngleD = this.angleD;
this.angleD += SPEED;
if (this.angleD > 90F)
this.angleD = 90F;
}
if (!this.openN && this.angleA > 0F) {
this.lastAngleA = this.angleA;
this.angleA -= SPEED;
if (this.angleA < 0F)
this.angleA = 0F;
}
if (!this.openW && this.angleB > 0F) {
this.lastAngleB = this.angleB;
this.angleB -= SPEED;
if (this.angleB < 0F)
this.angleB = 0F;
}
if (!this.openS && this.angleC > 0F) {
this.lastAngleC = this.angleC;
this.angleC -= SPEED;
if (this.angleC < 0F)
this.angleC = 0F;
}
if (!this.openE && this.angleD > 0F) {
this.lastAngleD = this.angleD;
this.angleD -= SPEED;
if (this.angleD < 0F)
this.angleD = 0F;
}
} else {
if (this.cooldown > 0) {
this.cooldown--;
}
boolean updateRequired = false;
if (this.openN) {
boolean clash = false;
BlockPos testPos = this.pos.north(1);
IBlockState bs = this.worldObj.getBlockState(testPos);
if (!(bs.getBlock() instanceof BlockAir)) {
if (bs.getBlock().isOpaqueCube()) {
clash = true;
} else {
AxisAlignedBB check = AxisAlignedBB.fromBounds(this.pos.getX() + 0.125D, this.pos.getY() + 0.125D, this.pos.getZ() - 5 / 16D, this.pos.getX() + 0.875D, this.pos.getY() + 0.875D, this.pos.getZ());
AxisAlignedBB neighbour = bs.getBlock().getCollisionBoundingBox(this.worldObj, testPos, bs);
if (neighbour != null) {
clash = check.intersectsWith(neighbour);
}
}
}
if (clash) {
this.openN = false;
updateRequired = true;
}
}
if (this.openS) {
boolean clash = false;
BlockPos testPos = this.pos.south(1);
IBlockState bs = this.worldObj.getBlockState(testPos);
if (!(bs.getBlock() instanceof BlockAir)) {
if (bs.getBlock().isOpaqueCube()) {
clash = true;
} else {
AxisAlignedBB check = AxisAlignedBB.fromBounds(this.pos.getX() + 0.125D, this.pos.getY() + 0.125D, this.pos.getZ() + 1D, this.pos.getX() + 0.875D, this.pos.getY() + 0.875D, this.pos.getZ() + 21 / 16D);
AxisAlignedBB neighbour = bs.getBlock().getCollisionBoundingBox(this.worldObj, testPos, bs);
if (neighbour != null) {
clash = check.intersectsWith(neighbour);
}
}
}
if (clash) {
this.openS = false;
updateRequired = true;
}
}
if (this.openW) {
boolean clash = false;
BlockPos testPos = this.pos.west(1);
IBlockState bs = this.worldObj.getBlockState(testPos);
if (!(bs.getBlock() instanceof BlockAir)) {
if (bs.getBlock().isOpaqueCube()) {
clash = true;
} else {
AxisAlignedBB check = AxisAlignedBB.fromBounds(this.pos.getX() - 5 / 16D, this.pos.getY() + 0.125D, this.pos.getZ() + 0.125D, this.pos.getX(), this.pos.getY() + 0.875D, this.pos.getZ() + 0.875D);
AxisAlignedBB neighbour = bs.getBlock().getCollisionBoundingBox(this.worldObj, testPos, bs);
if (neighbour != null) {
clash = check.intersectsWith(neighbour);
}
}
}
if (clash) {
this.openW = false;
updateRequired = true;
}
}
if (this.openE) {
boolean clash = false;
BlockPos testPos = this.pos.east(1);
IBlockState bs = this.worldObj.getBlockState(testPos);
if (!(bs.getBlock() instanceof BlockAir)) {
if (bs.getBlock().isOpaqueCube()) {
clash = true;
} else {
AxisAlignedBB check = AxisAlignedBB.fromBounds(this.pos.getX() + 1D, this.pos.getY() + 0.125D, this.pos.getZ() + 0.125D, this.pos.getX() + 21 / 16D, this.pos.getY() + 0.875D, this.pos.getZ() + 0.875D);
AxisAlignedBB neighbour = bs.getBlock().getCollisionBoundingBox(this.worldObj, testPos, bs);
if (neighbour != null) {
clash = check.intersectsWith(neighbour);
}
}
}
if (clash) {
this.openE = false;
updateRequired = true;
}
}
if (updateRequired) {
this.updateClients();
}
if (this.worldObj.rand.nextInt(15) == 0) {
this.scareMobs();
}
}
}
use of net.minecraft.util.AxisAlignedBB in project BuildCraft by BuildCraft.
the class PipeItemsObsidian method getSuckingBox.
private AxisAlignedBB getSuckingBox(EnumFacing orientation, int distance) {
if (orientation == null) {
return null;
}
Vec3d p1 = Utils.convert(container.getPos()).add(Utils.VEC_HALF);
Vec3d p2 = p1;
switch(orientation) {
case EAST:
p1 = p1.addVector(distance, 0, 0);
p2 = p2.addVector(distance + 1, 0, 0);
break;
case WEST:
p1 = p1.addVector(-distance - 1, 0, 0);
p2 = p2.addVector(-distance, 0, 0);
break;
case UP:
case DOWN:
p1 = p1.addVector(distance + 1, 0, distance + 1);
p2 = p2.addVector(-distance, 0, -distance);
break;
case SOUTH:
p1 = p1.addVector(0, 0, distance);
p2 = p2.addVector(0, 0, distance + 1);
break;
case NORTH:
default:
p1 = p1.addVector(0, 0, -distance - 1);
p2 = p2.addVector(0, 0, -distance);
break;
}
switch(orientation) {
case EAST:
case WEST:
p1 = p1.addVector(0, distance + 1, distance + 1);
p2 = p2.addVector(0, -distance, -distance);
break;
case UP:
p1 = p1.addVector(0, distance + 1, 0);
p2 = p2.addVector(0, distance, 0);
break;
case DOWN:
p1 = p1.addVector(0, -distance - 1, 0);
p2 = p2.addVector(0, -distance, 0);
break;
case SOUTH:
case NORTH:
default:
p1 = p1.addVector(distance + 1, distance + 1, 0);
p2 = p2.addVector(-distance, -distance, 0);
break;
}
Vec3d min = Utils.min(p1, p2);
Vec3d max = Utils.max(p1, p2);
return new AxisAlignedBB(min.xCoord, min.yCoord, min.zCoord, max.xCoord, max.yCoord, max.zCoord);
}
use of net.minecraft.util.AxisAlignedBB in project BuildCraft by BuildCraft.
the class BlockHighlightHandler method handleBlockHighlight.
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void handleBlockHighlight(DrawBlockHighlightEvent e) {
if (e.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
int x = MathHelper.floor_double(e.target.hitVec.xCoord);
int y = MathHelper.floor_double(e.target.hitVec.yCoord);
int z = MathHelper.floor_double(e.target.hitVec.zCoord);
BlockPos pos = new BlockPos(x, y, z);
IBlockState state = e.player.worldObj.getBlockState(pos);
Block block = state.getBlock();
if (block instanceof ICustomHighlight) {
AxisAlignedBB[] aabbs = ((ICustomHighlight) block).getBoxes(e.player.worldObj, pos, state);
Vec3d nPos = e.player.getPositionEyes(e.partialTicks).subtract(0, e.player.getEyeHeight(), 0);
// Highlight "breathing"
long millis = System.currentTimeMillis();
float expansion = (millis % 5000) / 2500F - 1;
expansion *= Math.PI * 2;
expansion = (MathHelper.sin(expansion) + 1) / 2;
expansion *= ((ICustomHighlight) block).getBreathingCoefficent();
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.4F);
GL11.glLineWidth(2F);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDepthMask(false);
double exp = ((ICustomHighlight) block).getExpansion();
exp += expansion / 32D;
nPos = nPos.subtract(x, y, z);
for (AxisAlignedBB aabb : aabbs) {
AxisAlignedBB changed = aabb.expand(exp, exp, exp).offset(-nPos.xCoord, -nPos.yCoord, -nPos.zCoord);
RenderGlobal.drawSelectionBoundingBox(changed);
}
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_BLEND);
e.setCanceled(true);
}
}
}
use of net.minecraft.util.AxisAlignedBB in project ClaySoldiersMod by SanAndreasP.
the class EntitySnowball method onUpdate.
@Override
public void onUpdate() {
super.onUpdate();
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) {
float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
prevRotationYaw = rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D);
prevRotationPitch = rotationPitch = (float) ((Math.atan2(motionY, f) * 180D) / 3.1415927410125732D);
}
int i = worldObj.getBlockId(xTile, yTile, zTile);
if (i > 0) {
Block.blocksList[i].setBlockBoundsBasedOnState(worldObj, xTile, yTile, zTile);
AxisAlignedBB axisalignedbb = Block.blocksList[i].getCollisionBoundingBoxFromPool(worldObj, xTile, yTile, zTile);
if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(posX, posY, posZ))) {
inGround = true;
}
}
if (arrowShake > 0) {
arrowShake--;
}
if (inGround) {
int j = worldObj.getBlockId(xTile, yTile, zTile);
int k = worldObj.getBlockMetadata(xTile, yTile, zTile);
if (j != inTile || k != field_28019_h) {
inGround = false;
motionX *= rand.nextFloat() * 0.2F;
motionY *= rand.nextFloat() * 0.2F;
motionZ *= rand.nextFloat() * 0.2F;
ticksInGround = 0;
ticksInAir = 0;
return;
}
ticksInGround++;
if (ticksInGround == 1200) {
setDead();
}
return;
}
ticksInAir++;
Vec3 vec3d = Vec3.createVectorHelper(posX, posY, posZ);
Vec3 vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks_do_do(vec3d, vec3d1, false, true);
vec3d = Vec3.createVectorHelper(posX, posY, posZ);
vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
if (movingobjectposition != null) {
vec3d1 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
}
Entity entity = null;
List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
double d = 0.0D;
for (int l = 0; l < list.size(); l++) {
Entity entity1 = (Entity) list.get(l);
if (!entity1.canBeCollidedWith() || entity1 == owner && ticksInAir < 5) {
continue;
}
float f4 = 0.3F;
AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand(f4, f4, f4);
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec3d, vec3d1);
if (movingobjectposition1 == null) {
continue;
}
double d1 = vec3d.distanceTo(movingobjectposition1.hitVec);
if (d1 < d || d == 0.0D) {
entity = entity1;
d = d1;
}
}
if (entity != null) {
movingobjectposition = new MovingObjectPosition(entity);
}
if (movingobjectposition != null) {
if (movingobjectposition.entityHit != null) {
int attackU = 0;
if (!(movingobjectposition.entityHit instanceof EntityClayMan || movingobjectposition.entityHit instanceof EntityMob)) {
attackU = 0;
} else {
if (movingobjectposition.entityHit instanceof EntityClayMan) {
if (((EntityClayMan) movingobjectposition.entityHit).getClayTeam() == getClayTeam()) {
setDead();
return;
}
}
((EntityLiving) movingobjectposition.entityHit).addPotionEffect(new PotionEffect(Potion.moveSlowdown.getId(), 30, 1));
movingobjectposition.entityHit.motionX = motionX;
movingobjectposition.entityHit.motionY += 0.25F;
movingobjectposition.entityHit.motionZ = motionZ;
setDead();
}
} else {
xTile = movingobjectposition.blockX;
yTile = movingobjectposition.blockY;
zTile = movingobjectposition.blockZ;
inTile = worldObj.getBlockId(xTile, yTile, zTile);
field_28019_h = worldObj.getBlockMetadata(xTile, yTile, zTile);
motionX = (float) (movingobjectposition.hitVec.xCoord - posX);
motionY = (float) (movingobjectposition.hitVec.yCoord - posY);
motionZ = (float) (movingobjectposition.hitVec.zCoord - posZ);
float f1 = MathHelper.sqrt_double(motionX * motionX + motionY * motionY + motionZ * motionZ);
posX -= (motionX / f1) * 0.05000000074505806D;
posY -= (motionY / f1) * 0.05000000074505806D;
posZ -= (motionZ / f1) * 0.05000000074505806D;
inGround = true;
arrowShake = 7;
}
}
posX += motionX;
posY += motionY;
posZ += motionZ;
float f2 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D);
for (rotationPitch = (float) ((Math.atan2(motionY, f2) * 180D) / 3.1415927410125732D); rotationPitch - prevRotationPitch < -180F; prevRotationPitch -= 360F) {
}
for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F) {
}
for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F) {
}
for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F) {
}
rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
float f3 = 0.99F;
float f5 = 0.03F;
if (isInWater()) {
for (int i1 = 0; i1 < 4; i1++) {
float f6 = 0.25F;
worldObj.spawnParticle("bubble", posX - motionX * f6, posY - motionY * f6, posZ - motionZ * f6, motionX, motionY, motionZ);
}
f3 = 0.8F;
}
motionX *= f3;
motionY *= f3;
motionZ *= f3;
motionY -= f5;
setPosition(posX, posY, posZ);
if (ticksInGround > 0 || inGround) {
isDead = true;
}
if (isDead) {
double a = posX + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
double b = boundingBox.minY + 0.125D + ((rand.nextFloat() - rand.nextFloat()) * 0.25D);
double c = posZ + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
CSMModRegistry.proxy.showEffect(this.worldObj, this, 12);
// if (FMLCommonHandler.instance().getSide().isClient())
// CSM_ModRegistry.proxy.showEffect((new EntityDiggingFX(CSM_ModRegistry.proxy.getClientWorld(), a, b, c, 0.0D, 0.0D, 0.0D, Block.gravel, 0, 0)));
worldObj.playSoundAtEntity(this, "step.gravel", 0.6F, 1.0F / (rand.nextFloat() * 0.2F + 0.9F));
}
}
Aggregations