Cannot remove bucket from Hobbyist's Steam Engine
RalphFox opened this issue ยท 6 comments
I can automatically add lava bucket to the Hobbyist's Steam Engine, but i cannot take the empty bucket back;
I tried bc wooden pipe, transfer node(items), and itemduct with servo..
Setup:
Hobbyist's Steam Engine, transfer pipe(from extra utilities), the pipe connected to a transfer node(items) that is connected to a chest with lava buckets; then there is another transfer node(items) connected to the engine, and a pipe, and then a chest;
Setup works nicely, i can add lava-filled bucket, but not remove the empty bucket automatically; only by going manually and removing the bucket from the gui;
I tried looking at the code, but i never programmed in java minecraft;
The farthest i got is that in TileEngineSteamHobby.java there is a SteamBoiler class construction(new) that seems to be burning the fuel; Looking inside it i saw that there is a function "addFuel" that itself calls fuelProvider.getMoreFuel(); that i suspect that is the function that burns the fuel, using the set fuelprovider, in this case that is SolidFuelProvider.java; inside it, there is a function, InvTools.depleteItem(fuel) that i'm mostly sure is what "burns" the item; going deeper into InvTools.java i can see that there is a stack.splitStack(1), that is a instance of IInventory.. and that's a minecraft class that i have no idea what is.. i found only references to it in the net, and them i got burnout(got dizzy/tired of investigating, that took almost an hour navigating/tracking the code) haha
Anyway.. i suppose that i was following the path of how the fuel is burned, but i should have been looking of how the item gets inside; i couldn't find that anywhere.. I suppose that since is an minecraft inventory, items can get inside by default, per minecraft implementation, but to get outside you would need to code something specific somewhere to allow the item to be put out;
Sorry if i got anything wrong, and for the walltext.. i really wanted to code/help, but i never touched minecraft-java-forge-mods, and i am not an pro in coding..
Items are removed in the same way they are put in. I see nothing in the code that would prevent this from happening. You can't access the inventory from the engine business end, but that's about it.
Empty buckets go into SLOT_LIQUID_OUTPUT also known as slot 3 (or they should). Slot 3 is the lower slot. It is the only slot that can be extracted from. The only thing that would prevent removal is if the empty bucket isn't ending up in slot 3.
A few screenshots would be worth a thousand words.
Relevant lines of code:
https://github.com/CovertJaguar/Railcraft/blob/master/src/main/java/mods/railcraft/common/blocks/machine/beta/TileEngineSteamHobby.java#L216
https://github.com/CovertJaguar/Railcraft/blob/master/src/main/java/mods/railcraft/common/blocks/machine/beta/TileEngineSteamHobby.java#L226
Oh, I think I see what you are trying to do. Empty buckets are not moved from the fuel slot to slot 3.
Ha, nice! That was fast, wow! Also, nice job on the few lines of code, good work!
Will this work for 1.7.10?
On a side note, may i ask how did you set up the inventory slots/containers, so when something tries to remove anything from the entity, it only removes from slot 3?
Thanks again!
Nvm, i think i found out:
I think is this this line
https://github.com/CovertJaguar/Railcraft/blob/master/src/main/java/mods/railcraft/common/blocks/machine/beta/TileEngineSteamHobby.java#L232
aah, i got it, the @ override overrides the original entity/block function from minecraft; that does makes sense!
Hmm... how would you set up that function instead of moving items to slot 3, to allow more than one item to be removed?
since pipes/systems can only interact with only one inventory at time, maybe that isn't possible at all.. it could be something on the lines of
public boolean canExtractItem(int slot, ItemStack stack, int side) {
bool extractable = false;
if (slot == SLOT_LIQUID_OUTPUT || slot == SLOT_FUEL) {
if (ItemStack.stackSize > 0 ) {
extractable = true;
}
}
return extractable;
}
Yes, I submitted this to the 1.7 branch and merged it into the 1.8 branch.
The problem with your snippet of code is that you don't want allow actual burnable items to be removable from the fuel slot. Otherwise you get issues with random machines stealing coal from your engines. Oh and also "ItemStack.stackSize" is invalid, not sure what you meant there.
A better solution would be:
public boolean canExtractItem(int slot, ItemStack stack, int side) {
if (slot == SLOT_LIQUID_OUTPUT)
return true;
return slot == SLOT_FUEL && FuelPlugin.getBurnTime(getStackInSlot(slot)) <= 0;
}
This would have been a perfectly reasonable alternative solution to the one I committed, though I generally prefer static access rules versus dynamic access rules that change based on what's currently in the slot.