Giter Club home page Giter Club logo

inventorytabs's Introduction

InventoryTabs

Adds tabs to access nearby blocks without leaving your inventory. Completely client-side.

Inventory Tabs showcase

Showcase GIF

BigInv support

PlayerEx support

New in 0.8.1: Chest icons and hover text can be changed by nearby item frames!

InventoryTabs-nearby-item-frames

New in 0.9.0: Entity support!

Chest Minecart showcase

Villager inventory showcase

Devs

Importing

To add Inventory Tabs to your project, you need to add https://jitpack.io as a repo and com.github.dhyces:InventoryTabs:inventorytabs-(mod version)-(Minecraft version)-forge as a dependency. For example:

repositories {
	maven {
		url "https://jitpack.io"
	}
}

dependencies {
	modImplementation "com.github.dhyces:InventoryTabs:inventorytabs-0.9.0-1.19.2-forge"
}

See the releases page for available versions.

Adding Custom Tabs

There are multiple ways to add custom tabs.

Simple Block Tabs

A "simple block tab" is a tab that is opened via interaction with a block. If your block falls under this category, adding a tab is as easy as passing your block to TabProviderRegistry#registerSimpleBlock.

Chest Tabs

Chest tabs are tabs belonging to chests that are able to double up along the horizontal axis. To register your chest, pass the block reference to TabProviderRegistry#registerChest. Chests that do not match vanilla chest behavior should not use this method.

Custom Tabs

The first step to adding a custom tab is creating a class that implements the Tab interface. This represents the tab that players will see, and it also controls what happens when the tab is clicked.

The next step is to register a TabProvider using the TabProviderRegistry. TabProvider objects are called every tick while a screen is open in order to populate the list of tabs available to the player. The list is not managed by the mod, so be sure to check for duplicates yourself. The GenericBlockTabProvider class is provided, and serves as a basis for adding tabs for blocks that open handled screens (it also checks for duplicates for you). Feel free to see the EnderChestTabProvider and ShulkerBoxTabProvider classes for implementation details.

Your handled screen needs to update the TabManager, which you can grab a reference of by calling TabManager#getInstance. In the init method (not your constructor), you must call TabManager$#onScreenOpen. After doing that, you need to do a check to see if your screen was opened via tab or other means. If it wasn't opened via tab (check by calling TabManager#screenOpenedViaTab), call TabManager#onOpenTab with your Tab object. See VanillaScreenTabAdder for more details on how to do this. You can also adjust the y-axis positioning of the bottom row of tabs by setting TabRenderer#bottomRowYOffset (there is a reference to a TabRenderer object in the TabManager).

Finally, there are some methods to call for rendering and managing the tabs. In the render method before anything is drawn, call TabRenderer#renderBackground. In the drawBackground, call TabRenderer#renderForeground and TabRenderer#renderHoverTooltips. In the mouseClicked method, call TabManager#mouseClicked.

If your screen's GUI dynamically changes (in the case of a recipe book opening), you can implement the TabRenderingHints interface and offset the top and bottom rows however you like.

Credits

This 1.18 and 1.19 port is based on LiamMCW's fork of the original mod by cakewhip. Full credits can be found at https://github.com/Andrew6rant/inventorytabs/graphs/contributors.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.