net.minecraft.client.renderer.EntityRenderer Java Examples

The following examples show how to use net.minecraft.client.renderer.EntityRenderer. 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: FacadeRenderer.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static List<CCQuad> applyItemTint(List<CCQuad> quads, ItemStack stack) {
    List<CCQuad> retQuads = new LinkedList<>();
    for (CCQuad quad : quads) {
        int colour = -1;

        if (quad.hasTint()) {
            colour = Minecraft.getMinecraft().getItemColors().colorMultiplier(stack, quad.tintIndex);

            if (EntityRenderer.anaglyphEnable) {
                colour = TextureUtil.anaglyphColor(colour);
            }
            colour = colour | 0xFF000000;
        }
        CCQuad copyQuad = quad.copy();

        Colour c = new ColourARGB(colour);
        for (Colour qC : copyQuad.colours) {
            qC.multiply(c);
        }
        retQuads.add(copyQuad);
    }

    return retQuads;
}
 
Example #2
Source File: HeavyChainRenderer.java    From GardenCollection with MIT License 6 votes vote down vote up
private void renderCrossedSquares (RenderBlocks renderer, Block block, int x, int y, int z)
{
    Tessellator tessellator = Tessellator.instance;
    tessellator.setBrightness(block.getMixedBrightnessForBlock(renderer.blockAccess, x, y, z));
    int l = block.colorMultiplier(renderer.blockAccess, x, y, z);
    float f = (float)(l >> 16 & 255) / 255.0F;
    float f1 = (float)(l >> 8 & 255) / 255.0F;
    float f2 = (float)(l & 255) / 255.0F;

    if (EntityRenderer.anaglyphEnable)
    {
        float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F;
        float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F;
        float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F;
        f = f3;
        f1 = f4;
        f2 = f5;
    }

    tessellator.setColorOpaque_F(f, f1, f2);

    IIcon iicon = renderer.getBlockIconFromSideAndMetadata(block, 0, renderer.blockAccess.getBlockMetadata(x, y, z));
    drawCrossedSquares(renderer, iicon, x, y, z, 1.0F);
}
 
Example #3
Source File: RenderHelper.java    From GardenCollection with MIT License 6 votes vote down vote up
public static void calculateBaseColor (float[] target, int color) {
    float r = (float)(color >> 16 & 255) / 255f;
    float g = (float)(color >> 8 & 255) / 255f;
    float b = (float)(color & 255) / 255f;

    if (EntityRenderer.anaglyphEnable) {
        float gray = (r * 30f + g * 59f + b * 11f) / 100f;
        float rg = (r * 30f + g * 70f) / 100f;
        float rb = (r * 30f + b * 70f) / 100f;

        r = gray;
        g = rg;
        b = rb;
    }

    target[0] = r;
    target[1] = g;
    target[2] = b;
}
 
Example #4
Source File: BlockExtendedNodeJarRenderer.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
private int setBrightness(IBlockAccess blockAccess, int i, int j, int k, Block block) {
    Tessellator tessellator = Tessellator.instance;
    int mb = block.getMixedBrightnessForBlock(blockAccess, i, j, k);
    tessellator.setBrightness(mb);

    float f = 1.0F;

    int l = block.colorMultiplier(blockAccess, i, j, k);
    float f1 = (l >> 16 & 0xFF) / 255.0F;
    float f2 = (l >> 8 & 0xFF) / 255.0F;
    float f3 = (l & 0xFF) / 255.0F;
    if (EntityRenderer.anaglyphEnable) {
        float f6 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F;
        float f4 = (f1 * 30.0F + f2 * 70.0F) / 100.0F;
        float f7 = (f1 * 30.0F + f3 * 70.0F) / 100.0F;
        f1 = f6;
        f2 = f4;
        f3 = f7;
    }
    tessellator.setColorOpaque_F(f * f1, f * f2, f * f3);
    return mb;
}
 
