Java Code Examples for net.minecraft.client.renderer.GlStateManager#translate()

The following examples show how to use net.minecraft.client.renderer.GlStateManager#translate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RenderCyberlimbHand.java    From Cyberware with MIT License 6 votes vote down vote up
private void transformEatFirstPerson(float p_187454_1_, EnumHandSide p_187454_2_, ItemStack p_187454_3_)
{
	float f = (float)this.mc.thePlayer.getItemInUseCount() - p_187454_1_ + 1.0F;
	float f1 = f / (float)p_187454_3_.getMaxItemUseDuration();

	if (f1 < 0.8F)
	{
		float f2 = MathHelper.abs(MathHelper.cos(f / 4.0F * (float)Math.PI) * 0.1F);
		GlStateManager.translate(0.0F, f2, 0.0F);
	}

	float f3 = 1.0F - (float)Math.pow((double)f1, 27.0D);
	int i = p_187454_2_ == EnumHandSide.RIGHT ? 1 : -1;
	GlStateManager.translate(f3 * 0.6F * (float)i, f3 * -0.5F, f3 * 0.0F);
	GlStateManager.rotate((float)i * f3 * 90.0F, 0.0F, 1.0F, 0.0F);
	GlStateManager.rotate(f3 * 10.0F, 1.0F, 0.0F, 0.0F);
	GlStateManager.rotate((float)i * f3 * 30.0F, 0.0F, 0.0F, 1.0F);
}
 
Example 2
Source File: DisplayTable.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void draw(int x, int y) {
    boolean first = true;
    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, 0);

    for (String[] row : rows) {
        FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj;
        GlStateManager.pushMatrix();

        for (int i = 0; i < row.length; i++) {
            String tmp = row[i];
            fontRendererObj.drawString((first ? EnumChatFormatting.BOLD : "") + tmp, 0, 0, Color.WHITE.getRGB());
            GlStateManager.translate(rowSpacing[i], 0, 0);
        }

        GlStateManager.popMatrix();
        GlStateManager.translate(0, 11, 0);
        first = false;
    }

    GlStateManager.popMatrix();
}
 
Example 3
Source File: Widget.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SideOnly(Side.CLIENT)
protected static void drawItemStack(ItemStack itemStack, int x, int y, @Nullable String altTxt) {
    GlStateManager.pushMatrix();
    GlStateManager.translate(0.0F, 0.0F, 32.0F);
    GlStateManager.color(1F, 1F, 1F, 1F);
    GlStateManager.enableRescaleNormal();
    GlStateManager.enableLighting();
    RenderHelper.enableGUIStandardItemLighting();
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0f, 240.0f);
    Minecraft mc = Minecraft.getMinecraft();
    RenderItem itemRender = mc.getRenderItem();
    itemRender.renderItemAndEffectIntoGUI(itemStack, x, y);
    itemRender.renderItemOverlayIntoGUI(mc.fontRenderer, itemStack, x, y, altTxt);
    GlStateManager.disableRescaleNormal();
    GlStateManager.disableLighting();
    GlStateManager.color(1F, 1F, 1F, 1F);
    GlStateManager.popMatrix();
    GlStateManager.enableBlend();
    GlStateManager.disableDepth();
}
 
Example 4
Source File: Scaffold.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Scaffold visuals
 *
 * @param event
 */
@EventTarget
public void onRender2D(final Render2DEvent event) {
    if (counterDisplayValue.get()) {
        GlStateManager.pushMatrix();

        final BlockOverlay blockOverlay = (BlockOverlay) LiquidBounce.moduleManager.getModule(BlockOverlay.class);
        if (blockOverlay.getState() && blockOverlay.getInfoValue().get() && blockOverlay.getCurrentBlock() != null)
            GlStateManager.translate(0, 15F, 0);

        final String info = "Blocks: ยง7" + getBlocksAmount();
        final ScaledResolution scaledResolution = new ScaledResolution(mc);

        RenderUtils.drawBorderedRect((scaledResolution.getScaledWidth() / 2) - 2,
                (scaledResolution.getScaledHeight() / 2) + 5,
                (scaledResolution.getScaledWidth() / 2) + Fonts.font40.getStringWidth(info) + 2,
                (scaledResolution.getScaledHeight() / 2) + 16, 3, Color.BLACK.getRGB(), Color.BLACK.getRGB());
        GlStateManager.resetColor();
        Fonts.font40.drawString(info, scaledResolution.getScaledWidth() / 2,
                scaledResolution.getScaledHeight() / 2 + 7, Color.WHITE.getRGB());

        GlStateManager.popMatrix();
    }
}
 
