mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-28 18:04:47 +00:00
Do not refuel beyond the turtle limit (#274)
This commit is contained in:
parent
303b57779a
commit
a2880b12ca
@ -30,9 +30,13 @@ public final class FurnaceRefuelHandler implements TurtleRefuelEvent.Handler
|
|||||||
@Override
|
@Override
|
||||||
public int refuel( @Nonnull ITurtleAccess turtle, @Nonnull ItemStack currentStack, int slot, int limit )
|
public int refuel( @Nonnull ITurtleAccess turtle, @Nonnull ItemStack currentStack, int slot, int limit )
|
||||||
{
|
{
|
||||||
ItemStack stack = turtle.getItemHandler().extractItem( slot, limit, false );
|
int fuelSpaceLeft = turtle.getFuelLimit() - turtle.getFuelLevel();
|
||||||
int fuelToGive = getFuelPerItem( stack ) * stack.getCount();
|
int fuelPerItem = getFuelPerItem( turtle.getItemHandler().getStackInSlot( slot ) );
|
||||||
|
int fuelItemLimit = (int) Math.ceil( fuelSpaceLeft / (double) fuelPerItem );
|
||||||
|
if ( limit > fuelItemLimit ) limit = fuelItemLimit;
|
||||||
|
|
||||||
|
ItemStack stack = turtle.getItemHandler().extractItem( slot, limit, false );
|
||||||
|
int fuelToGive = fuelPerItem * stack.getCount();
|
||||||
// Store the replacement item in the inventory
|
// Store the replacement item in the inventory
|
||||||
ItemStack replacementStack = stack.getItem().getContainerItem( stack );
|
ItemStack replacementStack = stack.getItem().getContainerItem( stack );
|
||||||
if( !replacementStack.isEmpty() )
|
if( !replacementStack.isEmpty() )
|
||||||
|
Loading…
Reference in New Issue
Block a user