Update EntityChangeBlockEvent to new BlockData API

This commit is contained in:
md_5 2018-07-20 10:29:34 +10:00
parent 49ac8a7446
commit ca1af9368b

View File

@ -24,6 +24,7 @@ import org.bukkit.craftbukkit.CraftStatistic;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.block.CraftBlockState;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.entity.CraftPlayer;
@ -704,9 +705,8 @@ public class CraftEventFactory {
public static EntityChangeBlockEvent callEntityChangeBlockEvent(Entity entity, BlockPosition position, IBlockData newBlock, boolean cancelled) {
Block block = entity.world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ());
Material material = CraftMagicNumbers.getMaterial(newBlock).getItemType();
EntityChangeBlockEvent event = new EntityChangeBlockEvent(entity.getBukkitEntity(), block, material, (byte) 0);
EntityChangeBlockEvent event = new EntityChangeBlockEvent(entity.getBukkitEntity(), block, CraftBlockData.fromData(newBlock));
event.setCancelled(cancelled);
event.getEntity().getServer().getPluginManager().callEvent(event);
return event;