Example 5
Source File: ModelFoxDesert.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sets the models various rotation angles then renders the model.
 */
@Override
public void render(Entity entityIn, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float scale)
{
	this.setRotationAngles(p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, scale, entityIn);

	GlStateManager.pushMatrix();
	GlStateManager.scale(0.5, 0.5, 0.5);
	GlStateManager.translate(0.0F, 1.5, -0.5F);
	this.Head.render(scale);
	this.Neck.render(scale);
	this.Body.render(scale);
	LegLeftFront.render(scale);
	LegLeftRear.render(scale);
	LegRightFront.render(scale);
	LegRightRear.render(scale);
	Tail.render(scale);
	GlStateManager.popMatrix();
}
 
Example 6
Source File: RenderCyberlimbHand.java    From Cyberware with MIT License 6 votes vote down vote up
private void renderMapFirstPersonSide(float p_187465_1_, EnumHandSide p_187465_2_, float p_187465_3_, ItemStack p_187465_4_)
{
	float f = p_187465_2_ == EnumHandSide.RIGHT ? 1.0F : -1.0F;
	GlStateManager.translate(f * 0.125F, -0.125F, 0.0F);

	if (!this.mc.thePlayer.isInvisible())
	{
		GlStateManager.pushMatrix();
		GlStateManager.rotate(f * 10.0F, 0.0F, 0.0F, 1.0F);
		this.renderArmFirstPerson(p_187465_1_, p_187465_3_, p_187465_2_);
		GlStateManager.popMatrix();
	}

	GlStateManager.pushMatrix();
	GlStateManager.translate(f * 0.51F, -0.08F + p_187465_1_ * -1.2F, -0.75F);
	float f1 = MathHelper.sqrt_float(p_187465_3_);
	float f2 = MathHelper.sin(f1 * (float)Math.PI);
	float f3 = -0.5F * f2;
	float f4 = 0.4F * MathHelper.sin(f1 * ((float)Math.PI * 2F));
	float f5 = -0.3F * MathHelper.sin(p_187465_3_ * (float)Math.PI);
	GlStateManager.translate(f * f3, f4 - 0.3F * f2, f5);
	GlStateManager.rotate(f2 * -45.0F, 1.0F, 0.0F, 0.0F);
	GlStateManager.rotate(f * f2 * -30.0F, 0.0F, 1.0F, 0.0F);
	this.renderMapFirstPerson(p_187465_4_);
	GlStateManager.popMatrix();
}
 
Example 7
Source File: RenderSphere.java    From YouTubeModdingTutorial with MIT License 6 votes vote down vote up
@Override
public void doRender(EntitySphere entity, double x, double y, double z, float entityYaw, float partialTicks) {
    GlStateManager.depthMask(false);

    GlStateManager.pushMatrix();
    GlStateManager.translate((float)x, (float)y, (float)z);
    rotateToPlayer();

    // ----------------------------------------

    this.bindTexture(sphere);

    GlStateManager.enableRescaleNormal();
    GlStateManager.color(1.0f, 1.0f, 1.0f);

    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_ONE, GL11.GL_ONE);

    long t = System.currentTimeMillis() % 6;
    renderBillboardQuad(0.3f, t * (1.0f / 6.0f), (1.0f / 6.0f));

    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.depthMask(true);

    GlStateManager.popMatrix();
}
 
Example 8
Source File: RenderCyberlimbHand.java    From Cyberware with MIT License 6 votes vote down vote up
private void renderArm(EnumHandSide p_187455_1_)
{
	this.mc.getTextureManager().bindTexture(this.mc.thePlayer.getLocationSkin());
	Render<AbstractClientPlayer> render = getEntityRenderObject(this.mc.thePlayer, p_187455_1_);
	RenderPlayer renderplayer = (RenderPlayer)render;
	GlStateManager.pushMatrix();
	float f = p_187455_1_ == EnumHandSide.RIGHT ? 1.0F : -1.0F;
	GlStateManager.rotate(92.0F, 0.0F, 1.0F, 0.0F);
	GlStateManager.rotate(45.0F, 1.0F, 0.0F, 0.0F);
	GlStateManager.rotate(f * -41.0F, 0.0F, 0.0F, 1.0F);
	GlStateManager.translate(f * 0.3F, -1.1F, 0.45F);

	if (p_187455_1_ == EnumHandSide.RIGHT)
	{
		renderplayer.renderRightArm(this.mc.thePlayer);
	}
	else
	{
		renderplayer.renderLeftArm(this.mc.thePlayer);
	}

	GlStateManager.popMatrix();
}
 
