Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Hoppers and custom furnaces [Solved]


AppliedOnce
 Share

Recommended Posts

What code should I take a look at to see how vanilla furnaces works with the hopper like if the hopper is underneath the custom furnace it will only take out the output, if above it will only put into the input and so on. And also if you could tell me if there is a way to first check if there is a chest next to the furnace and then send the output to the chest.

Link to comment
Share on other sites

As the Hopper's TileEntity class is rather large, I'll point you even more in the right direction.

 

The reason why insertion and extraction of Furnaces is side dependant is because the Furnace's TileEntity is implementing ISidedInventory and the Hopper respects this.

In TileEntityFurnace.java there is a method that specifies which slots refer to which side:

/**
     * Returns an array containing the indices of the slots that can be accessed by automation on the given side of this
     * block.
     */
    public int[] getAccessibleSlotsFromSide(int par1)
    {
        return par1 == 0 ? slots_bottom : (par1 == 1 ? slots_top : slots_sides);
    }

par1 is the side, so if the side == 0, the bottom slot(s) are returned, when side == 1 the top slots are returned and for the sides the side slots are returned.

 

As I said, the Hopper respects this and does that in the following way (TileEntityHopper.java, line 278 in the suckItemsIntoHopper method) :

byte b0 = 0;//b0 is the side, which is always the bottom (where it extracts from).

if(iinventory instanceof ISidedInventory && b0 > -1) {
ISidedInventory isidedinventory = (ISidedInventory)iinventory;
int[] aint = isidedinventory.getAccessibleSlotsFromSide(b0);

for(int element : aint) {
    if(insertStackFromInventory(par0Hopper, iinventory, element, b0)) {
          return true;
      }
    }
}
(...)

 

Author of PneumaticCraft, MineChess, Minesweeper Mod and Sokoban Mod. Visit www.minemaarten.com to take a look at them.

Link to comment
Share on other sites

Ahh the Vanilla Hopper code. I made a lot of new Hoppers with alot of functions

i mean i made really a lot and there are about 200-300 differend hoppers in my mod. And for the extracting code i can tell you do not copy it from Vannilla Minecraft. it is useless. For that you have to copy the whole Hopper Class. I had to write my own Hopper Extracting code. Thats only a hint.

xD.

There will be Deployer Hoppers xD and there are still a lot planed.

 

Speiger

Link to comment
Share on other sites

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
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.