Search in sources :

Example 16 with WorldClient

use of net.minecraft.client.multiplayer.WorldClient in project DynamicSurroundings by OreCruncher.

the class SoundEffectHandler method doMoodProcessing.

// Going to hijack the mood processing logic in MC since it is kinda busted.
public void doMoodProcessing() {
    final WorldClient wc = (WorldClient) EnvironState.getWorld();
    // in the dark or something).
    if (wc.ambienceTicks == 1) {
        // Calculate a point around the player. +/- 15 blocks.
        final int deltaX = this.RANDOM.nextInt(30) - 15;
        final int deltaY = this.RANDOM.nextInt(30) - 15;
        final int deltaZ = this.RANDOM.nextInt(30) - 15;
        final int distance = deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ;
        if (distance > 4 && distance <= 255) {
            final BlockPos blockpos = EnvironState.getPlayerPosition().add(deltaX, deltaY, deltaZ);
            final IBlockState iblockstate = wc.getBlockState(blockpos);
            if (iblockstate.getMaterial() == Material.AIR)
                if (wc.getLightFor(EnumSkyBlock.SKY, blockpos) <= 0)
                    if (wc.getLight(blockpos) <= this.RANDOM.nextInt(8)) {
                        final BasicSound<?> fx = Sounds.AMBIENT_CAVE.createSoundAt(blockpos).setVolume(0.9F).setPitch(0.8F + this.RANDOM.nextFloat() * 0.2F);
                        playSound(fx);
                        wc.ambienceTicks = this.RANDOM.nextInt(12000) + 6000;
                        DSurround.log().debug("Next ambient event: %d ticks", wc.ambienceTicks);
                    }
        }
    }
    // triggering.
    if (wc.ambienceTicks == 1)
        wc.ambienceTicks = 2;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockPos(net.minecraft.util.math.BlockPos) WorldClient(net.minecraft.client.multiplayer.WorldClient)

Example 17 with WorldClient

use of net.minecraft.client.multiplayer.WorldClient in project BuildCraft by BuildCraft.

the class RenderTickListener method renderHeldItemInWorld.

private static void renderHeldItemInWorld(float partialTicks) {
    Minecraft mc = Minecraft.getMinecraft();
    EntityPlayer player = Minecraft.getMinecraft().player;
    if (player == null) {
        return;
    }
    ItemStack mainHand = StackUtil.asNonNull(player.getHeldItemMainhand());
    ItemStack offHand = StackUtil.asNonNull(player.getHeldItemOffhand());
    WorldClient world = mc.world;
    mc.mcProfiler.startSection("bc");
    mc.mcProfiler.startSection("renderWorld");
    DetachedRenderer.fromWorldOriginPre(player, partialTicks);
    Item mainHandItem = mainHand.getItem();
    Item offHandItem = offHand.getItem();
    if (mainHandItem == BCCoreItems.mapLocation) {
        renderMapLocation(mainHand);
    } else if (mainHandItem == BCCoreItems.markerConnector || offHandItem == BCCoreItems.markerConnector) {
        renderMarkerConnector(world, player);
    }
    DetachedRenderer.fromWorldOriginPost();
    mc.mcProfiler.endSection();
    mc.mcProfiler.endSection();
}
Also used : Item(net.minecraft.item.Item) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) WorldClient(net.minecraft.client.multiplayer.WorldClient)

Example 18 with WorldClient

use of net.minecraft.client.multiplayer.WorldClient in project RFToolsDimensions by McJty.

the class SkyRenderer method renderSky.

/**
 * Renders the sky with the partial tick time. Args: partialTickTime
 */
