Tech Reborn

Tech Reborn

30M Downloads

TechReborn blocks don't implement getInvAvailableSlots(), making accessing available slots unusually complicated.

vini2003 opened this issue ยท 7 comments

commented

Working on Tubular for 1.14.4, I noticed weird behavior when attempting to insert/extract items into/from TechReborn machinery.

As it turns out, getInvAvailableSlots() is not implemented/overriden, meaning that, while SidedInventory is implemented, whenever a mod asks for the available slots, weird things happen:

"Electric Furnace"

Blocks such as the vanilla Composter Block implement it like:

public int[] getInvAvailableSlots(Direction direction_1) {
   return direction_1 == Direction.UP ? new int[]{0} : new int[0];
}

Which returns that the available slot from Direction UP is 0; thus items can be correctly extracted from such slots. While vanilla Hoppers work with TechReborn, I'm not sure how that interaction works - meaning it's possible to work with this, but not as comfortable as it likely should be.

commented

As a follow up, the correct thing to do would be fully implement the SidedInventory methods in all machines:

public interface SidedInventory extends Inventory {
   int[] getInvAvailableSlots(Direction var1);
   // Get slots accessible from that direction (eg. UP)
   boolean canInsertInvStack(int var1, ItemStack var2, @Nullable Direction var3);
   // Check if can insert stack in specified slot (if slot has restricted item types, from my understanding)
   boolean canExtractInvStack(int var1, ItemStack var2, Direction var3);
   // Check if item can be extracted from specified slot (if slot is meant to only ever be inserted to, for example, such as Furnace fuel)
}

That greatly simplifies the process of interacting with machinery, since you can just inventory.canExtractInvStack(itemStack); whenever you need to; also, it's the vanilla way and should probably be a standard to make developer's lifes easier.

commented

Huh, okay, my searches failed miserably. I was having issues specifically with TechReborn machinery not working properly with my tubes, then did a search:

Search

And it turned up nothing, which is weird given SidedInventory is imported. I then looked at machine entities themselves but not the base block, which explains why I missed it.

The issue seems to be with my implementation and a bad search then.

commented

I dont think github allows you to search branches other than master, so you would have been searching the 1.12 branch.

commented

Ouch, that explains it. Suppose this issue ends here.

commented

If your sure its your issue, as it could easily be an issue with my code?

commented

Gonana close this, if there is an issue with how they are implimented please make a new issue. Thanks.