Search in sources :

Example 96 with AxisAlignedBB

use of net.minecraft.util.AxisAlignedBB in project Armourers-Workshop by RiskyKen.

the class RenderBlockSkinnable method renderSkin.

private void renderSkin(TileEntitySkinnable tileEntity, double x, double y, double z, Skin skin) {
    int rotation = tileEntity.getBlockMetadata();
    double distance = Minecraft.getMinecraft().thePlayer.getDistance(tileEntity.xCoord + 0.5F, tileEntity.yCoord + 0.5F, tileEntity.zCoord + 0.5F);
    if (ConfigHandlerClient.showLodLevels) {
        int colour = 0x00FF00;
        int lod = MathHelper.floor_double(distance / ConfigHandlerClient.lodDistance);
        lod = MathHelper.clamp_int(lod, 0, ConfigHandlerClient.maxLodLevels);
        if (lod == 1) {
            colour = 0xFFFF00;
        } else if (lod == 2) {
            colour = 0xFF0000;
        } else if (lod == 3) {
            colour = 0xFF00FF;
        }
        AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glColor4f(1F, 1F, 1F, 1F);
        GL11.glLineWidth(1.0F);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        RenderGlobal.drawOutlinedBoundingBox(aabb, colour);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glColor4f(1F, 1F, 1F, 1F);
    }
    GL11.glTranslated(x + 0.5F, y + 0.5F, z + 0.5F);
    GL11.glScalef(-1, -1, 1);
    if (rotation != 0) {
        GL11.glRotatef((90F * rotation), 0, 1, 0);
    }
    for (int i = 0; i < skin.getParts().size(); i++) {
        SkinPart skinPart = skin.getParts().get(i);
        SkinPartRenderer.INSTANCE.renderPart(skinPart, 0.0625F, tileEntity.getSkinPointer().getSkinDye(), null, distance, true);
    }
    if (rotation != 0) {
        GL11.glRotatef((90F * -rotation), 0, 1, 0);
    }
    GL11.glScalef(-1, -1, 1);
    GL11.glTranslated(-x - 0.5F, -y - 0.5F, -z - 0.5F);
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) SkinPart(riskyken.armourersWorkshop.common.skin.data.SkinPart)

Example 97 with AxisAlignedBB

use of net.minecraft.util.AxisAlignedBB in project Armourers-Workshop by RiskyKen.

the class RenderBlockSkinnable method renderTileEntityAt.

@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTickTime) {
    if (!(tileEntity instanceof TileEntitySkinnableChild)) {
        renderList.add(new RenderLast(tileEntity, x, y, z));
    }
    if (ConfigHandlerClient.showSkinBlockBounds) {
        if (!(tileEntity.getBlockType() instanceof BlockSkinnable)) {
            return;
        }
        BlockSkinnable block = (BlockSkinnable) tileEntity.getBlockType();
        block.setBlockBoundsBasedOnState(tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
        double minX = block.getBlockBoundsMinX();
        double minY = block.getBlockBoundsMinY();
        double minZ = block.getBlockBoundsMinZ();
        double maxX = block.getBlockBoundsMaxX();
        double maxY = block.getBlockBoundsMaxY();
        double maxZ = block.getBlockBoundsMaxZ();
        float f1 = 0.002F;
        AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
        aabb.offset(x, y, z);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glDisable(GL11.GL_LIGHTING);
        OpenGlHelper.glBlendFunc(770, 771, 1, 0);
        GL11.glColor4f(0.0F, 1.0F, 0.0F, 0.4F);
        GL11.glLineWidth(1.0F);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDepthMask(false);
        RenderGlobal.drawOutlinedBoundingBox(aabb.contract(f1, f1, f1), -1);
        GL11.glDepthMask(true);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_BLEND);
    }
    if (ConfigHandlerClient.showSkinRenderBounds) {
        if ((tileEntity instanceof TileEntitySkinnableChild)) {
            return;
        }
        float f1 = 0.002F;
        AxisAlignedBB aabb = tileEntity.getRenderBoundingBox().copy();
        aabb.offset(x - tileEntity.xCoord, y - tileEntity.yCoord, z - tileEntity.zCoord);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glDisable(GL11.GL_LIGHTING);
        OpenGlHelper.glBlendFunc(770, 771, 1, 0);
        GL11.glColor4f(1.0F, 1.0F, 0.0F, 0.4F);
        GL11.glLineWidth(1.0F);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDepthMask(false);
        RenderGlobal.drawOutlinedBoundingBox(aabb.contract(f1, f1, f1), -1);
        GL11.glDepthMask(true);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_BLEND);
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) TileEntitySkinnableChild(riskyken.armourersWorkshop.common.tileentities.TileEntitySkinnableChild) ModelBlockSkinnable(riskyken.armourersWorkshop.client.model.block.ModelBlockSkinnable) BlockSkinnable(riskyken.armourersWorkshop.common.blocks.BlockSkinnable)

