use of net.minecraft.util.AxisAlignedBB in project Engine by VoltzEngine-Project.
the class BlockTile method addCollisionBoxesToList.
@Override
@SuppressWarnings("unchecked")
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity) {
Tile tile = inject(world, x, y, z);
Iterable<Cube> bounds = tile.getCollisionBoxes(new Cube(aabb).subtract(new Pos(x, y, z)), entity);
eject();
if (bounds != null) {
for (Cube cuboid : bounds) {
AxisAlignedBB bb = cuboid.toAABB().offset(x, y, z);
if (aabb.intersectsWith(bb)) {
list.add(bb);
}
}
}
}
use of net.minecraft.util.AxisAlignedBB in project BetterStorage by copygirl.
the class ClientProxy method drawBlockHighlight.
@SubscribeEvent
public void drawBlockHighlight(DrawBlockHighlightEvent event) {
EntityPlayer player = event.player;
World world = player.worldObj;
MovingObjectPosition target = WorldUtils.rayTrace(player, event.partialTicks);
if ((target == null) || (target.typeOfHit != MovingObjectType.BLOCK))
return;
int x = target.blockX;
int y = target.blockY;
int z = target.blockZ;
AxisAlignedBB box = null;
Block block = world.getBlock(x, y, z);
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (block instanceof TileArmorStand)
box = getArmorStandHighlightBox(player, world, x, y, z, target.hitVec);
else if (block == Blocks.iron_door)
box = getIronDoorHightlightBox(player, world, x, y, z, target.hitVec, block);
else if (tileEntity instanceof IHasAttachments)
box = getAttachmentPointsHighlightBox(player, tileEntity, target);
if (box == null)
return;
double xOff = player.lastTickPosX + (player.posX - player.lastTickPosX) * event.partialTicks;
double yOff = player.lastTickPosY + (player.posY - player.lastTickPosY) * event.partialTicks;
double zOff = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * event.partialTicks;
box.offset(-xOff, -yOff, -zOff);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.4F);
GL11.glLineWidth(2.0F);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDepthMask(false);
RenderGlobal.drawOutlinedBoundingBox(box, -1);
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_BLEND);
event.setCanceled(true);
}
use of net.minecraft.util.AxisAlignedBB in project BetterStorage by copygirl.
the class CommonProxy method getIronDoorHightlightBox.
protected AxisAlignedBB getIronDoorHightlightBox(EntityPlayer player, World world, int x, int y, int z, Vec3 hitVec, Block block) {
if (!StackUtils.isLock(player.getCurrentEquippedItem()))
return null;
int meta = world.getBlockMetadata(x, y, z);
boolean isMirrored;
if (meta >= 8) {
isMirrored = meta == 9;
y -= 1;
meta = world.getBlockMetadata(x, y, z);
} else
isMirrored = world.getBlockMetadata(x, y + 1, z) == 9;
boolean isOpen = (meta & 4) == 4;
int rotation = (meta & 3);
rotation = isMirrored ? (rotation == 0 ? 3 : rotation == 1 ? 0 : rotation == 2 ? 1 : 2) : rotation;
isOpen = isMirrored ? !isOpen : isOpen;
AxisAlignedBB box;
switch(rotation) {
case 0:
if (!isOpen)
box = AxisAlignedBB.getBoundingBox(x - 0.005 / 16F, y + 14.5 / 16F, z + 10 / 16F, x + 3.005 / 16F, y + 20.5 / 16F, z + 15 / 16F);
else
box = AxisAlignedBB.getBoundingBox(x + 10 / 16F, y + 14.5 / 16F, z - 0.005 / 16F, x + 15 / 16F, y + 20.5 / 16F, z + 3.005 / 16F);
break;
case 1:
if (!isOpen)
box = AxisAlignedBB.getBoundingBox(x + 1 / 16F, y + 14.5 / 16F, z - 0.005 / 16F, x + 6 / 16F, y + 20.5 / 16F, z + 3.005 / 16F);
else
box = AxisAlignedBB.getBoundingBox(x + 12.995 / 16F, y + 14.5 / 16F, z + 10 / 16F, x + 16.005 / 16F, y + 20.5 / 16F, z + 15 / 16F);
break;
case 2:
if (!isOpen)
box = AxisAlignedBB.getBoundingBox(x + 12.995 / 16F, y + 14.5 / 16F, z + 1 / 16F, x + 16.005 / 16F, y + 20.5 / 16F, z + 6 / 16F);
else
box = AxisAlignedBB.getBoundingBox(x + 1 / 16F, y + 14.5 / 16F, z + 12.995 / 16F, x + 6 / 16F, y + 20.5 / 16F, z + 16.005 / 16F);
break;
default:
if (!isOpen)
box = AxisAlignedBB.getBoundingBox(x + 10 / 16F, y + 14.5 / 16F, z + 12.995 / 16F, x + 15 / 16F, y + 20.5 / 16F, z + 16.005 / 16F);
else
box = AxisAlignedBB.getBoundingBox(x - 0.005 / 16F, y + 14.5 / 16F, z + 1 / 16F, x + 3.005 / 16F, y + 20.5 / 16F, z + 6 / 16F);
break;
}
return box.isVecInside(hitVec) ? box : null;
}
use of net.minecraft.util.AxisAlignedBB in project BetterStorage by copygirl.
the class LockAttachment method use.
private boolean use(EntityPlayer player, ItemStack holding) {
if (player.worldObj.isRemote)
return false;
ILockable lockable = (ILockable) tileEntity;
ItemStack lock = lockable.getLock();
if (lock == null) {
if (StackUtils.isLock(holding) && lockable.isLockValid(holding)) {
lockable.setLock(holding);
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
return true;
}
} else if (StackUtils.isKey(holding)) {
IKey keyType = (IKey) holding.getItem();
ILock lockType = (ILock) lock.getItem();
boolean success = keyType.unlock(holding, lock, true);
lockType.onUnlock(lock, holding, lockable, player, success);
if (!success)
return true;
if (player.isSneaking()) {
AxisAlignedBB box = getHighlightBox();
double x = (box.minX + box.maxX) / 2;
double y = (box.minY + box.maxY) / 2;
double z = (box.minZ + box.maxZ) / 2;
EntityItem item = WorldUtils.spawnItem(player.worldObj, x, y, z, lock);
lockable.setLock(null);
} else
lockable.useUnlocked(player);
return true;
}
return false;
}
use of net.minecraft.util.AxisAlignedBB in project MineFactoryReloaded by powercrystals.
the class ItemSpyglass method rayTrace.
private MovingObjectPosition rayTrace() {
if (Minecraft.getMinecraft().renderViewEntity == null || Minecraft.getMinecraft().theWorld == null) {
return null;
}
double range = MFRConfig.spyglassRange.getInt();
MovingObjectPosition objHit = Minecraft.getMinecraft().renderViewEntity.rayTrace(range, 1.0F);
double blockDist = range;
Vec3 playerPos = Minecraft.getMinecraft().renderViewEntity.getPosition(1.0F);
if (objHit != null) {
blockDist = objHit.hitVec.distanceTo(playerPos);
}
Vec3 playerLook = Minecraft.getMinecraft().renderViewEntity.getLook(1.0F);
Vec3 playerLookRel = playerPos.addVector(playerLook.xCoord * range, playerLook.yCoord * range, playerLook.zCoord * range);
List<?> list = Minecraft.getMinecraft().theWorld.getEntitiesWithinAABBExcludingEntity(Minecraft.getMinecraft().renderViewEntity, Minecraft.getMinecraft().renderViewEntity.boundingBox.addCoord(playerLook.xCoord * range, playerLook.yCoord * range, playerLook.zCoord * range).expand(1, 1, 1));
double entityDistTotal = blockDist;
Entity pointedEntity = null;
for (int i = 0; i < list.size(); ++i) {
Entity entity = (Entity) list.get(i);
if (entity.canBeCollidedWith()) {
double entitySize = entity.getCollisionBorderSize();
AxisAlignedBB axisalignedbb = entity.boundingBox.expand(entitySize, entitySize, entitySize);
MovingObjectPosition movingobjectposition = axisalignedbb.calculateIntercept(playerPos, playerLookRel);
if (axisalignedbb.isVecInside(playerPos)) {
if (0.0D < entityDistTotal || entityDistTotal == 0.0D) {
pointedEntity = entity;
entityDistTotal = 0.0D;
}
} else if (movingobjectposition != null) {
double entityDist = playerPos.distanceTo(movingobjectposition.hitVec);
if (entityDist < entityDistTotal || entityDistTotal == 0.0D) {
pointedEntity = entity;
entityDistTotal = entityDist;
}
}
}
}
if (pointedEntity != null && (entityDistTotal < blockDist || objHit == null)) {
objHit = new MovingObjectPosition(pointedEntity);
}
return objHit;
}
Aggregations