net.minecraft.client.renderer.texture.TextureMap Java Examples

The following examples show how to use net.minecraft.client.renderer.texture.TextureMap. 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: GuiSelectableButton.java    From BigReactors with MIT License 6 votes vote down vote up
@Override
public void drawButton(Minecraft minecraft, int par2, int par3) {
       if (this.visible)
       {
           minecraft.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
           this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;
           
           int k = this.getHoverState(this.field_146123_n);
           int borderColor = this.selected ? this.selectedColor : 0xFF000000;
           int bgColor = 0xFF565656; // disabled
           if(k == 1) {
           	bgColor = 0xFF999999; // enabled
           }
           else if(k == 2) {
           	bgColor = 0xFF9999CC; // hovered
           	borderColor = this.selected ? this.selectedColor : 0xFF5555AA;
           }

       	this.drawRect(this.xPosition, this.yPosition, this.xPosition+this.width, this.yPosition+this.height, borderColor);
       	this.drawRect(this.xPosition+1, this.yPosition+1, this.xPosition+this.width-1, this.yPosition+this.height-1, bgColor);
           GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
           this.drawTexturedModelRectFromIcon(this.xPosition+1, this.yPosition+1, this.icon, this.width-2, this.height-2);
           
           this.mouseDragged(minecraft, par2, par3);
       }
}
 
Example #2
Source File: GuiFluidKineticGenerator.java    From Production-Line with MIT License 6 votes vote down vote up
@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
    super.drawGuiContainerBackgroundLayer(f, x, y);
    TileFluidKineticGenerator tile = this.container.getTileEntity();

    if (tile.active) {
        this.mc.renderEngine.bindTexture(this.getResource());
        this.drawTexturedModalRect(this.x + 51, this.y + 55, 176, 0, 14, 14);
    }

    if (tile.fluidTank.getFluidAmount() > 0) {
        ResourceLocation fluidIconIdent = this.container.tile.fluidTank.getFluid().getFluid().getStill();
        TextureAtlasSprite icon = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(fluidIconIdent.toString());
        if (icon != null) {
            this.mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
            int fy = PLUtil.getGuiScaled(47, tile.fluidTank.getFluidAmount(), tile.fluidTank.getCapacity());
            this.drawTexturedModalRect(this.x + 74, this.y + 24 + 47 - fy, icon, 12, fy);
            this.mc.renderEngine.bindTexture(this.getResource());
            this.drawTexturedModalRect(this.x + 74, this.y + 24, 176, 72, 12, 47);
        }
    }
}
 
Example #3
Source File: BlockExtendedNodeJarRenderer.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
    GL11.glPushMatrix();
    GL11.glEnable(3042);
    GL11.glBlendFunc(770, 771);
    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
    IIcon i1 = ((BlockJar) ConfigBlocks.blockJar).iconJarTop;
    IIcon i2 = ((BlockJar) ConfigBlocks.blockJar).iconJarSide;
    block.setBlockBounds(W3, 0.0F, W3, W13, W12, W13);
    renderer.setRenderBoundsFromBlock(block);
    drawFaces(renderer, block, ((BlockJar) ConfigBlocks.blockJar).iconJarBottom, i1, i2, i2, i2, i2, true);
    block.setBlockBounds(W5, W12, W5, W11, W14, W11);
    renderer.setRenderBoundsFromBlock(block);
    drawFaces(renderer, block, ((BlockJar) ConfigBlocks.blockJar).iconJarBottom, i1, i2, i2, i2, i2, true);
    GL11.glPopMatrix();
}
 
Example #4
Source File: GuiComponentItemStackSpinner.java    From OpenModsLib with MIT License 6 votes vote down vote up
private void renderItem(ItemStack itemStack) {
	parent.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);

	final RenderItem itemRenderer = parent.getItemRenderer();
	final ItemModelMesher itemModelMesher = itemRenderer.getItemModelMesher();
	final IBakedModel model = itemModelMesher.getItemModel(stack);

	GlStateManager.disableLighting();
	GlStateManager.enableRescaleNormal();
	GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1F);
	GlStateManager.enableBlend();
	GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
	GlStateManager.pushMatrix();
	itemRenderer.renderItem(stack, model);
	GlStateManager.cullFace(CullFace.BACK);
	GlStateManager.popMatrix();
	GlStateManager.disableRescaleNormal();
	GlStateManager.disableBlend();

	GlStateManager.enableLighting();
}
 