Example #5
Source File: EssentialsMissingHandlerClient.java    From Cyberware with MIT License 6 votes vote down vote up
@SubscribeEvent
public void handleRenderHand(RenderHandEvent event)
{
	if (CyberwareConfig.RENDER && !(FMLClientHandler.instance().hasOptifine()) && (missingArm || missingSecondArm || hasRoboLeft || hasRoboRight))
	{
		float partialTicks = event.getPartialTicks();
		EntityRenderer er = mc.entityRenderer;
		event.setCanceled(true);
		
		
		boolean flag = mc.getRenderViewEntity() instanceof EntityLivingBase && ((EntityLivingBase)mc.getRenderViewEntity()).isPlayerSleeping();

		if (mc.gameSettings.thirdPersonView == 0 && !flag && !mc.gameSettings.hideGUI && !mc.playerController.isSpectator())
		{
			er.enableLightmap();
			renderItemInFirstPerson(partialTicks);
			er.disableLightmap();
		}
	}
}
 
Example #6
Source File: ItemEspHack.java    From ForgeWurst with GNU General Public License v3.0 6 votes vote down vote up
private void renderBoxes(double partialTicks)
{
	for(EntityItem e : items)
	{
		GL11.glPushMatrix();
		GL11.glTranslated(e.prevPosX + (e.posX - e.prevPosX) * partialTicks,
			e.prevPosY + (e.posY - e.prevPosY) * partialTicks,
			e.prevPosZ + (e.posZ - e.prevPosZ) * partialTicks);
		
		if(style.getSelected().boxes)
			GL11.glCallList(itemBox);
		
		if(names.isChecked())
		{
			ItemStack stack = WItem.getItemStack(e);
			EntityRenderer.drawNameplate(WMinecraft.getFontRenderer(),
				WItem.getStackSize(stack) + "x " + stack.getDisplayName(),
				0, 1, 0, 0, mc.getRenderManager().playerViewY,
				mc.getRenderManager().playerViewX,
				mc.getRenderManager().options.thirdPersonView == 2, false);
			GL11.glDisable(GL11.GL_LIGHTING);
		}
		
		GL11.glPopMatrix();
	}
}
 
Example #7
Source File: PlayerCameraRenderer.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
public PlayerCameraRenderer(Minecraft minecraft, EntityRenderer prevRenderer) {
    super(minecraft, minecraft.getResourceManager());
    this.minecraft = minecraft;

    this.isMarkedForRemoval = false;
    this.isRemoved = false;
    this.prevRenderer = prevRenderer;
}
 
Example #8
Source File: TransformationHelper.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static boolean isForeignTransformed() {
    Minecraft mc = Minecraft.getMinecraft();
    return !mc.renderViewEntity.equals(mc.thePlayer)
            || RegisteredIntegrations.morph.isMorphed()
            || (!mc.entityRenderer.getClass().equals(EntityRenderer.class)
                && !(mc.entityRenderer instanceof PlayerCameraRenderer));
}
 
Example #9
Source File: GardenProxyRenderer.java    From GardenCollection with MIT License 5 votes vote down vote up
private boolean renderCrossedSquares(IBlockAccess world, RenderBlocks renderer, Block block, int x, int y, int z, TileEntityGarden te)
{
    Tessellator tessellator = Tessellator.instance;
    tessellator.setBrightness(block.getMixedBrightnessForBlock(renderer.blockAccess, x, y, z));
    int l = block.colorMultiplier(renderer.blockAccess, x, y, z);
    //if (l == world.getBiomeGenForCoords(x, z).getBiomeGrassColor(x, y, z))
    //    l = ColorizerGrass.getGrassColor(te.getBiomeTemperature(), te.getBiomeHumidity());

    float f = (float)(l >> 16 & 255) / 255.0F;
    float f1 = (float)(l >> 8 & 255) / 255.0F;
    float f2 = (float)(l & 255) / 255.0F;

    if (EntityRenderer.anaglyphEnable)
    {
        float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F;
        float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F;
        float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F;
        f = f3;
        f1 = f4;
        f2 = f5;
    }

    tessellator.setColorOpaque_F(f, f1, f2);
    double d1 = (double)x;
    double d2 = (double)y;
    double d0 = (double)z;
    long i1;

    IIcon iicon = renderer.getBlockIconFromSideAndMetadata(block, 0, renderer.blockAccess.getBlockMetadata(x, y, z));
    renderer.drawCrossedSquares(iicon, d1, d2, d0, 1.0F);
    return true;
}
 
