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

I have a little problem with my Inventory. I want to make it upgradeble so you can have more Slots in it. So I addet an Integer in the TileEntiy for the number of Slots and changed the size of the LazyOptional<ItemStackHandler> inventory and it seems to work, but the screen is a bit buggy. The bigger inventory occupies slots from the playerinventory and does not extend its own one, althouge I adjust the number of slots via the Integer in the tileEntity. Any idea what I am doing wrong? 

 

My Function to increase size in the TileEntity:

	public void setItemSlots(int itemSlots) {
		this.itemSlots = itemSlots;
		LazyOptional<ItemStackHandler> itemHandler = LazyOptional.of(() -> new ItemStackHandler(itemSlots));
		inventory.ifPresent(consumer -> {
			for (int i = 0; i < consumer.getSlots(); i++) {
				int slot = i;
				itemHandler.ifPresent(consumer1 -> consumer1.setStackInSlot(slot, consumer.getStackInSlot(slot)));
			}		
			
		});
		inventory = itemHandler;	
	}

 

 

The init of the Container. Maybe I need to re-init it, but I dont know how

	@Override
	public void init() {
		tileEntity.getInventory().ifPresent(handler -> addSlots(handler, 0 , 8, 25, tileEntity.getItemSlots()));
		addPlayerInventory(8, 113);	

	}

The addSlots Functions:

public int addHorizontalSlots(IItemHandler handler, int index, int x, int y, int amount) {
		for (int i = 0; i < amount; i++) {
			addSlot(new SlotItemHandler(handler, index, x, y));
			x+=18;
			index++;
		}
		return index;
	}
	

	
	public int addSlots(IItemHandler handler, int index, int x, int y, int amount) {
		int verticalAmount = (int) Math.ceil(amount/9);
		for (int i = 0; i < verticalAmount; i++) {			
			index = addHorizontalSlots(handler,index,x,y,9);
			y+=18;
		}
		index = addHorizontalSlots(handler, index, x, y, amount%9);
		return index;
		
	}

 

My render in screen:

	@Override
	public void render(int mouseX, int mouseY, float partialTicks) {
		// TODO Auto-generated method stub
		renderBackground();		
		super.render(mouseX, mouseY, partialTicks);
		renderHoveredToolTip(mouseX, mouseY);
		getHoverdVillager(mouseX, mouseY);
		
		renderVillagerTooltip(mouseX,mouseY,this.font);
	}

 

 

 

 

 

 

 

 

 

 

 

Edited by Anubis
Couldn't find insert code last time

  • Author

Maybe thats an stupid question, but how do i synchronize that?

That's my NetworkHooks for the tileentity:

NetworkHooks.openGui((ServerPlayerEntity) playerEntity, village_Center_Tile_Entity, blockPos);

What do I need to add, so it will synchronize?

  • 2 weeks later...
  • Author

I don't know if anyone is interested, but I found my mistake. After long searching I found the problem, just a stupid one. Before the upgrading procedure I had a isRemote check, witch cases the unsync between client and server side.

 

Thanks for help everyone

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.