use of net.minecraft.util.AxisAlignedBB in project Galacticraft by micdoodle8.
the class TileEntityAirLockController method update.
@Override
public void update() {
super.update();
if (!this.worldObj.isRemote) {
this.active = false;
if (this.redstoneActivation) {
this.active = this.worldObj.isBlockIndirectlyGettingPowered(this.getPos()) > 0;
}
if ((this.active || !this.redstoneActivation) && this.playerDistanceActivation) {
double distance = 0D;
switch(this.playerDistanceSelection) {
case 0:
distance = 1.0D;
break;
case 1:
distance = 2.0D;
break;
case 2:
distance = 5.0D;
break;
case 3:
distance = 10.0D;
break;
}
Vector3 minPos = new Vector3(this).translate(0.5D - distance);
Vector3 maxPos = new Vector3(this).translate(0.5D + distance);
AxisAlignedBB matchingRegion = AxisAlignedBB.fromBounds(minPos.x, minPos.y, minPos.z, maxPos.x, maxPos.y, maxPos.z);
List<EntityPlayer> playersWithin = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, matchingRegion);
if (this.playerNameMatches) {
boolean foundPlayer = false;
for (EntityPlayer p : playersWithin) {
if (PlayerUtil.getName(p).equalsIgnoreCase(this.playerToOpenFor)) {
foundPlayer = true;
break;
}
}
this.active = foundPlayer;
} else {
this.active = !playersWithin.isEmpty();
}
}
if (!this.invertSelection) {
this.active = !this.active;
}
if (this.protocol == null) {
this.protocol = this.lastProtocol = new AirLockProtocol(this);
}
if (this.ticks % 5 == 0) {
if (this.horizontalModeEnabled != this.lastHorizontalModeEnabled) {
this.unsealAirLock();
} else if (this.active || this.lastActive) {
this.lastOtherAirLocks = this.otherAirLocks;
this.otherAirLocks = this.protocol.calculate(this.horizontalModeEnabled);
if (this.active) {
if (this.otherAirLocks != this.lastOtherAirLocks || !this.lastActive) {
this.unsealAirLock();
if (this.otherAirLocks >= 0) {
this.sealAirLock();
}
}
} else {
if (this.lastActive) {
this.unsealAirLock();
}
}
}
if (this.active != this.lastActive) {
this.worldObj.markBlockForUpdate(this.getPos());
}
this.lastActive = this.active;
this.lastProtocol = this.protocol;
this.lastHorizontalModeEnabled = this.horizontalModeEnabled;
}
}
}
use of net.minecraft.util.AxisAlignedBB in project Galacticraft by micdoodle8.
the class EntityFXLaunchParticle method moveEntity.
@Override
public void moveEntity(double x, double y, double z) {
double d0 = y;
List<AxisAlignedBB> list = this.getCollidingBoundingBoxes(this.getEntityBoundingBox().addCoord(x, y, z));
AxisAlignedBB axisalignedbb = this.getEntityBoundingBox();
for (AxisAlignedBB blocker : list) {
y = blocker.calculateYOffset(axisalignedbb, y);
}
axisalignedbb = axisalignedbb.offset(0.0D, y, 0.0D);
for (AxisAlignedBB blocker : list) {
x = blocker.calculateXOffset(axisalignedbb, x);
}
axisalignedbb = axisalignedbb.offset(x, 0.0D, 0.0D);
for (AxisAlignedBB blocker : list) {
z = blocker.calculateZOffset(axisalignedbb, z);
}
axisalignedbb = axisalignedbb.offset(0.0D, 0.0D, z);
this.setEntityBoundingBox(axisalignedbb);
this.posX = (axisalignedbb.minX + axisalignedbb.maxX) / 2.0D;
this.posY = axisalignedbb.minY;
this.posZ = (axisalignedbb.minZ + axisalignedbb.maxZ) / 2.0D;
this.isCollided = false;
}
use of net.minecraft.util.AxisAlignedBB in project Galacticraft by micdoodle8.
the class EntityFXLaunchParticle method getCollidingBoundingBoxes.
/**
* Simplified for performance: no colliding boxes for entities (most/all of the entities will be other launch particles)
*/
public List<AxisAlignedBB> getCollidingBoundingBoxes(AxisAlignedBB bb) {
List<AxisAlignedBB> list = new LinkedList<>();
World w = this.worldObj;
int xs = MathHelper.floor_double(bb.minX);
int xe = MathHelper.floor_double(bb.maxX);
int ys = MathHelper.floor_double(bb.minY) - 1;
int ye = MathHelper.floor_double(bb.maxY);
int zs = MathHelper.floor_double(bb.minZ);
int ze = MathHelper.floor_double(bb.maxZ);
BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos();
for (int x = xs; x <= xe; ++x) {
for (int z = zs; z <= ze; ++z) {
if (w.isBlockLoaded(mutablePos.set(x, 64, z))) {
for (int y = ys; y <= ye; ++y) {
mutablePos.set(x, y, z);
IBlockState iblockstate1 = w.getBlockState(mutablePos);
iblockstate1.getBlock().addCollisionBoxesToList(w, mutablePos, iblockstate1, bb, list, null);
}
}
}
}
return list;
}
use of net.minecraft.util.AxisAlignedBB in project Galacticraft by micdoodle8.
the class TileEntityPlatform method motionObstructed.
@SideOnly(Side.CLIENT)
public boolean motionObstructed(double y, double velocityY) {
EntityPlayerSP p = FMLClientHandler.instance().getClientPlayerEntity();
int x = this.pos.getX() + 1;
int z = this.pos.getZ() + 1;
double size = 9 / 16D;
double height = p.height + velocityY;
double depth = velocityY < 0D ? 0.179D : 0D;
AxisAlignedBB bb = AxisAlignedBB.fromBounds(x - size, y - depth, z - size, x + size, y + height, z + size);
BlockPlatform.ignoreCollisionTests = true;
boolean obstructed = !this.worldObj.getCollidingBoundingBoxes(p, bb).isEmpty();
BlockPlatform.ignoreCollisionTests = false;
return obstructed;
}
use of net.minecraft.util.AxisAlignedBB in project Galacticraft by micdoodle8.
the class WorldOverlayRenderer method getSpawnMode.
private static int getSpawnMode(Chunk chunk, int x, int y, int z) {
World world = chunk.getWorld();
BlockPos pos = new BlockPos(x, y, z);
if (!SpawnerAnimals.canCreatureTypeSpawnAtLocation(SpawnPlacementType.ON_GROUND, world, pos) || chunk.getLightFor(EnumSkyBlock.BLOCK, pos) >= 8) {
return 0;
}
c.set(x + 0.2, y + 0.01, z + 0.2, x + 0.8, y + 1.8, z + 0.8);
AxisAlignedBB aabb = c.aabb();
if (!world.checkNoEntityCollision(aabb) || !world.getCollidingBoundingBoxes(dummyEntity, aabb).isEmpty() || world.isAnyLiquid(aabb)) {
return 0;
}
if (chunk.getLightFor(EnumSkyBlock.SKY, pos) >= 8) {
return 1;
}
return 2;
}
Aggregations