Example #10
Source File: BlockModelRendererSchematic.java    From litematica with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void renderQuadsFlat(IBlockAccess blockAccessIn, IBlockState stateIn, BlockPos posIn, int brightnessIn, boolean ownBrightness, BufferBuilder buffer, List<BakedQuad> list, BitSet bitSet)
{
    Vec3d vec3d = stateIn.getOffset(blockAccessIn, posIn);
    double d0 = (double)posIn.getX() + vec3d.x;
    double d1 = (double)posIn.getY() + vec3d.y;
    double d2 = (double)posIn.getZ() + vec3d.z;
    int i = 0;

    for (int j = list.size(); i < j; ++i)
    {
        BakedQuad bakedquad = list.get(i);

        if (ownBrightness)
        {
            this.fillQuadBounds(stateIn, bakedquad.getVertexData(), bakedquad.getFace(), (float[])null, bitSet);
            BlockPos blockpos = bitSet.get(0) ? posIn.offset(bakedquad.getFace()) : posIn;
            brightnessIn = stateIn.getPackedLightmapCoords(blockAccessIn, blockpos);
        }

        buffer.addVertexData(bakedquad.getVertexData());
        buffer.putBrightness4(brightnessIn, brightnessIn, brightnessIn, brightnessIn);

        if (bakedquad.hasTintIndex())
        {
            int k = this.blockColors.colorMultiplier(stateIn, blockAccessIn, posIn, bakedquad.getTintIndex());

            if (EntityRenderer.anaglyphEnable)
            {
                k = TextureUtil.anaglyphColor(k);
            }

            float f = (float)(k >> 16 & 255) / 255.0F;
            float f1 = (float)(k >> 8 & 255) / 255.0F;
            float f2 = (float)(k & 255) / 255.0F;
            buffer.putColorMultiplier(f, f1, f2, 4);
            buffer.putColorMultiplier(f, f1, f2, 3);
            buffer.putColorMultiplier(f, f1, f2, 2);
            buffer.putColorMultiplier(f, f1, f2, 1);
        }

        buffer.putPosition(d0, d1, d2);
    }
}
 
Example #11
Source File: BlockModelRendererSchematic.java    From litematica with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void renderQuadsSmooth(IBlockAccess blockAccessIn, IBlockState stateIn, BlockPos posIn, BufferBuilder buffer, List<BakedQuad> list, float[] quadBounds, BitSet bitSet, AmbientOcclusionFace aoFace)
{
    Vec3d vec3d = stateIn.getOffset(blockAccessIn, posIn);
    double x = (double)posIn.getX() + vec3d.x;
    double y = (double)posIn.getY() + vec3d.y;
    double z = (double)posIn.getZ() + vec3d.z;
    int i = 0;

    for (int j = list.size(); i < j; ++i)
    {
        BakedQuad bakedquad = list.get(i);
        this.fillQuadBounds(stateIn, bakedquad.getVertexData(), bakedquad.getFace(), quadBounds, bitSet);
        aoFace.updateVertexBrightness(blockAccessIn, stateIn, posIn, bakedquad.getFace(), quadBounds, bitSet);
        buffer.addVertexData(bakedquad.getVertexData());
        buffer.putBrightness4(aoFace.vertexBrightness[0], aoFace.vertexBrightness[1], aoFace.vertexBrightness[2], aoFace.vertexBrightness[3]);

        if (bakedquad.hasTintIndex())
        {
            int k = this.blockColors.colorMultiplier(stateIn, blockAccessIn, posIn, bakedquad.getTintIndex());

            if (EntityRenderer.anaglyphEnable)
            {
                k = TextureUtil.anaglyphColor(k);
            }

            float f = (float)(k >> 16 & 255) / 255.0F;
            float f1 = (float)(k >> 8 & 255) / 255.0F;
            float f2 = (float)(k & 255) / 255.0F;
            buffer.putColorMultiplier(aoFace.vertexColorMultiplier[0] * f, aoFace.vertexColorMultiplier[0] * f1, aoFace.vertexColorMultiplier[0] * f2, 4);
            buffer.putColorMultiplier(aoFace.vertexColorMultiplier[1] * f, aoFace.vertexColorMultiplier[1] * f1, aoFace.vertexColorMultiplier[1] * f2, 3);
            buffer.putColorMultiplier(aoFace.vertexColorMultiplier[2] * f, aoFace.vertexColorMultiplier[2] * f1, aoFace.vertexColorMultiplier[2] * f2, 2);
            buffer.putColorMultiplier(aoFace.vertexColorMultiplier[3] * f, aoFace.vertexColorMultiplier[3] * f1, aoFace.vertexColorMultiplier[3] * f2, 1);
        }
        else
        {
            buffer.putColorMultiplier(aoFace.vertexColorMultiplier[0], aoFace.vertexColorMultiplier[0], aoFace.vertexColorMultiplier[0], 4);
            buffer.putColorMultiplier(aoFace.vertexColorMultiplier[1], aoFace.vertexColorMultiplier[1], aoFace.vertexColorMultiplier[1], 3);
            buffer.putColorMultiplier(aoFace.vertexColorMultiplier[2], aoFace.vertexColorMultiplier[2], aoFace.vertexColorMultiplier[2], 2);
            buffer.putColorMultiplier(aoFace.vertexColorMultiplier[3], aoFace.vertexColorMultiplier[3], aoFace.vertexColorMultiplier[3], 1);
        }

        buffer.putPosition(x, y, z);
    }
}
 
