20w15a
This commit is contained in:
parent
0bf6159801
commit
55f9a5df52
33 changed files with 195 additions and 360 deletions
|
@ -155,16 +155,16 @@ public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEnt
|
|||
}
|
||||
|
||||
if (!isBurning && canSmelt()) {
|
||||
burnTime = totalBurnTime = getItemBurnTime(inventory.getInvStack(fuelSlot));
|
||||
burnTime = totalBurnTime = getItemBurnTime(inventory.getStack(fuelSlot));
|
||||
if (burnTime > 0) {
|
||||
// Fuel slot
|
||||
ItemStack fuelStack = inventory.getInvStack(fuelSlot);
|
||||
ItemStack fuelStack = inventory.getStack(fuelSlot);
|
||||
if (fuelStack.getItem().hasRecipeRemainder()) {
|
||||
inventory.setInvStack(fuelSlot, new ItemStack(fuelStack.getItem().getRecipeRemainder()));
|
||||
inventory.setStack(fuelSlot, new ItemStack(fuelStack.getItem().getRecipeRemainder()));
|
||||
} else if (fuelStack.getCount() > 1) {
|
||||
inventory.shrinkSlot(fuelSlot, 1);
|
||||
} else if (fuelStack.getCount() == 1) {
|
||||
inventory.setInvStack(fuelSlot, ItemStack.EMPTY);
|
||||
inventory.setStack(fuelSlot, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class IronAlloyFurnaceBlockEntity extends AbstractIronMachineBlockEntity
|
|||
for (RebornIngredient ingredient : recipeType.getRebornIngredients()) {
|
||||
boolean hasItem = false;
|
||||
for (int inputslot = 0; inputslot < 2; inputslot++) {
|
||||
if (ingredient.test(inventory.getInvStack(inputslot))) {
|
||||
if (ingredient.test(inventory.getStack(inputslot))) {
|
||||
hasItem = true;
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class IronAlloyFurnaceBlockEntity extends AbstractIronMachineBlockEntity
|
|||
|
||||
@Override
|
||||
protected boolean canSmelt() {
|
||||
if (inventory.getInvStack(input1).isEmpty() || inventory.getInvStack(input2).isEmpty()) {
|
||||
if (inventory.getStack(input1).isEmpty() || inventory.getStack(input2).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
ItemStack itemstack = null;
|
||||
|
@ -79,12 +79,12 @@ public class IronAlloyFurnaceBlockEntity extends AbstractIronMachineBlockEntity
|
|||
|
||||
if (itemstack == null)
|
||||
return false;
|
||||
if (inventory.getInvStack(output).isEmpty())
|
||||
if (inventory.getStack(output).isEmpty())
|
||||
return true;
|
||||
if (!inventory.getInvStack(output).isItemEqualIgnoreDamage(itemstack))
|
||||
if (!inventory.getStack(output).isItemEqualIgnoreDamage(itemstack))
|
||||
return false;
|
||||
int result = inventory.getInvStack(output).getCount() + itemstack.getCount();
|
||||
return result <= inventory.getStackLimit() && result <= inventory.getInvStack(output).getMaxCount();
|
||||
int result = inventory.getStack(output).getCount() + itemstack.getCount();
|
||||
return result <= inventory.getStackLimit() && result <= inventory.getStack(output).getMaxCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -108,15 +108,15 @@ public class IronAlloyFurnaceBlockEntity extends AbstractIronMachineBlockEntity
|
|||
if (outputStack.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (inventory.getInvStack(output).isEmpty()) {
|
||||
inventory.setInvStack(output, outputStack.copy());
|
||||
} else if (inventory.getInvStack(output).getItem() == outputStack.getItem()) {
|
||||
if (inventory.getStack(output).isEmpty()) {
|
||||
inventory.setStack(output, outputStack.copy());
|
||||
} else if (inventory.getStack(output).getItem() == outputStack.getItem()) {
|
||||
inventory.shrinkSlot(output, -outputStack.getCount());
|
||||
}
|
||||
|
||||
for (RebornIngredient ingredient : currentRecipe.getRebornIngredients()) {
|
||||
for (int inputSlot = 0; inputSlot < 2; inputSlot++) {
|
||||
if (ingredient.test(inventory.getInvStack(inputSlot))) {
|
||||
if (ingredient.test(inventory.getStack(inputSlot))) {
|
||||
inventory.shrinkSlot(inputSlot, ingredient.getCount());
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -88,35 +88,35 @@ public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity imple
|
|||
if (!canSmelt()) {
|
||||
return;
|
||||
}
|
||||
ItemStack inputStack = inventory.getInvStack(inputSlot);
|
||||
ItemStack inputStack = inventory.getStack(inputSlot);
|
||||
ItemStack resultStack = getResultFor(inputStack);
|
||||
|
||||
if (inventory.getInvStack(outputSlot).isEmpty()) {
|
||||
inventory.setInvStack(outputSlot, resultStack.copy());
|
||||
} else if (inventory.getInvStack(outputSlot).isItemEqualIgnoreDamage(resultStack)) {
|
||||
inventory.getInvStack(outputSlot).increment(resultStack.getCount());
|
||||
if (inventory.getStack(outputSlot).isEmpty()) {
|
||||
inventory.setStack(outputSlot, resultStack.copy());
|
||||
} else if (inventory.getStack(outputSlot).isItemEqualIgnoreDamage(resultStack)) {
|
||||
inventory.getStack(outputSlot).increment(resultStack.getCount());
|
||||
}
|
||||
experience += getExperienceFor(inputStack);
|
||||
if (inputStack.getCount() > 1) {
|
||||
inventory.shrinkSlot(inputSlot, 1);
|
||||
} else {
|
||||
inventory.setInvStack(inputSlot, ItemStack.EMPTY);
|
||||
inventory.setStack(inputSlot, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canSmelt() {
|
||||
if (inventory.getInvStack(inputSlot).isEmpty()) {
|
||||
if (inventory.getStack(inputSlot).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
ItemStack outputStack = getResultFor(inventory.getInvStack(inputSlot));
|
||||
ItemStack outputStack = getResultFor(inventory.getStack(inputSlot));
|
||||
if (outputStack.isEmpty())
|
||||
return false;
|
||||
if (inventory.getInvStack(outputSlot).isEmpty())
|
||||
if (inventory.getStack(outputSlot).isEmpty())
|
||||
return true;
|
||||
if (!inventory.getInvStack(outputSlot).isItemEqualIgnoreDamage(outputStack))
|
||||
if (!inventory.getStack(outputSlot).isItemEqualIgnoreDamage(outputStack))
|
||||
return false;
|
||||
int result = inventory.getInvStack(outputSlot).getCount() + outputStack.getCount();
|
||||
int result = inventory.getStack(outputSlot).getCount() + outputStack.getCount();
|
||||
return result <= inventory.getStackLimit() && result <= outputStack.getMaxCount();
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ public class ChargeOMatBlockEntity extends PowerAcceptorBlockEntity
|
|||
return;
|
||||
}
|
||||
for (int i = 0; i < 6; i++) {
|
||||
ItemStack stack = inventory.getInvStack(i);
|
||||
ItemStack stack = inventory.getStack(i);
|
||||
|
||||
if (Energy.valid(stack)) {
|
||||
Energy.of(this)
|
||||
|
|
|
@ -83,7 +83,7 @@ public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implem
|
|||
ticksSinceLastChange++;
|
||||
// Check cells input slot 2 time per second
|
||||
if (!world.isClient && ticksSinceLastChange >= 10) {
|
||||
if (!inventory.getInvStack(1).isEmpty()) {
|
||||
if (!inventory.getStack(1).isEmpty()) {
|
||||
FluidUtils.fillContainers(tank, inventory, 1, 2, tank.getFluid());
|
||||
}
|
||||
ticksSinceLastChange = 0;
|
||||
|
|
|
@ -126,11 +126,11 @@ public class FusionControlComputerBlockEntity extends PowerAcceptorBlockEntity
|
|||
if (stack.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
if (inventory.getInvStack(slot).isEmpty()) {
|
||||
if (inventory.getStack(slot).isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
if (ItemUtils.isItemEqual(inventory.getInvStack(slot), stack, true, tags)) {
|
||||
return stack.getCount() + inventory.getInvStack(slot).getCount() <= stack.getMaxCount();
|
||||
if (ItemUtils.isItemEqual(inventory.getStack(slot), stack, true, tags)) {
|
||||
return stack.getCount() + inventory.getStack(slot).getCount() <= stack.getMaxCount();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -186,8 +186,8 @@ public class FusionControlComputerBlockEntity extends PowerAcceptorBlockEntity
|
|||
}
|
||||
for (RebornIngredient ingredient : recipeType.getRebornIngredients()) {
|
||||
boolean hasItem = false;
|
||||
if (ingredient.test(inventory.getInvStack(topStackSlot))
|
||||
|| ingredient.test(inventory.getInvStack(bottomStackSlot))) {
|
||||
if (ingredient.test(inventory.getStack(topStackSlot))
|
||||
|| ingredient.test(inventory.getStack(bottomStackSlot))) {
|
||||
hasItem = true;
|
||||
}
|
||||
if (!hasItem) {
|
||||
|
@ -207,7 +207,7 @@ public class FusionControlComputerBlockEntity extends PowerAcceptorBlockEntity
|
|||
return;
|
||||
}
|
||||
for (RebornIngredient ingredient : currentRecipe.getRebornIngredients()) {
|
||||
if (ingredient.test(inventory.getInvStack(slot))) {
|
||||
if (ingredient.test(inventory.getStack(slot))) {
|
||||
inventory.shrinkSlot(slot, ingredient.getCount());
|
||||
break;
|
||||
}
|
||||
|
@ -288,8 +288,8 @@ public class FusionControlComputerBlockEntity extends PowerAcceptorBlockEntity
|
|||
} else if (crafingTickTime >= currentRecipe.getTime()) {
|
||||
ItemStack result = currentRecipe.getOutputs().get(0);
|
||||
if (canFitStack(result, outputStackSlot, true)) {
|
||||
if (inventory.getInvStack(outputStackSlot).isEmpty()) {
|
||||
inventory.setInvStack(outputStackSlot, result.copy());
|
||||
if (inventory.getStack(outputStackSlot).isEmpty()) {
|
||||
inventory.setStack(outputStackSlot, result.copy());
|
||||
} else {
|
||||
inventory.shrinkSlot(outputStackSlot, -result.getCount());
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ public class IndustrialGrinderBlockEntity extends GenericMachineBlockEntity impl
|
|||
ticksSinceLastChange++;
|
||||
// Check cells input slot 2 time per second
|
||||
if (!world.isClient && ticksSinceLastChange >= 10) {
|
||||
if (!inventory.getInvStack(1).isEmpty()) {
|
||||
if (!inventory.getStack(1).isEmpty()) {
|
||||
FluidUtils.drainContainers(tank, inventory, 1, 6);
|
||||
FluidUtils.fillContainers(tank, inventory, 1, 6, tank.getFluid());
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ public class IndustrialSawmillBlockEntity extends GenericMachineBlockEntity impl
|
|||
ticksSinceLastChange++;
|
||||
// Check cells input slot 2 time per second
|
||||
if (!world.isClient && ticksSinceLastChange >= 10) {
|
||||
if (!inventory.getInvStack(1).isEmpty()) {
|
||||
if (!inventory.getStack(1).isEmpty()) {
|
||||
FluidUtils.drainContainers(tank, inventory, 1, 5);
|
||||
FluidUtils.fillContainers(tank, inventory, 1, 5, tank.getFluidInstance().getFluid());
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
|||
@Nullable
|
||||
public CraftingRecipe getCurrentRecipe() {
|
||||
CraftingInventory crafting = getCraftingInventory();
|
||||
if (!crafting.isInvEmpty()) {
|
||||
if (!crafting.isEmpty()) {
|
||||
if (lastRecipe != null) {
|
||||
if (lastRecipe.matches(crafting, world)) {
|
||||
return lastRecipe;
|
||||
|
@ -108,7 +108,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
|||
}, 3, 3);
|
||||
}
|
||||
for (int i = 0; i < 9; i++) {
|
||||
inventoryCrafting.setInvStack(i, inventory.getInvStack(i));
|
||||
inventoryCrafting.setStack(i, inventory.getStack(i));
|
||||
}
|
||||
return inventoryCrafting;
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
|||
boolean missingOutput = false;
|
||||
int[] stacksInSlots = new int[9];
|
||||
for (int i = 0; i < 9; i++) {
|
||||
stacksInSlots[i] = inventory.getInvStack(i).getCount();
|
||||
stacksInSlots[i] = inventory.getStack(i).getCount();
|
||||
}
|
||||
|
||||
DefaultedList<Ingredient> ingredients = recipe.getPreviewInputs();
|
||||
|
@ -130,7 +130,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
|||
if(checkedSlots.contains(i)) {
|
||||
continue;
|
||||
}
|
||||
ItemStack stack = inventory.getInvStack(i);
|
||||
ItemStack stack = inventory.getStack(i);
|
||||
int requiredSize = locked ? 1 : 0;
|
||||
if (stack.getMaxCount() == 1) {
|
||||
requiredSize = 0;
|
||||
|
@ -160,7 +160,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
|||
}
|
||||
|
||||
boolean hasRoomForExtraItem(ItemStack stack) {
|
||||
ItemStack extraOutputSlot = inventory.getInvStack(10);
|
||||
ItemStack extraOutputSlot = inventory.getStack(10);
|
||||
if (extraOutputSlot.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
|||
}
|
||||
|
||||
public boolean hasOutputSpace(ItemStack output, int slot) {
|
||||
ItemStack stack = inventory.getInvStack(slot);
|
||||
ItemStack stack = inventory.getStack(slot);
|
||||
if (stack.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
@ -188,34 +188,34 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
|||
DefaultedList<Ingredient> ingredients = recipe.getPreviewInputs();
|
||||
Ingredient ingredient = ingredients.get(i);
|
||||
// Looks for the best slot to take it from
|
||||
ItemStack bestSlot = inventory.getInvStack(i);
|
||||
ItemStack bestSlot = inventory.getStack(i);
|
||||
if (ingredient.test(bestSlot)) {
|
||||
ItemStack remainderStack = getRemainderItem(bestSlot);
|
||||
if(remainderStack.isEmpty()) {
|
||||
bestSlot.decrement(1);
|
||||
} else {
|
||||
inventory.setInvStack(i, remainderStack);
|
||||
inventory.setStack(i, remainderStack);
|
||||
}
|
||||
|
||||
} else {
|
||||
for (int j = 0; j < 9; j++) {
|
||||
ItemStack stack = inventory.getInvStack(j);
|
||||
ItemStack stack = inventory.getStack(j);
|
||||
if (ingredient.test(stack)) {
|
||||
ItemStack remainderStack = getRemainderItem(stack);
|
||||
if(remainderStack.isEmpty()) {
|
||||
stack.decrement(1);
|
||||
} else {
|
||||
inventory.setInvStack(j, remainderStack);
|
||||
inventory.setStack(j, remainderStack);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ItemStack output = inventory.getInvStack(9);
|
||||
ItemStack output = inventory.getStack(9);
|
||||
ItemStack outputStack = recipe.craft(getCraftingInventory());
|
||||
if (output.isEmpty()) {
|
||||
inventory.setInvStack(9, outputStack.copy());
|
||||
inventory.setStack(9, outputStack.copy());
|
||||
} else {
|
||||
output.increment(recipe.getOutput().getCount());
|
||||
}
|
||||
|
@ -295,15 +295,15 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
|||
if (world.isClient) {
|
||||
return Optional.empty();
|
||||
}
|
||||
if (craftCache.isInvEmpty()) {
|
||||
if (craftCache.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
balanceSlot++;
|
||||
if (balanceSlot > craftCache.getInvSize()) {
|
||||
if (balanceSlot > craftCache.size()) {
|
||||
balanceSlot = 0;
|
||||
}
|
||||
//Find the best slot for each item in a recipe, and move it if needed
|
||||
ItemStack sourceStack = inventory.getInvStack(balanceSlot);
|
||||
ItemStack sourceStack = inventory.getStack(balanceSlot);
|
||||
if (sourceStack.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
|||
if(possibleSlots.contains(i)) {
|
||||
continue;
|
||||
}
|
||||
ItemStack stackInSlot = inventory.getInvStack(i);
|
||||
ItemStack stackInSlot = inventory.getStack(i);
|
||||
Ingredient ingredient = currentRecipe.getPreviewInputs().get(s);
|
||||
if (ingredient != Ingredient.EMPTY && ingredient.test(sourceStack)) {
|
||||
if (stackInSlot.getItem() == sourceStack.getItem()) {
|
||||
|
@ -327,7 +327,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
|||
|
||||
if(!possibleSlots.isEmpty()){
|
||||
int totalItems = possibleSlots.stream()
|
||||
.mapToInt(value -> inventory.getInvStack(value).getCount()).sum();
|
||||
.mapToInt(value -> inventory.getStack(value).getCount()).sum();
|
||||
int slots = possibleSlots.size();
|
||||
|
||||
//This makes an array of ints with the best possible slot EnvTyperibution
|
||||
|
@ -344,7 +344,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
|||
}
|
||||
|
||||
List<Integer> slotEnvTyperubution = possibleSlots.stream()
|
||||
.mapToInt(value -> inventory.getInvStack(value).getCount())
|
||||
.mapToInt(value -> inventory.getStack(value).getCount())
|
||||
.boxed().collect(Collectors.toList());
|
||||
|
||||
boolean needsBalance = false;
|
||||
|
@ -367,7 +367,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
|||
//Slot, count
|
||||
Pair<Integer, Integer> bestSlot = null;
|
||||
for (Integer slot : possibleSlots) {
|
||||
ItemStack slotStack = inventory.getInvStack(slot);
|
||||
ItemStack slotStack = inventory.getStack(slot);
|
||||
if (slotStack.isEmpty()) {
|
||||
bestSlot = Pair.of(slot, 0);
|
||||
}
|
||||
|
@ -380,12 +380,12 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
|||
if (bestSlot == null
|
||||
|| bestSlot.getLeft() == balanceSlot
|
||||
|| bestSlot.getRight() == sourceStack.getCount()
|
||||
|| inventory.getInvStack(bestSlot.getLeft()).isEmpty()
|
||||
|| !ItemUtils.isItemEqual(sourceStack, inventory.getInvStack(bestSlot.getLeft()), true, true)) {
|
||||
|| inventory.getStack(bestSlot.getLeft()).isEmpty()
|
||||
|| !ItemUtils.isItemEqual(sourceStack, inventory.getStack(bestSlot.getLeft()), true, true)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
sourceStack.decrement(1);
|
||||
inventory.getInvStack(bestSlot.getLeft()).increment(1);
|
||||
inventory.getStack(bestSlot.getLeft()).increment(1);
|
||||
inventory.setChanged();
|
||||
|
||||
return Optional.of(getCraftingInventory());
|
||||
|
|
|
@ -72,7 +72,7 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
|
|||
}
|
||||
|
||||
private void updateCurrentRecipe() {
|
||||
if (inventory.getInvStack(inputSlot).isEmpty()) {
|
||||
if (inventory.getStack(inputSlot).isEmpty()) {
|
||||
resetCrafter();
|
||||
return;
|
||||
}
|
||||
|
@ -95,17 +95,17 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
|
|||
if (recipeOutput.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
if (inventory.getInvStack(slot).isEmpty()) {
|
||||
if (inventory.getStack(slot).isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
if (ItemUtils.isItemEqual(inventory.getInvStack(slot), recipeOutput, true, true)) {
|
||||
return recipeOutput.getCount() + inventory.getInvStack(slot).getCount() <= recipeOutput.getMaxCount();
|
||||
if (ItemUtils.isItemEqual(inventory.getStack(slot), recipeOutput, true, true)) {
|
||||
return recipeOutput.getCount() + inventory.getStack(slot).getCount() <= recipeOutput.getMaxCount();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canCraftAgain() {
|
||||
if (inventory.getInvStack(inputSlot).isEmpty()) {
|
||||
if (inventory.getStack(inputSlot).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
if (currentRecipe == null) {
|
||||
|
@ -139,7 +139,7 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
|
|||
if (recipe == null) {
|
||||
return false;
|
||||
}
|
||||
if (inventory.getInvStack(inputSlot).isEmpty()) {
|
||||
if (inventory.getStack(inputSlot).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -153,16 +153,16 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
|
|||
if (!canAcceptOutput(recipe, outputSlot)) {
|
||||
return;
|
||||
}
|
||||
ItemStack outputStack = inventory.getInvStack(outputSlot);
|
||||
ItemStack outputStack = inventory.getStack(outputSlot);
|
||||
if (outputStack.isEmpty()) {
|
||||
inventory.setInvStack(outputSlot, recipe.getOutput().copy());
|
||||
inventory.setStack(outputSlot, recipe.getOutput().copy());
|
||||
}
|
||||
else {
|
||||
// Just increment. We already checked stack match and stack size
|
||||
outputStack.increment(1);
|
||||
}
|
||||
|
||||
inventory.getInvStack(inputSlot).decrement(1);
|
||||
inventory.getStack(inputSlot).decrement(1);
|
||||
}
|
||||
|
||||
public int getProgressScaled(int scale) {
|
||||
|
|
|
@ -192,9 +192,9 @@ public class GreenhouseControllerBlockEntity extends PowerAcceptorBlockEntity
|
|||
}
|
||||
|
||||
private boolean insertIntoInv(int slot, ItemStack stack) {
|
||||
ItemStack targetStack = inventory.getInvStack(slot);
|
||||
ItemStack targetStack = inventory.getStack(slot);
|
||||
if (targetStack.isEmpty()) {
|
||||
inventory.setInvStack(slot, stack.copy());
|
||||
inventory.setStack(slot, stack.copy());
|
||||
stack.decrement(stack.getCount());
|
||||
return true;
|
||||
} else {
|
||||
|
|
|
@ -75,24 +75,24 @@ public class RecyclerBlockEntity extends PowerAcceptorBlockEntity
|
|||
final int randomchance = this.world.random.nextInt(chance);
|
||||
|
||||
if (randomchance == 1) {
|
||||
if (inventory.getInvStack(1).isEmpty()) {
|
||||
inventory.setInvStack(1, itemstack.copy());
|
||||
if (inventory.getStack(1).isEmpty()) {
|
||||
inventory.setStack(1, itemstack.copy());
|
||||
}
|
||||
else {
|
||||
inventory.getInvStack(1).increment(itemstack.getCount());
|
||||
inventory.getStack(1).increment(itemstack.getCount());
|
||||
}
|
||||
}
|
||||
inventory.shrinkSlot(0, 1);
|
||||
}
|
||||
|
||||
public boolean canRecycle() {
|
||||
return !inventory.getInvStack(0) .isEmpty() && hasSlotGotSpace(1);
|
||||
return !inventory.getStack(0) .isEmpty() && hasSlotGotSpace(1);
|
||||
}
|
||||
|
||||
public boolean hasSlotGotSpace(int slot) {
|
||||
if (inventory.getInvStack(slot).isEmpty()) {
|
||||
if (inventory.getStack(slot).isEmpty()) {
|
||||
return true;
|
||||
} else if (inventory.getInvStack(slot).getCount() < inventory.getInvStack(slot).getMaxCount()) {
|
||||
} else if (inventory.getStack(slot).getCount() < inventory.getStack(slot).getMaxCount()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -131,16 +131,16 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
|||
currentRecipeOutput = findMatchingRecipeOutput(craftMatrix, world);
|
||||
if (!currentRecipeOutput.isEmpty()) {
|
||||
boolean hasCrafted = false;
|
||||
if (inventory.getInvStack(outputSlot).isEmpty()) {
|
||||
inventory.setInvStack(outputSlot, currentRecipeOutput.copy());
|
||||
if (inventory.getStack(outputSlot).isEmpty()) {
|
||||
inventory.setStack(outputSlot, currentRecipeOutput.copy());
|
||||
tickTime = 0;
|
||||
hasCrafted = true;
|
||||
} else {
|
||||
if (inventory.getInvStack(outputSlot).getCount()
|
||||
if (inventory.getStack(outputSlot).getCount()
|
||||
+ currentRecipeOutput.getCount() <= currentRecipeOutput.getMaxCount()) {
|
||||
final ItemStack stack = inventory.getInvStack(outputSlot);
|
||||
final ItemStack stack = inventory.getStack(outputSlot);
|
||||
stack.setCount(stack.getCount() + currentRecipeOutput.getCount());
|
||||
inventory.setInvStack(outputSlot, stack);
|
||||
inventory.setStack(outputSlot, stack);
|
||||
tickTime = 0;
|
||||
hasCrafted = true;
|
||||
} else {
|
||||
|
@ -148,7 +148,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
|||
}
|
||||
}
|
||||
if (hasCrafted) {
|
||||
for (int i = 0; i < craftMatrix.getInvSize(); i++) {
|
||||
for (int i = 0; i < craftMatrix.size(); i++) {
|
||||
inventory.shrinkSlot(i, 1);
|
||||
}
|
||||
currentRecipeOutput = ItemStack.EMPTY;
|
||||
|
@ -198,21 +198,21 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
|||
if (!locked) {
|
||||
return Optional.empty();
|
||||
}
|
||||
if (craftCache.isInvEmpty()) {
|
||||
if (craftCache.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
balanceSlot++;
|
||||
if (balanceSlot > craftCache.getInvSize()) {
|
||||
if (balanceSlot > craftCache.size()) {
|
||||
balanceSlot = 0;
|
||||
}
|
||||
//Find the best slot for each item in a recipe, and move it if needed
|
||||
ItemStack sourceStack = inventory.getInvStack(balanceSlot);
|
||||
ItemStack sourceStack = inventory.getStack(balanceSlot);
|
||||
if (sourceStack.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
List<Integer> possibleSlots = new ArrayList<>();
|
||||
for (int s = 0; s < currentRecipe.getPreviewInputs().size(); s++) {
|
||||
ItemStack stackInSlot = inventory.getInvStack(s);
|
||||
ItemStack stackInSlot = inventory.getStack(s);
|
||||
Ingredient ingredient = (Ingredient) currentRecipe.getPreviewInputs().get(s);
|
||||
if (ingredient != Ingredient.EMPTY && ingredient.test(sourceStack)) {
|
||||
if (stackInSlot.isEmpty()) {
|
||||
|
@ -225,7 +225,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
|||
|
||||
if(!possibleSlots.isEmpty()){
|
||||
int totalItems = possibleSlots.stream()
|
||||
.mapToInt(value -> inventory.getInvStack(value).getCount()).sum();
|
||||
.mapToInt(value -> inventory.getStack(value).getCount()).sum();
|
||||
int slots = possibleSlots.size();
|
||||
|
||||
//This makes an array of ints with the best possible slot EnvTyperibution
|
||||
|
@ -242,7 +242,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
|||
}
|
||||
|
||||
List<Integer> slotEnvTyperubution = possibleSlots.stream()
|
||||
.mapToInt(value -> inventory.getInvStack(value).getCount())
|
||||
.mapToInt(value -> inventory.getStack(value).getCount())
|
||||
.boxed().collect(Collectors.toList());
|
||||
|
||||
boolean needsBalance = false;
|
||||
|
@ -265,7 +265,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
|||
//Slot, count
|
||||
Pair<Integer, Integer> bestSlot = null;
|
||||
for (Integer slot : possibleSlots) {
|
||||
ItemStack slotStack = inventory.getInvStack(slot);
|
||||
ItemStack slotStack = inventory.getStack(slot);
|
||||
if (slotStack.isEmpty()) {
|
||||
bestSlot = Pair.of(slot, 0);
|
||||
}
|
||||
|
@ -278,12 +278,12 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
|||
if (bestSlot == null
|
||||
|| bestSlot.getLeft() == balanceSlot
|
||||
|| bestSlot.getRight() == sourceStack.getCount()
|
||||
|| inventory.getInvStack(bestSlot.getLeft()).isEmpty()
|
||||
|| !ItemUtils.isItemEqual(sourceStack, inventory.getInvStack(bestSlot.getLeft()), true, true)) {
|
||||
|| inventory.getStack(bestSlot.getLeft()).isEmpty()
|
||||
|| !ItemUtils.isItemEqual(sourceStack, inventory.getStack(bestSlot.getLeft()), true, true)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
sourceStack.decrement(1);
|
||||
inventory.getInvStack(bestSlot.getLeft()).increment(1);
|
||||
inventory.getStack(bestSlot.getLeft()).increment(1);
|
||||
inventory.setChanged();
|
||||
|
||||
return Optional.of(getCraftingMatrix());
|
||||
|
@ -295,7 +295,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
|||
}
|
||||
if (inventory.hasChanged()) {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
craftCache.setInvStack(i, inventory.getInvStack(i).copy());
|
||||
craftCache.setStack(i, inventory.getStack(i).copy());
|
||||
}
|
||||
inventory.resetChanged();
|
||||
}
|
||||
|
@ -305,8 +305,8 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
|||
public boolean canMake(CraftingInventory craftMatrix) {
|
||||
ItemStack stack = findMatchingRecipeOutput(craftMatrix, this.world);
|
||||
if (locked) {
|
||||
for (int i = 0; i < craftMatrix.getInvSize(); i++) {
|
||||
ItemStack stack1 = craftMatrix.getInvStack(i);
|
||||
for (int i = 0; i < craftMatrix.size(); i++) {
|
||||
ItemStack stack1 = craftMatrix.getStack(i);
|
||||
if (!stack1.isEmpty() && stack1.getCount() < 2) {
|
||||
return false;
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
|||
if (stack.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
ItemStack output = inventory.getInvStack(outputSlot);
|
||||
ItemStack output = inventory.getStack(outputSlot);
|
||||
if (output.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
@ -393,7 +393,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
|||
.slot(0, 30, 22).slot(1, 48, 22).slot(2, 66, 22)
|
||||
.slot(3, 30, 40).slot(4, 48, 40).slot(5, 66, 40)
|
||||
.slot(6, 30, 58).slot(7, 48, 58).slot(8, 66, 58)
|
||||
.onCraft(inv -> this.inventory.setInvStack(1, findMatchingRecipeOutput(getCraftingMatrix(), this.world)))
|
||||
.onCraft(inv -> this.inventory.setStack(1, findMatchingRecipeOutput(getCraftingMatrix(), this.world)))
|
||||
.outputSlot(9, 124, 40)
|
||||
.energySlot(10, 8, 70)
|
||||
.syncEnergyValue().sync(this::getBurnTime, this::setBurnTime).sync(this::getLockedInt, this::setLockedInt).addInventory().create(this, syncID);
|
||||
|
|
|
@ -59,9 +59,9 @@ public class MatterFabricatorBlockEntity extends PowerAcceptorBlockEntity
|
|||
}
|
||||
|
||||
private boolean spaceForOutput(int slot) {
|
||||
return inventory.getInvStack(slot).isEmpty()
|
||||
|| ItemUtils.isItemEqual(inventory.getInvStack(slot), TRContent.Parts.UU_MATTER.getStack(), true, true)
|
||||
&& inventory.getInvStack(slot).getCount() < 64;
|
||||
return inventory.getStack(slot).isEmpty()
|
||||
|| ItemUtils.isItemEqual(inventory.getStack(slot), TRContent.Parts.UU_MATTER.getStack(), true, true)
|
||||
&& inventory.getStack(slot).getCount() < 64;
|
||||
}
|
||||
|
||||
private void addOutputProducts() {
|
||||
|
@ -74,11 +74,11 @@ public class MatterFabricatorBlockEntity extends PowerAcceptorBlockEntity
|
|||
}
|
||||
|
||||
private void addOutputProducts(int slot) {
|
||||
if (inventory.getInvStack(slot).isEmpty()) {
|
||||
inventory.setInvStack(slot, TRContent.Parts.UU_MATTER.getStack());
|
||||
if (inventory.getStack(slot).isEmpty()) {
|
||||
inventory.setStack(slot, TRContent.Parts.UU_MATTER.getStack());
|
||||
}
|
||||
else if (ItemUtils.isItemEqual(this.inventory.getInvStack(slot), TRContent.Parts.UU_MATTER.getStack(), true, true)) {
|
||||
inventory.getInvStack(slot).setCount((Math.min(64, 1 + inventory.getInvStack(slot).getCount())));
|
||||
else if (ItemUtils.isItemEqual(this.inventory.getStack(slot), TRContent.Parts.UU_MATTER.getStack(), true, true)) {
|
||||
inventory.getStack(slot).setCount((Math.min(64, 1 + inventory.getStack(slot).getCount())));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ public class MatterFabricatorBlockEntity extends PowerAcceptorBlockEntity
|
|||
this.charge(11);
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
final ItemStack stack = inventory.getInvStack(i);
|
||||
final ItemStack stack = inventory.getStack(i);
|
||||
if (!stack.isEmpty() && spaceForOutput()) {
|
||||
final int amp = getValue(stack);
|
||||
final int euNeeded = amp * TechRebornConfig.matterFabricatorEnergyPerAmp;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue