Changed formatting to have bracing on a new line
This commit is contained in:
parent
e5eddd6c45
commit
e48eedb874
189 changed files with 6092 additions and 4041 deletions
|
@ -3,12 +3,16 @@ package WayofTime.bloodmagic.api.compress;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class CompressionHandler {
|
||||
public abstract class CompressionHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* Called to look at the inventory and syphons the required stack. Returns resultant stack if successful, and null if not.
|
||||
* @param inv The inventory iterated through
|
||||
* @return The result of the compression
|
||||
* Called to look at the inventory and syphons the required stack. Returns
|
||||
* resultant stack if successful, and null if not.
|
||||
*
|
||||
* @param inv
|
||||
* The inventory iterated through
|
||||
* @return The result of the compression
|
||||
*/
|
||||
public abstract ItemStack compressInventory(ItemStack[] inv, World world);
|
||||
}
|
||||
|
|
|
@ -9,31 +9,40 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A registry aimed to help compress items in an inventory into its compressible form.
|
||||
* A registry aimed to help compress items in an inventory into its compressible
|
||||
* form.
|
||||
*/
|
||||
public class CompressionRegistry {
|
||||
public class CompressionRegistry
|
||||
{
|
||||
|
||||
public static List<CompressionHandler> compressionRegistry = new ArrayList<CompressionHandler>();
|
||||
public static Map<ItemStack, Integer> thresholdMap = new HashMap<ItemStack, Integer>();
|
||||
|
||||
public static void registerHandler(CompressionHandler handler) {
|
||||
public static void registerHandler(CompressionHandler handler)
|
||||
{
|
||||
compressionRegistry.add(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an item so that it only compresses while above this threshold
|
||||
*
|
||||
* @param stack item/block to be compressed
|
||||
* @param threshold amount that is to be compressed
|
||||
*
|
||||
* @param stack
|
||||
* item/block to be compressed
|
||||
* @param threshold
|
||||
* amount that is to be compressed
|
||||
*/
|
||||
public static void registerItemThreshold(ItemStack stack, int threshold) {
|
||||
public static void registerItemThreshold(ItemStack stack, int threshold)
|
||||
{
|
||||
thresholdMap.put(stack, threshold);
|
||||
}
|
||||
|
||||
public static ItemStack compressInventory(ItemStack[] inv, World world) {
|
||||
for (CompressionHandler handler : compressionRegistry) {
|
||||
public static ItemStack compressInventory(ItemStack[] inv, World world)
|
||||
{
|
||||
for (CompressionHandler handler : compressionRegistry)
|
||||
{
|
||||
ItemStack stack = handler.compressInventory(inv, world);
|
||||
if (stack != null) {
|
||||
if (stack != null)
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
@ -41,9 +50,12 @@ public class CompressionRegistry {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static int getItemThreshold(ItemStack stack) {
|
||||
for (Map.Entry<ItemStack, Integer> entry : thresholdMap.entrySet()) {
|
||||
if (areItemStacksEqual(entry.getKey(), stack)) {
|
||||
public static int getItemThreshold(ItemStack stack)
|
||||
{
|
||||
for (Map.Entry<ItemStack, Integer> entry : thresholdMap.entrySet())
|
||||
{
|
||||
if (areItemStacksEqual(entry.getKey(), stack))
|
||||
{
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +63,8 @@ public class CompressionRegistry {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public static boolean areItemStacksEqual(ItemStack stack, ItemStack compressedStack) {
|
||||
public static boolean areItemStacksEqual(ItemStack stack, ItemStack compressedStack)
|
||||
{
|
||||
return stack.isItemEqual(compressedStack) && (stack.getTagCompound() == null ? compressedStack.getTagCompound() == null : stack.getTagCompound().equals(compressedStack.getTagCompound()));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue