Search in sources :

Example 1 with SimpleTexture

use of net.minecraft.client.renderer.texture.SimpleTexture in project blockbuster by mchorse.

the class URLDownloadThread method addToManager.

public static void addToManager(ResourceLocation url, InputStream is) throws IOException {
    BufferedImage image = ImageIO.read(is);
    SimpleTexture texture = new SimpleTexture(url);
    TextureUtil.uploadTextureImageAllocate(texture.getGlTextureId(), image, false, false);
    TextureManager manager = Minecraft.getMinecraft().renderEngine;
    Map<ResourceLocation, ITextureObject> map = ReflectionUtils.getTextures(manager);
    map.put(url, texture);
}
Also used : TextureManager(net.minecraft.client.renderer.texture.TextureManager) ITextureObject(net.minecraft.client.renderer.texture.ITextureObject) ResourceLocation(net.minecraft.util.ResourceLocation) SimpleTexture(net.minecraft.client.renderer.texture.SimpleTexture) BufferedImage(java.awt.image.BufferedImage)

Example 2 with SimpleTexture

use of net.minecraft.client.renderer.texture.SimpleTexture in project GregTech by GregTechCEu.

the class GTLaserBeamParticle method renderParticle.

@Override
public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
    GlStateManager.translate(posX - interpPosX, posY - interpPosY, posZ - interpPosZ);
    Vector3 cameraDirection = null;
    if (!doubleVertical) {
        cameraDirection = new Vector3(posX, posY, posZ).subtract(new Vector3(entityIn.getPositionEyes(partialTicks)));
    }
    TextureManager renderEngine = MINECRAFT.getRenderManager().renderEngine;
    ITextureObject bodyTexture = null;
    if (body != null) {
        bodyTexture = renderEngine.getTexture(body);
        if (bodyTexture == null) {
            bodyTexture = new SimpleTexture(body);
            renderEngine.loadTexture(body, bodyTexture);
        }
    }
    ITextureObject headTexture = null;
    if (head != null) {
        headTexture = renderEngine.getTexture(head);
        if (headTexture == null) {
            headTexture = new SimpleTexture(head);
            renderEngine.loadTexture(head, headTexture);
        }
    }
    float offset = -emit * (MINECRAFT.player.ticksExisted + partialTicks);
    LaserBeamRenderer.renderRawBeam(bodyTexture == null ? -1 : bodyTexture.getGlTextureId(), headTexture == null ? -1 : headTexture.getGlTextureId(), direction, cameraDirection, beamHeight, headWidth, alpha, offset);
    GlStateManager.translate(interpPosX - posX, interpPosY - posY, interpPosZ - posZ);
}
Also used : TextureManager(net.minecraft.client.renderer.texture.TextureManager) ITextureObject(net.minecraft.client.renderer.texture.ITextureObject) Vector3(codechicken.lib.vec.Vector3) SimpleTexture(net.minecraft.client.renderer.texture.SimpleTexture)

Example 3 with SimpleTexture

use of net.minecraft.client.renderer.texture.SimpleTexture in project MCMOD-Industria by M-Marvin.

the class AnimatedTexture method load.

public void load(IResourceManager manager) throws IOException {
    SimpleTexture.TextureData simpletexture$texturedata = this.getTextureImage(manager);
    simpletexture$texturedata.throwIfError();
    TextureMetadataSection texturemetadatasection = simpletexture$texturedata.getTextureMetadata();
    boolean flag;
    boolean flag1;
    if (texturemetadatasection != null) {
        flag = texturemetadatasection.isBlur();
        flag1 = texturemetadatasection.isClamp();
    } else {
        flag = false;
        flag1 = false;
    }
    NativeImage nativeimage = simpletexture$texturedata.getImage();
    if (!RenderSystem.isOnRenderThreadOrInit()) {
        RenderSystem.recordRenderCall(() -> {
            this.loadImage(nativeimage, flag, flag1);
        });
    } else {
        this.loadImage(nativeimage, flag, flag1);
    }
    this.size = simpletexture$texturedata.getImage().getWidth();
    this.textureHeight = simpletexture$texturedata.getImage().getHeight();
    ResourceLocation metadataFile = new ResourceLocation(this.location.getNamespace(), this.location.getPath() + ".mcmeta");
    try {
        IResource metadataResource = manager.getResource(metadataFile);
        InputStreamReader inputStreamReader = new InputStreamReader(metadataResource.getInputStream());
        BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
        StringBuffer stringBuffer = new StringBuffer();
        String string;
        while ((string = bufferedReader.readLine()) != null) {
            stringBuffer.append(string);
        }
        CompoundNBT metadataNBT = JsonToNBT.parseTag(stringBuffer.toString());
        CompoundNBT animation = metadataNBT.getCompound("animation");
        this.frameTime = animation.getInt("frametime");
        if (animation.contains("frames")) {
            ListNBT arr = animation.getList("frames", 3);
            frames = new int[arr.size()];
            for (int i = 0; i < arr.size(); i++) {
                this.frames[i] = arr.getInt(i);
            }
        } else {
            int height = simpletexture$texturedata.getImage().getHeight();
            int frameCount = height / size;
            frames = new int[frameCount];
            for (int i = 0; i < frameCount; i++) {
                this.frames[i] = i;
            }
        }
    } catch (CommandSyntaxException | FileNotFoundException e) {
        this.frames = new int[] { 0 };
        this.frameTime = 1;
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) CompoundNBT(net.minecraft.nbt.CompoundNBT) TextureMetadataSection(net.minecraft.client.resources.data.TextureMetadataSection) FileNotFoundException(java.io.FileNotFoundException) SimpleTexture(net.minecraft.client.renderer.texture.SimpleTexture) ListNBT(net.minecraft.nbt.ListNBT) NativeImage(net.minecraft.client.renderer.texture.NativeImage) ResourceLocation(net.minecraft.util.ResourceLocation) BufferedReader(java.io.BufferedReader) IResource(net.minecraft.resources.IResource) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException)

Aggregations

SimpleTexture (net.minecraft.client.renderer.texture.SimpleTexture)3 ITextureObject (net.minecraft.client.renderer.texture.ITextureObject)2 TextureManager (net.minecraft.client.renderer.texture.TextureManager)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 Vector3 (codechicken.lib.vec.Vector3)1 CommandSyntaxException (com.mojang.brigadier.exceptions.CommandSyntaxException)1 BufferedImage (java.awt.image.BufferedImage)1 BufferedReader (java.io.BufferedReader)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStreamReader (java.io.InputStreamReader)1 NativeImage (net.minecraft.client.renderer.texture.NativeImage)1 TextureMetadataSection (net.minecraft.client.resources.data.TextureMetadataSection)1 CompoundNBT (net.minecraft.nbt.CompoundNBT)1 ListNBT (net.minecraft.nbt.ListNBT)1 IResource (net.minecraft.resources.IResource)1