private static List<BakedQuad> transformQuads(List<BakedQuad> oldQuads, Set<String> textures) { List<BakedQuad> quads = new ArrayList<>(oldQuads); for (int i = 0; i < quads.size(); ++i) { BakedQuad quad = quads.get(i); if (textures.contains(quad.getSprite().getIconName())) { quads.set(i, transformQuad(quad, 0.007F)); } } return quads; }
private ResourceLocation getResourceLocation(TextureAtlasSprite p_184396_1_) { ResourceLocation resourcelocation = new ResourceLocation(p_184396_1_.getIconName()); return new ResourceLocation(resourcelocation.getNamespace(), String.format("%s/%s%s", this.basePath, resourcelocation.getPath(), ".png")); } }
private ResourceLocation getResourceLocation(TextureAtlasSprite p_184396_1_) { ResourceLocation resourcelocation = new ResourceLocation(p_184396_1_.getIconName()); return new ResourceLocation(resourcelocation.getNamespace(), String.format("%s/%s%s", this.basePath, resourcelocation.getPath(), ".png")); } }
@Override protected ResourceLocation getEntityTexture(EntityChameleonTick tick) { String blockPath = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(tick.blockID.getStateFromMeta(tick.blockMeta)).getIconName(); String modName = "minecraft"; if (blockPath.contains(":")) { modName = blockPath.split(":")[0]; blockPath = blockPath.split(":")[1]; } return new ResourceLocation(modName, "textures/" + blockPath + ".png"); } }
@Override protected ResourceLocation getEntityTexture(EntityAnimatedBlock animatedblock) { String blockPath = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(animatedblock.blockID.getStateFromMeta(animatedblock.blockMeta)).getIconName(); String modName = "minecraft"; if (blockPath.contains(":")) { modName = blockPath.split(":")[0]; blockPath = blockPath.split(":")[1]; } return new ResourceLocation(modName, "textures/" + blockPath + ".png"); } }
private ResourceLocation getResourceLocation(TextureAtlasSprite p_184396_1_) { ResourceLocation resourcelocation = new ResourceLocation(p_184396_1_.getIconName()); return new ResourceLocation(resourcelocation.getResourceDomain(), String.format("%s/%s%s", this.basePath, resourcelocation.getResourcePath(), ".png")); } }
public LimitedTextureAtlasSprite(TextureAtlasSprite parent, Vector4f uv) { super(parent.getIconName()); copyFrom(parent); minU = super.getInterpolatedU(uv.x * 16); maxU = super.getInterpolatedU(uv.z * 16); minV = super.getInterpolatedV(uv.y * 16); maxV = super.getInterpolatedV(uv.w * 16); }
protected IBakedModel handleDisplayStandType(ItemStack displayStandType, boolean axisX, EnumFacing facing) { if (displayStandType != null && !displayStandType.isEmpty()) { // Get reference texture IBlockState blockState = BlockHelpers.getBlockStateFromItemStack(displayStandType); String textureName = Minecraft.getMinecraft().getBlockRendererDispatcher() .getBlockModelShapes().getTexture(blockState).getIconName(); // Retexture our model String cacheName = textureName + axisX + facing.toString(); IBakedModel bakedRetexturedModel = retexturedCache.get(cacheName); if (bakedRetexturedModel == null) { IModel retexturedModel = retexturableModel.retexture(ImmutableMap.of("base", textureName)); IModelState modelState = ROTATIONS.get(facing); // Hack, see DisplayStand#bakeVariantModel, should just be retexturableModel.getDefaultState(); bakedRetexturedModel = retexturedModel.bake(modelState, DefaultVertexFormats.BLOCK, org.cyclops.cyclopscore.helper.RenderHelpers.TEXTURE_GETTER); retexturedCache.put(cacheName, bakedRetexturedModel); } return bakedRetexturedModel; } return untexturedBakedModel; }
for ( final TextureAtlasSprite s : textures.keySet() ) output.append( "\"" ).append( System.identityHashCode( s ) ).append( "\": \"" ).append( s.getIconName() ).append( "\",\n" );
@Override @SideOnly (Side.CLIENT) public void registerModels() { StateMap.Builder stateMap = new StateMap.Builder(); stateMap.ignore(VARIANT); ModelLoader.setCustomStateMapper(this, stateMap.build()); ModelResourceLocation location = new ModelResourceLocation(getRegistryName(), "normal"); for (Type type : Type.values()) { ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(this), type.getMetadata(), location); } ModelRegistryHelper.register(location, new CCBakeryModel()); ModelBakery.registerBlockKeyGenerator(this, state -> { TileDynamoBase dynamo = state.getValue(TEProps.TILE_DYNAMO); StringBuilder builder = new StringBuilder(state.getBlock().getRegistryName() + "|" + state.getBlock().getMetaFromState(state)); builder.append(",creative=").append(dynamo.isCreative); builder.append(",level=").append(dynamo.getLevel()); builder.append(",facing=").append(dynamo.getFacing()); builder.append(",active=").append(dynamo.isActive); builder.append(",coil=").append(dynamo.getCoil()); builder.append(",coil_anim=").append(dynamo.getCoilUnderlayTexture().getIconName()); builder.append(",base_anim=").append(dynamo.getBaseUnderlayTexture().getIconName()); return builder.toString(); }); ModelBakery.registerItemKeyGenerator(itemBlock, stack -> ModelBakery.defaultItemKeyGenerator.generateKey(stack) + ",creative=" + itemBlock.isCreative(stack) + ",level=" + itemBlock.getLevel(stack)); }
/** * Bake a model. * @param model The model to bake. * @param icon The icon to use as default texture. * @param transformation The rotation of the model. * @return The baked model. */ public static IBakedModel bakeModel(ModelBlock model, TextureAtlasSprite icon, ITransformation transformation) { ModelBlock itemModel = MODEL_GENERATOR.makeItemModel(Minecraft.getMinecraft().getTextureMapBlocks(), model); SimpleBakedModel.Builder builder = (new SimpleBakedModel.Builder(itemModel, itemModel.createOverrides())); itemModel.textures.put("layer0", icon.getIconName()); builder.setTexture(icon); for(BlockPart blockPart : itemModel.getElements()) { for(EnumFacing side : blockPart.mapFaces.keySet()) { BlockPartFace blockPartFace = blockPart.mapFaces.get(side); builder.addGeneralQuad(makeBakedQuad(blockPart, blockPartFace, icon, side, transformation, false)); } } return builder.makeBakedModel(); }
if (tile.hasFluidUnderlay() && tile.isActive) { FluidStack stack = tile.getRenderFluid(); builder.append(",fluid=").append(stack != null ? FluidHelper.getFluidHash(stack) : tile.getTexture(tile.getFacing(), 0).getIconName());
public void addSprite(TextureAtlasSprite sprite) { Holder holder = new Holder(sprite, mipmapLevels); if (maxSpriteSize > 0) { holder.setNewDimension(maxSpriteSize); } Slot slot = allocateSlot(holder); if (slot == null) { throw new StitcherException(null, String.format("Unable to fit %s (size %dx%d)", sprite.getIconName(), sprite.getIconWidth(), sprite.getIconHeight())); } sprite.initSprite(BASE_WIDTH, BASE_HEIGHT, slot.getOriginX(), slot.getOriginY(), holder.isRotated()); }
@Override @SideOnly (Side.CLIENT) public void registerModels() { StateMap.Builder stateMap = new StateMap.Builder(); stateMap.ignore(VARIANT); ModelLoader.setCustomStateMapper(this, stateMap.build()); ModelResourceLocation location = new ModelResourceLocation(getRegistryName(), "normal"); for (Type type : Type.values()) { ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(this), type.getMetadata(), location); } ModelRegistryHelper.register(location, new CCBakeryModel()); ModelBakery.registerBlockKeyGenerator(this, state -> { TileDeviceBase tile = state.getValue(TEProps.TILE_DEVICE); StringBuilder builder = new StringBuilder(state.getBlock().getRegistryName().toString() + "|" + state.getBlock().getMetaFromState(state)); builder.append("facing=").append(tile.getFacing()); builder.append(",active=").append(tile.isActive); builder.append(",side_config={"); for (int i : tile.sideCache) { builder.append(",").append(i); } builder.append("}"); if (tile.hasFluidUnderlay() && tile.isActive) { FluidStack stack = tile.getRenderFluid(); builder.append(",fluid=").append(stack != null ? FluidHelper.getFluidHash(stack) : tile.getTexture(tile.getFacing(), 0).getIconName()); } return builder.toString(); }); }
texture = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(blockState).getIconName(); flowerPot.getTileData().setString(TAG_TEXTURE_PATH, texture);
/** * Renders a texture at the specified location * Copy/pasted static version of Gui.func_175175_a() * @param x * @param y * @param item * @param width * @param height */ public static void RenderItemTexture(int x, int y, Item item, int width, int height) { IBakedModel iBakedModel = mc.getRenderItem().getItemModelMesher().getItemModel(new ItemStack(item)); TextureAtlasSprite textureAtlasSprite = mc.getTextureMapBlocks().getAtlasSprite(iBakedModel.getTexture().getIconName()); mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture); RenderTexture(x, y, textureAtlasSprite, width, height, 0); }
bar.step(textureatlassprite1.getIconName()); if (textureatlassprite1 == this.missingImage || this.generateMipmaps(resourceManager, textureatlassprite1)) { String s = textureatlassprite1.getIconName(); map.remove(s); this.mapUploadedSprites.put(s, textureatlassprite1);
@SideOnly(Side.CLIENT) public static void renderItemCurrentGui(ItemStack stack, int x, int y, int dim) { // first get texture from item stack IBakedModel iBakedModel = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(stack); TextureAtlasSprite textureAtlasSprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(iBakedModel.getParticleTexture().getIconName()); Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); if (Minecraft.getMinecraft().currentScreen != null) { Minecraft.getMinecraft().currentScreen.drawTexturedModalRect(x, y, textureAtlasSprite, dim, dim); } } }
/** * @reason Replaces the updateAnimations method to only tick animated textures * that are in one of the loaded RenderChunks. This can lead to an FPS more than * three times higher on large modpacks with many textures. * <p> * Also breaks down the "root.tick.textures" profiler by texture name. */ @Overwrite public void updateAnimations() { // TODO: Recalculate list after chunk update instead! Minecraft.getMinecraft().profiler.startSection("determineVisibleTextures"); for (RenderGlobal.ContainerLocalRenderInformation renderInfo : Minecraft.getMinecraft().renderGlobal.renderInfos) { for (TextureAtlasSprite texture : ((IPatchedCompiledChunk) renderInfo.renderChunk.compiledChunk).getVisibleTextures()) { ((IPatchedTextureAtlasSprite) texture).markNeedsAnimationUpdate(); } } Minecraft.getMinecraft().profiler.endSection(); GlStateManager.bindTexture(getGlTextureId()); for (TextureAtlasSprite texture : listAnimatedSprites) { if (((IPatchedTextureAtlasSprite) texture).needsAnimationUpdate()) { Minecraft.getMinecraft().profiler.startSection(texture.getIconName()); texture.updateAnimation(); ((IPatchedTextureAtlasSprite) texture).unmarkNeedsAnimationUpdate(); // Can't do this from updateAnimation mixin, that method can be overriden Minecraft.getMinecraft().profiler.endSection(); } } } }
public static void renderIconAt(Minecraft mc, int x, int y, float zLevel, TextureAtlasSprite icon) { if (icon == null) { return; } GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(new ResourceLocation(icon.getIconName())); Tessellator tess = Tessellator.getInstance(); BufferBuilder buf = tess.getBuffer(); buf.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); buf.pos(x, y + 16, GuiGraphics.zLevel).tex(icon.getMinU(), icon.getMaxV()).endVertex(); buf.pos(x + 16, y + 16, GuiGraphics.zLevel).tex(icon.getMaxU(), icon.getMaxV()).endVertex(); buf.pos(x + 16, y, GuiGraphics.zLevel).tex(icon.getMaxU(), icon.getMinV()).endVertex(); buf.pos(x, y, GuiGraphics.zLevel).tex(icon.getMinU(), icon.getMinV()).endVertex(); tess.draw(); }