Search in sources :

Example 1 with Vec2f

use of net.minecraft.util.math.Vec2f in project DynamicSurroundings by OreCruncher.

the class LightLevelHUD method textureRender.

private static void textureRender(final EntityPlayer player, final RenderManager manager) {
    final boolean isThirdPerson = manager.options.thirdPersonView == 2;
    EnumFacing playerFacing = player.getHorizontalFacing();
    if (isThirdPerson)
        playerFacing = playerFacing.getOpposite();
    final float rotationAngle = playerFacing.getOpposite().getHorizontalAngle();
    sheet.bindTexture();
    final BufferBuilder renderer = Tessellator.getInstance().getBuffer();
    for (int i = 0; i < nextCoord; i++) {
        final LightCoord coord = lightLevels.get(i);
        final double x = coord.x - manager.viewerPosX;
        final double y = coord.y - manager.viewerPosY;
        final double z = coord.z - manager.viewerPosZ;
        final Vec2f U = sheet.getMinMaxU(coord.lightLevel);
        final Vec2f V = sheet.getMinMaxV(coord.lightLevel);
        GlStateManager.pushMatrix();
        GlStateManager.translate(x + 0.5D, y, z + 0.5D);
        GlStateManager.rotate(-rotationAngle, 0F, 1F, 0F);
        GlStateManager.translate(-0.5D, 0.0005D, -0.5D);
        GlStateManager.rotate(90F, 1F, 0F, 0F);
        final float red = coord.color.red;
        final float green = coord.color.green;
        final float blue = coord.color.blue;
        final float alpha = ColorSet.ALPHA;
        renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
        renderer.pos(0F, 1F, 0F).tex(U.x, V.x).color(red, green, blue, alpha).endVertex();
        renderer.pos(1F, 1F, 0F).tex(U.y, V.x).color(red, green, blue, alpha).endVertex();
        renderer.pos(1F, 0F, 0F).tex(U.y, V.y).color(red, green, blue, alpha).endVertex();
        renderer.pos(0F, 0F, 0F).tex(U.x, V.y).color(red, green, blue, alpha).endVertex();
        Tessellator.getInstance().draw();
        GlStateManager.popMatrix();
    }
}
Also used : Vec2f(net.minecraft.util.math.Vec2f) EnumFacing(net.minecraft.util.EnumFacing) BufferBuilder(net.minecraft.client.renderer.BufferBuilder)

Example 2 with Vec2f

use of net.minecraft.util.math.Vec2f in project BloodMagic by WayofTime.

the class AlchemyArrayEffectArrowTurret method update.

@Override
public boolean update(TileEntity tile, int ticksActive) {
    BlockPos pos = tile.getPos();
    World world = tile.getWorld();
    BlockPos chestPos = pos.down();
    TileEntity chestTile = world.getTileEntity(chestPos);
    if (chestTile == null) {
        return false;
    }
    IItemHandler itemHandler = Utils.getInventory(chestTile, EnumFacing.UP);
    if (itemHandler == null) {
        return false;
    }
    ItemStack arrowStack = new ItemStack(Items.AIR);
    if (lastChestSlot >= 0 && lastChestSlot < itemHandler.getSlots()) {
        ItemStack testStack = itemHandler.extractItem(lastChestSlot, 1, true);
        if (testStack.isEmpty() || !(testStack.getItem() instanceof ItemArrow)) {
            lastChestSlot = -1;
        } else {
            arrowStack = testStack;
        }
    }
    if (lastChestSlot < 0) {
        for (int i = 0; i < itemHandler.getSlots(); i++) {
            ItemStack testStack = itemHandler.extractItem(i, 1, true);
            if (!testStack.isEmpty() && testStack.getItem() instanceof ItemArrow) {
                arrowStack = testStack;
                lastChestSlot = i;
                break;
            }
        }
    }
    if (lastChestSlot < 0) {
        // No arrows in the chest. Welp!
        return false;
    }
    if (canFireOnMob(world, pos, target)) {
        Vec2f pitchYaw = getPitchYaw(pos, target);
        lastPitch = pitch;
        lastYaw = yaw;
        pitch = pitchYaw.x;
        yaw = pitchYaw.y;
        arrowTimer++;
        if (arrowTimer >= ARROW_WINDUP) {
            // ItemStack arrowStack = new ItemStack(Items.ARROW);
            fireOnTarget(world, pos, arrowStack, target);
            if (!world.isRemote) {
                itemHandler.extractItem(lastChestSlot, 1, false);
            }
            arrowTimer = 0;
        }
        return false;
    } else {
        target = null;
        arrowTimer = -1;
    }
    List<EntityMob> mobsInRange = world.getEntitiesWithinAABB(EntityMob.class, getBounds(pos));
    for (EntityMob entity : mobsInRange) {
        if (// && isMobInFilter(ent))
        canFireOnMob(world, pos, entity)) {
            target = entity;
            arrowTimer = 0;
            return false;
        }
    }
    arrowTimer = -1;
    target = null;
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EntityMob(net.minecraft.entity.monster.EntityMob) Vec2f(net.minecraft.util.math.Vec2f) IItemHandler(net.minecraftforge.items.IItemHandler) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) ItemArrow(net.minecraft.item.ItemArrow)

Aggregations

Vec2f (net.minecraft.util.math.Vec2f)2 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)1 EntityMob (net.minecraft.entity.monster.EntityMob)1 ItemArrow (net.minecraft.item.ItemArrow)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1 EnumFacing (net.minecraft.util.EnumFacing)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1 IItemHandler (net.minecraftforge.items.IItemHandler)1