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

  • Author
31 minutes ago, diesieben07 said:
9 hours ago, TehStoneMan said:

How do you use DeferredWorkQueue? I have not encountered that before.

It has javadocs. Did you read them? You give it a Runnable or Supplier and it will run it on the main game thread and provide you with a CompletableFuture for when it's done.

If I understood the javadocs, I wouldn't be asking for help.

 

32 minutes ago, diesieben07 said:
9 hours ago, TehStoneMan said:

I already know how to use openGui in blocks/tile entities, but don't how to use INamedContainerProvider in an item.

It's an interface. You implement it.

If I knew how to implement it with an item, I wouldn't be asking for help.

  • Author

OK, I think I managed to figure out DefferedWorkQueue. Minecraft even seemed to launch faster. Am I correct with this?

DeferredWorkQueue.runLater( () ->
{
	ScreenManager.registerFactory( BetterStorageContainerTypes.LOCKER, GuiBetterStorage::new );
	ScreenManager.registerFactory( BetterStorageContainerTypes.CRATE, GuiCrate::new );
	ScreenManager.registerFactory( BetterStorageContainerTypes.REINFORCED_CHEST, GuiReinforcedChest::new );
	ScreenManager.registerFactory( BetterStorageContainerTypes.REINFORCED_LOCKER, GuiReinforcedLocker::new );
	ScreenManager.registerFactory( BetterStorageContainerTypes.KEYRING, GuiKeyring::new );
} );

What other startup calls would this be recommended to use this with?

 

As for the item, this is my current guess based on how my tile entities are implemented:

public class ItemKeyring extends ItemBetterStorage implements IKey, INamedContainerProvider // <-- Is this the right place?
{
	public ItemKeyring()
	{
		super( "keyring", new Item.Properties().group( BetterStorage.ITEM_GROUP ) );
		addPropertyOverride( new ResourceLocation( "full" ), ( itemStack, world, entityPlayer ) ->
		{
			return 0.0F;
		} );
	}

	@Override
	public ActionResult< ItemStack > onItemRightClick( World world, PlayerEntity player, Hand hand )
	{
		final ItemStack stack = player.getHeldItem( hand );

		if( !player.isSneaking() )
			return new ActionResult( ActionResultType.PASS, stack );

		if( !world.isRemote)
		{
			NetworkHooks.openGui( (ServerPlayerEntity)player, BetterStorageItems.KEYRING ); // <-- Don't know what to put here
		}
		return new ActionResult( ActionResultType.SUCCESS, stack );
	}

	....

}

 

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.