Example 9
Source File: SurfaceHelper.java    From ForgeHax with MIT License 5 votes vote down vote up
private static void renderItemModelIntoGUI(
    ItemStack stack, double x, double y, IBakedModel bakedmodel, double scale) {
  GlStateManager.pushMatrix();
  MC.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
  MC.getTextureManager()
      .getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE)
      .setBlurMipmap(false, false);
  GlStateManager.enableRescaleNormal();
  GlStateManager.enableAlpha();
  GlStateManager.alphaFunc(516, 0.1F);
  GlStateManager.enableBlend();
  GlStateManager.blendFunc(
      GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
  GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
  
  GlStateManager.translate(x, y, 100.0F + MC.getRenderItem().zLevel);
  GlStateManager.translate(8.0F, 8.0F, 0.0F);
  GlStateManager.scale(1.0F, -1.0F, 1.0F);
  GlStateManager.scale(scale, scale, scale);
  
  if (bakedmodel.isGui3d()) {
    GlStateManager.enableLighting();
  } else {
    GlStateManager.disableLighting();
  }
  
  bakedmodel =
      net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(
          bakedmodel, ItemCameraTransforms.TransformType.GUI, false);
  MC.getRenderItem().renderItem(stack, bakedmodel);
  GlStateManager.disableAlpha();
  GlStateManager.disableRescaleNormal();
  GlStateManager.disableLighting();
  GlStateManager.popMatrix();
  MC.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
  MC.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap();
}
 
Example 10
Source File: RenderCodex.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static void transformFirstPerson(EnumHandSide p_187453_1_, float p_187453_2_) {
	int i = p_187453_1_ == EnumHandSide.RIGHT ? 1 : -1;
	// Botania - added
	GlStateManager.translate(p_187453_1_ == EnumHandSide.RIGHT ? 0.2F : 0.52F, -0.125F, p_187453_1_ == EnumHandSide.RIGHT ? 0.6F : 0.25F);
	GlStateManager.rotate(p_187453_1_ == EnumHandSide.RIGHT ? 60F : 120F, 0F, 1F, 0F);
	GlStateManager.rotate(30F, 0F, 0F, -1F);
	// End add
	float f = MathHelper.sin(p_187453_2_ * p_187453_2_ * (float) Math.PI);
	GlStateManager.rotate(i * (45.0F + f * -20.0F), 0.0F, 1.0F, 0.0F);
	float f1 = MathHelper.sin(MathHelper.sqrt(p_187453_2_) * (float) Math.PI);
	GlStateManager.rotate(i * f1 * -20.0F, 0.0F, 0.0F, 1.0F);
	GlStateManager.rotate(f1 * -80.0F, 1.0F, 0.0F, 0.0F);
	GlStateManager.rotate(i * -45.0F, 0.0F, 1.0F, 0.0F);
}
 
Example 11
Source File: RenderFallTofu.java    From TofuCraftReload with MIT License 5 votes vote down vote up
/**
 * Renders the desired {@code T} type Entity.
 */
public void doRender(EntityFallTofu entity, double x, double y, double z, float entityYaw, float partialTicks) {

    IBlockState iblockstate = BlockLoader.tofuTerrain.getDefaultState();

    if (iblockstate.getRenderType() == EnumBlockRenderType.MODEL) {
        World world = entity.getWorldObj();

        if (iblockstate != world.getBlockState(new BlockPos(entity)) && iblockstate.getRenderType() != EnumBlockRenderType.INVISIBLE) {
            this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
            GlStateManager.pushMatrix();
            GlStateManager.disableLighting();
            Tessellator tessellator = Tessellator.getInstance();
            BufferBuilder bufferbuilder = tessellator.getBuffer();

            if (this.renderOutlines) {
                GlStateManager.enableColorMaterial();
                GlStateManager.enableOutlineMode(this.getTeamColor(entity));
            }

            bufferbuilder.begin(7, DefaultVertexFormats.BLOCK);
            BlockPos blockpos = new BlockPos(entity.posX, entity.getEntityBoundingBox().maxY, entity.posZ);
            GlStateManager.translate((float) (x - (double) blockpos.getX() - 0.5D), (float) (y - (double) blockpos.getY()), (float) (z - (double) blockpos.getZ() - 0.5D));
            BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
            blockrendererdispatcher.getBlockModelRenderer().renderModel(world, blockrendererdispatcher.getModelForState(iblockstate), iblockstate, blockpos, bufferbuilder, false);
            tessellator.draw();

            if (this.renderOutlines) {
                GlStateManager.disableOutlineMode();
                GlStateManager.disableColorMaterial();
            }

            GlStateManager.enableLighting();
            GlStateManager.popMatrix();
            super.doRender(entity, x, y, z, entityYaw, partialTicks);
        }
    }

}
 
