Don't store Block objects, use BlockState

Fixes #1811, Closes #1822
This commit is contained in:
TfT_02
2014-01-30 20:45:21 +01:00
parent b50ba9c02e
commit 6264bfa15f
5 changed files with 20 additions and 18 deletions

View File

@ -15,18 +15,19 @@ public class AlchemyBrewCheckTask extends BukkitRunnable {
private final static int INGREDIENT_SLOT = 3;
private Player player;
private Block brewingStand;
private BrewingStand brewingStand;
private ItemStack[] oldInventory;
public AlchemyBrewCheckTask(Player player, BrewingStand brewingStand) {
this.player = player;
this.brewingStand = brewingStand.getBlock();
this.brewingStand = brewingStand;
this.oldInventory = Arrays.copyOfRange(brewingStand.getInventory().getContents(), 0, 4);
}
@Override
public void run() {
ItemStack[] newInventory = Arrays.copyOfRange(((BrewingStand) brewingStand.getState()).getInventory().getContents(), 0, 4);
Block block = brewingStand.getBlock();
ItemStack[] newInventory = Arrays.copyOfRange(((BrewingStand) block.getState()).getInventory().getContents(), 0, 4);
if (Alchemy.brewingStandMap.containsKey(brewingStand)) {
if (oldInventory[INGREDIENT_SLOT] == null || newInventory[INGREDIENT_SLOT] == null || !oldInventory[INGREDIENT_SLOT].isSimilar(newInventory[INGREDIENT_SLOT]) || !AlchemyPotionBrewer.isValidBrew(player, newInventory)) {

View File

@ -1,7 +1,7 @@
package com.gmail.nossr50.runnables.skills;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.BrewingStand;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
@ -21,12 +21,12 @@ public class AlchemyBrewTask extends BukkitRunnable {
private static double DEFAULT_BREW_SPEED = 1.0;
private static int DEFAULT_BREW_TICKS = 400;
private Block brewingStand;
private BlockState brewingStand;
private double brewSpeed;
private double brewTimer;
private Player player;
public AlchemyBrewTask(Block brewingStand, Player player) {
public AlchemyBrewTask(BlockState brewingStand, Player player) {
this.brewingStand = brewingStand;
this.player = player;
@ -75,7 +75,7 @@ public class AlchemyBrewTask extends BukkitRunnable {
finish();
}
else {
((BrewingStand) brewingStand.getState()).setBrewingTime((int) brewTimer);
((BrewingStand) brewingStand).setBrewingTime((int) brewTimer);
}
}
@ -100,7 +100,7 @@ public class AlchemyBrewTask extends BukkitRunnable {
public void cancelBrew() {
this.cancel();
((BrewingStand) brewingStand.getState()).setBrewingTime(-1);
((BrewingStand) brewingStand).setBrewingTime(-1);
Alchemy.brewingStandMap.remove(brewingStand);
}
}