Discovered that in world transmutation isn't exactly great, have to come up with a good resolution

This commit is contained in:
pahimar 2012-12-21 14:01:23 -05:00
parent e50d589945
commit aee18dfa79
4 changed files with 13 additions and 39 deletions

View file

@ -80,23 +80,18 @@ public class TransmutationHelper {
public static ItemStack getNextBlock(int id, int meta) {
return getNextBlock(id, meta, true);
}
public static ItemStack getNextBlock(int id, int meta, boolean allowFalling) {
ArrayList<ItemStack> list = EquivalencyHandler.instance().getEquivalencyList(id, meta);
ItemStack nextStack = null;
if (list != null) {
return getNextBlock(id, meta, id, meta, allowFalling);
return getNextBlock(id, meta, id, meta);
}
return nextStack;
}
private static ItemStack getNextBlock(int id, int meta, int origId, int origMeta, boolean allowFalling) {
private static ItemStack getNextBlock(int id, int meta, int origId, int origMeta) {
ArrayList<ItemStack> list = EquivalencyHandler.instance().getEquivalencyList(id, meta);
@ -104,6 +99,7 @@ public class TransmutationHelper {
if (list != null) {
nextStack = EquivalencyHandler.instance().getNextInList(id, meta);
nextStack.stackSize = 1;
/*
* If the current item is the same as the original one we started
@ -115,33 +111,11 @@ public class TransmutationHelper {
return nextStack;
}
else {
/*
* If we are allowing any block (including falling ones) just
* check to see if the next item is a block. If it is, return
* it. Otherwise continue the recursion.
*/
if (allowFalling) {
if (nextStack.getItem() instanceof ItemBlock) {
return nextStack;
}
else {
return getNextBlock(nextStack.itemID, nextStack.getItemDamage(), origId, origMeta, allowFalling);
}
if (nextStack.getItem() instanceof ItemBlock) {
return nextStack;
}
/*
* Else we need to check to make sure the next item is both a
* block and not an instance of BlockSand (which all gravity
* affected blocks are a subclass of. If the next item is a
* block, and is not a subclass of BlockSand return it,
* otherwise, continue the recursion.
*/
else {
if ((nextStack.getItem() instanceof ItemBlock) && (!(Block.blocksList[nextStack.itemID] instanceof BlockSand))) {
return nextStack;
}
else {
return getNextBlock(nextStack.itemID, nextStack.getItemDamage(), origId, origMeta, allowFalling);
}
return getNextBlock(nextStack.itemID, nextStack.getItemDamage(), origId, origMeta);
}
}
}

View file

@ -101,7 +101,7 @@ public class ItemMiniumStone extends ItemEE
}
else if (keyBinding.equals(ConfigurationSettings.KEYBINDING_TOGGLE)) {
if (TransmutationHelper.targetBlockStack != null) {
TransmutationHelper.targetBlockStack = TransmutationHelper.getNextBlock(TransmutationHelper.targetBlockStack.itemID, TransmutationHelper.targetBlockStack.getItemDamage(), true);
TransmutationHelper.targetBlockStack = TransmutationHelper.getNextBlock(TransmutationHelper.targetBlockStack.itemID, TransmutationHelper.targetBlockStack.getItemDamage());
}
}

View file

@ -180,7 +180,7 @@ public class ItemPhilosopherStone extends ItemEE
}
else if (keyBinding.equals(ConfigurationSettings.KEYBINDING_TOGGLE)) {
if (TransmutationHelper.targetBlockStack != null) {
TransmutationHelper.targetBlockStack = TransmutationHelper.getNextBlock(TransmutationHelper.targetBlockStack.itemID, TransmutationHelper.targetBlockStack.getItemDamage(), true);
TransmutationHelper.targetBlockStack = TransmutationHelper.getNextBlock(TransmutationHelper.targetBlockStack.itemID, TransmutationHelper.targetBlockStack.getItemDamage());
}
}
else if (keyBinding.equals(ConfigurationSettings.KEYBINDING_CHARGE)) {

View file

@ -45,7 +45,7 @@ public class PacketResultEvent extends PacketEE {
System.out.println(shouldChangeNextBlock);
if (shouldChangeNextBlock) {
System.out.format("previous %d:%d, current %d:%d, target %d:%d\n", TransmutationHelper.previousBlockStack.itemID, TransmutationHelper.previousBlockStack.getItemDamage(), TransmutationHelper.currentBlockStack.itemID, TransmutationHelper.currentBlockStack.getItemDamage(), TransmutationHelper.targetBlockStack.itemID, TransmutationHelper.targetBlockStack.getItemDamage());
TransmutationHelper.targetBlockStack = TransmutationHelper.getNextBlock(TransmutationHelper.targetBlockStack.itemID, TransmutationHelper.targetBlockStack.getItemDamage(), true);
TransmutationHelper.targetBlockStack = TransmutationHelper.getNextBlock(TransmutationHelper.targetBlockStack.itemID, TransmutationHelper.targetBlockStack.getItemDamage());
System.out.format("previous %d:%d, current %d:%d, target %d:%d\n", TransmutationHelper.previousBlockStack.itemID, TransmutationHelper.previousBlockStack.getItemDamage(), TransmutationHelper.currentBlockStack.itemID, TransmutationHelper.currentBlockStack.getItemDamage(), TransmutationHelper.targetBlockStack.itemID, TransmutationHelper.targetBlockStack.getItemDamage());
}
}