Example 98 with AxisAlignedBB

use of net.minecraft.util.AxisAlignedBB in project Armourers-Workshop by RiskyKen.

the class BlockHighlightRenderHandler method drawSkinnableBlockHelper.

private void drawSkinnableBlockHelper(World world, int x, int y, int z, int side, EntityPlayer player, float partialTicks, ISkinPointer skinPointer) {
    // int meta = world.getBlockMetadata(x, y, z);
    // Rectangle3D[][][] blockGrid;
    Skin skin = ClientSkinCache.INSTANCE.getSkin(skinPointer, false);
    if (skin != null) {
    // blockGrid = skin.getParts().get(0).getBlockGrid();
    } else {
        return;
    }
    double xOff = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
    double yOff = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
    double zOff = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
    float f1 = 0.002F;
    float scale = 0.0625F;
    ForgeDirection dir = UtilPlayer.getDirectionSide(player).getOpposite();
    for (int ix = 0; ix < 3; ix++) {
        for (int iy = 0; iy < 3; iy++) {
            for (int iz = 0; iz < 3; iz++) {
                float[] bounds = TileEntitySkinnable.getBlockBounds(skin, -ix + 2, iy, iz, dir);
                if (bounds != null) {
                    double minX = bounds[0];
                    double minY = bounds[1];
                    double minZ = bounds[2];
                    double maxX = bounds[3];
                    double maxY = bounds[4];
                    double maxZ = bounds[5];
                    AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
                    aabb.offset(-xOff - 1, -yOff, -zOff - 1);
                    aabb.offset(dir.offsetX * -1, 0, dir.offsetZ * -1);
                    aabb.offset(x, y, z);
                    aabb.offset(ix, iy, iz);
                    GL11.glEnable(GL11.GL_BLEND);
                    OpenGlHelper.glBlendFunc(770, 771, 1, 0);
                    GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.75F);
                    if (!world.isAirBlock(x + ix - 1 - dir.offsetX, y + iy, z + iz - 1 - dir.offsetZ)) {
                        GL11.glColor4f(1.0F, 0.0F, 0.0F, 0.75F);
                    }
                    GL11.glLineWidth(1F);
                    GL11.glDisable(GL11.GL_TEXTURE_2D);
                    GL11.glDepthMask(false);
                    GL11.glDisable(GL11.GL_DEPTH_TEST);
                    RenderGlobal.drawOutlinedBoundingBox(aabb.contract(f1, f1, f1), -1);
                    GL11.glEnable(GL11.GL_DEPTH_TEST);
                    GL11.glDepthMask(true);
                    GL11.glEnable(GL11.GL_TEXTURE_2D);
                    GL11.glDisable(GL11.GL_BLEND);
                }
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Skin(riskyken.armourersWorkshop.common.skin.data.Skin)

Example 99 with AxisAlignedBB

use of net.minecraft.util.AxisAlignedBB in project Armourers-Workshop by RiskyKen.

the class BlockHighlightRenderHandler method drawMannequinBlockBounds.

private void drawMannequinBlockBounds(World world, int x, int y, int z, EntityPlayer player, Block block, float partialTicks) {
    int meta = world.getBlockMetadata(x, y, z);
    double xOff = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
    double yOff = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
    double zOff = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
    double minX = x + block.getBlockBoundsMinX();
    double minY = y + block.getBlockBoundsMinY();
    double minZ = z + block.getBlockBoundsMinZ();
    double maxX = x + block.getBlockBoundsMaxX();
    double maxY = y + block.getBlockBoundsMaxY();
    double maxZ = z + block.getBlockBoundsMaxZ();
    if (meta == 0) {
        maxY += 1;
    }
    if (meta == 1) {
        minY -= 1;
    }
    float f1 = 0.002F;
    AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
    aabb.offset(-xOff, -yOff, -zOff);
    GL11.glEnable(GL11.GL_BLEND);
    OpenGlHelper.glBlendFunc(770, 771, 1, 0);
    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(aabb.contract(f1, f1, f1), -1);
    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB)

Example 100 with AxisAlignedBB

use of net.minecraft.util.AxisAlignedBB in project Armourers-Workshop by RiskyKen.

the class ItemBlendingTool method onDrawBlockHighlightEvent.

@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onDrawBlockHighlightEvent(DrawBlockHighlightEvent event) {
    EntityPlayer player = event.player;
    World world = event.player.worldObj;
    MovingObjectPosition target = event.target;
    if (target != null && target.typeOfHit != MovingObjectType.BLOCK) {
        return;
    }
    int x = target.blockX;
    int y = target.blockY;
    int z = target.blockZ;
    int side = target.sideHit;
    Block block = world.getBlock(x, y, z);
    ItemStack stack = player.getCurrentEquippedItem();
    if (stack == null || stack.getItem() != this) {
        return;
    }
    if (!(block instanceof BlockColourable)) {
        return;
    }
    int radiusSample = (Integer) ToolOptions.RADIUS_SAMPLE.readFromNBT(stack.getTagCompound(), 2);
    int radiusEffect = (Integer) ToolOptions.RADIUS_EFFECT.readFromNBT(stack.getTagCompound(), 1);
    ArrayList<BlockLocation> blockSamples = BlockUtils.findTouchingBlockFaces(world, x, y, z, side, radiusSample);
    ArrayList<BlockLocation> blockEffects = BlockUtils.findTouchingBlockFaces(world, x, y, z, side, radiusEffect);
    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;
    float f1 = 0.002F;
    for (int i = 0; i < blockSamples.size(); i++) {
        int colour = 0xFF0000;
        BlockLocation blockLoc = blockSamples.get(i);
        AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(blockLoc.x, blockLoc.y, blockLoc.z, blockLoc.x + 1, blockLoc.y + 1, blockLoc.z + 1);
        aabb.offset(-xOff, -yOff, -zOff);
        GL11.glEnable(GL11.GL_BLEND);
        OpenGlHelper.glBlendFunc(770, 771, 1, 0);
        GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.2F);
        GL11.glLineWidth(2.0F);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDepthMask(false);
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        RenderGlobal.drawOutlinedBoundingBox(aabb.expand(f1, f1, f1), colour);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glDepthMask(true);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_BLEND);
    }
    for (int i = 0; i < blockEffects.size(); i++) {
        BlockLocation blockLoc = blockEffects.get(i);
        AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(blockLoc.x + 0.10F, blockLoc.y + 0.10F, blockLoc.z + 0.10F, blockLoc.x + 0.90F, blockLoc.y + 0.90F, blockLoc.z + 0.90F);
        aabb.offset(-xOff, -yOff, -zOff);
        GL11.glEnable(GL11.GL_BLEND);
        OpenGlHelper.glBlendFunc(770, 771, 1, 0);
        GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.2F);
        GL11.glLineWidth(2.0F);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        // GL11.glDepthMask(false);
        RenderGlobal.drawOutlinedBoundingBox(aabb.expand(f1, f1, f1), 0x00FF00);
        // GL11.glDepthMask(true);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_BLEND);
    }
    event.setCanceled(true);
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) World(net.minecraft.world.World) BlockLocation(riskyken.armourersWorkshop.common.blocks.BlockLocation) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Block(net.minecraft.block.Block) IPantableBlock(riskyken.armourersWorkshop.api.common.painting.IPantableBlock) ItemStack(net.minecraft.item.ItemStack) BlockColourable(riskyken.armourersWorkshop.common.blocks.BlockColourable) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Aggregations

AxisAlignedBB (net.minecraft.util.AxisAlignedBB)123 Entity (net.minecraft.entity.Entity)40 EntityPlayer (net.minecraft.entity.player.EntityPlayer)28 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)24 TileEntity (net.minecraft.tileentity.TileEntity)20 Vec3 (net.minecraft.util.Vec3)20 ArrayList (java.util.ArrayList)16 ItemStack (net.minecraft.item.ItemStack)16 List (java.util.List)15 Block (net.minecraft.block.Block)15 EntityLivingBase (net.minecraft.entity.EntityLivingBase)15 EntityItem (net.minecraft.entity.item.EntityItem)13 SideOnly (cpw.mods.fml.relauncher.SideOnly)10 World (net.minecraft.world.World)7 Pos (com.builtbroken.mc.imp.transform.vector.Pos)6 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)6 Iterator (java.util.Iterator)5 BlockPos (net.minecraft.util.BlockPos)5 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)4 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)4