Example 12
Source File: RenderListener.java    From SkyblockAddons with MIT License 5 votes vote down vote up
private void renderItem(ItemStack item, float x, float y) {
    GlStateManager.enableRescaleNormal();
    RenderHelper.enableGUIStandardItemLighting();
    GlStateManager.enableDepth();

    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, 0);
    Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(item, 0, 0);
    GlStateManager.popMatrix();

    GlStateManager.disableDepth();
    RenderHelper.disableStandardItemLighting();
    GlStateManager.disableRescaleNormal();
}
 
Example 13
Source File: RenderSaltPan.java    From TofuCraftReload with MIT License 4 votes vote down vote up
@Override
public void render(TileEntitySaltPan te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
	if(!(te.getBlockType() instanceof BlockSaltPan)) return;
	BlockSaltPan panframe = (BlockSaltPan)te.getBlockType();
	World worldIn = te.getWorld();
	BlockPos framePos = te.getPos();
	BlockSaltPan.Stat myStat = panframe.getStat(worldIn, framePos);
	
	GlStateManager.pushMatrix();
    GlStateManager.enableDepth();
    GlStateManager.enableRescaleNormal();
    GlStateManager.translate(x, y, z);
     
    //content
	ResourceLocation contentTexture;
	int frame = (int)te.getWorld().getWorldInfo().getWorldTime()%64/2;
	if (myStat == BlockSaltPan.Stat.WATER){
		contentTexture = WATER[frame];
	}
	else if (myStat == BlockSaltPan.Stat.BITTERN){
		contentTexture = BITTERN[frame];

	}
	else if (myStat == BlockSaltPan.Stat.SALT){
		contentTexture = SALT_TEXTURE;
	}
	else contentTexture = null;
	
	if (contentTexture != null) {
		
		boolean edgeNorth = this.shouldSideBeRendered(worldIn, myStat, framePos.north(), panframe);
		boolean edgeEast = this.shouldSideBeRendered(worldIn, myStat, framePos.east(), panframe);
		boolean edgeSouth = this.shouldSideBeRendered(worldIn, myStat, framePos.south(), panframe);
		boolean edgeWest = this.shouldSideBeRendered(worldIn, myStat, framePos.west(), panframe);
		
    	this.bindTexture(contentTexture);
    	GlStateManager.enableBlend();
    	GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    	if(myStat != BlockSaltPan.Stat.SALT) GlStateManager.depthMask(false);

    	GlStateManager.enableAlpha();
    	
    	this.modelSaltpan.renderContent();
    	this.modelSaltpan.renderContentEdge(edgeNorth, edgeEast, edgeSouth, edgeWest);
    	
    	GlStateManager.depthMask(true);
	}
    
    GlStateManager.disableRescaleNormal();
    GlStateManager.popMatrix();
}
 
