use of com.loohp.interactivechatdiscordsrvaddon.resources.textures.TextureResource in project InteractiveChat-DiscordSRV-Addon by LOOHP.
the class MinecraftFontRenderer method getRawEnchantedImage.
public BufferedImage getRawEnchantedImage(BufferedImage source) {
TextureResource resource = resourceManager.getTextureManager().getTexture(ResourceRegistry.MISC_TEXTURE_LOCATION + "enchanted_item_glint");
BufferedImage tintOriginal = resource.getTexture();
if (resource.hasTextureMeta()) {
TextureMeta meta = resource.getTextureMeta();
if (meta.hasProperties()) {
TextureProperties properties = meta.getProperties();
if (properties.isBlur()) {
tintOriginal = ImageUtils.applyGaussianBlur(tintOriginal);
}
}
if (meta.hasAnimation()) {
TextureAnimation animation = meta.getAnimation();
if (animation.hasWidth() && animation.hasHeight()) {
tintOriginal = ImageUtils.copyAndGetSubImage(tintOriginal, 0, 0, animation.getWidth(), animation.getHeight());
} else {
tintOriginal = ImageUtils.copyAndGetSubImage(tintOriginal, 0, 0, tintOriginal.getWidth(), tintOriginal.getWidth());
}
}
}
BufferedImage tintImage = new BufferedImage(source.getWidth(), source.getHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics2D g3 = tintImage.createGraphics();
g3.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
g3.drawImage(tintOriginal, 0, 0, tintImage.getWidth() * 4, tintImage.getHeight() * 4, null);
g3.dispose();
return tintImage;
}
use of com.loohp.interactivechatdiscordsrvaddon.resources.textures.TextureResource in project InteractiveChat-DiscordSRV-Addon by LOOHP.
the class ModelRenderer method render.
public RenderResult render(int width, int height, int internalWidth, int internalHeight, ResourceManager manager, boolean post1_8, String modelKey, ModelDisplayPosition displayPosition, Map<ModelOverrideType, Float> predicate, Map<String, TextureResource> providedTextures, TintIndexData tintIndexData, boolean enchanted, boolean usePlayerModelPosition) {
String cacheKey = cacheKey(width, height, manager.getUuid(), modelKey, displayPosition, predicate, cacheKeyProvidedTextures(providedTextures), enchanted);
Cache<?> cachedRender = Cache.getCache(cacheKey);
if (cachedRender != null) {
RenderResult cachedResult = (RenderResult) cachedRender.getObject();
if (cachedResult.isSuccessful()) {
return cachedResult;
}
}
String rejectedReason = null;
BlockModel blockModel = manager.getModelManager().resolveBlockModel(modelKey, post1_8, predicate);
if (blockModel == null) {
return new RenderResult(MODEL_NOT_FOUND, null);
}
BufferedImage image = new BufferedImage(internalWidth, internalHeight, BufferedImage.TYPE_INT_ARGB);
if (blockModel.getRawParent() == null || !blockModel.getRawParent().contains("/")) {
renderBlockModel(generateStandardRenderModel(blockModel, manager, providedTextures, tintIndexData, enchanted, false), image, blockModel.getDisplay(displayPosition), blockModel.getGUILight(), usePlayerModelPosition);
} else if (blockModel.getRawParent().equals(ModelManager.ITEM_BASE)) {
Graphics2D g = image.createGraphics();
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
for (int i = 0; blockModel.getTextures().containsKey(ModelManager.ITEM_BASE_LAYER + i); i++) {
String resourceLocation = blockModel.getTextures().get(ModelManager.ITEM_BASE_LAYER + i);
if (!resourceLocation.contains(":")) {
resourceLocation = ResourceRegistry.DEFAULT_NAMESPACE + ":" + resourceLocation;
}
TextureResource resource = providedTextures.get(resourceLocation);
if (resource == null) {
resource = manager.getTextureManager().getTexture(resourceLocation);
}
BufferedImage texture = resource.getTexture();
if (resource.hasTextureMeta()) {
TextureMeta meta = resource.getTextureMeta();
if (meta.hasProperties()) {
TextureProperties properties = meta.getProperties();
if (properties.isBlur()) {
texture = ImageUtils.applyGaussianBlur(texture);
}
}
if (meta.hasAnimation()) {
TextureAnimation animation = meta.getAnimation();
if (animation.hasWidth() && animation.hasHeight()) {
texture = ImageUtils.copyAndGetSubImage(texture, 0, 0, animation.getWidth(), animation.getHeight());
} else {
texture = ImageUtils.copyAndGetSubImage(texture, 0, 0, texture.getWidth(), texture.getWidth());
}
}
}
if (resourceLocation.equals(ResourceRegistry.MAP_MARKINGS_LOCATION)) {
ImageUtils.xor(image, ImageUtils.resizeImageAbs(texture, image.getWidth(), image.getHeight()), 200);
} else {
g.drawImage(texture, 0, 0, image.getWidth(), image.getHeight(), null);
}
}
g.dispose();
image = tintIndexData.applyTint(image, 0);
if (enchanted) {
image = enchantmentGlintProvider.apply(image);
}
} else {
rejectedReason = blockModel.getRawParent();
}
RenderResult result;
if (rejectedReason == null) {
result = new RenderResult(ImageUtils.resizeImageQuality(image, width, height), blockModel);
} else {
result = new RenderResult(rejectedReason == null ? "null" : rejectedReason, blockModel);
}
Cache.putCache(cacheKey, result, cacheTimeoutSupplier.getAsLong());
return result;
}
Aggregations