@SideOnly(Side.CLIENT)
private static void renderSky(float partialTickTime, DimensionInformation information) {
    initialize();
    EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
    WorldClient world = Minecraft.getMinecraft().theWorld;
    TextureManager renderEngine = Minecraft.getMinecraft().getTextureManager();
    GlStateManager.disableTexture2D();
    Vec3 vec3 = world.getSkyColor(player, partialTickTime);
    float skyRed = (float) vec3.xCoord;
    float skyGreen = (float) vec3.yCoord;
    float skyBlue = (float) vec3.zCoord;
    boolean anaglyph = Minecraft.getMinecraft().gameSettings.anaglyph;
    if (anaglyph) {
        float f4 = (skyRed * 30.0F + skyGreen * 59.0F + skyBlue * 11.0F) / 100.0F;
        float f5 = (skyRed * 30.0F + skyGreen * 70.0F) / 100.0F;
        float f6 = (skyRed * 30.0F + skyBlue * 70.0F) / 100.0F;
        skyRed = f4;
        skyGreen = f5;
        skyBlue = f6;
    }
    GlStateManager.color(skyRed, skyGreen, skyBlue);
    Tessellator tessellator = Tessellator.getInstance();
    WorldRenderer renderer = tessellator.getWorldRenderer();
    GlStateManager.depthMask(false);
    GlStateManager.enableFog();
    GlStateManager.color(skyRed, skyGreen, skyBlue);
    // @todo support VBO?
    // if (OpenGlHelper.useVbo()) {
    // skyVBO.bindBuffer();
    // GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    // GL11.glVertexPointer(3, GL11.GL_FLOAT, 12, 0L);
    // this.skyVBO.drawArrays(7);
    // this.skyVBO.unbindBuffer();
    // GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
    // 
    // } else {
    GlStateManager.callList(glSkyList);
    // }
    GlStateManager.disableFog();
    GlStateManager.disableAlpha();
    GlStateManager.enableBlend();
    GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
    RenderHelper.disableStandardItemLighting();
    float[] sunsetColors = world.provider.calcSunriseSunsetColors(world.getCelestialAngle(partialTickTime), partialTickTime);
    if (sunsetColors != null) {
        GlStateManager.disableTexture2D();
        GlStateManager.shadeModel(7425);
        GlStateManager.pushMatrix();
        GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.rotate(MathHelper.sin(world.getCelestialAngleRadians(partialTickTime)) < 0.0F ? 180.0F : 0.0F, 0.0F, 0.0F, 1.0F);
        GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F);
        float f6 = sunsetColors[0];
        float f7 = sunsetColors[1];
        float f8 = sunsetColors[2];
        if (anaglyph) {
            float f9 = (f6 * 30.0F + f7 * 59.0F + f8 * 11.0F) / 100.0F;
            float f10 = (f6 * 30.0F + f7 * 70.0F) / 100.0F;
            float f11 = (f6 * 30.0F + f8 * 70.0F) / 100.0F;
            f6 = f9;
            f7 = f10;
            f8 = f11;
        }
        renderer.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR);
        renderer.pos(0.0D, 100.0D, 0.0D).color(f6, f7, f8, sunsetColors[3]).endVertex();
        for (int j = 0; j <= 16; ++j) {
            float f11 = j * (float) Math.PI * 2.0F / 16.0f;
            float f12 = MathHelper.sin(f11);
            float f13 = MathHelper.cos(f11);
            renderer.pos((f12 * 120.0F), (f13 * 120.0F), (-f13 * 40.0F * sunsetColors[3])).color(sunsetColors[0], sunsetColors[1], sunsetColors[2], 0.0F).endVertex();
        }
        tessellator.draw();
        GlStateManager.popMatrix();
        GlStateManager.shadeModel(GL11.GL_FLAT);
    }
    renderCelestialBodies(partialTickTime, information, world, renderEngine, tessellator);
    GlStateManager.color(0.0F, 0.0F, 0.0F);
    double d0 = player.getPosition().getY() - world.getHorizon();
    if (d0 < 0.0D) {
        GlStateManager.pushMatrix();
        GlStateManager.translate(0.0F, 12.0F, 0.0F);
        // @todo
        // if (this.vboEnabled)
        // {
        // this.sky2VBO.bindBuffer();
        // GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
        // GL11.glVertexPointer(3, GL11.GL_FLOAT, 12, 0L);
        // this.sky2VBO.drawArrays(7);
        // this.sky2VBO.unbindBuffer();
        // GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
        // }
        // else
        // {
        GlStateManager.callList(glSkyList2);
        // GlStateManager.callList(this.glSkyList2);
        // }
        GlStateManager.popMatrix();
        float f8 = 1.0F;
        float f9 = -((float) (d0 + 65.0D));
        float f10 = -f8;
        renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
        renderer.pos((-f8), f9, f8).color(0, 0, 0, 255).endVertex();
        renderer.pos(f8, f9, f8).color(0, 0, 0, 255).endVertex();
        renderer.pos(f8, f10, f8).color(0, 0, 0, 255).endVertex();
        renderer.pos((-f8), f10, f8).color(0, 0, 0, 255).endVertex();
        renderer.pos((-f8), f10, (-f8)).color(0, 0, 0, 255).endVertex();
        renderer.pos(f8, f10, (-f8)).color(0, 0, 0, 255).endVertex();
        renderer.pos(f8, f9, (-f8)).color(0, 0, 0, 255).endVertex();
        renderer.pos((-f8), f9, (-f8)).color(0, 0, 0, 255).endVertex();
        renderer.pos(f8, f10, (-f8)).color(0, 0, 0, 255).endVertex();
        renderer.pos(f8, f10, f8).color(0, 0, 0, 255).endVertex();
        renderer.pos(f8, f9, f8).color(0, 0, 0, 255).endVertex();
        renderer.pos(f8, f9, (-f8)).color(0, 0, 0, 255).endVertex();
        renderer.pos((-f8), f9, (-f8)).color(0, 0, 0, 255).endVertex();
        renderer.pos((-f8), f9, f8).color(0, 0, 0, 255).endVertex();
        renderer.pos((-f8), f10, f8).color(0, 0, 0, 255).endVertex();
        renderer.pos((-f8), f10, (-f8)).color(0, 0, 0, 255).endVertex();
        renderer.pos((-f8), f10, (-f8)).color(0, 0, 0, 255).endVertex();
        renderer.pos((-f8), f10, f8).color(0, 0, 0, 255).endVertex();
        renderer.pos(f8, f10, f8).color(0, 0, 0, 255).endVertex();
        renderer.pos(f8, f10, (-f8)).color(0, 0, 0, 255).endVertex();
        tessellator.draw();
    }
    if (world.provider.isSkyColored()) {
        GlStateManager.color(skyRed * 0.2F + 0.04F, skyGreen * 0.2F + 0.04F, skyBlue * 0.6F + 0.1F);
    } else {
        GlStateManager.color(skyRed, skyGreen, skyBlue);
    }
    GlStateManager.pushMatrix();
    GlStateManager.translate(0.0F, -((float) (d0 - 16.0D)), 0.0F);
    GlStateManager.callList(glSkyList2);
    GlStateManager.popMatrix();
    GlStateManager.enableTexture2D();
    GlStateManager.depthMask(true);
}
Also used : TextureManager(net.minecraft.client.renderer.texture.TextureManager) Vec3(net.minecraft.util.Vec3) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) WorldClient(net.minecraft.client.multiplayer.WorldClient) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 19 with WorldClient