Example 14
Source File: MixinEntityRenderer.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
@Inject(method = "orientCamera", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Vec3;distanceTo(Lnet/minecraft/util/Vec3;)D"), cancellable = true)
private void cameraClip(float partialTicks, CallbackInfo callbackInfo) {
    if (LiquidBounce.moduleManager.getModule(CameraClip.class).getState()) {
        callbackInfo.cancel();

        Entity entity = this.mc.getRenderViewEntity();
        float f = entity.getEyeHeight();

        if(entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isPlayerSleeping()) {
            f = (float) ((double) f + 1D);
            GlStateManager.translate(0F, 0.3F, 0.0F);

            if(!this.mc.gameSettings.debugCamEnable) {
                BlockPos blockpos = new BlockPos(entity);
                IBlockState iblockstate = this.mc.theWorld.getBlockState(blockpos);
                net.minecraftforge.client.ForgeHooksClient.orientBedCamera(this.mc.theWorld, blockpos, iblockstate, entity);

                GlStateManager.rotate(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks + 180.0F, 0.0F, -1.0F, 0.0F);
                GlStateManager.rotate(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTicks, -1.0F, 0.0F, 0.0F);
            }
        }else if(this.mc.gameSettings.thirdPersonView > 0) {
            double d3 = (double) (this.thirdPersonDistanceTemp + (this.thirdPersonDistance - this.thirdPersonDistanceTemp) * partialTicks);

            if(this.mc.gameSettings.debugCamEnable) {
                GlStateManager.translate(0.0F, 0.0F, (float) (-d3));
            }else{
                float f1 = entity.rotationYaw;
                float f2 = entity.rotationPitch;

                if(this.mc.gameSettings.thirdPersonView == 2)
                    f2 += 180.0F;

                if(this.mc.gameSettings.thirdPersonView == 2)
                    GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);

                GlStateManager.rotate(entity.rotationPitch - f2, 1.0F, 0.0F, 0.0F);
                GlStateManager.rotate(entity.rotationYaw - f1, 0.0F, 1.0F, 0.0F);
                GlStateManager.translate(0.0F, 0.0F, (float) (-d3));
                GlStateManager.rotate(f1 - entity.rotationYaw, 0.0F, 1.0F, 0.0F);
                GlStateManager.rotate(f2 - entity.rotationPitch, 1.0F, 0.0F, 0.0F);
            }
        }else
            GlStateManager.translate(0.0F, 0.0F, -0.1F);

        if(!this.mc.gameSettings.debugCamEnable) {
            float yaw = entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks + 180.0F;
            float pitch = entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTicks;
            float roll = 0.0F;
            if(entity instanceof EntityAnimal) {
                EntityAnimal entityanimal = (EntityAnimal) entity;
                yaw = entityanimal.prevRotationYawHead + (entityanimal.rotationYawHead - entityanimal.prevRotationYawHead) * partialTicks + 180.0F;
            }

            Block block = ActiveRenderInfo.getBlockAtEntityViewpoint(this.mc.theWorld, entity, partialTicks);
            net.minecraftforge.client.event.EntityViewRenderEvent.CameraSetup event = new net.minecraftforge.client.event.EntityViewRenderEvent.CameraSetup((EntityRenderer) (Object) this, entity, block, partialTicks, yaw, pitch, roll);
            net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event);
            GlStateManager.rotate(event.roll, 0.0F, 0.0F, 1.0F);
            GlStateManager.rotate(event.pitch, 1.0F, 0.0F, 0.0F);
            GlStateManager.rotate(event.yaw, 0.0F, 1.0F, 0.0F);
        }

        GlStateManager.translate(0.0F, -f, 0.0F);
        double d0 = entity.prevPosX + (entity.posX - entity.prevPosX) * (double) partialTicks;
        double d1 = entity.prevPosY + (entity.posY - entity.prevPosY) * (double) partialTicks + (double) f;
        double d2 = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double) partialTicks;
        this.cloudFog = this.mc.renderGlobal.hasCloudFog(d0, d1, d2, partialTicks);
    }
}
 
Example 15
Source File: PhysObjectRenderManager.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
public void inverseTransform(double partialTicks) {
    Vector centerOfRotation = parent.getCenterCoord();

    double p0 = Minecraft.getMinecraft().player.lastTickPosX
        + (Minecraft.getMinecraft().player.posX - Minecraft.getMinecraft().player.lastTickPosX)
        * partialTicks;
    double p1 = Minecraft.getMinecraft().player.lastTickPosY
        + (Minecraft.getMinecraft().player.posY - Minecraft.getMinecraft().player.lastTickPosY)
        * partialTicks;
    double p2 = Minecraft.getMinecraft().player.lastTickPosZ
        + (Minecraft.getMinecraft().player.posZ - Minecraft.getMinecraft().player.lastTickPosZ)
        * partialTicks;

    ShipTransform renderTransform = parent.getShipTransformationManager().getRenderTransform();

    Vector renderPos = new Vector(centerOfRotation);
    renderTransform.transform(renderPos, TransformType.SUBSPACE_TO_GLOBAL);

    double moddedX = renderPos.X;
    double moddedY = renderPos.Y;
    double moddedZ = renderPos.Z;

    double[] radians = renderTransform
        .createRotationQuaternion(TransformType.SUBSPACE_TO_GLOBAL).toRadians();

    double moddedPitch = Math.toDegrees(radians[0]);
    double moddedYaw = Math.toDegrees(radians[1]);
    double moddedRoll = Math.toDegrees(radians[2]);

    if (offsetPos != null) {
        double offsetX = offsetPos.getX() - centerOfRotation.X;
        double offsetY = offsetPos.getY() - centerOfRotation.Y;
        double offsetZ = offsetPos.getZ() - centerOfRotation.Z;

        GL11.glTranslated(-offsetX, -offsetY, -offsetZ);
        GL11.glRotated(-moddedRoll, 0, 0, 1D);
        GL11.glRotated(-moddedYaw, 0, 1D, 0);
        GL11.glRotated(-moddedPitch, 1D, 0, 0);
        GlStateManager.translate(p0 - moddedX, p1 - moddedY, p2 - moddedZ);
    }
}
 
