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

My custom container slots are overlaying player's invetory slots (not visually). When i click on slots in my container, it somehow clicks on the respective slot in player's inventory and swaps/puts/takes items from it . How do i manage that ? In my container constructor i didn't add any player's inventory slots, i don't need them.

  • Author

TickHandler - Server - player

 

  //ThaumicWheelProject  
	if(utils.isKeyPressed("V",player.username) && player.getCurrentEquippedItem()!= null && player.getCurrentEquippedItem().getItem() instanceof ItemWandCasting && (!player.getEntityData().hasKey(ThaumicWheelUtils.isOpenedForNBT) || !player.getEntityData().getBoolean(ThaumicWheelUtils.isOpenedForNBT))){
		player.getEntityData().setBoolean(ThaumicWheelUtils.isOpenedForNBT, true);
		new SimplePacket().openNewThaumicWheelGUI(player);

	}
	else if(!utils.isKeyPressed("V",player.username) && (player.getEntityData().hasKey(ThaumicWheelUtils.isOpenedForNBT) || player.getEntityData().getBoolean(ThaumicWheelUtils.isOpenedForNBT))){
		player.getEntityData().setBoolean(ThaumicWheelUtils.isOpenedForNBT, false);
		if(ThaumicWheelUtils.GUIs.containsKey(player))
			player.closeScreen();
		ThaumicWheelUtils.GUIs.remove(player);
	}
	//................

 

In packethandler FMLNetworkHandler.openGui is used.

 

Container

 public class ThaumicWheelContainer extends Container{

public World world;
public EntityPlayer player;
public int posX,posY,posZ;
public ItemStack pouch;
public int pouchSlot = -1;
public IInventory inv = new FocusPouchINV();

public ThaumicWheelContainer(EntityPlayer player,World par2World, int par3, int par4, int par5)
  {
    this.world = par2World;
    this.posX = par3;
    this.posY = par4;
    this.posZ = par5;
    this.player = player;
    this.pouch = ThaumicWheelUtils.playerGetPouch(player);
    this.pouchSlot = ThaumicWheelUtils.playerGetPouchSlot(player);
    ThaumicWheelUtils.GUIs.put(player, this);

    for (int a = 0; a < 18; a++) {
      this.addSlotToContainer(new RestrictedSlot(inv, a, 37 + a % 6 * 18, 60 + a / 6 * 18,IWandFocus.class));
    }
    
    ItemFocusPouch p = (ItemFocusPouch) ConfigItems.itemFocusPouch;
    if(pouch != null && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemWandCasting){
       ItemStack[] fs = p.getInventory(pouch);
       for(int i = 0;i<fs.length;i++){
    	   inv.setInventorySlotContents(i, fs[i]);
       }
    }else{
    	player.closeScreen();
    	player.getEntityData().setBoolean(ThaumicWheelUtils.isOpenedForNBT, false);
		if(ThaumicWheelUtils.GUIs.containsKey(player))
			player.closeScreen();
		ThaumicWheelUtils.GUIs.remove(player);
    }
    
  }






@Override
public boolean canInteractWith(EntityPlayer entityplayer) {
	return true;
}

public ItemStack slotClick(int par1, int par2, int par3, EntityPlayer par4EntityPlayer){
	new SimplePacket().changeWandFoci(par4EntityPlayer,par1);
	return (((Slot)this.inventorySlots.get(par1)) != null) ? ((Slot)this.inventorySlots.get(par1)).getStack() : null;




}



} 

 

GuiContainer

 

 public class ThaumicWheelGUI extends GuiContainer{

public EntityPlayer player;
public ItemStack wand;


public ThaumicWheelGUI(EntityPlayer player,World world,int x, int y,int z){
	super(new ThaumicWheelContainer(player,world,x,y,z));
	this.player = player;
	this.wand = player.getCurrentEquippedItem();
}

public boolean doesGuiPauseGame()
    {
        return false;
    }

public void drawScreen(int par1, int par2, float par3)
    {
        super.drawScreen(par1, par2, par3);
    }

@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
	UtilsFX.drawTag(50, 50, Aspect.AIR);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("thaumcraft","textures/gui/gui_focuspouch.png"));
        int x = (this.width-175)/2;
        int y = (this.height-142)/2;
        GL11.glEnable(3042);
        this.drawTexturedModalRect(x, y, 0, 0, 175, 142);
        GL11.glDisable(3042);

}

}

 

  • Author

Where should i call FMLNetworkHandler.openGui/EntityPlayer.openGui on SERVER or on CLIENT ?

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.