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

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

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.