Example 16
Source File: MixinItemRenderer.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @author CCBlueX
 */
@Overwrite
public void renderItemInFirstPerson(float partialTicks) {
    float f = 1.0F - (this.prevEquippedProgress + (this.equippedProgress - this.prevEquippedProgress) * partialTicks);
    AbstractClientPlayer abstractclientplayer = this.mc.thePlayer;
    float f1 = abstractclientplayer.getSwingProgress(partialTicks);
    float f2 = abstractclientplayer.prevRotationPitch + (abstractclientplayer.rotationPitch - abstractclientplayer.prevRotationPitch) * partialTicks;
    float f3 = abstractclientplayer.prevRotationYaw + (abstractclientplayer.rotationYaw - abstractclientplayer.prevRotationYaw) * partialTicks;
    this.rotateArroundXAndY(f2, f3);
    this.setLightMapFromPlayer(abstractclientplayer);
    this.rotateWithPlayerRotations((EntityPlayerSP) abstractclientplayer, partialTicks);
    GlStateManager.enableRescaleNormal();
    GlStateManager.pushMatrix();

    if(this.itemToRender != null) {
        final KillAura killAura = (KillAura) LiquidBounce.moduleManager.getModule(KillAura.class);

        if(this.itemToRender.getItem() instanceof net.minecraft.item.ItemMap) {
            this.renderItemMap(abstractclientplayer, f2, f, f1);
        } else if (abstractclientplayer.getItemInUseCount() > 0 || (itemToRender.getItem() instanceof ItemSword && killAura.getBlockingStatus())) {
            EnumAction enumaction = killAura.getBlockingStatus() ? EnumAction.BLOCK : this.itemToRender.getItemUseAction();

            switch(enumaction) {
                case NONE:
                    this.transformFirstPersonItem(f, 0.0F);
                    break;
                case EAT:
                case DRINK:
                    this.performDrinking(abstractclientplayer, partialTicks);
                    this.transformFirstPersonItem(f, f1);
                    break;
                case BLOCK:
                    this.transformFirstPersonItem(f + 0.1F, f1);
                    this.doBlockTransformations();
                    GlStateManager.translate(-0.5F, 0.2F, 0.0F);
                    break;
                case BOW:
                    this.transformFirstPersonItem(f, f1);
                    this.doBowTransformations(partialTicks, abstractclientplayer);
            }
        }else{
            if (!LiquidBounce.moduleManager.getModule(SwingAnimation.class).getState())
                this.doItemUsedTransformations(f1);
            this.transformFirstPersonItem(f, f1);
        }

        this.renderItem(abstractclientplayer, this.itemToRender, ItemCameraTransforms.TransformType.FIRST_PERSON);
    }else if(!abstractclientplayer.isInvisible()) {
        this.renderPlayerArm(abstractclientplayer, f, f1);
    }

    GlStateManager.popMatrix();
    GlStateManager.disableRescaleNormal();
    RenderHelper.disableStandardItemLighting();
}
 