Example #12
Source File: RenderUtils.java    From LookingGlass with GNU General Public License v3.0 4 votes vote down vote up
@SideOnly(Side.CLIENT)
public final static void renderWorldToTexture(float renderTime, int framebuffer, int width, int height) {
	if (framebuffer == 0) return;
	Minecraft mc = Minecraft.getMinecraft();
	if (mc.skipRenderWorld) return;
	EntityRenderer entityRenderer = mc.entityRenderer;

	//Backup current render settings
	int heightBackup = mc.displayHeight;
	int widthBackup = mc.displayWidth;

	int thirdPersonBackup = mc.gameSettings.thirdPersonView;
	boolean hideGuiBackup = mc.gameSettings.hideGUI;
	int particleBackup = mc.gameSettings.particleSetting;
	boolean anaglyphBackup = mc.gameSettings.anaglyph;
	int renderDistanceBackup = mc.gameSettings.renderDistanceChunks;
	float FOVbackup = mc.gameSettings.fovSetting;

	//Render world
	try {
		//Set all of the render setting to work on the proxy world
		mc.displayHeight = height;
		mc.displayWidth = width;

		//TODO: params (FOV, Particle setting, renderDistance)
		mc.gameSettings.thirdPersonView = 0;
		mc.gameSettings.hideGUI = true;
		//mc.gameSettings.particleSetting = ;
		mc.gameSettings.anaglyph = false;
		//mc.gameSettings.renderDistanceChunks = ;  
		//mc.gameSettings.fovSetting = ;

		//Set gl options
		GL11.glViewport(0, 0, mc.displayWidth, mc.displayHeight);
		GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
		EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, framebuffer);
		GL11.glClearColor(1.0f, 0.0f, 0.0f, 0.5f);
		GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

		int i1 = mc.gameSettings.limitFramerate;
		if (mc.isFramerateLimitBelowMax()) {
			entityRenderer.renderWorld(renderTime, (1000000000 / i1));
		} else {
			entityRenderer.renderWorld(renderTime, 0L);
		}
	} catch (Exception e) {
		try {
			//Clean up the tessellator, just in case.
			Tessellator.instance.draw();
		} catch (Exception e2) {
			//It might throw an exception, but that just means we didn't need to clean it up (this time)
		}
		throw new RuntimeException("Error while rendering proxy world", e);
	} finally {
		GL11.glEnable(GL11.GL_TEXTURE_2D);
		EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0);

		GL11.glViewport(0, 0, widthBackup, heightBackup);
		GL11.glLoadIdentity();

		mc.gameSettings.thirdPersonView = thirdPersonBackup;
		mc.gameSettings.hideGUI = hideGuiBackup;
		mc.gameSettings.particleSetting = particleBackup;
		mc.gameSettings.anaglyph = anaglyphBackup;
		mc.gameSettings.renderDistanceChunks = renderDistanceBackup;
		mc.gameSettings.fovSetting = FOVbackup;

		mc.displayHeight = heightBackup;
		mc.displayWidth = widthBackup;
	}
}
 
