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
src/main/java/WayofTime/bloodmagic/compress

View file

@ -4,31 +4,37 @@ import WayofTime.bloodmagic.api.compress.CompressionHandler;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class BaseCompressionHandler extends CompressionHandler {
public class BaseCompressionHandler extends CompressionHandler
{
private final ItemStack required;
private final ItemStack result;
private final int leftover;
public BaseCompressionHandler(ItemStack requested, ItemStack result, int leftover) {
public BaseCompressionHandler(ItemStack requested, ItemStack result, int leftover)
{
super();
this.required = requested;
this.result = result;
this.leftover = leftover;
}
public ItemStack getResultStack() {
public ItemStack getResultStack()
{
return this.result.copy();
}
public ItemStack getRequiredStack() {
public ItemStack getRequiredStack()
{
return this.required.copy();
}
@Override
public ItemStack compressInventory(ItemStack[] inv, World world) {
public ItemStack compressInventory(ItemStack[] inv, World world)
{
int remaining = this.getRemainingNeeded(inv);
if (remaining <= 0) {
if (remaining <= 0)
{
this.drainInventory(inv);
return this.getResultStack();
}
@ -36,41 +42,51 @@ public class BaseCompressionHandler extends CompressionHandler {
return null;
}
public int getRemainingNeeded(ItemStack[] inv) {
public int getRemainingNeeded(ItemStack[] inv)
{
return iterateThroughInventory(inv, false);
}
public int drainInventory(ItemStack[] inv) {
public int drainInventory(ItemStack[] inv)
{
return iterateThroughInventory(inv, true);
}
public int iterateThroughInventory(ItemStack[] inv, boolean doDrain) {
public int iterateThroughInventory(ItemStack[] inv, boolean doDrain)
{
int needed = this.required.stackSize;
int kept = this.getLeftover();
int i = -1;
for (ItemStack invStack : inv) {
for (ItemStack invStack : inv)
{
i++;
if (invStack == null) {
if (invStack == null)
{
continue;
}
if (invStack.isItemEqual(this.required) && (invStack.getTagCompound() == null ? this.required.getTagCompound() == null : invStack.getTagCompound().equals(this.required.getTagCompound()))) {
if (invStack.isItemEqual(this.required) && (invStack.getTagCompound() == null ? this.required.getTagCompound() == null : invStack.getTagCompound().equals(this.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;
}
}
@ -78,7 +94,8 @@ public class BaseCompressionHandler extends CompressionHandler {
needed -= (stackSize - used - remainingFromStack);
}
if (needed <= 0) {
if (needed <= 0)
{
return 0;
}
}
@ -87,7 +104,8 @@ public class BaseCompressionHandler extends CompressionHandler {
return needed;
}
public int getLeftover() {
public int getLeftover()
{
return this.leftover;
}
}