Example 17
Source File: GuiDownloadTofuTerrain.java    From TofuCraftReload with MIT License 4 votes vote down vote up
private void drawPanorama(float ticks) {
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    GlStateManager.matrixMode(GL11.GL_PROJECTION);
    GlStateManager.pushMatrix();
    GlStateManager.loadIdentity();
    Project.gluPerspective(120.0F, 1.0F, 0.05F, 10.0F);
    GlStateManager.matrixMode(GL11.GL_MODELVIEW);
    GlStateManager.pushMatrix();
    GlStateManager.loadIdentity();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
    GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F);
    GlStateManager.enableBlend();
    GlStateManager.disableAlpha();
    GlStateManager.disableCull();
    GlStateManager.depthMask(false);
    GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
    byte b0 = 8;

    for (int k = 0; k < b0 * b0; ++k) {
        GlStateManager.pushMatrix();
        float f1 = ((float) (k % b0) / (float) b0 - 0.5F) / 64.0F;
        float f2 = ((float) (k / b0) / (float) b0 - 0.5F) / 64.0F;
        float f3 = 0.0F;
        GlStateManager.translate(f1, f2, f3);
        GlStateManager.rotate(MathHelper.sin((panoramaTimer + ticks) / 400.0F) * 15.0F + 10.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.rotate(-(panoramaTimer + ticks) * 0.08F, 0.0F, 1.0F, 0.0F);

        for (int l = 0; l < 6; ++l) {
            GlStateManager.pushMatrix();

            switch (l) {
                case 1:
                    GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
                    break;
                case 2:
                    GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
                    break;
                case 3:
                    GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F);
                    break;
                case 4:
                    GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
                    break;
                case 5:
                    GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F);
                    break;
            }

            mc.getTextureManager().bindTexture(getPanoramaPaths().getPath(l));
            buffer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
            int i = 255 / (k + 1);
            buffer.pos(-1.0D, -1.0D, 1.0D).tex(0.0D, 0.0D).color(255, 255, 255, i).endVertex();
            buffer.pos(1.0D, -1.0D, 1.0D).tex(1.0D, 0.0D).color(255, 255, 255, i).endVertex();
            buffer.pos(1.0D, 1.0D, 1.0D).tex(1.0D, 1.0D).color(255, 255, 255, i).endVertex();
            buffer.pos(-1.0D, 1.0D, 1.0D).tex(0.0D, 1.0D).color(255, 255, 255, i).endVertex();
            tessellator.draw();
            GlStateManager.popMatrix();
        }

        GlStateManager.popMatrix();
        GlStateManager.colorMask(true, true, true, false);
    }

    buffer.setTranslation(0.0D, 0.0D, 0.0D);
    GlStateManager.colorMask(true, true, true, true);
    GlStateManager.matrixMode(GL11.GL_PROJECTION);
    GlStateManager.popMatrix();
    GlStateManager.matrixMode(GL11.GL_MODELVIEW);
    GlStateManager.popMatrix();
    GlStateManager.depthMask(true);
    GlStateManager.enableCull();
    GlStateManager.enableDepth();
}
 
Example 18
Source File: RenderCrucible.java    From ExNihiloAdscensio with MIT License 4 votes vote down vote up
@Override
public void renderTileEntityAt(TileCrucible te, double x, double y, double z,
		float partialTicks, int destroyStage) 
{
	Tessellator tes = Tessellator.getInstance();
	VertexBuffer wr = tes.getBuffer();

	RenderHelper.disableStandardItemLighting();
	GlStateManager.pushMatrix();
	GlStateManager.translate(x, y, z);
	SpriteColor sprite = te.getSpriteAndColor();
	if (sprite != null)
	{
		TextureAtlasSprite icon = sprite.getSprite();
		double minU = (double) icon.getMinU();
		double maxU = (double) icon.getMaxU();
		double minV = (double) icon.getMinV();
		double maxV = (double) icon.getMaxV();
		
		// determine the tint for the fluid/block
		Color color = sprite.getColor();

		this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);

		wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR_NORMAL);
		//wr.begin(GL11.GL_QUADS, new VertexFormat().addElement(DefaultVertexFormats.POSITION_3F).addElement(DefaultVertexFormats.COLOR_4UB).addElement(DefaultVertexFormats.NORMAL_3B));
		// Offset by bottome of crucible, which is 4 pixels above the base of the block
		float fillAmount = (12F / 16F) * te.getFilledAmount() + (4F / 16F);
		
		wr.pos(0.125F, fillAmount, 0.125F).tex(minU, minV).color(color.r, color.g, color.b, color.a).normal(0, 1, 0).endVertex();
		wr.pos(0.125F, fillAmount, 0.875F).tex(minU, maxV).color(color.r, color.g, color.b, color.a).normal(0, 1, 0).endVertex();
		wr.pos(0.875F, fillAmount, 0.875F).tex(maxU, maxV).color(color.r, color.g, color.b, color.a).normal(0, 1, 0).endVertex();
		wr.pos(0.875F, fillAmount, 0.125F).tex(maxU, minV).color(color.r, color.g, color.b, color.a).normal(0, 1, 0).endVertex();

		tes.draw();
	}

	GlStateManager.disableBlend();
	GlStateManager.enableLighting();
	GlStateManager.popMatrix();
	RenderHelper.enableStandardItemLighting();

}
 
