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.

[1.14/1.15] Basic Chest Requirements

Featured Replies

Posted

Hello, I have begun creating my first mod which I am mostly using as a testing grounds to become familiar with the different things Forge is capable of.

Currently I've only created very simple blocks with crafting recipes, loot tables, texturing, etc. As of the past 24 hours or so, I've been trying to understand how to create Tile Entities, specifically chests.

Through my reading of the Forge Docs, I've concluded that it requires a a TileEntity inheritance, and an implementation of IItemHandler and/or ICapabilityProvider. I feel as if I've found some or all of the correct pieces to the puzzle, but I am unsure of how they fit together.

I believe I've created a block that is technically a Tile Entity but has no functionality or GUI with the following code:
 

public class ChestBlock extends BlockBase
{
	public ChestBlock(Properties properties, String registryName)
	{
		super(properties, registryName);
	}

	@Override
	public boolean hasTileEntity(BlockState state)
	{
		return true;
	}

	@Nullable
	@Override
	public TileEntity createTileEntity(BlockState state, IBlockReader world)
	{
		return new TestTileEntity();
	}
}

 

public class TestTileEntity extends TileEntity
{
	private NonNullList<ItemStack> chestContents;

	public TestTileEntity(TileEntityType<?> tileEntityTypeIn)
	{
		super(tileEntityTypeIn);
	}

	public TestTileEntity()
	{
		this(TileEntityLibrary.TEST_CHEST);
	}

	@Override
	public CompoundNBT write(CompoundNBT compound)
	{
		return super.write(compound);
	}

	@Override
	public void read(CompoundNBT compound)
	{
		super.read(compound);
	}
}

 

I've looked at some open source mods for guidance, but those I have looked at are rather complex and consist of many custom classes and implementations for inventories. I would just like to know what are the absolute most basic requirements for creating a custom chest. I do not need sided, orientation, animations, modeling, or any other functionality simply than being able to right click a block, it opens a GUI, and that tile entity is able to receive an ItemStack and properly sync it.

 

If you need any more snippets of my code, please simply ask.

 

Thank you.

Edited by TheHolyChase

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.