Changed formatting to have bracing on a new line

This commit is contained in:
WayofTime 2015-12-30 15:34:40 -05:00
parent e5eddd6c45
commit e48eedb874
189 changed files with 6092 additions and 4041 deletions

View file

@ -8,27 +8,35 @@ import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class AdvancedCompressionHandler extends CompressionHandler {
public class AdvancedCompressionHandler extends CompressionHandler
{
@Override
public ItemStack compressInventory(ItemStack[] inv, World world) {
public ItemStack compressInventory(ItemStack[] inv, World world)
{
return test(inv, true, world);
}
public ItemStack test(ItemStack[] inv, boolean doDrain, World world) {
for (ItemStack invStack : inv) {
if (invStack == null) {
public ItemStack test(ItemStack[] inv, boolean doDrain, World world)
{
for (ItemStack invStack : inv)
{
if (invStack == null)
{
continue;
}
for (int i = 2; i <= 3; i++) {
for (int i = 2; i <= 3; i++)
{
ItemStack stacky = getRecipe(invStack, world, i);
if (stacky != null) {
if (stacky != null)
{
int threshold = CompressionRegistry.getItemThreshold(invStack);
int needed = i * i;
int neededLeft = iterateThroughInventory(invStack, threshold + invStack.getMaxStackSize() - needed, inv, needed, false);
if (neededLeft <= 0) {
if (neededLeft <= 0)
{
iterateThroughInventory(invStack, 0, inv, needed, true);
return stacky;
}
@ -39,31 +47,39 @@ public class AdvancedCompressionHandler extends CompressionHandler {
return null;
}
public int iterateThroughInventory(ItemStack required, int kept, ItemStack[] inv, int needed, boolean doDrain) {
public int iterateThroughInventory(ItemStack required, int kept, ItemStack[] inv, int needed, boolean doDrain)
{
int i = -1;
for (ItemStack invStack : inv) {
for (ItemStack invStack : inv)
{
i++;
if (invStack == null) {
if (invStack == null)
{
continue;
}
if (invStack.isItemEqual(required) && (invStack.getTagCompound() == null ? required.getTagCompound() == null : invStack.getTagCompound().equals(required.getTagCompound()))) {
if (invStack.isItemEqual(required) && (invStack.getTagCompound() == null ? required.getTagCompound() == null : invStack.getTagCompound().equals(required.getTagCompound())))
{
int stackSize = invStack.stackSize;
int used = 0;
if (kept > 0) {
if (kept > 0)
{
int remainingFromStack = Math.max(stackSize - kept, 0);
used += stackSize - remainingFromStack;
}
kept -= used;
if (kept <= 0 && needed > 0) {
if (kept <= 0 && needed > 0)
{
int remainingFromStack = Math.max(stackSize - used - needed, 0);
if (doDrain) {
if (doDrain)
{
invStack.stackSize = remainingFromStack + used;
if (invStack.stackSize <= 0) {
if (invStack.stackSize <= 0)
{
inv[i] = null;
}
}
@ -71,7 +87,8 @@ public class AdvancedCompressionHandler extends CompressionHandler {
needed -= (stackSize - used - remainingFromStack);
}
if (needed <= 0) {
if (needed <= 0)
{
return 0;
}
}
@ -80,12 +97,16 @@ public class AdvancedCompressionHandler extends CompressionHandler {
return needed;
}
public static boolean isResultStackReversible(ItemStack stack, int gridSize, World world) {
if (stack == null) {
public static boolean isResultStackReversible(ItemStack stack, int gridSize, World world)
{
if (stack == null)
{
return false;
}
InventoryCrafting inventory = new InventoryCrafting(new Container() {
public boolean canInteractWith(EntityPlayer player) {
InventoryCrafting inventory = new InventoryCrafting(new Container()
{
public boolean canInteractWith(EntityPlayer player)
{
return false;
}
}, 2, 2);
@ -93,49 +114,59 @@ public class AdvancedCompressionHandler extends CompressionHandler {
inventory.setInventorySlotContents(0, stack);
ItemStack returnStack = StorageBlockCraftingManager.getInstance().findMatchingRecipe(inventory, world);
if (returnStack == null) {
if (returnStack == null)
{
return false;
}
ItemStack compressedStack = null;
switch (gridSize) {
case 2:
compressedStack = get22Recipe(returnStack, world);
break;
case 3:
compressedStack = get33Recipe(returnStack, world);
break;
switch (gridSize)
{
case 2:
compressedStack = get22Recipe(returnStack, world);
break;
case 3:
compressedStack = get33Recipe(returnStack, world);
break;
}
return compressedStack != null && CompressionRegistry.areItemStacksEqual(stack, compressedStack);
}
public static ItemStack getRecipe(ItemStack stack, World world, int gridSize) {
InventoryCrafting inventory = new InventoryCrafting(new Container() {
public boolean canInteractWith(EntityPlayer player) {
public static ItemStack getRecipe(ItemStack stack, World world, int gridSize)
{
InventoryCrafting inventory = new InventoryCrafting(new Container()
{
public boolean canInteractWith(EntityPlayer player)
{
return false;
}
}, gridSize, gridSize);
for (int i = 0; i < inventory.getSizeInventory(); i++) {
for (int i = 0; i < inventory.getSizeInventory(); i++)
{
inventory.setInventorySlotContents(i, stack);
}
return StorageBlockCraftingManager.getInstance().findMatchingRecipe(inventory, world);
}
public static boolean has22Recipe(ItemStack stack, World world) {
public static boolean has22Recipe(ItemStack stack, World world)
{
return get22Recipe(stack, world) != null;
}
public static ItemStack get22Recipe(ItemStack stack, World world) {
public static ItemStack get22Recipe(ItemStack stack, World world)
{
return getRecipe(stack, world, 2);
}
public static boolean has33Recipe(ItemStack stack, World world) {
public static boolean has33Recipe(ItemStack stack, World world)
{
return get33Recipe(stack, world) != null;
}
public static ItemStack get33Recipe(ItemStack stack, World world) {
public static ItemStack get33Recipe(ItemStack stack, World world)
{
return getRecipe(stack, world, 3);
}
}