Example 19
Source File: RendererBackpack.java    From WearableBackpacks with MIT License 4 votes vote down vote up
public void doRenderLayer(EntityLivingBase entity, float limbSwing, float limbSwingAmount,
                          float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
	
	IBackpack backpack;
	RenderOptions renderOptions;
	if (_overrideBackpack != null) {
		backpack = _overrideBackpack;
		renderOptions = _overrideRenderOptions;
	} else {
		backpack = BackpackHelper.getBackpack(entity);
		BackpackEntityEntry entry = BackpackRegistry.getEntityEntry(entity.getClass());
		renderOptions = (entry != null) ? entry.renderOptions : null;
	}
	if ((backpack == null) || (renderOptions == null)) return;
	
	GlStateManager.pushMatrix();
	
	if (entity.isChild()) {
		GlStateManager.scale(0.5F, 0.5F, 0.5F);
		GlStateManager.translate(0.0F, 24.0F * scale, 0.0F);
	}
	
	ModelBase modelBase = this.livingEntityRenderer.getMainModel();
	if (modelBase instanceof ModelBiped) {
		ModelRenderer bipedBody = ((ModelBiped) modelBase).bipedBody;
		
		if (entity.isSneaking()) {
			// FIXME: Can be sneaking while flying with the elytra, then backpack is misaligned..?
			GlStateManager.translate(0.0F, 0.2F, 0.0F);
		}
		
		bipedBody.postRender(scale);
	} else {
		// Fallback to the custom way of transforming the backpack.
		// Make backpack swing with body as players swing their arms.
		float swingProgress = entity.getSwingProgress(partialTicks);
		float swingAngle = MathHelper.sin(MathHelper.sqrt(swingProgress) * ((float)Math.PI * 2.0F)) * 0.2F;
		if ((entity.swingingHand == EnumHand.OFF_HAND) ^
		    (entity.getPrimaryHand() == EnumHandSide.LEFT)) swingAngle *= -1;
		if (swingAngle != 0) GlStateManager.rotate((float)Math.toDegrees(swingAngle), 0.0F, 1.0F, 0.0F);
		
		// Rotate backpack if entity is sneaking.
		if (entity.isSneaking()) {
			// FIXME: Can be sneaking while flying with the elytra, then backpack is misaligned..?
			GlStateManager.translate(0.0F, 0.2F, 0.0F);
			GlStateManager.rotate(90.0F / (float)Math.PI, 1.0F, 0.0F, 0.0F);
		}
	}
	
	GlStateManager.scale(renderOptions.scale, renderOptions.scale, renderOptions.scale);
	GlStateManager.translate(8.0F * scale, renderOptions.y * scale, renderOptions.z * scale);
	GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
	GlStateManager.rotate((float)renderOptions.rotate, 1.0F, 0.0F, 0.0F);
	GlStateManager.translate(0, ProxyClient.MODEL_BACKPACK_BOX.maxY * scale * -16,
	                            ProxyClient.MODEL_BACKPACK_BOX.minZ * scale * -16);
	
	renderBackpack(backpack, entity.ticksExisted + partialTicks, false);
	
	GlStateManager.popMatrix();
	
}
 
Example 20
Source File: RenderUtils.java    From LiquidBounce with GNU General Public License v3.0 2 votes vote down vote up
public static void draw2D(final BlockPos blockPos, final int color, final int backgroundColor) {
    final RenderManager renderManager = mc.getRenderManager();

    final double posX = (blockPos.getX() + 0.5) - renderManager.renderPosX;
    final double posY = blockPos.getY() - renderManager.renderPosY;
    final double posZ = (blockPos.getZ() + 0.5) - renderManager.renderPosZ;

    GlStateManager.pushMatrix();
    GlStateManager.translate(posX, posY, posZ);
    GlStateManager.rotate(-mc.getRenderManager().playerViewY, 0F, 1F, 0F);
    GlStateManager.scale(-0.1D, -0.1D, 0.1D);

    glDisable(GL_DEPTH_TEST);
    glEnable(GL_BLEND);
    glDisable(GL_TEXTURE_2D);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    GlStateManager.depthMask(true);

    glColor(color);

    glCallList(DISPLAY_LISTS_2D[0]);

    glColor(backgroundColor);

    glCallList(DISPLAY_LISTS_2D[1]);

    GlStateManager.translate(0, 9, 0);

    glColor(color);

    glCallList(DISPLAY_LISTS_2D[2]);

    glColor(backgroundColor);

    glCallList(DISPLAY_LISTS_2D[3]);

    // Stop render
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_TEXTURE_2D);
    glDisable(GL_BLEND);

    GlStateManager.popMatrix();
}