Run formatter

This commit is contained in:
Nicholas Ignoffo 2017-08-15 21:30:48 -07:00
parent 61c44a831b
commit 08258fd6ef
606 changed files with 13464 additions and 22975 deletions

View file

@ -1,9 +1,13 @@
package WayofTime.bloodmagic.tile;
import java.util.ArrayList;
import java.util.List;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.orb.BloodOrb;
import WayofTime.bloodmagic.api.orb.IBloodOrb;
import WayofTime.bloodmagic.api.recipe.AlchemyTableRecipe;
import WayofTime.bloodmagic.api.registry.AlchemyTableRecipeRegistry;
import WayofTime.bloodmagic.api.saving.SoulNetwork;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import com.google.common.base.Strings;
import net.minecraft.block.state.IBlockState;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
@ -16,17 +20,11 @@ import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.ItemHandlerHelper;
import net.minecraftforge.items.wrapper.SidedInvWrapper;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.saving.SoulNetwork;
import WayofTime.bloodmagic.api.orb.IBloodOrb;
import WayofTime.bloodmagic.api.recipe.AlchemyTableRecipe;
import WayofTime.bloodmagic.api.registry.AlchemyTableRecipeRegistry;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import com.google.common.base.Strings;
import java.util.ArrayList;
import java.util.List;
public class TileAlchemyTable extends TileInventory implements ISidedInventory, ITickable
{
public class TileAlchemyTable extends TileInventory implements ISidedInventory, ITickable {
public static final int orbSlot = 6;
public static final int toolSlot = 7;
public static final int outputSlot = 8;
@ -37,26 +35,22 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
public int ticksRequired = 1;
public BlockPos connectedPos = BlockPos.ORIGIN;
public boolean[] blockedSlots = new boolean[] { false, false, false, false, false, false };
public boolean[] blockedSlots = new boolean[]{false, false, false, false, false, false};
public TileAlchemyTable()
{
public TileAlchemyTable() {
super(9, "alchemyTable");
}
public void setInitialTableParameters(EnumFacing direction, boolean isSlave, BlockPos connectedPos)
{
public void setInitialTableParameters(EnumFacing direction, boolean isSlave, BlockPos connectedPos) {
this.isSlave = isSlave;
this.connectedPos = connectedPos;
if (!isSlave)
{
if (!isSlave) {
this.direction = direction;
}
}
public boolean isInvisible()
{
public boolean isInvisible() {
return isSlave();
}
@ -64,15 +58,13 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
return !(slot < 6 && slot >= 0) || !blockedSlots[slot];
}
public void toggleInputSlotAccessible(int slot)
{
public void toggleInputSlotAccessible(int slot) {
if (slot < 6 && slot >= 0)
blockedSlots[slot] = !blockedSlots[slot];
}
@Override
public void deserialize(NBTTagCompound tag)
{
public void deserialize(NBTTagCompound tag) {
super.deserialize(tag);
isSlave = tag.getBoolean("isSlave");
@ -88,8 +80,7 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
}
@Override
public NBTTagCompound serialize(NBTTagCompound tag)
{
public NBTTagCompound serialize(NBTTagCompound tag) {
super.serialize(tag);
tag.setBoolean("isSlave", isSlave);
@ -111,19 +102,14 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing)
{
if (facing != null && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
{
if (this.isSlave())
{
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
if (facing != null && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
if (this.isSlave()) {
TileEntity tile = getWorld().getTileEntity(connectedPos);
if (tile instanceof TileAlchemyTable)
{
if (tile instanceof TileAlchemyTable) {
return (T) new SidedInvWrapper((TileAlchemyTable) tile, facing);
}
} else
{
} else {
return (T) new SidedInvWrapper(this, facing);
}
}
@ -132,73 +118,58 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
}
@Override
public int[] getSlotsForFace(EnumFacing side)
{
switch (side)
{
case DOWN:
return new int[] { outputSlot };
case UP:
return new int[] { orbSlot, toolSlot };
default:
return new int[] { 0, 1, 2, 3, 4, 5 };
public int[] getSlotsForFace(EnumFacing side) {
switch (side) {
case DOWN:
return new int[]{outputSlot};
case UP:
return new int[]{orbSlot, toolSlot};
default:
return new int[]{0, 1, 2, 3, 4, 5};
}
}
@Override
public boolean canInsertItem(int index, ItemStack stack, EnumFacing direction)
{
switch (direction)
{
case DOWN:
return index != outputSlot && index != orbSlot && index != toolSlot;
case UP:
if (index == orbSlot && !stack.isEmpty() && stack.getItem() instanceof IBloodOrb)
{
return true;
} else if (index == toolSlot)
{
return false; //TODO:
} else
{
return true;
}
default:
return getAccessibleInputSlots(direction).contains(index);
public boolean canInsertItem(int index, ItemStack stack, EnumFacing direction) {
switch (direction) {
case DOWN:
return index != outputSlot && index != orbSlot && index != toolSlot;
case UP:
if (index == orbSlot && !stack.isEmpty() && stack.getItem() instanceof IBloodOrb) {
return true;
} else if (index == toolSlot) {
return false; //TODO:
} else {
return true;
}
default:
return getAccessibleInputSlots(direction).contains(index);
}
}
@Override
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction)
{
switch (direction)
{
case DOWN:
return index == outputSlot;
case UP:
if (index == orbSlot && !stack.isEmpty() && stack.getItem() instanceof IBloodOrb)
{
return true;
} else if (index == toolSlot)
{
return true; //TODO:
} else
{
return true;
}
default:
return getAccessibleInputSlots(direction).contains(index);
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
switch (direction) {
case DOWN:
return index == outputSlot;
case UP:
if (index == orbSlot && !stack.isEmpty() && stack.getItem() instanceof IBloodOrb) {
return true;
} else if (index == toolSlot) {
return true; //TODO:
} else {
return true;
}
default:
return getAccessibleInputSlots(direction).contains(index);
}
}
public List<Integer> getAccessibleInputSlots(EnumFacing direction)
{
public List<Integer> getAccessibleInputSlots(EnumFacing direction) {
List<Integer> list = new ArrayList<Integer>();
for (int i = 0; i < 6; i++)
{
if (isInputSlotAccessible(i))
{
for (int i = 0; i < 6; i++) {
if (isInputSlotAccessible(i)) {
list.add(i);
}
}
@ -207,19 +178,15 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
}
@Override
public void update()
{
if (isSlave())
{
public void update() {
if (isSlave()) {
return;
}
List<ItemStack> inputList = new ArrayList<ItemStack>();
for (int i = 0; i < 6; i++)
{
if (!getStackInSlot(i).isEmpty())
{
for (int i = 0; i < 6; i++) {
if (!getStackInSlot(i).isEmpty()) {
inputList.add(getStackInSlot(i));
}
}
@ -227,34 +194,26 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
int tier = getTierOfOrb();
AlchemyTableRecipe recipe = AlchemyTableRecipeRegistry.getMatchingRecipe(inputList, getWorld(), getPos());
if (recipe != null && (burnTime > 0 || (!getWorld().isRemote && tier >= recipe.getTierRequired() && this.getContainedLp() >= recipe.getLpDrained())))
{
if (burnTime == 1)
{
if (recipe != null && (burnTime > 0 || (!getWorld().isRemote && tier >= recipe.getTierRequired() && this.getContainedLp() >= recipe.getLpDrained()))) {
if (burnTime == 1) {
IBlockState state = getWorld().getBlockState(pos);
getWorld().notifyBlockUpdate(getPos(), state, state, 3);
}
if (canCraft(inputList, recipe))
{
if (canCraft(inputList, recipe)) {
ticksRequired = recipe.getTicksRequired();
burnTime++;
if (burnTime == ticksRequired)
{
if (!getWorld().isRemote)
{
if (burnTime == ticksRequired) {
if (!getWorld().isRemote) {
int requiredLp = recipe.getLpDrained();
if (requiredLp > 0)
{
if (!getWorld().isRemote)
{
if (requiredLp > 0) {
if (!getWorld().isRemote) {
consumeLp(requiredLp);
}
}
if (!getWorld().isRemote)
{
if (!getWorld().isRemote) {
craftItem(inputList, recipe);
}
}
@ -263,29 +222,23 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
IBlockState state = getWorld().getBlockState(pos);
getWorld().notifyBlockUpdate(getPos(), state, state, 3);
} else if (burnTime > ticksRequired + 10)
{
} else if (burnTime > ticksRequired + 10) {
burnTime = 0;
}
} else
{
} else {
burnTime = 0;
}
} else
{
} else {
burnTime = 0;
}
}
public double getProgressForGui()
{
public double getProgressForGui() {
return ((double) burnTime) / ticksRequired;
}
private boolean canCraft(List<ItemStack> inputList, AlchemyTableRecipe recipe)
{
if (recipe == null)
{
private boolean canCraft(List<ItemStack> inputList, AlchemyTableRecipe recipe) {
if (recipe == null) {
return false;
}
@ -301,13 +254,10 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
return result <= getInventoryStackLimit() && result <= currentOutputStack.getMaxStackSize();
}
public int getTierOfOrb()
{
public int getTierOfOrb() {
ItemStack orbStack = getStackInSlot(orbSlot);
if (!orbStack.isEmpty())
{
if (orbStack.getItem() instanceof IBloodOrb)
{
if (!orbStack.isEmpty()) {
if (orbStack.getItem() instanceof IBloodOrb) {
BloodOrb orb = ((IBloodOrb) orbStack.getItem()).getOrb(orbStack);
return orb == null ? 0 : orb.getTier();
}
@ -316,24 +266,19 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
return 0;
}
public int getContainedLp()
{
public int getContainedLp() {
ItemStack orbStack = getStackInSlot(orbSlot);
if (!orbStack.isEmpty())
{
if (orbStack.getItem() instanceof IBloodOrb)
{
if (!orbStack.isEmpty()) {
if (orbStack.getItem() instanceof IBloodOrb) {
NBTTagCompound itemTag = orbStack.getTagCompound();
if (itemTag == null)
{
if (itemTag == null) {
return 0;
}
String ownerUUID = itemTag.getString(Constants.NBT.OWNER_UUID);
if (Strings.isNullOrEmpty(ownerUUID))
{
if (Strings.isNullOrEmpty(ownerUUID)) {
return 0;
}
@ -346,18 +291,14 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
return 0;
}
public void craftItem(List<ItemStack> inputList, AlchemyTableRecipe recipe)
{
if (this.canCraft(inputList, recipe))
{
public void craftItem(List<ItemStack> inputList, AlchemyTableRecipe recipe) {
if (this.canCraft(inputList, recipe)) {
ItemStack outputStack = recipe.getRecipeOutput(inputList);
ItemStack currentOutputStack = getStackInSlot(outputSlot);
if (currentOutputStack.isEmpty())
{
if (currentOutputStack.isEmpty()) {
setInventorySlotContents(outputSlot, outputStack);
} else if (ItemHandlerHelper.canItemStacksStack(outputStack, currentOutputStack))
{
} else if (ItemHandlerHelper.canItemStacksStack(outputStack, currentOutputStack)) {
currentOutputStack.grow(outputStack.getCount());
}
@ -365,16 +306,12 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
}
}
public int consumeLp(int requested)
{
public int consumeLp(int requested) {
ItemStack orbStack = getStackInSlot(orbSlot);
if (!orbStack.isEmpty())
{
if (orbStack.getItem() instanceof IBloodOrb)
{
if (NetworkHelper.syphonFromContainer(orbStack, requested))
{
if (!orbStack.isEmpty()) {
if (orbStack.getItem() instanceof IBloodOrb) {
if (NetworkHelper.syphonFromContainer(orbStack, requested)) {
return requested;
}
}
@ -383,34 +320,19 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
return 0;
}
public void consumeInventory(AlchemyTableRecipe recipe)
{
public void consumeInventory(AlchemyTableRecipe recipe) {
ItemStack[] input = new ItemStack[6];
for (int i = 0; i < 6; i++)
{
for (int i = 0; i < 6; i++) {
input[i] = getStackInSlot(i);
}
ItemStack[] result = recipe.getRemainingItems(input);
for (int i = 0; i < 6; i++)
{
for (int i = 0; i < 6; i++) {
setInventorySlotContents(i, result[i]);
}
}
public static int getOrbSlot() {
return orbSlot;
}
public static int getToolSlot() {
return toolSlot;
}
public static int getOutputSlot() {
return outputSlot;
}
public EnumFacing getDirection() {
return direction;
}
@ -434,4 +356,16 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
public boolean[] getBlockedSlots() {
return blockedSlots;
}
public static int getOrbSlot() {
return orbSlot;
}
public static int getToolSlot() {
return toolSlot;
}
public static int getOutputSlot() {
return outputSlot;
}
}