當前位置: 首頁>>代碼示例>>Java>>正文


Java Minecraft.getRenderViewEntity方法代碼示例

本文整理匯總了Java中net.minecraft.client.Minecraft.getRenderViewEntity方法的典型用法代碼示例。如果您正苦於以下問題:Java Minecraft.getRenderViewEntity方法的具體用法?Java Minecraft.getRenderViewEntity怎麽用?Java Minecraft.getRenderViewEntity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.client.Minecraft的用法示例。


在下文中一共展示了Minecraft.getRenderViewEntity方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: runShader

import net.minecraft.client.Minecraft; //導入方法依賴的package包/類
public static void runShader() {
	Minecraft mc = Minecraft.getMinecraft();
	
	//TODO remove
	if (Keyboard.isKeyDown(Keyboard.KEY_NUMPAD5)) {
		destroyShader();
		createShader();
	}
	
	//Use shader program
	GL20.glUseProgram(shader.getShaderProgram());
	
	//TODO third person view
	Entity entity = mc.getRenderViewEntity();
	float partialTicks = mc.getRenderPartialTicks();
	double entityPosX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double)partialTicks;
       double entityPosY = entity.lastTickPosY + entity.getEyeHeight() + (entity.posY - entity.lastTickPosY) * (double)partialTicks;
       double entityPosZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double)partialTicks;
       float fov = (float) Math.toRadians(mc.entityRenderer.getFOVModifier(partialTicks, true));
	
	//Set uniform values
	int texUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "tex");
	GL20.glUniform1i(texUniform, 0);
	int cameraPosUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "cameraPos");
	GL20.glUniform3f(cameraPosUniform, (float)entityPosX%16, (float)entityPosY%16, (float)entityPosZ%16);
	int cameraDirUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "cameraDir");
	GL20.glUniform3f(cameraDirUniform, -(float)Math.toRadians(entity.rotationPitch), (float)Math.toRadians(180+entity.rotationYaw), 0);
	int fovyUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "fovy");
	GL20.glUniform1f(fovyUniform, fov);
	int fovxUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "fovx");
	GL20.glUniform1f(fovxUniform, fov*Display.getWidth()/(float)Display.getHeight());
	int sphericalUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "spherical");
	GL20.glUniform1i(sphericalUniform, RayTracerSettings.spherical ? 1 : 0);
	int stereoscopicUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "stereoscopic3d");
	GL20.glUniform1i(stereoscopicUniform, RayTracerSettings.stereoscopic ? 1 : 0);
	int eyeWidthUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "eyeWidth");
	GL20.glUniform1f(eyeWidthUniform, 0.063f); //TODO input eyeWidth option
	
	if (!pauseRendering) {
		if (worldLoader == null) {
			worldLoader = new WorldLoader();
		}
		if (worldLoader.dimension != mc.world.provider.getDimension()) {
			worldLoader.dimension = mc.world.provider.getDimension();
		}
		worldLoader.updateWorld(entityPosX, entityPosY, entityPosZ, shader);

		//Setup view
		GL11.glMatrixMode(GL11.GL_PROJECTION);
		GL11.glPushMatrix();
		GL11.glLoadIdentity();
		GL11.glOrtho(-1, 1, -1, 1, -1, 1);
		GL11.glMatrixMode(GL11.GL_MODELVIEW);
		GL11.glPushMatrix();
		GL11.glLoadIdentity();

		//Bind vbo and texture
		GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, shader.getVbo());
		GL20.glEnableVertexAttribArray(0);
		GL20.glVertexAttribPointer(0, 2, GL11.GL_BYTE, false, 0, 0L);
		GL11.glBindTexture(GL11.GL_TEXTURE_2D, 8);

		//Render
		GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, 6);

		//Reset vbo and texture
		GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
		GL20.glDisableVertexAttribArray(0);
		GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);

		//Reset view
		GL11.glMatrixMode(GL11.GL_PROJECTION);
		GL11.glPopMatrix();
		GL11.glMatrixMode(GL11.GL_MODELVIEW);
		GL11.glPopMatrix();
	}
	
	//Stop using shader program
	GL20.glUseProgram(0);
}
 
開發者ID:18107,項目名稱:MC-Ray-Tracer,代碼行數:81,代碼來源:RenderUtil.java

示例2: drawScene

import net.minecraft.client.Minecraft; //導入方法依賴的package包/類
public void drawScene(TileEntityGlassBase te, float partialTick)
{
    if(WorldPortalRenderer.renderLevel == 0 && !GeneralLaymansAestheticSpyingScreen.eventHandlerClient.drawnChannels.contains(te.channel))
    {
        //Draw scene
        GeneralLaymansAestheticSpyingScreen.eventHandlerClient.drawnChannels.add(te.channel);

        TerminalPlacement placement = GeneralLaymansAestheticSpyingScreen.eventHandlerClient.getTerminalPlacement(te.channel);

        if(placement != null)
        {
            placement.renderCaller = te;

            Minecraft mc = Minecraft.getMinecraft();
            Entity entity = mc.getRenderViewEntity();
            double centerX = placement.master.getPos().getX() + 0.5D;
            double centerY = placement.master.getPos().getY() + 0.5D;
            double centerZ = placement.master.getPos().getZ() + 0.5D;

            double destX = placement.terminal.getPos().getX() + 0.5D;
            double destY = placement.terminal.getPos().getY() + 0.5D;
            double destZ = placement.terminal.getPos().getZ() + 0.5D;

            float[] appliedOffset = placement.getQuaternionFormula().applyPositionalRotation(new float[] { EntityHelper.interpolateValues((float)entity.prevPosX, (float)entity.posX, partialTick) - (float)centerX, EntityHelper.interpolateValues((float)entity.prevPosY, (float)entity.posY, partialTick) + entity.getEyeHeight() - (float)centerY, EntityHelper.interpolateValues((float)entity.prevPosZ, (float)entity.posZ, partialTick) - (float)centerZ });
            float[] appliedRotation = placement.getQuaternionFormula().applyRotationalRotation(new float[] { EntityHelper.interpolateValues(entity.prevRotationYaw, entity.rotationYaw, partialTick), EntityHelper.interpolateValues(entity.prevRotationPitch, entity.rotationPitch, partialTick), WorldPortalRenderer.getRollFactor(WorldPortalRenderer.renderLevel, partialTick) });

            EntityTransformationStack ets = new EntityTransformationStack(entity).moveEntity(destX, destY, destZ, new float[] { 0F, 0F, 0F }, appliedRotation, partialTick);
            mc.entityRenderer.updateFogColor(partialTick);
            ets.reset();
            //End Transform the player position for fog.

            GlStateManager.enableCull();
            for(TileEntityGlassBase base : placement.activeBlocks)
            {
                if(base.active && base.lastDraw > 0)
                {
                    GlStateManager.pushMatrix();
                    GlStateManager.translate(base.getPos().getX() - te.getPos().getX(), base.getPos().getY() - te.getPos().getY(), base.getPos().getZ() - te.getPos().getZ());

                    TileEntityGlassRenderer.drawPlanes(base, mc.entityRenderer.fogColorRed, mc.entityRenderer.fogColorGreen, mc.entityRenderer.fogColorBlue, 1F, 0.501D, partialTick);

                    GlStateManager.popMatrix();
                }
            }

            //Draw the new scene
            WorldPortalRenderer.renderWorldPortal(mc, placement, entity, appliedOffset, appliedRotation, partialTick);// EXPLOSIONS

            //Reset the states
            GlStateManager.disableTexture2D();
            GlStateManager.color(1F, 1F, 1F, 1F);
            GlStateManager.disableLighting();
            GlStateManager.disableNormalize();
            GlStateManager.enableBlend();
            GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
            GlStateManager.alphaFunc(GL11.GL_GREATER, 0.00625F);
            GlStateManager.enableCull();
            OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240F, 240F);
        }
    }
}
 
開發者ID:iChun,項目名稱:GeneralLaymansAestheticSpyingScreen,代碼行數:62,代碼來源:TileEntityGlassRenderer.java

示例3: func_92037_i

import net.minecraft.client.Minecraft; //導入方法依賴的package包/類
private boolean func_92037_i()
{
    Minecraft minecraft = Minecraft.getMinecraft();
    return minecraft == null || minecraft.getRenderViewEntity() == null || minecraft.getRenderViewEntity().getDistanceSq(this.posX, this.posY, this.posZ) >= 256.0D;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:6,代碼來源:EntityFirework.java

示例4: renderWorld

import net.minecraft.client.Minecraft; //導入方法依賴的package包/類
/**
 * Render the world.
 * Called between {@link net.minecraft.client.renderer.EntityRenderer#renderWorld(float, long) renderWorld}
 * and {@link net.minecraft.client.renderer.EntityRenderer#renderWorldPass(int, float, long) renderWorldPass}
 */
public void renderWorld(EntityRenderer er, Minecraft mc, Framebuffer framebuffer, Shader shader,
		int[] framebufferTextures, float partialTicks, long finishTimeNano, int width, int height, float sizeIncrease) {
	//save the players state
	player = mc.getRenderViewEntity();
	yaw = player.rotationYaw;
	pitch = player.rotationPitch;
	prevYaw = player.prevRotationYaw;
	prevPitch = player.prevRotationPitch;

	//clear the primary framebuffer
	mc.getFramebuffer().framebufferClear();
	//clear the secondary framebuffer
	framebuffer.framebufferClear();
	//bind the secondary framebuffer
	framebuffer.bindFramebuffer(false);

	//displayWidth and displayHeight are called during world rendering
	//set them to the secondary framebuffer dimensions
	mc.displayWidth = (int)(height*sizeIncrease);
	mc.displayHeight = (int)(height*sizeIncrease); //Must be square

	RenderUtil.partialWidth = mc.displayWidth; //TODO is this even needed?
	RenderUtil.partialHeight = mc.displayHeight; //TODO remove

	RenderUtil.render360 = true;

	Globe globe = globes[globeIndex];
	for (int i=0; i<globe.getCount(); i++) {
		// set camera/player rotation state (read by hooks at the correct moment)
		coordFrame = globe.getCoordFrame(i);
		playerFov = globe.getFov(i);

		// the forward vector is the opposite direction of the z-axis
		float x = -coordFrame.get(2);
		float y = -coordFrame.get(6);
		float z = -coordFrame.get(10);

		// calculate the delta yaw/pitch to point the player
		float lon = (float)Math.atan2(x, -z);
		float lat = (float)Math.atan2(y, Math.sqrt(x*x+z*z));
		playerDeltaYaw = lon;
		playerDeltaPitch = lat;

		// render to texture
		OpenGlHelper.glFramebufferTexture2D(OpenGlHelper.GL_FRAMEBUFFER, OpenGlHelper.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, framebufferTextures[i], 0);
		GlStateManager.bindTexture(0);
		er.renderWorldPass(2, partialTicks, finishTimeNano);

		// reset player view
		player.rotationYaw = yaw;
		player.rotationPitch = pitch;
		player.prevRotationYaw = prevYaw;
		player.prevRotationPitch = prevPitch;
	}

	//reset displayWidth and displayHeight to the primary framebuffer dimensions
	mc.displayWidth = width;
	mc.displayHeight = height;

	//reset viewport to full screen
	GlStateManager.viewport(0, 0, width, height);
	//bind primary framebuffer
	mc.getFramebuffer().bindFramebuffer(false);

	if (!getResizeGui() || mc.gameSettings.hideGUI) {
		GL20.glUseProgram(shader.getShaderProgram());
		int cursorUniform = GL20.glGetUniformLocation(shader.getShaderProgram(), "drawCursor");
		GL20.glUniform1i(cursorUniform, 0);
		runShader(mc, shader, framebufferTextures);
	}
}
 
開發者ID:shaunlebron,項目名稱:flex-fov,代碼行數:77,代碼來源:RenderMethod.java

示例5: isFarFromCamera

import net.minecraft.client.Minecraft; //導入方法依賴的package包/類
private boolean isFarFromCamera()
{
    Minecraft minecraft = Minecraft.getMinecraft();
    return minecraft == null || minecraft.getRenderViewEntity() == null || minecraft.getRenderViewEntity().getDistanceSq(this.posX, this.posY, this.posZ) >= 256.0D;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:6,代碼來源:ParticleFirework.java

示例6: render

import net.minecraft.client.Minecraft; //導入方法依賴的package包/類
@Override
public void render(float partialTicks, WorldClient world, Minecraft mc)
{
	if (((ExPWorld)IExPWorld.of(world)).rainTicksRemaining <= 0)
	{
		return;
	}
	
	GlStateManager.depthMask(true);
	Vec3d offset = IExPWorld.of(world).getWindDirection();
	offset = offset.scale(IExPWorld.of(world).getWindStrength() / 3);
	float wStr = IExPWorld.of(world).getWindStrength();
	Random rand = new Random();
	GlStateManager.disableCull();
	GlStateManager.enableBlend();
       GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
       GlStateManager.alphaFunc(516, 0.1F);
	mc.renderEngine.bindTexture(ExPTextures.WEATHER);
	Entity entity = mc.getRenderViewEntity();
	double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double)partialTicks;
       double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double)partialTicks;
       double d2 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double)partialTicks;
       BlockPos pos = entity.getPosition();
	BufferBuilder vb = Tessellator.getInstance().getBuffer();
	vb.setTranslation(-d0, -d1, -d2);
	vb.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP);
	int x = pos.getX();
	int y = pos.getY();
	int z = pos.getZ();
	for (int dx = -8; dx <= 8; ++dx)
	{
		for (int dz = -8; dz <= 8; ++dz)
		{
			rand.setSeed(MathHelper.getCoordinateRandom(x + dx, 0, z + dz));
			int py = world.getPrecipitationHeight(pos.add(dx, 0, dz)).getY();
			py = Math.max(py, y - 8);
			double offsetYTex = rand.nextDouble() + (float)(world.getWorldTime() % 10) / 10 + partialTicks / 10;
			BlockPos renderedAt = new BlockPos(x + dx, py, z + dz);
			double offsetXTex = Helpers.getTemperatureAt(world, renderedAt) < 0 ? 0.5 : 0;
			float rOffX = rand.nextFloat() / 10;
			float rOffZ = rand.nextFloat() / 10;
			
			if (offsetXTex == 0.5)
			{
				float texOf = Math.max(2, 55 - wStr);
				offsetYTex = rand.nextDouble() + world.getWorldTime() % texOf / texOf + partialTicks / texOf;
			}
			
			int j3 = world.getCombinedLight(renderedAt, 0);
               int k3 = j3 >> 16 & 65535;
               int l3 = j3 & 65535;
			vb.pos(rOffX + x + 1 + dx - offset.x, py + 16, rOffZ + z + dz + 0.5 - offset.z).tex(offsetXTex, offsetYTex + 4).color(1, 1, 1, 0.5F).lightmap(k3, l3).endVertex();
			vb.pos(rOffX + x + dx - offset.x, py + 16, rOffZ + z + dz + 0.5 - offset.z).tex(offsetXTex + 0.5, offsetYTex + 4).color(1, 1, 1, 0.5F).lightmap(k3, l3).endVertex();
			vb.pos(rOffX + x + dx, py, rOffZ + z + dz + 0.5).tex(offsetXTex + 0.5, offsetYTex).color(1, 1, 1, 0.5F).lightmap(k3, l3).endVertex();
			vb.pos(rOffX + x + 1 + dx, py, rOffZ + z + dz + 0.5).tex(offsetXTex, offsetYTex).color(1, 1, 1, 0.5F).lightmap(k3, l3).endVertex();
			vb.pos(rOffX + x + 0.5 + dx - offset.x, py + 16, rOffZ + z + dz + 1 - offset.z).tex(offsetXTex, offsetYTex + 4).color(1, 1, 1, 0.5F).lightmap(k3, l3).endVertex();
			vb.pos(rOffX + x + 0.5 + dx - offset.x, py + 16, rOffZ + z + dz - offset.z).tex(offsetXTex + 0.5, offsetYTex + 4).color(1, 1, 1, 0.5F).lightmap(k3, l3).endVertex();
			vb.pos(rOffX + x + 0.5 + dx , py, rOffZ + z + dz).tex(offsetXTex + 0.5, offsetYTex).color(1, 1, 1, 0.5F).lightmap(k3, l3).endVertex();
			vb.pos(rOffX + x + 0.5 + dx, py, z + rOffZ + dz + 1).tex(offsetXTex, offsetYTex).color(1, 1, 1, 0.5F).lightmap(k3, l3).endVertex();
		}
	}
	
	Tessellator.getInstance().draw();
	vb.setTranslation(0, 0, 0);
	GlStateManager.enableCull();
       GlStateManager.disableBlend();
       GlStateManager.alphaFunc(516, 0.1F);
       GlStateManager.depthMask(false);
}
 
開發者ID:V0idWa1k3r,項目名稱:ExPetrum,代碼行數:70,代碼來源:WorldWeatherRenderer.java


注:本文中的net.minecraft.client.Minecraft.getRenderViewEntity方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。