Jump to content

Recommended Posts

Posted (edited)

Hello, I am trying to create a machine block that has a gui, and have so far managed to create everything, except it seems to have a glitch with it. I can open the GUI just fine, but when I do the GUI's slots are scaled much larger than my container's and it doesn't align with them. The texture I am using is a small modification of the furnace texture, so it should work fine.

Here I'll attach the code for my container and GUI, as well as the texture and a screenshot of my game.

Spoiler

    private static final ResourceLocation TEXTURES =  new ResourceLocation(Data.MODID + ":textures/gui/extractor.png");
    private final InventoryPlayer player;
    private final TileEntityExtractor tileentity;
    public extractorGUI(InventoryPlayer p, TileEntityExtractor t) {
        super(new extractorContainer(p, t));
        player = p;
        tileentity = t;
        xSize = 256;
        ySize = 256;
        
        // TODO Auto-generated constructor stub
    }
    @Override
    protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
        // TODO Auto-generated method stub
        String name = this.tileentity.getGuiName();
        this.fontRenderer.drawString(name, this.xSize/2-this.fontRenderer.getStringWidth(name)/2, 8, 4210752);
        this.fontRenderer.drawString(this.player.getDisplayName().getUnformattedText(), 22, this.ySize-26+2, 4210752);
    }
    
    @Override
    protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
        // TODO Auto-generated method stub
        GlStateManager.color(1.0f, 1.0f, 1.0f);
        this.mc.getTextureManager().bindTexture(TEXTURES);
        int marginHorizontal = (width - xSize) / 2;
        int marginVertical = (height - ySize) / 2;
        System.out.println(xSize);
        drawTexturedModalRect(marginHorizontal-100, marginVertical, 0, 0, xSize, ySize);
    }

 

 
Spoiler

private final TileEntityExtractor tileentity;

    public extractorContainer(InventoryPlayer player, TileEntityExtractor t) {
        tileentity = t;
        this.addSlotToContainer(new Slot(tileentity, 0, 71, 68));
        this.addSlotToContainer(new Slot(tileentity, 1, 201, 68));
        this.addSlotToContainer(new Slot(tileentity, 2, 258, 68));
        
        for( int y = 0; y < 3; y++) {
            for(int x = 0; x < 9; x++) {
                this.addSlotToContainer(new Slot(player, x+y*9+9, 8+x*18, (84+y*18)+48));
            }
        }
        
        for(int i = 0; i < 9; i++) {
            this.addSlotToContainer(new Slot(player, i, 8+i*18, 142+48));
        }
    }
    @Override
    public boolean canInteractWith(EntityPlayer playerIn) {
        // TODO Auto-generated method stub
        return true;
    }
    
    @Override
    public void addListener(IContainerListener l) {
        super.addListener(l);
        l.sendAllWindowProperties(this, tileentity);
    }

 

 

extractor.png

screenshot.png

Edited by PintsizedSix40

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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