Use RebornCore's ExtendedRecipeRemainder in the auto crafting table
This commit is contained in:
parent
727bd418fa
commit
8b03986d15
1 changed files with 21 additions and 21 deletions
|
@ -43,6 +43,7 @@ import reborncore.client.containerBuilder.IContainerProvider;
|
||||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
|
import reborncore.common.recipes.ExtendedRecipeRemainder;
|
||||||
import reborncore.common.util.IInventoryAccess;
|
import reborncore.common.util.IInventoryAccess;
|
||||||
import reborncore.common.util.ItemUtils;
|
import reborncore.common.util.ItemUtils;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
|
@ -137,11 +138,6 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
if (stacksInSlots[i] > requiredSize) {
|
if (stacksInSlots[i] > requiredSize) {
|
||||||
if (ingredient.test(stack)) {
|
if (ingredient.test(stack)) {
|
||||||
if (stack.getItem().getRecipeRemainder() != null) {
|
|
||||||
if (!hasRoomForExtraItem(new ItemStack(stack.getItem().getRecipeRemainder()))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foundIngredient = true;
|
foundIngredient = true;
|
||||||
checkedSlots.add(i);
|
checkedSlots.add(i);
|
||||||
stacksInSlots[i]--;
|
stacksInSlots[i]--;
|
||||||
|
@ -195,14 +191,23 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
||||||
// Looks for the best slot to take it from
|
// Looks for the best slot to take it from
|
||||||
ItemStack bestSlot = inventory.getInvStack(i);
|
ItemStack bestSlot = inventory.getInvStack(i);
|
||||||
if (ingredient.test(bestSlot)) {
|
if (ingredient.test(bestSlot)) {
|
||||||
handleContainerItem(bestSlot);
|
ItemStack remainderStack = getRemainderItem(bestSlot);
|
||||||
bestSlot.decrement(1);
|
if(remainderStack.isEmpty()) {
|
||||||
|
bestSlot.decrement(1);
|
||||||
|
} else {
|
||||||
|
inventory.setInvStack(i, remainderStack);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
for (int j = 0; j < 9; j++) {
|
for (int j = 0; j < 9; j++) {
|
||||||
ItemStack stack = inventory.getInvStack(j);
|
ItemStack stack = inventory.getInvStack(j);
|
||||||
if (ingredient.test(stack)) {
|
if (ingredient.test(stack)) {
|
||||||
handleContainerItem(stack);
|
ItemStack remainderStack = getRemainderItem(stack);
|
||||||
stack.decrement(1);
|
if(remainderStack.isEmpty()) {
|
||||||
|
stack.decrement(1);
|
||||||
|
} else {
|
||||||
|
inventory.setInvStack(j, remainderStack);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -218,19 +223,14 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleContainerItem(ItemStack stack) {
|
private ItemStack getRemainderItem(ItemStack stack) {
|
||||||
if (stack.getItem().hasRecipeRemainder()) {
|
if(stack.getItem() instanceof ExtendedRecipeRemainder) {
|
||||||
ItemStack containerItem = new ItemStack(stack.getItem().getRecipeRemainder());
|
return ((ExtendedRecipeRemainder) stack.getItem()).getRemainderStack(stack);
|
||||||
ItemStack extraOutputSlot = inventory.getInvStack(10);
|
|
||||||
if (hasOutputSpace(containerItem, 10)) {
|
} else if (stack.getItem().hasRecipeRemainder()) {
|
||||||
if (extraOutputSlot.isEmpty()) {
|
return new ItemStack(stack.getItem().getRecipeRemainder());
|
||||||
inventory.setInvStack(10, containerItem.copy());
|
|
||||||
} else if (ItemUtils.isItemEqual(extraOutputSlot, containerItem, true, true)
|
|
||||||
&& extraOutputSlot.getMaxCount() < extraOutputSlot.getCount() + containerItem.getCount()) {
|
|
||||||
extraOutputSlot.increment(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getProgress() {
|
public int getProgress() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue