use of net.minecraft.client.renderer.texture.TextureMap in project Charset by CharsetMC.
the class CharsetTweakUnifyColors method recolorTextures.
private void recolorTextures(TextureMap map, String prefix) {
ResourceLocation source = new ResourceLocation(prefix + "white");
for (int i = 0; i < 16; i++) {
String s = ColorUtils.getUnderscoredSuffix(EnumDyeColor.byMetadata(i));
ResourceLocation target = new ResourceLocation(prefix + s);
if (prefix.contains("hardened_clay")) {
BufferedImage image = RenderUtils.getTextureImage(new ResourceLocation("minecraft:blocks/hardened_clay"));
BufferedImage imageGrayscale = toGrayscale(image);
int[] imageData = computeMinMaxData(image);
int[] imageGrayData = computeMinMaxData(imageGrayscale);
int delta = imageGrayData[3] - imageGrayData[7];
final float divisor = delta > 5 ? (float) delta / 5.0f : 1.0f;
final int value2 = colorMultiplier(prefix, EnumDyeColor.byMetadata(i));
map.setTextureEntry(new PixelOperationSprite(target.toString(), source, (getter, x, y, value) -> {
int out = 0xFF000000;
for (int coff = 0; coff < 24; coff += 8) {
int v1 = (((imageGrayscale.getRGB(x, y) >> coff) & 0xFF) * 255 / imageGrayData[coff >> 3]) - 0xFF;
v1 /= divisor;
int v2 = ((value2 >> coff) & 0xFF) + v1;
if (v2 < 0)
v2 = 0;
if (v2 > 255)
v2 = 255;
int nonTintedOut = (v2 & 0xFF);
int tintedOut = nonTintedOut * imageData[8 + (coff >> 3)] / imageData[0 + 3];
out |= Math.round((nonTintedOut + tintedOut + (tintedOut / 2)) / 2.5f) << coff;
}
return out;
}));
} else if (i > 0) {
// skip white for non-clay
map.setTextureEntry(new PixelOperationSprite(target.toString(), source, PixelOperationSprite.multiply(colorMultiplier(prefix, EnumDyeColor.byMetadata(i)))));
}
}
}
use of net.minecraft.client.renderer.texture.TextureMap in project ForestryMC by ForestryMC.
the class ModelDecorativeLeaves method bakeBlock.
@Override
protected void bakeBlock(BlockDecorativeLeaves block, TreeDefinition treeDefinition, IModelBaker baker, boolean inventory) {
TextureMap map = Minecraft.getMinecraft().getTextureMapBlocks();
ITreeGenome genome = treeDefinition.getGenome();
IAlleleTreeSpecies species = genome.getPrimary();
ILeafSpriteProvider leafSpriteProvider = species.getLeafSpriteProvider();
ResourceLocation leafSpriteLocation = leafSpriteProvider.getSprite(false, Proxies.render.fancyGraphicsEnabled());
TextureAtlasSprite leafSprite = map.getAtlasSprite(leafSpriteLocation.toString());
// Render the plain leaf block.
baker.addBlockModel(null, leafSprite, BlockAbstractLeaves.FOLIAGE_COLOR_INDEX);
// Render overlay for fruit leaves.
ResourceLocation fruitSpriteLocation = genome.getFruitProvider().getDecorativeSprite();
if (fruitSpriteLocation != null) {
TextureAtlasSprite fruitSprite = map.getAtlasSprite(fruitSpriteLocation.toString());
baker.addBlockModel(null, fruitSprite, BlockAbstractLeaves.FRUIT_COLOR_INDEX);
}
// Set the particle sprite
baker.setParticleSprite(leafSprite);
}
use of net.minecraft.client.renderer.texture.TextureMap in project ForestryMC by ForestryMC.
the class ModelLeaves method getWorldKey.
@Override
protected Key getWorldKey(IBlockState state) {
IExtendedBlockState stateExtended = (IExtendedBlockState) state;
IBlockAccess world = stateExtended.getValue(UnlistedBlockAccess.BLOCKACCESS);
BlockPos pos = stateExtended.getValue(UnlistedBlockPos.POS);
boolean fancy = Proxies.render.fancyGraphicsEnabled();
TextureMap map = Minecraft.getMinecraft().getTextureMapBlocks();
if (world == null || pos == null) {
return createEmptyKey(map, fancy);
}
TileLeaves tile = TileUtil.getTile(world, pos, TileLeaves.class);
if (tile == null) {
return createEmptyKey(map, fancy);
}
ResourceLocation leafLocation = tile.getLeaveSprite(fancy);
ResourceLocation fruitLocation = tile.getFruitSprite();
return new Key(map.getAtlasSprite(leafLocation.toString()), fruitLocation != null ? map.getAtlasSprite(fruitLocation.toString()) : null, fancy);
}
use of net.minecraft.client.renderer.texture.TextureMap in project ForestryMC by ForestryMC.
the class ModelLeaves method getInventoryKey.
@Override
protected Key getInventoryKey(ItemStack itemStack) {
TextureMap map = Minecraft.getMinecraft().getTextureMapBlocks();
TileLeaves leaves = new TileLeaves();
if (itemStack.getTagCompound() != null) {
leaves.readFromNBT(itemStack.getTagCompound());
} else {
leaves.setTree(TreeRoot.treeTemplates.get(0));
}
boolean fancy = Proxies.render.fancyGraphicsEnabled();
ResourceLocation leafLocation = leaves.getLeaveSprite(fancy);
ResourceLocation fruitLocation = leaves.getFruitSprite();
return new Key(map.getAtlasSprite(leafLocation.toString()), fruitLocation != null ? map.getAtlasSprite(fruitLocation.toString()) : null, fancy);
}
use of net.minecraft.client.renderer.texture.TextureMap in project ForestryMC by ForestryMC.
the class BlockBase method registerSprites.
@SideOnly(Side.CLIENT)
@Override
public void registerSprites(ITextureManager manager) {
IMachineProperties<?> machineProperties = blockType.getMachineProperties();
if (machineProperties instanceof IMachinePropertiesTesr) {
TextureMap textureMapBlocks = Minecraft.getMinecraft().getTextureMapBlocks();
String particleTextureLocation = ((IMachinePropertiesTesr) machineProperties).getParticleTextureLocation();
textureMapBlocks.registerSprite(new ResourceLocation(particleTextureLocation));
}
}
Aggregations