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

Hello everyone,

 

I'm working on a multiblock structure with a core tile entity that should store all the data, like items. I got another tile entity in the multiblock that should be able to in- and output items to and from the inventory of that core tile entity. I tried to achieve this by returning the instance of the ItemStackHandler of the core tile entity in the getCapability method in the other tile entity. It looks like this:

//The class that should in and output to the core tile entity
public class TileEntityMultiblockItemHandler extends TileEntity implements IMultiblockTileEntity{

	private TSMultiblock block;
	
	public TileEntityMultiblockItemHandler()
	{
		
	}
	
	@Override
	public TSMultiblock getMultiblock() 
	{
		return ((IMultiblockBlock)world.getBlockState(pos).getBlock()).getMultiblock(world, pos);
	}
	
	@Override
	public boolean hasCapability(Capability<?> capability, EnumFacing facing) 
	{
		if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) 
		{
			return true;
		}
		return super.hasCapability(capability, facing);
	}
	
	@Override
	public <T> T getCapability(Capability<T> capability, EnumFacing facing) 
	{
		if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) 
		{
			return (T) getMultiblock().getCoreEntity().getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing);
		}
		return super.getCapability(capability, facing);
	}

	@Override
	public void onMultiblockLoad() 
	{
		
	}
}

 

And

 

//The core tile entity
public class TileEntityFabricator extends TileEntityMachineBasic implements ITickable, IInteractionObject, ITileEntityInterface{

	private int currentFormTime;
	private int totalFormTime;
	private int energyConsumption;
	private TSEnergyStorage energy;
	private TSItemStorage inventory;
	
	public TileEntityFabricator()
	{
		totalFormTime = TSConfigHandler.runtimeFabricator;
		currentFormTime = 0;
		energyConsumption = TSConfigHandler.fabricatorConsumption;
		energy = new TSEnergyStorage(10000, 0, 0);
		inventory = new TSItemStorage(10);
	}
	
	//I left a bunch of methods out here
	
	@Override
	public boolean hasCapability(Capability<?> capability, EnumFacing facing) 
	{
		if (capability == CapabilityEnergy.ENERGY) 
		{
			return true;
		}
		if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) 
		{
			return true;
		}
		return super.hasCapability(capability, facing);
	}
	
	@Override
	public <T> T getCapability(Capability<T> capability, EnumFacing facing) 
	{
		if (capability == CapabilityEnergy.ENERGY) 
		{
			return (T) energy;
		}
		if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) 
		{
			return (T) inventory;
		}
		return super.getCapability(capability, facing);
	}
}

 

The problem: when I attach a hopper to the itemhandler tile entity, it inputs items, but I can't see them on the gui. Furthermore, I can get the items I put in out again with a hopper, but the items inside that I can see and access through the gui stay put. What have I done wrong?

Edited by tommyte
quick spelling corrections (:

  • Author

False alarm, I figured it out already. My 'getCoreEntity()' method didn't work properly. I wonder why it didn't spit out an error, but o well. Thanks anyways!

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.