Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Im Working on my Gui, and in the spot where the fluid is supposed to be im getting a weird texture show up.

 

 

Tile Entity

package com.brady131313.steamreborn.tileentity;

import com.brady131313.steamreborn.init.ModFluids;
import com.brady131313.steamreborn.inventory.ContainerSR;
import com.brady131313.steamreborn.utility.Tank;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChatComponentText;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;

/**
* Created by brady on 8/6/2014.
*/
public class TileEntityAlloyCompressor extends TileMachineTank {

    public static final int INVENTORY_SIZE = 3;
    public static final int ITEM1_INVENTORY_INDEX = 0;
    public static final int ITEM2_INVENTORY_INDEX = 1;
    public static final int OUTPUT_INVENTORY_INDEX = 2;
    private int tankSize;

    public int itemCookTime; //How long the current item has been cooking

    public ItemStack outputItemStack;

    public TileEntityAlloyCompressor() {
        tank = new Tank(new FluidStack(ModFluids.steamFluid, 0), 10000);
        inventory = new ItemStack[iNVENTORY_SIZE];
    }

    @Override
    public int[] getAccessibleSlotsFromSide(int side) {

        return side == ForgeDirection.DOWN.ordinal() ? new int[]{OUTPUT_INVENTORY_INDEX} : new int[]{ITEM1_INVENTORY_INDEX, ITEM2_INVENTORY_INDEX, OUTPUT_INVENTORY_INDEX};
    }

    @Override
    public boolean canInsertItem(int slotIndex, ItemStack itemStack, int side) {

        if (worldObj.getTileEntity(xCoord, yCoord, zCoord) instanceof TileEntityAlloyCompressor) {
            return isItemValidForSlot(slotIndex, itemStack);
        } else {
            return false;
        }
    }

    @Override
    public boolean canExtractItem(int slotIndex, ItemStack itemStack, int side) {

        return slotIndex == OUTPUT_INVENTORY_INDEX;
    }

    @SideOnly(Side.CLIENT)
    public int getCookProgressScaled(int scale) {

        return this.itemCookTime * scale / 200;
    }

    public int getScaledSteamLevel(int scale) {

        final double steamLevel = tank.getFluid() == null ? 0 : this.tank.getFluidAmount();

        return (int) (steamLevel * scale / this.tank.getCapacity());
    }

    public FluidStack getSteam() {

        return tank.getFluid();
    }

    @Override
    public void process() {


    }

    public void getGUINetworkData(int id, int value) {

        if (id == 6) tankSize = value;
        else super.getGuiNetworkData(id, value);
    }

    public void sendGUINetworkData(ContainerSR container, ICrafting crafting) {

        super.sendGuiNetworkData(container, crafting);
        crafting.sendProgressBarUpdate(container, 6, tankSize);
    }

    @Override
    public void readFromNBT(NBTTagCompound nbt) {
        super.readFromNBT(nbt);
        tank.readFromNBT(nbt.getCompoundTag("steamTank"));
    }

    @Override
    public void writeToNBT(NBTTagCompound nbt) {

        super.writeToNBT(nbt);
        nbt.setTag("steamTank", tank.writeToNBT(new NBTTagCompound()));
    }

    public void sendChatInfoToPlayer(EntityPlayer player) {

        player.addChatMessage(new ChatComponentText("Tanks Fluid Amount: " + tank.getFluidAmount()));
        player.addChatMessage(new ChatComponentText("Tanks Capacity: " + tank.getCapacity()));
    }
}

 

Gui

package com.brady131313.steamreborn.client.gui.machines;

import com.brady131313.steamreborn.inventory.ContainerAlloyCompressor;
import com.brady131313.steamreborn.reference.Names;
import com.brady131313.steamreborn.reference.Textures;
import com.brady131313.steamreborn.tileentity.TileEntityAlloyCompressor;
import com.brady131313.steamreborn.utility.LogHelper;
import com.brady131313.steamreborn.utility.RenderUtils;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;

import java.util.logging.Logger;


@SideOnly(Side.CLIENT)
public class GuiAlloyCompressor extends GuiContainer {

    private TileEntityAlloyCompressor tileEntityAlloyCompressor;

    public GuiAlloyCompressor(InventoryPlayer inventoryPlayer, TileEntityAlloyCompressor tileEntityAlloyCompressor) {

        super(new ContainerAlloyCompressor(inventoryPlayer, tileEntityAlloyCompressor));
        this.tileEntityAlloyCompressor = tileEntityAlloyCompressor;
        xSize = 176;
        ySize = 187;
    }