Example #13
Source File: PlayerCameraRenderer.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
public EntityRenderer getPrevRenderer() {
    return prevRenderer;
}
 
Example #14
Source File: TransformationHelper.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static boolean isTransformable() {
    Minecraft mc = Minecraft.getMinecraft();
    return mc.thePlayer.equals(mc.renderViewEntity) && !RegisteredIntegrations.morph.isMorphed()
            && mc.entityRenderer.getClass().equals(EntityRenderer.class)
            && (renderer == null || renderer.isRemoved());
}
 
Example #15
Source File: RendererRoadLine.java    From Chisel-2 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block b, int modelId, RenderBlocks renderer) {
	int meta = world.getBlockMetadata(x, y, z);
	BlockRoadLine block = (BlockRoadLine) b;
	Tessellator tessellator = Tessellator.instance;

	tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));

	float f = 1.0F;
	int i1 = block.colorMultiplier(world, x, y, z);
	float f1 = (i1 >> 16 & 255) / 255.0F;
	float f2 = (i1 >> 8 & 255) / 255.0F;
	float f3 = (i1 & 255) / 255.0F;

	if (EntityRenderer.anaglyphEnable) {
		float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F;
		float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F;
		float f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F;
		f1 = f4;
		f2 = f5;
		f3 = f6;
	}
	tessellator.setColorOpaque_F(f * f1, f * f2, f * f3);

	boolean N = world.getBlock(x, y, z - 1).equals(block) && world.getBlockMetadata(x, y, z - 1) == meta;
	boolean S = world.getBlock(x, y, z + 1).equals(block) && world.getBlockMetadata(x, y, z + 1) == meta;
	boolean W = world.getBlock(x - 1, y, z).equals(block) && world.getBlockMetadata(x - 1, y, z) == meta;
	boolean E = world.getBlock(x + 1, y, z).equals(block) && world.getBlockMetadata(x + 1, y, z) == meta;

	if (!N && !S && !W && !E) {
		renderer.renderStandardBlock(block, x, y, z);
		return true;
	}

	if (N && S) {
		renderer.uvRotateTop = 0;
		renderer.overrideBlockTexture = block.fullLineIcon[meta];
		renderer.renderStandardBlock(block, x, y, z);

	} else {
		if (N) {
			renderer.uvRotateTop = 0;
			renderer.overrideBlockTexture = block.halfLineIcon[meta];
			renderer.renderStandardBlock(block, x, y, z);
		}
		if (S) {
			renderer.uvRotateTop = 3;
			renderer.overrideBlockTexture = block.halfLineIcon[meta];
			renderer.renderStandardBlock(block, x, y, z);
		}

	}

	if (E && W) {
		renderer.uvRotateTop = 1;
		renderer.overrideBlockTexture = block.fullLineIcon[meta];
		renderer.renderStandardBlock(block, x, y, z);
	} else {
		if (E) {
			renderer.uvRotateTop = 1;
			renderer.overrideBlockTexture = block.halfLineIcon[meta];
			renderer.renderStandardBlock(block, x, y, z);
		}
		if (W) {
			renderer.uvRotateTop = 2;
			renderer.overrideBlockTexture = block.halfLineIcon[meta];
			renderer.renderStandardBlock(block, x, y, z);
		}
	}

	renderer.uvRotateTop = 0;
	renderer.overrideBlockTexture = null;
	return true;
}
 
