Added previousBlock helper methods

You can reverse cycle with crouch+g key
This commit is contained in:
NeverCast 2012-12-31 17:04:34 +13:00
parent db2891c508
commit 96639ee9d0
2 changed files with 42 additions and 1 deletions

View file

@ -119,4 +119,41 @@ public class TransmutationHelper {
return nextStack;
}
public static ItemStack getPreviousBlock(int itemID, int meta) {
ArrayList<ItemStack> list = EquivalencyHandler.instance().getEquivalencyList(itemID, meta);
ItemStack prevStack = null;
if (list != null) {
return getPreviousBlock(itemID, meta, itemID, meta);
}
return prevStack;
}
private static ItemStack getPreviousBlock(int id, int meta, int origId, int origMeta) {
ArrayList<ItemStack> list = EquivalencyHandler.instance().getEquivalencyList(id, meta);
ItemStack prevStack = null;
if (list != null) {
prevStack = EquivalencyHandler.instance().getPrevInList(id, meta);
prevStack.stackSize = 1;
if ((prevStack.itemID == origId) && (prevStack.getItemDamage() == origMeta)) {
return prevStack;
}
else {
if (prevStack.getItem() instanceof ItemBlock) {
return prevStack;
}
else {
return getPreviousBlock(prevStack.itemID, prevStack.getItemDamage(), origId, origMeta);
}
}
}
// In the event the list is null, return null
return prevStack;
}
}

View file

@ -132,7 +132,11 @@ public class ItemPhilosopherStone extends ItemEE implements
}
else if (keyBinding.equals(ConfigurationSettings.KEYBINDING_TOGGLE)) {
if (TransmutationHelper.targetBlockStack != null) {
if(!thePlayer.isSneaking()){
TransmutationHelper.targetBlockStack = TransmutationHelper.getNextBlock(TransmutationHelper.targetBlockStack.itemID, TransmutationHelper.targetBlockStack.getItemDamage());
}else{
TransmutationHelper.targetBlockStack = TransmutationHelper.getPreviousBlock(TransmutationHelper.targetBlockStack.itemID, TransmutationHelper.targetBlockStack.getItemDamage());
}
}
}
else if (keyBinding.equals(ConfigurationSettings.KEYBINDING_CHARGE)) {