    @Override
    protected void drawGuiContainerForegroundLayer(int x, int y) {

        String containerName = StatCollector.translateToLocal(tileEntityAlloyCompressor.getInventoryName());
        fontRendererObj.drawString(containerName, xSize / 2 - fontRendererObj.getStringWidth(containerName) / 2, 6, 4210752);
        fontRendererObj.drawString(StatCollector.translateToLocal(Names.Containers.VANNILLA_INVENTORY), 8, ySize - 96 + 2, 4210752);
    }

    @Override
    protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {

        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

        this.mc.getTextureManager().bindTexture(Textures.Gui.ALLOY_COMPRESSOR);

        int xStart = (width - xSize) / 2;
        int yStart = (height - ySize) / 2;

        this.drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize);
        int scaleAdjustment;

        /*final int steamLevel = this.tileEntityAlloyCompressor.getScaledSteamLevel(58);
        this.drawTexturedModalRect(xStart + 15, yStart + 18, 208, 71, 16, steamLevel);
        LogHelper.info(steamLevel);*/

        drawFluid(tileEntityAlloyCompressor.getSteam(), xStart + 15, yStart + 18, 16, 58, tileEntityAlloyCompressor.tank.getCapacity());
        //TODO fix weird render issue with fluid in gui

        scaleAdjustment = this.tileEntityAlloyCompressor.getCookProgressScaled(36);
        this.drawTexturedModalRect(xStart + 63 , yStart + 32, 176, 34, scaleAdjustment + 1, 30);

        this.drawTexturedModalRect(xStart + 15, yStart + 23, 180, 73, 16, 49);

    }

    public void drawFluid(FluidStack fluid, int x, int y, int width, int height, int maxCapacity) {

        if (fluid == null || fluid.getFluid() == null) {
            return;
        }

        IIcon icon = fluid.getFluid().getIcon(fluid);
        LogHelper.info(fluid.getFluid().getIcon(fluid));
        mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture);
        RenderUtils.setGLColorFromInt(fluid.getFluid().getColor(fluid));
        int fullX = width / 16;
        int fullY = height / 16;
        int lastX = width - fullX * 16;
        int lastY = height - fullY * 16;
        int level = fluid.amount * height / maxCapacity;
        int fullLvl = (height - level) / 16;
        int lastLvl = (height - level) - fullLvl * 16;

        for (int i = 0; i < fullX; i++) {
            for (int j = 0; j < fullY; j++) {
                if (j >= fullLvl) {
                    drawCutIcon(icon, x + i * 16, y + j * 16, 16, 16, j == fullLvl ? lastLvl : 0);
                }
            }
        }

        for (int i = 0; i < fullX; i++) {
            drawCutIcon(icon, x + i * 16, y + fullY * 16, 16, lastY, fullLvl == fullY ? lastLvl : 0);
        }

        for (int i = 0; i < fullY; i++) {
            if (i >= fullLvl) {
                drawCutIcon(icon, x + fullX * 16, y + i * 16, lastX, 16, i == fullLvl ? lastLvl : 0);
            }
        }

        drawCutIcon(icon, x + fullX * 16, y + fullY * 16, lastX, lastY, fullLvl == fullY ? lastLvl : 0);
    }

    private void drawCutIcon(IIcon icon, int x, int y, int width, int height, int cut) {

        Tessellator tess = Tessellator.instance;
        tess.startDrawingQuads();
        tess.addVertexWithUV(x, y + height, zLevel, icon.getMinU(), icon.getInterpolatedV(height));
        tess.addVertexWithUV(x + width, y + height, zLevel, icon.getInterpolatedU(width), icon.getInterpolatedV(height));
        tess.addVertexWithUV(x + width, y + cut, zLevel, icon.getInterpolatedU(width), icon.getInterpolatedV(cut));
        tess.addVertexWithUV(x, y + cut, zLevel, icon.getMinU(), icon.getInterpolatedV(cut));
        tess.draw();
    }

}

Hi

 

It looks to me like you have either bound the wrong texture sheet (do you mean to use vanilla block sheet?) or you are using the wrong texture coordinates for your icon - i.e. something is wrong in your "cut" calculations.

 

-TGG

  • Author

I'm using the same methods as the buildcraft drawfluid and draw cut icon, as well as the same texture map as the build craft so I'm unsure as to why this is happening. When I removed tinkers construct it showed the vanilla textures so I know its not another mod causing it

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.