Example #5
Source File: FWTileRenderer.java    From NOVA-Core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float p_180535_8_, int p_180535_9_) {
	Block block = ((FWTile) te).getBlock();
	Optional<DynamicRenderer> opRenderer = block.components.getOp(DynamicRenderer.class);
	if (opRenderer.isPresent()) {
		BWModel model = new BWModel();
		model.matrix.translate(x + 0.5, y + 0.5, z + 0.5);
		opRenderer.get().onRender.accept(model);
		bindTexture(TextureMap.locationBlocksTexture);
		RenderUtility.enableBlending();
		Tessellator.getInstance().getWorldRenderer().startDrawingQuads();
		model.render();
		Tessellator.getInstance().draw();
		RenderUtility.disableBlending();
	}
}
 
Example #6
Source File: FWTileRenderer.java    From NOVA-Core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void renderTileEntityAt(FWTile te, double x, double y, double z, float partialTicks, int destroyStage) {
	Block block = te.getBlock();
	Optional<DynamicRenderer> opRenderer = block.components.getOp(DynamicRenderer.class);
	if (opRenderer.isPresent()) {
		BWModel model = new BWModel();
		model.matrix.translate(x + 0.5, y + 0.5, z + 0.5);
		opRenderer.get().onRender.accept(model);
		bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
		RenderUtility.enableBlending();
		Tessellator.getInstance().getBuffer().begin(GL_QUADS, DefaultVertexFormats.BLOCK);
		model.render(te.getWorld());
		Tessellator.getInstance().draw();
		RenderUtility.disableBlending();
	}
}
 
Example #7
Source File: RemoteTexManager.java    From WirelessRedstone with MIT License 6 votes vote down vote up
public static void load(TextureMap registrar)
{
    for(int i = 0; i < icons.length; i++)
        icons[i] = TextureUtils.getTextureSpecial(registrar, "wrcbe_addons:remote_"+i);
    
    texOn = TextureUtils.loadTextureColours(new ResourceLocation("wrcbe_addons", "textures/items/remoteOn.png"));
    texOff = TextureUtils.loadTextureColours(new ResourceLocation("wrcbe_addons", "textures/items/remoteOff.png"));
    texGrad = TextureUtils.loadTextureColours(new ResourceLocation("wrcbe_addons", "textures/items/remoteGrad.png"));

    for(int i = 0; i < RedstoneEther.numcolours; i++)
    {
        processTexture(RedstoneEther.colours[i], false, getIconIndex(i, false));
        processTexture(RedstoneEther.colours[i], true, getIconIndex(i, true));
    }
    processTexture(0xFFFFFFFF, false, getIconIndex(-1, false));
    processTexture(0xFFFFFFFF, true, getIconIndex(-1, true));
}
 
Example #8
Source File: FluidStackRenderer.java    From YouTubeModdingTutorial with MIT License 6 votes vote down vote up
public static boolean renderFluidStack(FluidStack fluidStack, int x, int y) {
    Fluid fluid = fluidStack.getFluid();
    if (fluid == null) {
        return false;
    }

    Minecraft mc = Minecraft.getMinecraft();
    TextureMap textureMapBlocks = mc.getTextureMapBlocks();
    ResourceLocation fluidStill = fluid.getStill();
    TextureAtlasSprite fluidStillSprite = null;
    if (fluidStill != null) {
        fluidStillSprite = textureMapBlocks.getTextureExtry(fluidStill.toString());
    }
    if (fluidStillSprite == null) {
        fluidStillSprite = textureMapBlocks.getMissingSprite();
    }

    int fluidColor = fluid.getColor(fluidStack);
    mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    setGLColorFromInt(fluidColor);
    drawFluidTexture(x, y, fluidStillSprite);

    return true;
}
 
Example #9
Source File: GuiIconButton.java    From BigReactors with MIT License 6 votes vote down vote up
/**
 * Draws this button to the screen.
 */
public void drawButton(Minecraft par1Minecraft, int par2, int par3)
{
    if (this.visible)
    {
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

        // Draw the border
        this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;
        int k = this.getHoverState(this.field_146123_n);
        int borderColor = k == 2 ? 0xFF5555AA : 0xFF000000;
    	drawRect(this.xPosition, this.yPosition, this.xPosition + this.width, this.yPosition + this.height, borderColor);
        
        this.mouseDragged(par1Minecraft, par2, par3);

        // Draw the icon
        if(this.icon != null) {
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            par1Minecraft.renderEngine.bindTexture(TextureMap.locationBlocksTexture);
        	this.drawTexturedModelRectFromIcon(this.xPosition + 1, this.yPosition + 1, this.icon, this.width-2, this.height-2);
        }
    }
}
 
Example #10
Source File: MetaTileEntityTESR.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void renderTileEntityFastPart(MetaTileEntityHolder te, double x, double y, double z, float partialTicks, int destroyStage) {
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    RenderHelper.disableStandardItemLighting();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.enableBlend();
    GlStateManager.disableCull();

    if (Minecraft.isAmbientOcclusionEnabled()) {
        GlStateManager.shadeModel(GL11.GL_SMOOTH);
    }
    else {
        GlStateManager.shadeModel(GL11.GL_FLAT);
    }
    buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);

    renderTileEntityFast(te, x, y, z, partialTicks, destroyStage, partialTicks, buffer);
    buffer.setTranslation(0, 0, 0);
    tessellator.draw();

    RenderHelper.enableStandardItemLighting();
}
 
Example #11
Source File: BeefGuiGrabTarget.java    From BigReactors with MIT License 6 votes vote down vote up
@Override
public void drawForeground(TextureManager renderEngine, int mouseX, int mouseY) {
	if(grabbable != null) {
		renderEngine.bindTexture(TextureMap.locationBlocksTexture);
		GL11.glColor4f(1f, 1f, 1f, 1f);
		this.guiContainer.drawTexturedModelRectFromIcon(relativeX, relativeY, grabbable.getIcon(), width, height);
	}
	
	if(this.isMouseOver(mouseX, mouseY)) {
		if(this.guiContainer.getGrabbedItem() != null && isAcceptedGrab(this.guiContainer.getGrabbedItem())) {
			this.drawRect(this.relativeX, this.relativeY, this.relativeX+this.width, this.relativeY+this.height, invalidHoverColor);
		}
		else {
			this.drawRect(this.relativeX, this.relativeY, this.relativeX+this.width, this.relativeY+this.height, hoverColor);
		}
	}
}
 
Example #12
Source File: DrawableAtlas.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void draw(@Nonnull Minecraft minecraft, int xOffset, int yOffset) {
	minecraft.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);

	float uMin = sprite.getMinU();
	float uMax = sprite.getMaxU();
	float vMin = sprite.getMinV();
	float vMax = sprite.getMaxV();

	Tessellator tessellator = Tessellator.getInstance();
	BufferBuilder bufferBuilder = tessellator.getBuffer();
	bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
	bufferBuilder.pos(xOffset, yOffset + 16, 0).tex(uMin, vMax).endVertex();
	bufferBuilder.pos(xOffset + getWidth(), yOffset + 16, 0).tex(uMax, vMax).endVertex();
	bufferBuilder.pos(xOffset + getWidth(), yOffset, 0).tex(uMax, vMin).endVertex();
	bufferBuilder.pos(xOffset, yOffset, 0).tex(uMin, vMin).endVertex();
	tessellator.draw();

}
 
Example #13
Source File: BigReactors.java    From BigReactors with MIT License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
public static void registerNonBlockFluidIcons(TextureMap map) {
	iconFuelColumnStill = map.registerIcon(TEXTURE_NAME_PREFIX + "fluid.fuelColumn.still");
	iconFuelColumnFlowing = map.registerIcon(TEXTURE_NAME_PREFIX + "fluid.fuelColumn.flowing");
	
	if(registeredOwnSteam) {
		iconSteamStill = map.registerIcon(TEXTURE_NAME_PREFIX + "fluid.steam.still");
		iconSteamFlowing = map.registerIcon(TEXTURE_NAME_PREFIX + "fluid.steam.flowing");
	}
}
 
Example #14
Source File: WidgetFluidTank.java    From ExtraCells1 with MIT License 5 votes vote down vote up
public void draw(int guiX, int guiY, int mouseX, int mouseY)
{
	if (tank == null || 73 < 31)
		return;

	GL11.glDisable(GL11.GL_LIGHTING);
	GL11.glColor3f(1.0F, 1.0F, 1.0F);

	Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("extracells", "textures/gui/fluidtank.png"));
	drawTexturedModalRect(posX, posY, 0, 0, 18, 73);

	int iconHeightRemainder = (73 - 4) % 16;

	FluidStack fluid = tank.getFluid();
	if (fluid != null && fluid.amount > 0)
	{
		Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);

		Icon fluidIcon = fluid.getFluid().getStillIcon();

		if (iconHeightRemainder > 0)
		{
			drawTexturedModelRectFromIcon(posX + 1, posY + 2, fluidIcon, 16, iconHeightRemainder);
		}
		for (int i = 0; i < (73 - 6) / 16; i++)
		{
			drawTexturedModelRectFromIcon(posX + 1, posY + 2 + i * 16 + iconHeightRemainder, fluidIcon, 16, 16);
		}

		Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("extracells", "textures/gui/fluidtank.png"));
		drawTexturedModalRect(posX + 2, posY + 1, 1, 1, 15, 72 - ((int) ((73) * ((float) fluid.amount / tank.getCapacity()))));
	}

	Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("extracells", "textures/gui/fluidtank.png"));
	drawTexturedModalRect(posX + 1, posY + 1, 19, 1, 16, 73);

	GL11.glEnable(GL11.GL_LIGHTING);
}
 
Example #15
Source File: BeefIconManager.java    From BigReactors with MIT License 5 votes vote down vote up
public void registerIcons(TextureMap textureMap) {
	if(iconNames == null) { return; }

	for(int i = 0; i < iconNames.length; i++) {
		nameToIdMap.put(iconNames[i], i);
		idToIconMap.put(i, textureMap.registerIcon(BigReactors.TEXTURE_NAME_PREFIX + getPath() + iconNames[i]));
	}
}
 
Example #16
Source File: RenderFrame.java    From Framez with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {

    boolean blend = GL11.glGetBoolean(GL11.GL_BLEND);
    boolean alpha = GL11.glGetBoolean(GL11.GL_ALPHA_TEST);

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_ALPHA_TEST);

    GL11.glPushMatrix();
    {
        if (type == ItemRenderType.INVENTORY)
            GL11.glTranslated(0, -0.0625, 0);
        if (type == ItemRenderType.ENTITY) {
            GL11.glScaled(0.5, 0.5, 0.5);
            GL11.glTranslated(-0.5, -0.45, -0.5);
        }

        Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
        IFrame f = ((IFrame) ((ItemPartFrame) item.getItem()).newPart(item, Framez.proxy.getPlayer(), Framez.proxy.getWorld(), null, 0,
                null));
        if (f != null)
            f.renderItem(item, type);
    }
    GL11.glPopMatrix();

    if (!blend)
        GL11.glDisable(GL11.GL_BLEND);
    if (!alpha)
        GL11.glDisable(GL11.GL_ALPHA_TEST);

}
 
Example #17
Source File: WidgetFluidSelector.java    From ExtraCells1 with MIT License 5 votes vote down vote up
@Override
public void drawWidget(int posX, int posY)
{
	Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);

	GL11.glDisable(GL11.GL_LIGHTING);
	GL11.glColor3f(1.0F, 1.0F, 1.0F);
	if (fluid != null && fluid.getIcon() != null)
		drawTexturedModelRectFromIcon(posX + 1, posY + 1, fluid.getIcon(), sizeX - 2, sizeY - 2);
	if (selected)
		drawHollowRectWithCorners(posX, posY, sizeX, sizeY, color, borderThickness);
	GL11.glEnable(GL11.GL_LIGHTING);
}
 
Example #18
Source File: RenderUtils.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Reimplement vanilla item so we can draw pearl stacks with opacity support.
 */
private static void renderEffect(IBakedModel model) {
	GlStateManager.depthMask(false);
	GlStateManager.depthFunc(514);
	GlStateManager.disableLighting();
	GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_COLOR, GlStateManager.DestFactor.ONE);
	Minecraft.getMinecraft().getTextureManager().bindTexture(RES_ITEM_GLINT);
	GlStateManager.matrixMode(5890);
	GlStateManager.pushMatrix();
	GlStateManager.scale(8.0F, 8.0F, 8.0F);
	float f = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F / 8.0F;
	GlStateManager.translate(f, 0.0F, 0.0F);
	GlStateManager.rotate(-50.0F, 0.0F, 0.0F, 1.0F);
	renderModel(model, -8372020, ItemStack.EMPTY);
	GlStateManager.popMatrix();
	GlStateManager.pushMatrix();
	GlStateManager.scale(8.0F, 8.0F, 8.0F);
	float f1 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F / 8.0F;
	GlStateManager.translate(-f1, 0.0F, 0.0F);
	GlStateManager.rotate(10.0F, 0.0F, 0.0F, 1.0F);
	renderModel(model, -8372020, ItemStack.EMPTY);
	GlStateManager.popMatrix();
	GlStateManager.matrixMode(5888);
	GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
	GlStateManager.enableLighting();
	GlStateManager.depthFunc(515);
	GlStateManager.depthMask(true);
	Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
	GlStateManager.scale(1 / 8.0F, 1 / 8.0F, 1 / 8.0F);
}
 
Example #19
Source File: SafeRenderer.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(TextureMap textureMap) {
    String formattedBase = GTValues.MODID + ":blocks/" + basePath;
    this.textures = new TextureAtlasSprite[7];
    this.textures[0] = textureMap.registerSprite(new ResourceLocation(formattedBase + "/base_bottom"));
    this.textures[1] = textureMap.registerSprite(new ResourceLocation(formattedBase + "/base_top"));
    this.textures[2] = textureMap.registerSprite(new ResourceLocation(formattedBase + "/base_side"));
    this.textures[3] = textureMap.registerSprite(new ResourceLocation(formattedBase + "/base_front"));

    this.textures[4] = textureMap.registerSprite(new ResourceLocation(formattedBase + "/door_side"));
    this.textures[5] = textureMap.registerSprite(new ResourceLocation(formattedBase + "/door_back"));
    this.textures[6] = textureMap.registerSprite(new ResourceLocation(formattedBase + "/door_front"));
}
 
Example #20
Source File: LayerGnomeHeldBlock.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void doRenderLayer(GnomeType entitylivingbaseIn, float limbSwing,
		float limbSwingAmount, float partialTicks, float ageInTicks,
		float netHeadYaw, float headPitch, float scale)
{
       IBlockState iblockstate = entitylivingbaseIn.getCarried();

       if (iblockstate != null)
       {
           BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
           GlStateManager.enableRescaleNormal();
           GlStateManager.pushMatrix();
           GlStateManager.translate(0.25F, 1.125F, -0.25F);
           //GlStateManager.translate(0.0F, 0.6875F, -0.75F);
           GlStateManager.rotate(20.0F, 1.0F, 0.0F, 0.0F);
           //GlStateManager.rotate(45.0F, 0.0F, 1.0F, 0.0F);
           //GlStateManager.translate(0.25F, 0.1875F, 0.25F);
           GlStateManager.scale(-0.5F, -0.5F, 0.5F);
           int i = entitylivingbaseIn.getBrightnessForRender();
           int j = i % 65536;
           int k = i / 65536;
           OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j, (float)k);
           GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
           this.render.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
           blockrendererdispatcher.renderBlockBrightness(iblockstate, 1.0F);
           GlStateManager.popMatrix();
           GlStateManager.disableRescaleNormal();
       }
}
 