Example #16
Source File: GardenProxyRenderer.java    From GardenCollection with MIT License 4 votes vote down vote up
private boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, BlockGardenProxy block, int modelId, RenderBlocks renderer) {
    TileEntityGarden te = block.getGardenEntity(world, x, y, z);
    BlockGarden garden = block.getGardenBlock(world, x, y, z);
    if (te == null || garden == null)
        return true;

    int section = y - te.yCoord;

    Tessellator tessellator = Tessellator.instance;

    for (int slot : garden.getSlotProfile().getPlantSlots()) {
        Block subBlock = block.getPlantBlockRestricted(te, slot);
        int subBlockData = block.getPlantData(te, slot);
        if (subBlock == null)
            continue;

        block.bindSlot(te.getWorldObj(), x, y, z, te, slot);

        float offsetX = block.getPlantOffsetX(world, x, y, z, slot);
        float offsetY = block.getPlantOffsetY(world, x, y, z, slot);
        float offsetZ = block.getPlantOffsetZ(world, x, y, z, slot);

        AxisAlignedBB[] clippingBounds = garden.getSlotProfile().getClippingBounds(world, x, te.yCoord, z, slot);

        int color = subBlock.colorMultiplier(world, x, y, z);
        if (color == world.getBiomeGenForCoords(x, z).getBiomeGrassColor(x, y, z))
            color = ColorizerGrass.getGrassColor(te.getBiomeTemperature(), te.getBiomeHumidity());

        float r = (color >> 16 & 255) / 255f;
        float g = (color >> 8 & 255) / 255f;
        float b = (color & 255) / 255f;

        if (EntityRenderer.anaglyphEnable) {
            float gray = (r * 30.0F + g * 59.0F + b * 11.0F) / 100.0F;
            float ra = (r * 30.0F + g * 70.0F) / 100.0F;
            float ba = (r * 30.0F + b * 70.0F) / 100.0F;
            r = gray;
            g = ra;
            b = ba;
        }

        tessellator.setColorOpaque_F(r, g, b);
        tessellator.setBrightness(subBlock.getMixedBrightnessForBlock(renderer.blockAccess, x, y, z));

        tessellator.addTranslation(offsetX, offsetY, offsetZ);

        try {
            IPlantRenderer plantRenderer = PlantRegistry.instance().getPlantRenderer(subBlock, subBlockData);
            if (plantRenderer != null) {
                IPlantMetaResolver resolver = PlantRegistry.instance().getPlantMetaResolver(subBlock, subBlockData);
                boolean shouldRender = section == 1;
                if (resolver != null && section <= resolver.getPlantHeight(subBlock, subBlockData))
                    shouldRender = true;

                if (shouldRender)
                    plantRenderer.render(world, x, y, z, renderer, subBlock, subBlockData, section, clippingBounds);
            }
            else
                renderer.renderBlockByRenderType(subBlock, x, y, z);
        }
        catch (Exception e) {
            continue;
        }
        finally {
            block.unbindSlot(te.getWorldObj(), x, y, z, te);
            tessellator.addTranslation(-offsetX, -offsetY, -offsetZ);
        }
    }

    return true;
}
 
