Permalink
Browse files

Fixed LightSwitches breaking torches.

  • Loading branch information...
me4502 committed Apr 9, 2017
1 parent 3c64e8a commit 6ce7bd677508fff7bdbccf27efeafaafc1dcff20
@@ -158,11 +158,10 @@ private boolean toggleLights(Block block, LocalPlayer player) {
if (changed >= maximum) return true;
if (on) {
- relBlock.setType(Material.TORCH);
+ relBlock.setTypeIdAndData(Material.TORCH.getId(), data, false);
} else {
- relBlock.setType(Material.REDSTONE_TORCH_ON);
+ relBlock.setTypeIdAndData(Material.REDSTONE_TORCH_ON.getId(), data, false);
}
- relBlock.setData(data);
changed++;
}
}
@@ -19,7 +19,6 @@
private HashMap<String, Object> advancedData = new HashMap<String, Object>();
public HashMap<String, Object> getAllAdvancedData() {
-
return advancedData;
}
@@ -41,7 +40,6 @@ public void addAdvancedData(String key, Object data) {
}
public CraftingItemStack(ItemStack item) {
-
this.item = item;
if(item != null && item.hasItemMeta()) //We have some advanced data to set.
addAdvancedData("item-meta", true);
@@ -53,24 +51,21 @@ public ItemStack getItemStack() {
}
public CraftingItemStack add(CraftingItemStack stack) {
-
if (stack.isSameType(this)) {
- ItemUtil.addToStack(item, stack.getItemStack());
- advancedData.putAll(stack.getAllAdvancedData());
+ ItemUtil.addToStack(item, stack.item);
+ advancedData.putAll(stack.advancedData);
}
return this;
}
public boolean isSameType(CraftingItemStack stack) {
-
return ItemUtil.areItemsIdentical(item, stack.item);
}
@Override
public int compareTo(CraftingItemStack stack) {
-
- if (stack.getItemStack().getAmount() > item.getAmount()) return 1;
- if (stack.getItemStack().getAmount() == item.getAmount()) return 0;
+ if (stack.item.getAmount() > item.getAmount()) return 1;
+ if (stack.item.getAmount() == item.getAmount()) return 0;
return -1;
}
@@ -96,18 +91,16 @@ public boolean equals(Object obj) {
for(String key : advancedData.keySet())
if(!stack.hasAdvancedData(key))
return false;
- return isSameType(stack) && stack.getItemStack().getAmount() == getItemStack().getAmount();
+ return isSameType(stack) && stack.item.getAmount() == item.getAmount();
}
return false;
}
@Override
public String toString() {
-
- String it = ItemSyntax.getStringFromItem(getItemStack());
-
+ String it = ItemSyntax.getStringFromItem(item);
if(hasAdvancedData("chance"))
- it = it + "%" + getAdvancedData("chance");
+ it = it + '%' + getAdvancedData("chance");
return it;
}
}
@@ -136,8 +136,7 @@ public void prepareCraft(PrepareItemCraftEvent event) {
} else
tests2 = recipe.getIngredients().toArray(new CraftingItemStack[recipe.getIngredients().size()]);
- ArrayList<ItemStack> leftovers = new ArrayList<ItemStack>();
- leftovers.addAll(Arrays.asList(tests));
+ ArrayList<ItemStack> leftovers = new ArrayList<ItemStack>(Arrays.asList(tests));
leftovers.removeAll(Collections.singleton(null));
for(ItemStack it : tests) {
@@ -373,7 +372,7 @@ private static ItemStack applyAdvancedEffects(ItemStack stack, Recipe rep, Playe
return res;
}
- private static boolean checkFurnaceRecipes(FurnaceRecipe rec1, ItemStack source, ItemStack result) throws InvalidCraftingException {
+ private static boolean checkFurnaceRecipes(FurnaceRecipe rec1, ItemStack source, ItemStack result) {
if(ItemUtil.areBaseItemsIdentical(rec1.getInput(), source))
if(ItemUtil.areBaseItemsIdentical(rec1.getResult(), result))

0 comments on commit 6ce7bd6

Please sign in to comment.