use of net.minecraft.client.multiplayer.WorldClient in project RFToolsDimensions by McJty.

the class SkyRenderer method registerSkybox.

public static void registerSkybox(GenericWorldProvider provider, final SkyType skyType) {
    provider.setSkyRenderer(new IRenderHandler() {

        @Override
        public void render(float partialTicks, WorldClient world, Minecraft mc) {
            ResourceLocation sky;
            ResourceLocation sky2 = null;
            int type = SKYTYPE_DARKTOP;
            switch(skyType) {
                case SKY_INFERNO:
                    sky = locationPlasmaSkyPng;
                    type = SKYTYPE_DARKTOP;
                    break;
                case SKY_STARS1:
                    sky = locationStars1;
                    sky2 = locationStars1a;
                    type = SKYTYPE_ALTERNATING;
                    break;
                case SKY_STARS2:
                    sky = locationStars2;
                    type = SKYTYPE_ALL;
                    break;
                case SKY_STARS3:
                    sky = locationStars3;
                    sky2 = locationStars3a;
                    type = SKYTYPE_ALLHORIZONTAL;
                    break;
                default:
                    return;
            }
            SkyRenderer.renderSkyTexture(sky, sky2, type);
        }
    });
    provider.setCloudRenderer(new IRenderHandler() {

        @Override
        public void render(float partialTicks, WorldClient world, Minecraft mc) {
        }
    });
}
Also used : IRenderHandler(net.minecraftforge.client.IRenderHandler) ResourceLocation(net.minecraft.util.ResourceLocation) WorldClient(net.minecraft.client.multiplayer.WorldClient) Minecraft(net.minecraft.client.Minecraft)

Example 20 with WorldClient

use of net.minecraft.client.multiplayer.WorldClient in project Almura by AlmuraDev.

the class LookingDebugPanel method drawForeground.

@Override
public void drawForeground(final GuiRenderer renderer, final int mouseX, final int mouseY, final float partialTick) {
    super.drawForeground(renderer, mouseX, mouseY, partialTick);
    this.baseHeight = 22;
    this.client.profiler.startSection("debug");
    // Draw block we're currently looking at
    final RayTraceResult objectMouseOver = this.client.objectMouseOver;
    if (this.lookingAtBlock) {
        final WorldClient world = this.client.world;
        final BlockPos blockPos = objectMouseOver.getBlockPos();
        final IBlockState state = getState(world, blockPos);
        final ItemStack pickStack = state.getBlock().getPickBlock(state, objectMouseOver, world, blockPos, this.client.player);
        this.renderItemStackFromBlock(state, pickStack);
    } else if (this.lookingAtEntity) {
        this.renderEntity(objectMouseOver.entityHit);
    }
    // Extra padding
    this.autoHeight += 4;
    this.autoSize();
    this.client.profiler.endSection();
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) RayTraceResult(net.minecraft.util.math.RayTraceResult) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) WorldClient(net.minecraft.client.multiplayer.WorldClient)

Aggregations

WorldClient (net.minecraft.client.multiplayer.WorldClient)39 Minecraft (net.minecraft.client.Minecraft)19 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)12 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)10 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)10 Entity (net.minecraft.entity.Entity)9 EntityPlayer (net.minecraft.entity.player.EntityPlayer)8 BlockPos (net.minecraft.util.math.BlockPos)7 Block (net.minecraft.block.Block)6 IBlockState (net.minecraft.block.state.IBlockState)6 IGalacticraftWorldProvider (micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)4 IRenderHandler (net.minecraftforge.client.IRenderHandler)4 BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)3 ItemStack (net.minecraft.item.ItemStack)3 TileEntity (net.minecraft.tileentity.TileEntity)3 BlockPos (net.minecraft.util.BlockPos)3 Function (com.google.common.base.Function)2 Random (java.util.Random)2 GuiCelestialSelection (micdoodle8.mods.galacticraft.core.client.gui.screen.GuiCelestialSelection)2 WorldProviderSpaceStation (micdoodle8.mods.galacticraft.core.dimension.WorldProviderSpaceStation)2