use of net.minecraft.util.math.AxisAlignedBB in project ImmersiveEngineering by BluSunrize.
the class TileEntityMixer method getAdvancedSelectionBounds.
@Override
public List<AxisAlignedBB> getAdvancedSelectionBounds() {
EnumFacing fl = facing;
EnumFacing fw = facing.rotateY();
if (mirrored)
fw = fw.getOpposite();
if (pos == 2) {
List<AxisAlignedBB> list = Lists.newArrayList(new AxisAlignedBB(0, 0, 0, 1, .5f, 1).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
float minX = fl == EnumFacing.WEST ? .625f : fl == EnumFacing.EAST ? .125f : .125f;
float maxX = fl == EnumFacing.EAST ? .375f : fl == EnumFacing.WEST ? .875f : .25f;
float minZ = fl == EnumFacing.NORTH ? .625f : fl == EnumFacing.SOUTH ? .125f : .125f;
float maxZ = fl == EnumFacing.SOUTH ? .375f : fl == EnumFacing.NORTH ? .875f : .25f;
list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
minX = fl == EnumFacing.WEST ? .625f : fl == EnumFacing.EAST ? .125f : .75f;
maxX = fl == EnumFacing.EAST ? .375f : fl == EnumFacing.WEST ? .875f : .875f;
minZ = fl == EnumFacing.NORTH ? .625f : fl == EnumFacing.SOUTH ? .125f : .75f;
maxZ = fl == EnumFacing.SOUTH ? .375f : fl == EnumFacing.NORTH ? .875f : .875f;
list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
return list;
} else if (pos == 4 || pos == 5 || pos == 7 || pos == 8) {
List<AxisAlignedBB> list = Lists.newArrayList(new AxisAlignedBB(0, 0, 0, 1, .5f, 1).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
if (pos > 5)
fl = fl.getOpposite();
if (pos % 3 == 2)
fw = fw.getOpposite();
float minX = fl == EnumFacing.WEST ? .6875f : fl == EnumFacing.EAST ? .0625f : fw == EnumFacing.EAST ? .0625f : .6875f;
float maxX = fl == EnumFacing.EAST ? .3125f : fl == EnumFacing.WEST ? .9375f : fw == EnumFacing.EAST ? .3125f : .9375f;
float minZ = fl == EnumFacing.NORTH ? .6875f : fl == EnumFacing.SOUTH ? .0625f : fw == EnumFacing.SOUTH ? .0625f : .6875f;
float maxZ = fl == EnumFacing.SOUTH ? .3125f : fl == EnumFacing.NORTH ? .9375f : fw == EnumFacing.SOUTH ? .3125f : .9375f;
list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
if (pos == 4) {
minX = fl == EnumFacing.WEST ? .375f : fl == EnumFacing.EAST ? .625f : fw == EnumFacing.WEST ? -.125f : 0;
maxX = fl == EnumFacing.EAST ? .375f : fl == EnumFacing.WEST ? .625f : fw == EnumFacing.EAST ? 1.125f : 1;
minZ = fl == EnumFacing.NORTH ? .375f : fl == EnumFacing.SOUTH ? .625f : fw == EnumFacing.NORTH ? -.125f : 0;
maxZ = fl == EnumFacing.SOUTH ? .375f : fl == EnumFacing.NORTH ? .625f : fw == EnumFacing.SOUTH ? 1.125f : 1;
list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, .75f, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
minX = fl == EnumFacing.WEST ? -.125f : fl == EnumFacing.EAST ? .625f : fw == EnumFacing.WEST ? -.125f : .875f;
maxX = fl == EnumFacing.EAST ? 1.125f : fl == EnumFacing.WEST ? .375f : fw == EnumFacing.EAST ? 1.125f : .125f;
minZ = fl == EnumFacing.NORTH ? -.125f : fl == EnumFacing.SOUTH ? .625f : fw == EnumFacing.NORTH ? -.125f : .875f;
maxZ = fl == EnumFacing.SOUTH ? 1.25f : fl == EnumFacing.NORTH ? .375f : fw == EnumFacing.SOUTH ? 1.125f : .125f;
list.add(new AxisAlignedBB(minX, .5f, minZ, maxX, .75f, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
minX = fl == EnumFacing.WEST ? -.125f : fl == EnumFacing.EAST ? .875f : fw == EnumFacing.WEST ? -.125f : .875f;
maxX = fl == EnumFacing.EAST ? 1.125f : fl == EnumFacing.WEST ? .125f : fw == EnumFacing.EAST ? 1.125f : .125f;
minZ = fl == EnumFacing.NORTH ? -.125f : fl == EnumFacing.SOUTH ? .875f : fw == EnumFacing.NORTH ? -.125f : .875f;
maxZ = fl == EnumFacing.SOUTH ? 1.25f : fl == EnumFacing.NORTH ? .125f : fw == EnumFacing.SOUTH ? 1.125f : .125f;
list.add(new AxisAlignedBB(minX, .75f, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
}
return list;
} else if ((pos == 13 || pos == 14 || pos == 16 || pos == 17)) {
List<AxisAlignedBB> list = new ArrayList<AxisAlignedBB>(3);
if (pos % 9 > 5)
fl = fl.getOpposite();
if (pos % 3 == 2)
fw = fw.getOpposite();
float minX = fl == EnumFacing.WEST ? 0f : fl == EnumFacing.EAST ? .1875f : fw == EnumFacing.EAST ? .1875f : 0f;
float maxX = fl == EnumFacing.EAST ? 1f : fl == EnumFacing.WEST ? .8125f : fw == EnumFacing.EAST ? 1f : .8125f;
float minZ = fl == EnumFacing.NORTH ? 0f : fl == EnumFacing.SOUTH ? .1875f : fw == EnumFacing.SOUTH ? .1875f : 0f;
float maxZ = fl == EnumFacing.SOUTH ? 1f : fl == EnumFacing.NORTH ? .8125f : fw == EnumFacing.SOUTH ? 1f : .8125f;
list.add(new AxisAlignedBB(minX, -.25, minZ, maxX, 0, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
minX = fl == EnumFacing.WEST ? 0f : fl == EnumFacing.EAST ? .0625f : fw == EnumFacing.EAST ? .0625f : .8125f;
maxX = fl == EnumFacing.EAST ? 1f : fl == EnumFacing.WEST ? .9375f : fw == EnumFacing.EAST ? .1875f : .9375f;
minZ = fl == EnumFacing.NORTH ? 0f : fl == EnumFacing.SOUTH ? .0625f : fw == EnumFacing.SOUTH ? .0625f : .8125f;
maxZ = fl == EnumFacing.SOUTH ? 1f : fl == EnumFacing.NORTH ? .9375f : fw == EnumFacing.SOUTH ? .1875f : .9375f;
list.add(new AxisAlignedBB(minX, 0, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
minX = fl == EnumFacing.WEST ? .8125f : fl == EnumFacing.EAST ? .0625f : fw == EnumFacing.EAST ? .1875f : 0f;
maxX = fl == EnumFacing.EAST ? .1875f : fl == EnumFacing.WEST ? .9375f : fw == EnumFacing.EAST ? 1f : .8125f;
minZ = fl == EnumFacing.NORTH ? .8125f : fl == EnumFacing.SOUTH ? .0625f : fw == EnumFacing.SOUTH ? .1875f : 0f;
maxZ = fl == EnumFacing.SOUTH ? .1875f : fl == EnumFacing.NORTH ? .9375f : fw == EnumFacing.SOUTH ? 1f : .8125f;
list.add(new AxisAlignedBB(minX, 0, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
return list;
} else if (pos == 21) {
List<AxisAlignedBB> list = new ArrayList<AxisAlignedBB>(1);
float minX = fl == EnumFacing.WEST ? .1875f : fl == EnumFacing.EAST ? .3125f : fw == EnumFacing.EAST ? .1875f : 0f;
float maxX = fl == EnumFacing.EAST ? .8125f : fl == EnumFacing.WEST ? .6875f : fw == EnumFacing.EAST ? 1f : .8125f;
float minZ = fl == EnumFacing.NORTH ? .1875f : fl == EnumFacing.SOUTH ? .3125f : fw == EnumFacing.SOUTH ? .1875f : 0f;
float maxZ = fl == EnumFacing.SOUTH ? .8125f : fl == EnumFacing.NORTH ? .6875f : fw == EnumFacing.SOUTH ? 1f : .8125f;
list.add(new AxisAlignedBB(minX, 0, minZ, maxX, .625f, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
return list;
} else if (pos == 22) {
List<AxisAlignedBB> list = new ArrayList<AxisAlignedBB>(2);
float minX = fl == EnumFacing.WEST ? -.4375f : fl == EnumFacing.EAST ? .5625f : fw == EnumFacing.EAST ? .5625f : -.4375f;
float maxX = fl == EnumFacing.EAST ? 1.4375f : fl == EnumFacing.WEST ? .4375f : fw == EnumFacing.EAST ? 1.4375f : .4375f;
float minZ = fl == EnumFacing.NORTH ? -.4375f : fl == EnumFacing.SOUTH ? .5625f : fw == EnumFacing.SOUTH ? .5625f : -.4375f;
float maxZ = fl == EnumFacing.SOUTH ? 1.4375f : fl == EnumFacing.NORTH ? .4375f : fw == EnumFacing.SOUTH ? 1.4375f : .4375f;
list.add(new AxisAlignedBB(minX, .1875, minZ, maxX, 1, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
minX = fl == EnumFacing.WEST ? 0f : fl == EnumFacing.EAST ? .5f : fw == EnumFacing.EAST ? 0f : .4375f;
maxX = fl == EnumFacing.EAST ? 1f : fl == EnumFacing.WEST ? .5f : fw == EnumFacing.EAST ? .5625f : 1f;
minZ = fl == EnumFacing.NORTH ? 0f : fl == EnumFacing.SOUTH ? .5f : fw == EnumFacing.SOUTH ? 0f : .4375f;
maxZ = fl == EnumFacing.SOUTH ? 1f : fl == EnumFacing.NORTH ? .5f : fw == EnumFacing.SOUTH ? .5625f : 1f;
list.add(new AxisAlignedBB(minX, 0, minZ, maxX, .875, maxZ).offset(getPos().getX(), getPos().getY(), getPos().getZ()));
return list;
}
return null;
}
use of net.minecraft.util.math.AxisAlignedBB in project ImmersiveEngineering by BluSunrize.
the class TileEntityFluidPipe method hammerUseSide.
@Override
public boolean hammerUseSide(EnumFacing side, EntityPlayer player, float hitX, float hitY, float hitZ) {
if (worldObj.isRemote)
return true;
EnumFacing fd = side;
List<AxisAlignedBB> boxes = this.getAdvancedSelectionBounds();
for (AxisAlignedBB box : boxes) if (box instanceof AdvancedAABB) {
if (box.expand(.002, .002, .002).isVecInside(new Vec3d(getPos().getX() + hitX, getPos().getY() + hitY, getPos().getZ() + hitZ)))
if (box instanceof AdvancedAABB && ((AdvancedAABB) box).fd != null)
fd = ((AdvancedAABB) box).fd;
}
if (fd != null) {
toggleSide(fd.ordinal());
this.markContainingBlockForUpdate(null);
TileEntityFluidPipe.indirectConnections.clear();
return true;
}
return false;
}
use of net.minecraft.util.math.AxisAlignedBB in project ImmersiveEngineering by BluSunrize.
the class TileEntityFluidPipe method getAdvancedSelectionBounds.
@Override
public List<AxisAlignedBB> getAdvancedSelectionBounds() {
List<AxisAlignedBB> list = Lists.newArrayList();
byte connections = getAvailableConnectionByte();
byte availableConnections = getConnectionByte();
double[] baseAABB = pipeCover != null ? new double[] { .002, .998, .002, .998, .002, .998 } : new double[] { .25, .75, .25, .75, .25, .75 };
for (int i = 0; i < 6; i++) {
double depth = getConnectionStyle(i) == 0 ? .25 : .125;
double size = getConnectionStyle(i) == 0 ? .25 : .125;
// size = 0;
if ((connections & 0x1) == 1)
list.add(new AdvancedAABB(new AxisAlignedBB(i == 4 ? 0 : i == 5 ? 1 - depth : size, i == 0 ? 0 : i == 1 ? 1 - depth : size, i == 2 ? 0 : i == 3 ? 1 - depth : size, i == 4 ? depth : i == 5 ? 1 : 1 - size, i == 0 ? depth : i == 1 ? 1 : 1 - size, i == 2 ? depth : i == 3 ? 1 : 1 - size).offset(getPos()), EnumFacing.getFront(i)));
if ((availableConnections & 0x1) == 1)
baseAABB[i] += i % 2 == 1 ? .125 : -.125;
baseAABB[i] = Math.min(Math.max(baseAABB[i], 0), 1);
availableConnections = (byte) (availableConnections >> 1);
connections = (byte) (connections >> 1);
}
list.add(new AdvancedAABB(new AxisAlignedBB(baseAABB[4], baseAABB[0], baseAABB[2], baseAABB[5], baseAABB[1], baseAABB[3]).offset(getPos()), null));
return list;
}
use of net.minecraft.util.math.AxisAlignedBB in project ImmersiveEngineering by BluSunrize.
the class EntityRevolvershotHoming method getTarget.
public EntityLivingBase getTarget() {
if (targetOverride != null && !targetOverride.isDead)
return targetOverride;
double r = 20D;
AxisAlignedBB aabb = new AxisAlignedBB(posX - r, posY - r, posZ - r, posX + r, posY + r, posZ + r);
EntityLivingBase target = null;
for (Object o : worldObj.getEntitiesWithinAABB(EntityLivingBase.class, aabb)) if (o instanceof EntityLivingBase && !o.equals(this.shootingEntity))
if (target == null || ((EntityLivingBase) o).getDistanceSqToEntity(this) < target.getDistanceSqToEntity(this))
target = (EntityLivingBase) o;
return target;
}
use of net.minecraft.util.math.AxisAlignedBB in project NetherEx by LogicTechCorp.
the class EventHandler method onLivingUpdate.
@SubscribeEvent
public static void onLivingUpdate(LivingEvent.LivingUpdateEvent event) {
World world = event.getEntityLiving().getEntityWorld();
BlockPos pos = new BlockPos(event.getEntityLiving());
EntityLivingBase entity = event.getEntityLiving();
boolean canFreeze = !(entity instanceof EntityPlayer) && !Arrays.asList(ConfigHandler.potionEffect.freeze.blacklist).contains(EntityList.getKey(entity).toString());
if (world.getBiomeForCoordsBody(pos) == NetherExBiomes.ARCTIC_ABYSS) {
if (canFreeze && !entity.isPotionActive(NetherExEffects.FREEZE) && world.rand.nextInt(ConfigHandler.biome.arcticAbyss.chanceOfFreezing) == 0) {
entity.addPotionEffect(new PotionEffect(NetherExEffects.FREEZE, 300, 0));
}
}
if (entity instanceof EntityLiving && canFreeze) {
if (!entity.isPotionActive(NetherExEffects.FREEZE)) {
if (((EntityLiving) entity).isAIDisabled()) {
((EntityLiving) entity).setNoAI(false);
entity.setSilent(false);
}
} else {
((EntityLiving) entity).setNoAI(true);
entity.setSilent(true);
if (world.rand.nextInt(ConfigHandler.potionEffect.freeze.chanceOfThawing) == 0) {
entity.removePotionEffect(NetherExEffects.FREEZE);
}
}
}
if (entity instanceof EntityPlayer && entity.isPotionActive(NetherExEffects.FREEZE)) {
entity.setPosition(entity.prevPosX, entity.posY, entity.prevPosZ);
}
boolean canSpawnSpore = entity instanceof EntityPlayer || !Arrays.asList(ConfigHandler.potionEffect.spore.blacklist).contains(EntityList.getKey(entity).toString());
if (canSpawnSpore && entity.isPotionActive(NetherExEffects.SPORE) && world.rand.nextInt(ConfigHandler.potionEffect.spore.chanceOfSporeSpawning) == 0) {
if (world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(pos).expand(1, 1, 1)).size() < 3) {
BlockPos newPos = pos.offset(EnumFacing.Plane.HORIZONTAL.random(world.rand));
if (!world.isRemote && world.isAirBlock(newPos) && world.getBlockState(newPos.down()).isSideSolid(world, newPos.down(), EnumFacing.UP)) {
EntitySpore spore = new EntitySpore(world, 0);
spore.setPosition(newPos.getX(), newPos.getY(), newPos.getZ());
world.spawnEntity(spore);
}
}
}
boolean canSpawnGhastling = entity instanceof EntityPlayer && world.provider.getDimension() == DimensionType.NETHER.getId();
if (canSpawnGhastling && entity.isPotionActive(NetherExEffects.LOST) && world.rand.nextInt(ConfigHandler.potionEffect.lost.chanceOfGhastlingSpawning) == 0) {
BlockPos newPos = pos.add(0, 5, 0).offset(entity.getHorizontalFacing().getOpposite(), 5);
if (!world.isRemote && world.isAirBlock(newPos)) {
EntityGhastling ghastling = new EntityGhastling(world);
ghastling.setPosition(newPos.getX(), newPos.getY(), newPos.getZ());
ghastling.setAttackTarget(entity);
world.spawnEntity(ghastling);
}
}
}
Aggregations