Jump to content

[SOLVED][1.6.4]Custom container is overlaying player's inventory


Recommended Posts

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.

Posted

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);

}

}

 

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.