Example #21
Source File: BaseVehicleRender.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void doRender(BaseVehicleEntity entity, double x, double y, double z, float entityYaw, float partialTicks) {
	this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);

	BufferBuilder buf = Tessellator.getInstance().getBuffer();

	GlStateManager.pushMatrix();
	
	buf.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);

	BlockPos offset = entity.getOffset();
	GlStateManager.translate(x - offset.getX(), y - offset.getY(), z - offset.getZ());

	if (entity.getStorage().bufferstate == null || entity.getStorage().updateRequired) {
		for (BlockPos bp : entity.getBlocks().keySet()) {
			if (bp == null)
				continue;
			Minecraft.getMinecraft().getBlockRendererDispatcher().renderBlock(entity.getStorage().getBlockState(bp),
					bp, entity.getStorage(), buf);
		}
		entity.getStorage().bufferstate = buf.getVertexState();
	} else {
		buf.setVertexState(entity.getStorage().bufferstate);
	}

	Tessellator.getInstance().draw(); 

	for (TileEntity t : entity.getStorage().getTESRs()) {
		if (t != null) {
			TileEntityRendererDispatcher.instance.render(t, t.getPos().getX(), t.getPos().getY(), t.getPos().getZ(),
					partialTicks);
		}
	}
	GlStateManager.popMatrix();
}
 
Example #22
Source File: XrayMod.java    From ForgeHax with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onPreRenderBlockLayer(RenderBlockLayerEvent.Pre event) {
  if (!isInternalCall) {
    if (!event.getRenderLayer().equals(BlockRenderLayer.TRANSLUCENT)) {
      event.setCanceled(true);
    } else if (event.getRenderLayer().equals(BlockRenderLayer.TRANSLUCENT)) {
      isInternalCall = true;
      Entity renderEntity = MC.getRenderViewEntity();
      GlStateManager.disableAlpha();
      MC.renderGlobal.renderBlockLayer(
          BlockRenderLayer.SOLID, event.getPartialTicks(), 0, renderEntity);
      GlStateManager.enableAlpha();
      MC.renderGlobal.renderBlockLayer(
          BlockRenderLayer.CUTOUT_MIPPED, event.getPartialTicks(), 0, renderEntity);
      MC.getTextureManager()
          .getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE)
          .setBlurMipmap(false, false);
      MC.renderGlobal.renderBlockLayer(
          BlockRenderLayer.CUTOUT, event.getPartialTicks(), 0, renderEntity);
      MC.getTextureManager()
          .getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE)
          .restoreLastBlurMipmap();
      GlStateManager.disableAlpha();
      isInternalCall = false;
    }
  }
}
 
Example #23
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 #24
Source File: SpriteSheetManager.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerIcons(TextureMap textureMap) {
    if (TextureUtils.refreshTexture(textureMap, resource.getResourcePath())) {
        reloadTexture();
        for (TextureSpecial sprite : sprites)
            if (sprite != null)
                textureMap.setTextureEntry(sprite.getIconName(), sprite);
    } else {
        for (int i : newSprites)
            textureMap.setTextureEntry(sprites[i].getIconName(), sprites[i]);
    }
    newSprites.clear();
}
 
Example #25
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 #26
Source File: TextureUtils.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static TextureSpecial getTextureSpecial(TextureMap textureMap, String name) {
    if (textureMap.getTextureExtry(name) != null)
        throw new IllegalStateException("Texture: " + name + " is already registered");

    TextureSpecial icon = new TextureSpecial(name);
    textureMap.setTextureEntry(name, icon);
    return icon;
}
 
Example #27
Source File: RenderUtils.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * @param stack The fluid stack to render
 * @return The icon of the fluid
 */
