Search in sources :

Example 51 with EntityPlayerSP

use of net.minecraft.client.entity.EntityPlayerSP in project LogisticsPipes by RS485.

the class LogisticsEventListener method clientLoggedIn.

@SubscribeEvent
public void clientLoggedIn(ClientConnectedToServerEvent event) {
    SimpleServiceLocator.clientBufferHandler.clear();
    if (Configs.CHECK_FOR_UPDATES) {
        LogisticsPipes.singleThreadExecutor.execute(() -> {
            // try to get player entity ten times, once a second
            int times = 0;
            EntityPlayerSP playerEntity;
            do {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    return;
                }
                playerEntity = FMLClientHandler.instance().getClientPlayerEntity();
                ++times;
            } while (playerEntity == null && times <= 10);
            if (times > 10) {
                return;
            }
            VersionChecker checker = LogisticsPipes.versionChecker;
            // send player message
            String versionMessage = checker.getVersionCheckerStatus();
            if (checker.isVersionCheckDone() && checker.getVersionInfo().isNewVersionAvailable() && !checker.getVersionInfo().isImcMessageSent()) {
                playerEntity.sendMessage(new TextComponentString(versionMessage));
                playerEntity.sendMessage(new TextComponentString("Use \"/logisticspipes changelog\" to see a changelog."));
            } else if (!checker.isVersionCheckDone()) {
                playerEntity.sendMessage(new TextComponentString(versionMessage));
            }
        });
    }
}
Also used : VersionChecker(logisticspipes.ticks.VersionChecker) TextComponentString(net.minecraft.util.text.TextComponentString) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) TextComponentString(net.minecraft.util.text.TextComponentString) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 52 with EntityPlayerSP

use of net.minecraft.client.entity.EntityPlayerSP 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 53 with EntityPlayerSP

use of net.minecraft.client.entity.EntityPlayerSP in project MineFactoryReloaded by powercrystals.

the class MineFactoryReloadedClient method tickStart.

@Override
public void tickStart(EnumSet<TickType> type, Object... tickData) {
    if (!(tickData[0] instanceof EntityPlayerSP)) {
        return;
    }
    EntityPlayerSP player = (EntityPlayerSP) tickData[0];
    int frontX = MathHelper.floor_double(player.posX + player.getLookVec().xCoord);
    int frontY = MathHelper.floor_double(player.boundingBox.minY);
    int frontZ = MathHelper.floor_double(player.posZ + player.getLookVec().zCoord);
    int blockId = player.worldObj.getBlockId(frontX, frontY, frontZ);
    if (blockId == MineFactoryReloadedCore.vineScaffoldBlock.blockID) {
        if (player.movementInput.moveForward > 0) {
            player.motionY = 0.2D;
        } else if (player.isSneaking()) {
            player.motionY = 0.0D;
        } else {
            player.motionY = -0.15D;
        }
    }
    ItemStack equipped = player.inventory.getCurrentItem();
    if (equipped != null && equipped.getItem() instanceof ItemRocketLauncher) {
        Entity e = rayTrace();
        if (_lastEntityOver != null && _lastEntityOver.isDead) {
            _lastEntityOver = null;
            _lockonTicks = 0;
        } else if ((e == null || e != _lastEntityOver) && _lockonLostTicks > 0) {
            _lockonLostTicks--;
        } else if (e == null && _lockonLostTicks == 0) {
            if (_lockonTicks > 0) {
                _lockonTicks--;
            }
            _lastEntityOver = null;
        } else if (_lastEntityOver == null) {
            _lastEntityOver = e;
        } else if (_lockonTicks < _lockonMax) {
            _lockonTicks++;
            if (_lockonTicks >= _lockonMax) {
                _lockonLostTicks = _lockonLostMax;
            }
        } else if (e != null && e == _lastEntityOver) {
            _lockonLostTicks = _lockonLostMax;
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) ItemRocketLauncher(powercrystals.minefactoryreloaded.item.ItemRocketLauncher) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) ItemStack(net.minecraft.item.ItemStack)

Example 54 with EntityPlayerSP

use of net.minecraft.client.entity.EntityPlayerSP in project pnc-repressurized by TeamPneumatic.

the class RenderEntityVortex method calculateXoffset.

private float calculateXoffset() {
    EntityPlayerSP player = Minecraft.getMinecraft().player;
    EnumHandSide hs = player.getPrimaryHand();
    if (player.getHeldItemMainhand().getItem() != Itemss.VORTEX_CANNON) {
        hs = hs.opposite();
    }
    // yeah, this is supposed to be asymmetric; it looks better that way
    return hs == EnumHandSide.RIGHT ? -4.0F : 16.0F;
}
Also used : EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) EnumHandSide(net.minecraft.util.EnumHandSide)

Example 55 with EntityPlayerSP

use of net.minecraft.client.entity.EntityPlayerSP in project malmo by Microsoft.

the class ChatCommandsImplementation method onExecute.

@Override
protected boolean onExecute(String verb, String parameter, MissionInit missionInit) {
    EntityPlayerSP player = Minecraft.getMinecraft().player;
    if (player == null) {
        return false;
    }
    if (!verb.equalsIgnoreCase(ChatCommand.CHAT.value())) {
        return false;
    }
    player.sendChatMessage(parameter);
    return true;
}
Also used : EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP)

Aggregations

EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)158 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)31 Minecraft (net.minecraft.client.Minecraft)29 ItemStack (net.minecraft.item.ItemStack)29 BlockPos (net.minecraft.util.math.BlockPos)27 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)23 Entity (net.minecraft.entity.Entity)21 EntityPlayer (net.minecraft.entity.player.EntityPlayer)13 TileEntity (net.minecraft.tileentity.TileEntity)13 WorldClient (net.minecraft.client.multiplayer.WorldClient)11 IBlockState (net.minecraft.block.state.IBlockState)10 Tessellator (net.minecraft.client.renderer.Tessellator)10 GCPlayerStatsClient (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient)8 ArrayList (java.util.ArrayList)6 Block (net.minecraft.block.Block)6 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)6 Vec3d (net.minecraft.util.math.Vec3d)6 World (net.minecraft.world.World)6 UUID (java.util.UUID)5 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)5