Java Code Examples for net.minecraft.entity.player.EntityPlayer#getBukkitEntity()
The following examples show how to use
net.minecraft.entity.player.EntityPlayer#getBukkitEntity() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CraftContainer.java From Kettle with GNU General Public License v3.0 | 6 votes |
public CraftContainer(final Inventory inventory, final EntityPlayer player, int id) { this(new InventoryView() { @Override public Inventory getTopInventory() { return inventory; } @Override public Inventory getBottomInventory() { return getPlayer().getInventory(); } @Override public HumanEntity getPlayer() { return player.getBukkitEntity(); } @Override public InventoryType getType() { return inventory.getType(); } }, player, id); }
Example 2
Source File: CraftEventFactory.java From Kettle with GNU General Public License v3.0 | 6 votes |
public static BlockPlaceEvent callBlockPlaceEvent(World world, EntityPlayer who, EnumHand hand, BlockState replacedBlockState, int clickedX, int clickedY, int clickedZ) { CraftWorld craftWorld = world.getWorld(); CraftServer craftServer = world.getServer(); Player player = (Player) who.getBukkitEntity(); Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ); Block placedBlock = replacedBlockState.getBlock(); boolean canBuild = canBuild(craftWorld, player, placedBlock.getX(), placedBlock.getZ()); org.bukkit.inventory.ItemStack item; EquipmentSlot equipmentSlot; if (hand == EnumHand.MAIN_HAND) { item = player.getInventory().getItemInMainHand(); equipmentSlot = EquipmentSlot.HAND; } else { item = player.getInventory().getItemInOffHand(); equipmentSlot = EquipmentSlot.OFF_HAND; } BlockPlaceEvent event = new BlockPlaceEvent(placedBlock, replacedBlockState, blockClicked, item, player, canBuild, equipmentSlot); craftServer.getPluginManager().callEvent(event); return event; }
Example 3
Source File: CraftEventFactory.java From Kettle with GNU General Public License v3.0 | 6 votes |
private static PlayerEvent getPlayerBucketEvent(boolean isFilling, EntityPlayer who, int clickedX, int clickedY, int clickedZ, EnumFacing clickedFace, ItemStack itemstack, net.minecraft.item.Item item) { Player player = (who == null) ? null : (Player) who.getBukkitEntity(); CraftItemStack itemInHand = CraftItemStack.asNewCraftStack(item); Material bucket = CraftMagicNumbers.getMaterial(itemstack.getItem()); CraftWorld craftWorld = (CraftWorld) player.getWorld(); CraftServer craftServer = (CraftServer) player.getServer(); Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ); BlockFace blockFace = CraftBlock.notchToBlockFace(clickedFace); PlayerEvent event = null; if (isFilling) { event = new PlayerBucketFillEvent(player, blockClicked, blockFace, bucket, itemInHand); ((PlayerBucketFillEvent) event).setCancelled(!canBuild(craftWorld, player, clickedX, clickedZ)); } else { event = new PlayerBucketEmptyEvent(player, blockClicked, blockFace, bucket, itemInHand); ((PlayerBucketEmptyEvent) event).setCancelled(!canBuild(craftWorld, player, clickedX, clickedZ)); } craftServer.getPluginManager().callEvent(event); return event; }
Example 4
Source File: CraftWorld.java From Kettle with GNU General Public License v3.0 | 5 votes |
public List<Player> getPlayers() { List<Player> list = new ArrayList<Player>(world.playerEntities.size()); for (EntityPlayer human : world.playerEntities) { HumanEntity bukkitEntity = human.getBukkitEntity(); if ((bukkitEntity != null) && (bukkitEntity instanceof Player)) { list.add((Player) bukkitEntity); } } return list; }
Example 5
Source File: CraftEventFactory.java From Kettle with GNU General Public License v3.0 | 5 votes |
/** * Block place methods */ public static BlockMultiPlaceEvent callBlockMultiPlaceEvent(World world, EntityPlayer who, EnumHand hand, List<BlockState> blockStates, int clickedX, int clickedY, int clickedZ) { CraftWorld craftWorld = world.getWorld(); CraftServer craftServer = world.getServer(); Player player = (Player) who.getBukkitEntity(); Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ); boolean canBuild = true; for (int i = 0; i < blockStates.size(); i++) { if (!canBuild(craftWorld, player, blockStates.get(i).getX(), blockStates.get(i).getZ())) { canBuild = false; break; } } org.bukkit.inventory.ItemStack item; if (hand == EnumHand.MAIN_HAND) { item = player.getInventory().getItemInMainHand(); } else { item = player.getInventory().getItemInOffHand(); } BlockMultiPlaceEvent event = new BlockMultiPlaceEvent(blockStates, blockClicked, item, player, canBuild); craftServer.getPluginManager().callEvent(event); return event; }
Example 6
Source File: CraftEventFactory.java From Kettle with GNU General Public License v3.0 | 5 votes |
public static PlayerInteractEvent callPlayerInteractEvent(EntityPlayer who, Action action, BlockPos position, EnumFacing direction, ItemStack itemstack, boolean cancelledBlock, EnumHand hand) { Player player = (who == null) ? null : (Player) who.getBukkitEntity(); CraftItemStack itemInHand = CraftItemStack.asCraftMirror(itemstack); CraftWorld craftWorld = (CraftWorld) player.getWorld(); CraftServer craftServer = (CraftServer) player.getServer(); Block blockClicked = null; if (position != null) { blockClicked = craftWorld.getBlockAt(position.getX(), position.getY(), position.getZ()); } else { switch (action) { case LEFT_CLICK_BLOCK: action = Action.LEFT_CLICK_AIR; break; case RIGHT_CLICK_BLOCK: action = Action.RIGHT_CLICK_AIR; break; } } BlockFace blockFace = CraftBlock.notchToBlockFace(direction); if (itemInHand.getType() == Material.AIR || itemInHand.getAmount() == 0) { itemInHand = null; } PlayerInteractEvent event = new PlayerInteractEvent(player, action, itemInHand, blockClicked, blockFace, (hand == null) ? null : ((hand == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND)); if (cancelledBlock) { event.setUseInteractedBlock(Event.Result.DENY); } craftServer.getPluginManager().callEvent(event); return event; }
Example 7
Source File: CraftEventFactory.java From Kettle with GNU General Public License v3.0 | 5 votes |
/** * BlockDamageEvent */ public static BlockDamageEvent callBlockDamageEvent(EntityPlayer who, int x, int y, int z, ItemStack itemstack, boolean instaBreak) { Player player = (who == null) ? null : (Player) who.getBukkitEntity(); CraftItemStack itemInHand = CraftItemStack.asCraftMirror(itemstack); CraftWorld craftWorld = (CraftWorld) player.getWorld(); CraftServer craftServer = (CraftServer) player.getServer(); Block blockClicked = craftWorld.getBlockAt(x, y, z); BlockDamageEvent event = new BlockDamageEvent(player, blockClicked, itemInHand, instaBreak); craftServer.getPluginManager().callEvent(event); return event; }
Example 8
Source File: CraftEventFactory.java From Kettle with GNU General Public License v3.0 | 5 votes |
/** * EntityTameEvent */ public static EntityTameEvent callEntityTameEvent(EntityLiving entity, EntityPlayer tamer) { org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity(); org.bukkit.entity.AnimalTamer bukkitTamer = (tamer != null ? tamer.getBukkitEntity() : null); CraftServer craftServer = (CraftServer) bukkitEntity.getServer(); entity.persistenceRequired = true; EntityTameEvent event = new EntityTameEvent((LivingEntity) bukkitEntity, bukkitTamer); craftServer.getPluginManager().callEvent(event); return event; }
Example 9
Source File: CraftEventFactory.java From Kettle with GNU General Public License v3.0 | 5 votes |
public static PlayerItemMendEvent callPlayerItemMendEvent(EntityPlayer entity, EntityXPOrb orb, ItemStack nmsMendedItem, int repairAmount) { Player player = (Player) entity.getBukkitEntity(); org.bukkit.inventory.ItemStack bukkitStack = CraftItemStack.asCraftMirror(nmsMendedItem); PlayerItemMendEvent event = new PlayerItemMendEvent(player, bukkitStack, (ExperienceOrb) orb.getBukkitEntity(), repairAmount); Bukkit.getPluginManager().callEvent(event); return event; }
Example 10
Source File: CraftMerchant.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public HumanEntity getTrader() { EntityPlayer eh = merchant.getCustomer(); return eh == null ? null : eh.getBukkitEntity(); }
Example 11
Source File: CraftEventFactory.java From Kettle with GNU General Public License v3.0 | 4 votes |
public static PlayerExpChangeEvent callPlayerExpChangeEvent(EntityPlayer entity, int expAmount) { Player player = (Player) entity.getBukkitEntity(); PlayerExpChangeEvent event = new PlayerExpChangeEvent(player, expAmount); Bukkit.getPluginManager().callEvent(event); return event; }
Example 12
Source File: CraftEventFactory.java From Kettle with GNU General Public License v3.0 | 4 votes |
public static FoodLevelChangeEvent callFoodLevelChangeEvent(EntityPlayer entity, int level) { FoodLevelChangeEvent event = new FoodLevelChangeEvent(entity.getBukkitEntity(), level); entity.getBukkitEntity().getServer().getPluginManager().callEvent(event); return event; }
Example 13
Source File: CraftEventFactory.java From Kettle with GNU General Public License v3.0 | 4 votes |
public static void callPlayerItemBreakEvent(EntityPlayer human, ItemStack brokenItem) { CraftItemStack item = CraftItemStack.asCraftMirror(brokenItem); PlayerItemBreakEvent event = new PlayerItemBreakEvent((Player) human.getBukkitEntity(), item); Bukkit.getPluginManager().callEvent(event); }
Example 14
Source File: CraftEventFactory.java From Kettle with GNU General Public License v3.0 | 4 votes |
public static PlayerUnleashEntityEvent callPlayerUnleashEntityEvent(EntityLiving entity, EntityPlayer player) { PlayerUnleashEntityEvent event = new PlayerUnleashEntityEvent(entity.getBukkitEntity(), (Player) player.getBukkitEntity()); entity.world.getServer().getPluginManager().callEvent(event); return event; }
Example 15
Source File: CraftEventFactory.java From Kettle with GNU General Public License v3.0 | 4 votes |
public static PlayerLeashEntityEvent callPlayerLeashEntityEvent(EntityLiving entity, Entity leashHolder, EntityPlayer player) { PlayerLeashEntityEvent event = new PlayerLeashEntityEvent(entity.getBukkitEntity(), leashHolder.getBukkitEntity(), (Player) player.getBukkitEntity()); entity.world.getServer().getPluginManager().callEvent(event); return event; }