Example #17
Source File: GardenProxyRenderer.java    From GardenCollection with MIT License 4 votes vote down vote up
private boolean renderBlockDoublePlant(IBlockAccess world, RenderBlocks renderer, BlockDoublePlant block, int x, int y, int z, TileEntityGarden potData)
{
    Tessellator tessellator = Tessellator.instance;
    tessellator.setBrightness(block.getMixedBrightnessForBlock(renderer.blockAccess, x, y, z));
    int l = block.colorMultiplier(renderer.blockAccess, x, y, z);
    //if (l == world.getBiomeGenForCoords(x, z).getBiomeGrassColor(x, y, z))
    //    l = ColorizerGrass.getGrassColor(potData.getBiomeTemperature(), potData.getBiomeHumidity());

    float f = (float)(l >> 16 & 255) / 255.0F;
    float f1 = (float)(l >> 8 & 255) / 255.0F;
    float f2 = (float)(l & 255) / 255.0F;

    if (EntityRenderer.anaglyphEnable)
    {
        float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F;
        float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F;
        float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F;
        f = f3;
        f1 = f4;
        f2 = f5;
    }

    tessellator.setColorOpaque_F(f, f1, f2);
    long j1 = (long)(x * 3129871) ^ (long)z * 116129781L;
    j1 = j1 * j1 * 42317861L + j1 * 11L;
    double d19 = (double)x;
    double d0 = (double)y;
    double d1 = (double)z;
    //d19 += ((double)((float)(j1 >> 16 & 15L) / 15.0F) - 0.5D) * 0.3D;
    //d1 += ((double)((float)(j1 >> 24 & 15L) / 15.0F) - 0.5D) * 0.3D;
    int i1 = renderer.blockAccess.getBlockMetadata(x, y, z);
    boolean flag = false;
    boolean flag1 = BlockDoublePlant.func_149887_c(i1);
    int k1;

    if (flag1)
    {
        k1 = BlockDoublePlant.func_149890_d(renderer.blockAccess.getBlockMetadata(x, y - 1, z));
    }
    else
    {
        k1 = BlockDoublePlant.func_149890_d(i1);
    }

    IIcon iicon = block.func_149888_a(flag1, k1);
    renderer.drawCrossedSquares(iicon, d19, d0, d1, 1.0F);

    if (flag1 && k1 == 0)
    {
        IIcon iicon1 = block.sunflowerIcons[0];
        double d2 = Math.cos((double)j1 * 0.8D) * Math.PI * 0.1D;
        double d3 = Math.cos(d2);
        double d4 = Math.sin(d2);
        double d5 = (double)iicon1.getMinU();
        double d6 = (double)iicon1.getMinV();
        double d7 = (double)iicon1.getMaxU();
        double d8 = (double)iicon1.getMaxV();
        double d9 = 0.3D;
        double d10 = -0.05D;
        double d11 = 0.5D + 0.3D * d3 - 0.5D * d4;
        double d12 = 0.5D + 0.5D * d3 + 0.3D * d4;
        double d13 = 0.5D + 0.3D * d3 + 0.5D * d4;
        double d14 = 0.5D + -0.5D * d3 + 0.3D * d4;
        double d15 = 0.5D + -0.05D * d3 + 0.5D * d4;
        double d16 = 0.5D + -0.5D * d3 + -0.05D * d4;
        double d17 = 0.5D + -0.05D * d3 - 0.5D * d4;
        double d18 = 0.5D + 0.5D * d3 + -0.05D * d4;
        tessellator.addVertexWithUV(d19 + d15, d0 + 1.0D, d1 + d16, d5, d8);
        tessellator.addVertexWithUV(d19 + d17, d0 + 1.0D, d1 + d18, d7, d8);
        tessellator.addVertexWithUV(d19 + d11, d0 + 0.0D, d1 + d12, d7, d6);
        tessellator.addVertexWithUV(d19 + d13, d0 + 0.0D, d1 + d14, d5, d6);
        IIcon iicon2 = block.sunflowerIcons[1];
        d5 = (double)iicon2.getMinU();
        d6 = (double)iicon2.getMinV();
        d7 = (double)iicon2.getMaxU();
        d8 = (double)iicon2.getMaxV();
        tessellator.addVertexWithUV(d19 + d17, d0 + 1.0D, d1 + d18, d5, d8);
        tessellator.addVertexWithUV(d19 + d15, d0 + 1.0D, d1 + d16, d7, d8);
        tessellator.addVertexWithUV(d19 + d13, d0 + 0.0D, d1 + d14, d7, d6);
        tessellator.addVertexWithUV(d19 + d11, d0 + 0.0D, d1 + d12, d5, d6);
    }

    return true;
}
 
Example #18
Source File: HyperiumEntityRenderer.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
public HyperiumEntityRenderer(EntityRenderer parent) {
    this.parent = parent;
    INSTANCE = this;
}
 
Example #19
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 #20
Source File: BlockRoadLineRenderer.java    From Chisel with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block b, int modelId, RenderBlocks renderer)
{
    int meta = world.getBlockMetadata(x, y, z);
    BlockRoadLine block = (BlockRoadLine) b;
    Tessellator tessellator = Tessellator.instance;

    tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));

    float f = 1.0F;
    int i1 = block.colorMultiplier(world, x, y, z);
    float f1 = (i1 >> 16 & 255) / 255.0F;
    float f2 = (i1 >> 8 & 255) / 255.0F;
    float f3 = (i1 & 255) / 255.0F;

    if(EntityRenderer.anaglyphEnable)
    {
        float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F;
        float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F;
        float f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F;
        f1 = f4;
        f2 = f5;
        f3 = f6;
    }
    tessellator.setColorOpaque_F(f * f1, f * f2, f * f3);

    boolean N = world.getBlock(x, y, z - 1).equals(block);
    boolean S = world.getBlock(x, y, z + 1).equals(block);
    boolean W = world.getBlock(x - 1, y, z).equals(block);
    boolean E = world.getBlock(x + 1, y, z).equals(block);

    if(!N && !S && !W && !E)
    {
        renderer.renderStandardBlock(block, x, y, z);
        return true;
    }

    if(N && S)
    {
        renderer.uvRotateTop = 0;
        renderer.overrideBlockTexture = block.fullLineIcon;
        renderer.renderStandardBlock(block, x, y, z);

    } else
    {
        if(N)
        {
            renderer.uvRotateTop = 0;
            renderer.overrideBlockTexture = block.halfLineIcon;
            renderer.renderStandardBlock(block, x, y, z);
        }
        if(S)
        {
            renderer.uvRotateTop = 3;
            renderer.overrideBlockTexture = block.halfLineIcon;
            renderer.renderStandardBlock(block, x, y, z);
        }

    }

    if(E && W)
    {
        renderer.uvRotateTop = 1;
        renderer.overrideBlockTexture = block.fullLineIcon;
        renderer.renderStandardBlock(block, x, y, z);
    } else
    {
        if(E)
        {
            renderer.uvRotateTop = 1;
            renderer.overrideBlockTexture = block.halfLineIcon;
            renderer.renderStandardBlock(block, x, y, z);
        }
        if(W)
        {
            renderer.uvRotateTop = 2;
            renderer.overrideBlockTexture = block.halfLineIcon;
            renderer.renderStandardBlock(block, x, y, z);
        }
    }

    renderer.uvRotateTop = 0;
    renderer.overrideBlockTexture = null;
    return true;
}
 
Example #21
Source File: RenderFakeBlock.java    From Artifacts with MIT License 4 votes vote down vote up
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
	float f = 0.03125F;
	float xn = 0F;
	float xp = 1F;
	float yn = 0F;
	float yp = 1F;
	float zn = 0F;
	float zp = 1F;
	if(!world.getBlock(x-1, y, z).isOpaqueCube()) {
		if(world.getBlock(x-1, y, z) != block)
			xn = f;
	}
	if(!world.getBlock(x+1, y, z).isOpaqueCube()) {
		if(world.getBlock(x+1, y, z) != block)
			xp = 1F-f;
	}
	if(!world.getBlock(x, y-1, z).isOpaqueCube()) {
		if(world.getBlock(x, y-1, z) != block)
			yn = f;
	}
	if(!world.getBlock(x, y+1, z).isOpaqueCube()) {
		if(world.getBlock(x, y+1, z) != block)
			yp = 1F-f;
	}
	if(!world.getBlock(x, y, z-1).isOpaqueCube()) {
		if(world.getBlock(x, y, z-1) != block)
			zn = f;
	}
	if(!world.getBlock(x, y, z+1).isOpaqueCube()) {
		if(world.getBlock(x, y, z+1) != block)
			zp = 1F-f;
	}
	//block.setBlockBounds(xn, yn, zn, xp, yp, zp);
	renderer.setRenderBounds(xn, yn, zn, xp, yp, zp);
	
	int l = block.colorMultiplier(world, x, y, z);
       float f0 = (float)(l >> 16 & 255) / 255.0F;
       float f1 = (float)(l >> 8 & 255) / 255.0F;
       float f2 = (float)(l & 255) / 255.0F;

       if (EntityRenderer.anaglyphEnable)
       {
           float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F;
           float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F;
           float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F;
           f0 = f3;
           f1 = f4;
           f2 = f5;
       }
       
       //if() {
       /*f0 *= 1.5;
       f1 *= 1.5;
       f2 *= 1.5;*/
       //}

       return renderer.renderStandardBlockWithColorMultiplier(block, x, y, z, f0, f1, f2);
}