Permalink
Browse files

Fixed Cauldrons

  • Loading branch information...
me4502 committed Sep 28, 2018
1 parent 8ffce09 commit 95bd3c553798b29ec221b2ddfc898cc1b35f3e12
@@ -60,7 +60,7 @@ public ItemStack getItemStack() {
public CauldronItemStack add(CauldronItemStack stack) {
if (stack.isSameType(this)) {
ItemUtil.addToStack(item, stack.getItemStack());
ItemUtil.addToStack(item, stack.item);
}
return this;
}
@@ -72,10 +72,7 @@ public boolean isSameType(CauldronItemStack stack) {
@Override
public int compareTo(CauldronItemStack stack) {
if (stack.getItemStack().getAmount() > item.getAmount()) return 1;
if (stack.getItemStack().getAmount() == item.getAmount()) return 0;
return -1;
return Integer.compare(stack.item.getAmount(), item.getAmount());
}
@Override
@@ -92,14 +89,14 @@ public boolean equals(Object obj) {
if (obj instanceof CauldronItemStack) {
CauldronItemStack stack = (CauldronItemStack) obj;
return isSameType(stack) && stack.getItemStack().getAmount() == getItemStack().getAmount();
return isSameType(stack) && stack.item.getAmount() == item.getAmount();
}
return false;
}
@Override
public String toString() {
return ItemSyntax.getStringFromItem(getItemStack());
return ItemSyntax.getStringFromItem(item);
}
}
@@ -20,6 +20,7 @@
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.Levelled;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
@@ -103,7 +104,8 @@ private boolean isCauldron(Block block) {
if(!found)
return false;
}
return ((Cauldron) block.getState().getData()).isFull();
Levelled levelled = (Levelled) block.getBlockData();
return levelled.getLevel() == levelled.getMaximumLevel();
}
return false;
}
@@ -404,7 +404,7 @@ public static boolean areBaseItemsIdentical(ItemStack item, ItemStack item2) {
if(!isStackValid(item) || !isStackValid(item2))
return !isStackValid(item) && !isStackValid(item2);
else {
return item.getType() == item2.getType() && !(item.getData().getData() != item2.getData().getData() && item.getData().getData() >= 0 && item2.getData().getData() >= 0);
return item.getType() == item2.getType();
}
}
@@ -4,8 +4,8 @@ cauldron-recipes:
description: "Test Recipe"
ingredients:
# 10 light wooden planks
'wood:2': 10
'birch_planks': 10
# 5 brown wool
'wool:12': 5
'brown_wool': 5
results:
'stone': 12
@@ -9,6 +9,7 @@
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.type.Snow;
import org.bukkit.inventory.ItemStack;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -35,28 +36,6 @@ public void testAreBlocksSimilar() {
assertTrue(BlockUtil.areBlocksSimilar(mockBlock1, mockBlock2));
}
@Test
public void testAreBlocksIdentical() {
Block mockBlock1 = mock(Block.class);
when(mockBlock1.getType()).thenReturn(Material.SAND);
when(mockBlock1.getData()).thenReturn((byte) 1);
Block mockBlock2 = mock(Block.class);
when(mockBlock2.getType()).thenReturn(Material.STONE);
when(mockBlock2.getData()).thenReturn((byte) 1);
assertTrue(!BlockUtil.areBlocksIdentical(mockBlock1, mockBlock2));
when(mockBlock2.getType()).thenReturn(Material.SAND);
assertTrue(BlockUtil.areBlocksIdentical(mockBlock1, mockBlock2));
when(mockBlock2.getData()).thenReturn((byte) 2);
assertTrue(!BlockUtil.areBlocksIdentical(mockBlock1, mockBlock2));
}
@Test
public void testIsBlockSimilarTo() {

0 comments on commit 95bd3c5

Please sign in to comment.