public static TextureAtlasSprite prepareFluidRender(FluidStack stack, int alpha) {
    GlStateManager.disableLighting();
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    Fluid fluid = stack.getFluid();
    CCRenderState.setColour(fluid.getColor(stack) << 8 | alpha);
    CCRenderState.changeTexture(TextureMap.locationBlocksTexture);

    String iconName = null;
    if (fluid == FluidRegistry.LAVA) iconName = "minecraft:blocks/lava_still";
    else if (fluid == FluidRegistry.WATER) iconName = "minecraft:blocks/water_still";
    return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(iconName);
}
 
Example #28
Source File: RenderSieve.java    From ExNihiloAdscensio with MIT License 5 votes vote down vote up
@Override
public void renderTileEntityAt(TileSieve te, double x, double y, double z,
		float partialTicks, int destroyStage) 
{
	Tessellator tes = Tessellator.getInstance();
	VertexBuffer wr = tes.getBuffer();

	GlStateManager.pushMatrix();
	GlStateManager.translate(x, y, z);
	if (te.getTexture() != null)
	{
		TextureAtlasSprite icon = te.getTexture();
		double minU = (double) icon.getMinU();
		double maxU = (double) icon.getMaxU();
		double minV = (double) icon.getMinV();
		double maxV = (double) icon.getMaxV();

		this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);

		wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL);
		double height = (100.0-te.getProgress()) / 100;
		float fillAmount = (float) (0.15625*height + 0.84375);
		
		wr.pos(0.0625f,fillAmount,0.0625f).tex(minU, minV).normal(0, 1, 0).endVertex();
		wr.pos(0.0625f,fillAmount,0.9375f).tex(minU,maxV).normal(0, 1, 0).endVertex();
		wr.pos(0.9375f,fillAmount,0.9375f).tex(maxU,maxV).normal(0, 1, 0).endVertex();
		wr.pos(0.9375f,fillAmount,0.0625f).tex(maxU,minV).normal(0, 1, 0).endVertex();

		tes.draw();
	}

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

}
 
Example #29
Source File: RenderEntityThrownItem.java    From Production-Line with MIT License 5 votes vote down vote up
/**
 * Renders the desired {@code T} type Entity.
 */
@Override
public void doRender(T entity, double x, double y, double z, float entityYaw, float partialTicks) {
    GlStateManager.pushMatrix();
    GlStateManager.translate((float) x, (float) y, (float) z);
    GlStateManager.enableRescaleNormal();
    GlStateManager.rotate(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate((float) (this.renderManager.options.thirdPersonView == 2 ? -1 : 1) * this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
    GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
    this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);

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

    this.itemRenderer.renderItem(this.getStackToRender(entity), ItemCameraTransforms.TransformType.GROUND);

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

    GlStateManager.disableRescaleNormal();
    GlStateManager.popMatrix();
    super.doRender(entity, x, y, z, entityYaw, partialTicks);
}
 
Example #30
Source File: TileEntityEndRodRenderer.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTicks) {
	OpenGLHelper.pushMatrix();
	OpenGLHelper.translate(x, y, z);
	OpenGLHelper.colour(0xFFFFFF);
	bindTexture(TextureMap.locationBlocksTexture);

	ForgeDirection dir = ForgeDirection.getOrientation(tile.getBlockMetadata());
	switch (dir) {
		case DOWN:
			OpenGLHelper.rotate(180, 1, 0, 0);
			OpenGLHelper.translate(0, -1, -1);
			break;
		case EAST:
			OpenGLHelper.rotate(270, 0, 0, 1);
			OpenGLHelper.translate(-1, 0, 0);
			break;
		case NORTH:
			OpenGLHelper.rotate(270, 1, 0, 0);
			OpenGLHelper.translate(0, -1, 0);
			break;
		case SOUTH:
			OpenGLHelper.rotate(90, 1, 0, 0);
			OpenGLHelper.translate(0, 0, -1);
			break;
		case WEST:
			OpenGLHelper.rotate(90, 0, 0, 1);
			OpenGLHelper.translate(0, -1, 0);
			break;
		default:
			break;
	}

	renderRod(renderer, tile.getBlockType(), tile.getBlockMetadata());

	OpenGLHelper.popMatrix();
}