Java 类net.minecraft.server.EntityHuman 实例源码

项目:CraftBukkit    文件:CraftEventFactory.java   
/**
 * Block place methods
 */
public static BlockMultiPlaceEvent callBlockMultiPlaceEvent(World world, EntityHuman who, List<BlockState> blockStates, int clickedX, int clickedY, int clickedZ) {
    CraftWorld craftWorld = world.getWorld();
    CraftServer craftServer = world.getServer();
    Player player = (who == null) ? null : (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;
        }
    }

    BlockMultiPlaceEvent event = new BlockMultiPlaceEvent(blockStates, blockClicked, player.getItemInHand(), player, canBuild);
    craftServer.getPluginManager().callEvent(event);

    return event;
}
项目:CraftBukkit    文件:CraftEventFactory.java   
private static PlayerEvent getPlayerBucketEvent(boolean isFilling, EntityHuman who, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemstack, net.minecraft.server.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;
}
项目:CraftBukkit    文件:CraftEventFactory.java   
public static EntityDamageEvent handleLivingEntityDamageEvent(Entity damagee, DamageSource source, double rawDamage, double hardHatModifier, double blockingModifier, double armorModifier, double resistanceModifier, double magicModifier, double absorptionModifier, Function<Double, Double> hardHat, Function<Double, Double> blocking, Function<Double, Double> armor, Function<Double, Double> resistance, Function<Double, Double> magic, Function<Double, Double> absorption) {
    Map<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class);
    Map<DamageModifier, Function<? super Double, Double>> modifierFunctions = new EnumMap<DamageModifier, Function<? super Double, Double>>(DamageModifier.class);
    modifiers.put(DamageModifier.BASE, rawDamage);
    modifierFunctions.put(DamageModifier.BASE, ZERO);
    if (source == DamageSource.FALLING_BLOCK || source == DamageSource.ANVIL) {
        modifiers.put(DamageModifier.HARD_HAT, hardHatModifier);
        modifierFunctions.put(DamageModifier.HARD_HAT, hardHat);
    }
    if (damagee instanceof EntityHuman) {
        modifiers.put(DamageModifier.BLOCKING, blockingModifier);
        modifierFunctions.put(DamageModifier.BLOCKING, blocking);
    }
    modifiers.put(DamageModifier.ARMOR, armorModifier);
    modifierFunctions.put(DamageModifier.ARMOR, armor);
    modifiers.put(DamageModifier.RESISTANCE, resistanceModifier);
    modifierFunctions.put(DamageModifier.RESISTANCE, resistance);
    modifiers.put(DamageModifier.MAGIC, magicModifier);
    modifierFunctions.put(DamageModifier.MAGIC, magic);
    modifiers.put(DamageModifier.ABSORPTION, absorptionModifier);
    modifierFunctions.put(DamageModifier.ABSORPTION, absorption);
    return handleEntityDamageEvent(damagee, source, modifiers, modifierFunctions);
}
项目:Almura-Server    文件:CraftEventFactory.java   
/**
 * Block place methods
 */
public static BlockPlaceEvent callBlockPlaceEvent(World world, EntityHuman who, BlockState replacedBlockState, int clickedX, int clickedY, int clickedZ) {
    CraftWorld craftWorld = world.getWorld();
    CraftServer craftServer = world.getServer();

    Player player = (who == null) ? null : (Player) who.getBukkitEntity();

    Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ);
    Block placedBlock = replacedBlockState.getBlock();

    boolean canBuild = canBuild(craftWorld, player, placedBlock.getX(), placedBlock.getZ());

    BlockPlaceEvent event = new BlockPlaceEvent(placedBlock, replacedBlockState, blockClicked, player.getItemInHand(), player, canBuild);
    craftServer.getPluginManager().callEvent(event);

    return event;
}
项目:Almura-Server    文件:CraftEventFactory.java   
private static PlayerEvent getPlayerBucketEvent(boolean isFilling, EntityHuman who, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemstack, net.minecraft.server.Item item) {
    Player player = (who == null) ? null : (Player) who.getBukkitEntity();
    CraftItemStack itemInHand = CraftItemStack.asNewCraftStack(item);
    Material bucket = Material.getMaterial(itemstack.id);

    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;
}
项目:Almura-Server    文件:ActivationRange.java   
/**
 * These entities are excluded from Activation range checks.
 *
 * @param entity
 * @param world
 * @return boolean If it should always tick.
 */
public static boolean initializeEntityActivationState(Entity entity, SpigotWorldConfig config)
{
    if ( ( entity.activationType == 3 && config.miscActivationRange == 0 )
            || ( entity.activationType == 2 && config.animalActivationRange == 0 )
            || ( entity.activationType == 1 && config.monsterActivationRange == 0 )
            || entity instanceof EntityHuman
            || entity instanceof EntityProjectile
            || entity instanceof EntityEnderDragon
            || entity instanceof EntityComplexPart
            || entity instanceof EntityWither
            || entity instanceof EntityFireball
            || entity instanceof EntityWeather
            || entity instanceof EntityTNTPrimed
            || entity instanceof EntityEnderCrystal
            || entity instanceof EntityFireworks )
    {
        return true;
    }

    return false;
}
项目:Tweakkit-Server    文件:CraftEventFactory.java   
/**
 * Block place methods
 */
public static BlockMultiPlaceEvent callBlockMultiPlaceEvent(World world, EntityHuman who, List<BlockState> blockStates, int clickedX, int clickedY, int clickedZ) {
    CraftWorld craftWorld = world.getWorld();
    CraftServer craftServer = world.getServer();
    Player player = (who == null) ? null : (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;
        }
    }

    BlockMultiPlaceEvent event = new BlockMultiPlaceEvent(blockStates, blockClicked, player.getItemInHand(), player, canBuild);
    craftServer.getPluginManager().callEvent(event);

    return event;
}
项目:Tweakkit-Server    文件:CraftEventFactory.java   
private static PlayerEvent getPlayerBucketEvent(boolean isFilling, EntityHuman who, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemstack, net.minecraft.server.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;
}
项目:Tweakkit-Server    文件:CraftEventFactory.java   
public static EntityDamageEvent handleLivingEntityDamageEvent(Entity damagee, DamageSource source, double rawDamage, double hardHatModifier, double blockingModifier, double armorModifier, double resistanceModifier, double magicModifier, double absorptionModifier, Function<Double, Double> hardHat, Function<Double, Double> blocking, Function<Double, Double> armor, Function<Double, Double> resistance, Function<Double, Double> magic, Function<Double, Double> absorption) {
    Map<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class);
    Map<DamageModifier, Function<? super Double, Double>> modifierFunctions = new EnumMap<DamageModifier, Function<? super Double, Double>>(DamageModifier.class);
    modifiers.put(DamageModifier.BASE, rawDamage);
    modifierFunctions.put(DamageModifier.BASE, ZERO);
    if (source == DamageSource.FALLING_BLOCK || source == DamageSource.ANVIL) {
        modifiers.put(DamageModifier.HARD_HAT, hardHatModifier);
        modifierFunctions.put(DamageModifier.HARD_HAT, hardHat);
    }
    if (damagee instanceof EntityHuman) {
        modifiers.put(DamageModifier.BLOCKING, blockingModifier);
        modifierFunctions.put(DamageModifier.BLOCKING, blocking);
    }
    modifiers.put(DamageModifier.ARMOR, armorModifier);
    modifierFunctions.put(DamageModifier.ARMOR, armor);
    modifiers.put(DamageModifier.RESISTANCE, resistanceModifier);
    modifierFunctions.put(DamageModifier.RESISTANCE, resistance);
    modifiers.put(DamageModifier.MAGIC, magicModifier);
    modifierFunctions.put(DamageModifier.MAGIC, magic);
    modifiers.put(DamageModifier.ABSORPTION, absorptionModifier);
    modifierFunctions.put(DamageModifier.ABSORPTION, absorption);
    return handleEntityDamageEvent(damagee, source, modifiers, modifierFunctions);
}
项目:Tweakkit-Server    文件:ActivationRange.java   
/**
 * These entities are excluded from Activation range checks.
 *
 * @param entity
 * @param world
 * @return boolean If it should always tick.
 */
public static boolean initializeEntityActivationState(Entity entity, SpigotWorldConfig config)
{
    if ( ( entity.activationType == 3 && config.miscActivationRange == 0 )
            || ( entity.activationType == 2 && config.animalActivationRange == 0 )
            || ( entity.activationType == 1 && config.monsterActivationRange == 0 )
            || entity instanceof EntityHuman
            || entity instanceof EntityProjectile
            || entity instanceof EntityEnderDragon
            || entity instanceof EntityComplexPart
            || entity instanceof EntityWither
            || entity instanceof EntityFireball
            || entity instanceof EntityWeather
            || entity instanceof EntityTNTPrimed
            || entity instanceof EntityEnderCrystal
            || entity instanceof EntityFireworks )
    {
        return true;
    }

    return false;
}
项目:SpigotSource    文件:ActivationRange.java   
/**
 * These entities are excluded from Activation range checks.
 *
 * @param entity
 * @param world
 * @return boolean If it should always tick.
 */
public static boolean initializeEntityActivationState(Entity entity, SpigotWorldConfig config)
{
    if ( ( entity.activationType == 3 && config.miscActivationRange == 0 )
            || ( entity.activationType == 2 && config.animalActivationRange == 0 )
            || ( entity.activationType == 1 && config.monsterActivationRange == 0 )
            || entity instanceof EntityHuman
            || entity instanceof EntityProjectile
            || entity instanceof EntityEnderDragon
            || entity instanceof EntityComplexPart
            || entity instanceof EntityWither
            || entity instanceof EntityFireball
            || entity instanceof EntityWeather
            || entity instanceof EntityTNTPrimed
            || entity instanceof EntityEnderCrystal
            || entity instanceof EntityFireworks )
    {
        return true;
    }

    return false;
}
项目:Craft-city    文件:CraftEventFactory.java   
/**
 * Block place methods
 */
public static BlockPlaceEvent callBlockPlaceEvent(World world, EntityHuman who, BlockState replacedBlockState, int clickedX, int clickedY, int clickedZ) {
    CraftWorld craftWorld = world.getWorld();
    CraftServer craftServer = world.getServer();

    Player player = (who == null) ? null : (Player) who.getBukkitEntity();

    Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ);
    Block placedBlock = replacedBlockState.getBlock();

    boolean canBuild = canBuild(craftWorld, player, placedBlock.getX(), placedBlock.getZ());

    BlockPlaceEvent event = new BlockPlaceEvent(placedBlock, replacedBlockState, blockClicked, player.getItemInHand(), player, canBuild);
    craftServer.getPluginManager().callEvent(event);

    return event;
}
项目:Craft-city    文件:CraftEventFactory.java   
private static PlayerEvent getPlayerBucketEvent(boolean isFilling, EntityHuman who, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemstack, net.minecraft.server.Item item) {
    Player player = (who == null) ? null : (Player) who.getBukkitEntity();
    CraftItemStack itemInHand = CraftItemStack.asNewCraftStack(item);
    Material bucket = Material.getMaterial(itemstack.id);

    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;
}
项目:Arcade2    文件:ArcadePlayer.java   
/**
 * Convert Mojang's chat visibility to this enum value.
 * @param mojang Mojang's chat state enum representation.
 */
static ChatState ofMojang(EntityHuman.EnumChatVisibility mojang) {
    if (mojang != null) {
        switch (mojang) {
            case FULL:
                return VISIBLE;
            case SYSTEM:
                return HIDDEN;
            case HIDDEN:
                return DISABLED;
        }
    }

    return VISIBLE; // defaults
}
项目:CraftBukkit    文件:CraftContainer.java   
@Override
public boolean c(EntityHuman entityhuman) {
    if (cachedType == view.getType() && cachedSize == getSize() && cachedTitle.equals(view.getTitle())) {
        return true;
    }
    // If the window type has changed for some reason, update the player
    // This method will be called every tick or something, so it's
    // as good a place as any to put something like this.
    boolean typeChanged = (cachedType != view.getType());
    cachedType = view.getType();
    cachedTitle = view.getTitle();
    if (view.getPlayer() instanceof CraftPlayer) {
        CraftPlayer player = (CraftPlayer) view.getPlayer();
        int type = getNotchInventoryType(cachedType);
        IInventory top = ((CraftInventory)view.getTopInventory()).getInventory();
        IInventory bottom = ((CraftInventory)view.getBottomInventory()).getInventory();
        this.b.clear();
        this.c.clear();
        if (typeChanged) {
            setupSlots(top, bottom);
        }
        int size = getSize();
        player.getHandle().playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.windowId, type, cachedTitle, size, true));
        player.updateInventory();
    }
    return true;
}
项目:CraftBukkit    文件:CraftEventFactory.java   
/**
 * Player Interact event
 */
public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, ItemStack itemstack) {
    if (action != Action.LEFT_CLICK_AIR && action != Action.RIGHT_CLICK_AIR) {
        throw new AssertionError(String.format("%s performing %s with %s", who, action, itemstack));
    }
    return callPlayerInteractEvent(who, action, 0, 256, 0, 0, itemstack);
}
项目:CraftBukkit    文件:CraftEventFactory.java   
public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemstack) {
    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(clickedX, clickedY, clickedZ);
    BlockFace blockFace = CraftBlock.notchToBlockFace(clickedFace);

    if (clickedY > 255) {
        blockClicked = null;
        switch (action) {
        case LEFT_CLICK_BLOCK:
            action = Action.LEFT_CLICK_AIR;
            break;
        case RIGHT_CLICK_BLOCK:
            action = Action.RIGHT_CLICK_AIR;
            break;
        }
    }

    if (itemInHand.getType() == Material.AIR || itemInHand.getAmount() == 0) {
        itemInHand = null;
    }

    PlayerInteractEvent event = new PlayerInteractEvent(player, action, itemInHand, blockClicked, blockFace);
    craftServer.getPluginManager().callEvent(event);

    return event;
}
项目:CraftBukkit    文件:CraftEventFactory.java   
/**
 * BlockDamageEvent
 */
public static BlockDamageEvent callBlockDamageEvent(EntityHuman 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;
}
项目:CraftBukkit    文件:CraftEventFactory.java   
/**
 * EntityTameEvent
 */
public static EntityTameEvent callEntityTameEvent(EntityInsentient entity, EntityHuman tamer) {
    org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity();
    org.bukkit.entity.AnimalTamer bukkitTamer = (tamer != null ? tamer.getBukkitEntity() : null);
    CraftServer craftServer = (CraftServer) bukkitEntity.getServer();

    entity.persistent = true;

    EntityTameEvent event = new EntityTameEvent((LivingEntity) bukkitEntity, bukkitTamer);
    craftServer.getPluginManager().callEvent(event);
    return event;
}
项目:CraftBukkit    文件:CraftEventFactory.java   
public static Cancellable handleStatisticsIncrease(EntityHuman entityHuman, net.minecraft.server.Statistic statistic, int current, int incrementation) {
    Player player = ((EntityPlayer) entityHuman).getBukkitEntity();
    Event event;
    if (statistic instanceof net.minecraft.server.Achievement) {
        if (current != 0) {
            return null;
        }
        event = new PlayerAchievementAwardedEvent(player, CraftStatistic.getBukkitAchievement((net.minecraft.server.Achievement) statistic));
    } else {
        org.bukkit.Statistic stat = CraftStatistic.getBukkitStatistic(statistic);
        switch (stat) {
            case FALL_ONE_CM:
            case BOAT_ONE_CM:
            case CLIMB_ONE_CM:
            case DIVE_ONE_CM:
            case FLY_ONE_CM:
            case HORSE_ONE_CM:
            case MINECART_ONE_CM:
            case PIG_ONE_CM:
            case PLAY_ONE_TICK:
            case SWIM_ONE_CM:
            case WALK_ONE_CM:
                // Do not process event for these - too spammy
                return null;
            default:
        }
        if (stat.getType() == Type.UNTYPED) {
            event = new PlayerStatisticIncrementEvent(player, stat, current, current + incrementation);
        } else if (stat.getType() == Type.ENTITY) {
            EntityType entityType = CraftStatistic.getEntityTypeFromStatistic(statistic);
            event = new PlayerStatisticIncrementEvent(player, stat, current, current + incrementation, entityType);
        } else {
            Material material = CraftStatistic.getMaterialFromStatistic(statistic);
            event = new PlayerStatisticIncrementEvent(player, stat, current, current + incrementation, material);
        }
    }
    entityHuman.world.getServer().getPluginManager().callEvent(event);
    return (Cancellable) event;
}
项目:Craftbukkit    文件:CraftContainer.java   
@Override
public boolean c(EntityHuman entityhuman) {
    if (cachedType == view.getType() && cachedSize == getSize() && cachedTitle.equals(view.getTitle())) {
        return true;
    }
    // If the window type has changed for some reason, update the player
    // This method will be called every tick or something, so it's
    // as good a place as any to put something like this.
    boolean typeChanged = (cachedType != view.getType());
    cachedType = view.getType();
    cachedTitle = view.getTitle();
    if (view.getPlayer() instanceof CraftPlayer) {
        CraftPlayer player = (CraftPlayer) view.getPlayer();
        String type = getNotchInventoryType(cachedType);
        IInventory top = ((CraftInventory)view.getTopInventory()).getInventory();
        IInventory bottom = ((CraftInventory)view.getBottomInventory()).getInventory();
        this.b.clear();
        this.c.clear();
        if (typeChanged) {
            setupSlots(top, bottom);
        }
        int size = getSize();
        player.getHandle().playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.windowId, type, new ChatComponentText(cachedTitle), size));
        player.updateInventory();
    }
    return true;
}
项目:Almura-Server    文件:CraftContainer.java   
@Override
public boolean c(EntityHuman entityhuman) {
    if (cachedType == view.getType() && cachedSize == getSize() && cachedTitle.equals(view.getTitle())) {
        return true;
    }
    // If the window type has changed for some reason, update the player
    // This method will be called every tick or something, so it's
    // as good a place as any to put something like this.
    boolean typeChanged = (cachedType != view.getType());
    cachedType = view.getType();
    cachedTitle = view.getTitle();
    if (view.getPlayer() instanceof CraftPlayer) {
        CraftPlayer player = (CraftPlayer) view.getPlayer();
        int type = getNotchInventoryType(cachedType);
        IInventory top = ((CraftInventory)view.getTopInventory()).getInventory();
        IInventory bottom = ((CraftInventory)view.getBottomInventory()).getInventory();
        this.b.clear();
        this.c.clear();
        if (typeChanged) {
            setupSlots(top, bottom);
        }
        int size = getSize();
        player.getHandle().playerConnection.sendPacket(new Packet100OpenWindow(this.windowId, type, cachedTitle, size, true));
        player.updateInventory();
    }
    return true;
}
项目:Almura-Server    文件:CraftEventFactory.java   
/**
 * Player Interact event
 */
public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, ItemStack itemstack) {
    if (action != Action.LEFT_CLICK_AIR && action != Action.RIGHT_CLICK_AIR) {
        throw new IllegalArgumentException();
    }
    return callPlayerInteractEvent(who, action, 0, 256, 0, 0, itemstack);
}
项目:Almura-Server    文件:CraftEventFactory.java   
public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemstack) {
    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(clickedX, clickedY, clickedZ);
    BlockFace blockFace = CraftBlock.notchToBlockFace(clickedFace);

    if (clickedY > 255) {
        blockClicked = null;
        switch (action) {
        case LEFT_CLICK_BLOCK:
            action = Action.LEFT_CLICK_AIR;
            break;
        case RIGHT_CLICK_BLOCK:
            action = Action.RIGHT_CLICK_AIR;
            break;
        }
    }

    if (itemInHand.getType() == Material.AIR || itemInHand.getAmount() == 0) {
        itemInHand = null;
    }

    PlayerInteractEvent event = new PlayerInteractEvent(player, action, itemInHand, blockClicked, blockFace);
    craftServer.getPluginManager().callEvent(event);

    return event;
}
项目:Almura-Server    文件:CraftEventFactory.java   
/**
 * BlockDamageEvent
 */
public static BlockDamageEvent callBlockDamageEvent(EntityHuman 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;
}
项目:Almura-Server    文件:CraftEventFactory.java   
/**
 * EntityTameEvent
 */
public static EntityTameEvent callEntityTameEvent(EntityInsentient entity, EntityHuman tamer) {
    org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity();
    org.bukkit.entity.AnimalTamer bukkitTamer = (tamer != null ? tamer.getBukkitEntity() : null);
    CraftServer craftServer = (CraftServer) bukkitEntity.getServer();

    entity.persistent = true;

    EntityTameEvent event = new EntityTameEvent((LivingEntity) bukkitEntity, bukkitTamer);
    craftServer.getPluginManager().callEvent(event);
    return event;
}
项目:Tweakkit-Server    文件:CraftContainer.java   
@Override
public boolean c(EntityHuman entityhuman) {
    if (cachedType == view.getType() && cachedSize == getSize() && cachedTitle.equals(view.getTitle())) {
        return true;
    }
    // If the window type has changed for some reason, update the player
    // This method will be called every tick or something, so it's
    // as good a place as any to put something like this.
    boolean typeChanged = (cachedType != view.getType());
    cachedType = view.getType();
    cachedTitle = view.getTitle();
    if (view.getPlayer() instanceof CraftPlayer) {
        CraftPlayer player = (CraftPlayer) view.getPlayer();
        int type = getNotchInventoryType(cachedType);
        IInventory top = ((CraftInventory)view.getTopInventory()).getInventory();
        IInventory bottom = ((CraftInventory)view.getBottomInventory()).getInventory();
        this.b.clear();
        this.c.clear();
        if (typeChanged) {
            setupSlots(top, bottom);
        }
        int size = getSize();
        player.getHandle().playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.windowId, type, cachedTitle, size, true));
        player.updateInventory();
    }
    return true;
}
项目:Tweakkit-Server    文件:CraftEventFactory.java   
/**
 * Player Interact event
 */
public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, ItemStack itemstack) {
    if (action != Action.LEFT_CLICK_AIR && action != Action.RIGHT_CLICK_AIR) {
        throw new IllegalArgumentException(String.format("%s performing %s with %s", who, action, itemstack)); // Spigot
    }
    return callPlayerInteractEvent(who, action, 0, 256, 0, 0, itemstack);
}
项目:Tweakkit-Server    文件:CraftEventFactory.java   
public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemstack) {
    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(clickedX, clickedY, clickedZ);
    BlockFace blockFace = CraftBlock.notchToBlockFace(clickedFace);

    if (clickedY > 255) {
        blockClicked = null;
        switch (action) {
        case LEFT_CLICK_BLOCK:
            action = Action.LEFT_CLICK_AIR;
            break;
        case RIGHT_CLICK_BLOCK:
            action = Action.RIGHT_CLICK_AIR;
            break;
        }
    }

    if (itemInHand.getType() == Material.AIR || itemInHand.getAmount() == 0) {
        itemInHand = null;
    }

    PlayerInteractEvent event = new PlayerInteractEvent(player, action, itemInHand, blockClicked, blockFace);
    craftServer.getPluginManager().callEvent(event);

    return event;
}
项目:Tweakkit-Server    文件:CraftEventFactory.java   
/**
 * BlockDamageEvent
 */
public static BlockDamageEvent callBlockDamageEvent(EntityHuman 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;
}
项目:Tweakkit-Server    文件:CraftEventFactory.java   
/**
 * EntityTameEvent
 */
public static EntityTameEvent callEntityTameEvent(EntityInsentient entity, EntityHuman tamer) {
    org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity();
    org.bukkit.entity.AnimalTamer bukkitTamer = (tamer != null ? tamer.getBukkitEntity() : null);
    CraftServer craftServer = (CraftServer) bukkitEntity.getServer();

    entity.persistent = true;

    EntityTameEvent event = new EntityTameEvent((LivingEntity) bukkitEntity, bukkitTamer);
    craftServer.getPluginManager().callEvent(event);
    return event;
}
项目:Tweakkit-Server    文件:CraftEventFactory.java   
public static Cancellable handleStatisticsIncrease(EntityHuman entityHuman, net.minecraft.server.Statistic statistic, int current, int incrementation) {
    Player player = ((EntityPlayer) entityHuman).getBukkitEntity();
    Event event;
    if (statistic instanceof net.minecraft.server.Achievement) {
        if (current != 0) {
            return null;
        }
        event = new PlayerAchievementAwardedEvent(player, CraftStatistic.getBukkitAchievement((net.minecraft.server.Achievement) statistic));
    } else {
        org.bukkit.Statistic stat = CraftStatistic.getBukkitStatistic(statistic);
        switch (stat) {
            case FALL_ONE_CM:
            case BOAT_ONE_CM:
            case CLIMB_ONE_CM:
            case DIVE_ONE_CM:
            case FLY_ONE_CM:
            case HORSE_ONE_CM:
            case MINECART_ONE_CM:
            case PIG_ONE_CM:
            case PLAY_ONE_TICK:
            case SWIM_ONE_CM:
            case WALK_ONE_CM:
                // Do not process event for these - too spammy
                return null;
            default:
        }
        if (stat.getType() == Type.UNTYPED) {
            event = new PlayerStatisticIncrementEvent(player, stat, current, current + incrementation);
        } else if (stat.getType() == Type.ENTITY) {
            EntityType entityType = CraftStatistic.getEntityTypeFromStatistic(statistic);
            event = new PlayerStatisticIncrementEvent(player, stat, current, current + incrementation, entityType);
        } else {
            Material material = CraftStatistic.getMaterialFromStatistic(statistic);
            event = new PlayerStatisticIncrementEvent(player, stat, current, current + incrementation, material);
        }
    }
    entityHuman.world.getServer().getPluginManager().callEvent(event);
    return (Cancellable) event;
}
项目:SpigotSource    文件:CraftContainer.java   
@Override
public boolean c(EntityHuman entityhuman) {
    if (cachedType == view.getType() && cachedSize == getSize() && cachedTitle.equals(view.getTitle())) {
        return true;
    }
    // If the window type has changed for some reason, update the player
    // This method will be called every tick or something, so it's
    // as good a place as any to put something like this.
    boolean typeChanged = (cachedType != view.getType());
    cachedType = view.getType();
    cachedTitle = view.getTitle();
    if (view.getPlayer() instanceof CraftPlayer) {
        CraftPlayer player = (CraftPlayer) view.getPlayer();
        String type = getNotchInventoryType(cachedType);
        IInventory top = ((CraftInventory) view.getTopInventory()).getInventory();
        IInventory bottom = ((CraftInventory) view.getBottomInventory()).getInventory();
        this.b.clear();
        this.c.clear();
        if (typeChanged) {
            setupSlots(top, bottom);
        }
        int size = getSize();
        player.getHandle().playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.windowId, type, new ChatComponentText(cachedTitle), size));
        player.updateInventory();
    }
    return true;
}
项目:SpigotSource    文件:ActivationRange.java   
/**
 * Find what entities are in range of the players in the world and set
 * active if in range.
 *
 * @param world
 */
public static void activateEntities(World world)
{
    SpigotTimings.entityActivationCheckTimer.startTiming();
    final int miscActivationRange = world.spigotConfig.miscActivationRange;
    final int animalActivationRange = world.spigotConfig.animalActivationRange;
    final int monsterActivationRange = world.spigotConfig.monsterActivationRange;

    int maxRange = Math.max( monsterActivationRange, animalActivationRange );
    maxRange = Math.max( maxRange, miscActivationRange );
    maxRange = Math.min( ( world.spigotConfig.viewDistance << 4 ) - 8, maxRange );

    for ( EntityHuman player : world.players )
    {

        player.activatedTick = MinecraftServer.currentTick;
        maxBB = player.getBoundingBox().grow( maxRange, 256, maxRange );
        miscBB = player.getBoundingBox().grow( miscActivationRange, 256, miscActivationRange );
        animalBB = player.getBoundingBox().grow( animalActivationRange, 256, animalActivationRange );
        monsterBB = player.getBoundingBox().grow( monsterActivationRange, 256, monsterActivationRange );

        int i = MathHelper.floor( maxBB.a / 16.0D );
        int j = MathHelper.floor( maxBB.d / 16.0D );
        int k = MathHelper.floor( maxBB.c / 16.0D );
        int l = MathHelper.floor( maxBB.f / 16.0D );

        for ( int i1 = i; i1 <= j; ++i1 )
        {
            for ( int j1 = k; j1 <= l; ++j1 )
            {
                if ( world.getWorld().isChunkLoaded( i1, j1 ) )
                {
                    activateChunkEntities( world.getChunkAt( i1, j1 ) );
                }
            }
        }
    }
    SpigotTimings.entityActivationCheckTimer.stopTiming();
}
项目:Craft-city    文件:CraftContainer.java   
@Override
public boolean c(EntityHuman entityhuman) {
    if (cachedType == view.getType() && cachedSize == getSize() && cachedTitle.equals(view.getTitle())) {
        return true;
    }
    // If the window type has changed for some reason, update the player
    // This method will be called every tick or something, so it's
    // as good a place as any to put something like this.
    boolean typeChanged = (cachedType != view.getType());
    cachedType = view.getType();
    cachedTitle = view.getTitle();
    if (view.getPlayer() instanceof CraftPlayer) {
        CraftPlayer player = (CraftPlayer) view.getPlayer();
        int type = getNotchInventoryType(cachedType);
        IInventory top = ((CraftInventory)view.getTopInventory()).getInventory();
        IInventory bottom = ((CraftInventory)view.getBottomInventory()).getInventory();
        this.b.clear();
        this.c.clear();
        if (typeChanged) {
            setupSlots(top, bottom);
        }
        int size = getSize();
        player.getHandle().playerConnection.sendPacket(new Packet100OpenWindow(this.windowId, type, cachedTitle, size, true));
        player.updateInventory();
    }
    return true;
}
项目:Craft-city    文件:CraftEventFactory.java   
/**
 * Player Interact event
 */
public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, ItemStack itemstack) {
    if (action != Action.LEFT_CLICK_AIR && action != Action.RIGHT_CLICK_AIR) {
        throw new IllegalArgumentException();
    }
    return callPlayerInteractEvent(who, action, 0, 256, 0, 0, itemstack);
}
项目:Craft-city    文件:CraftEventFactory.java   
public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemstack) {
    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(clickedX, clickedY, clickedZ);
    BlockFace blockFace = CraftBlock.notchToBlockFace(clickedFace);

    if (clickedY > 255) {
        blockClicked = null;
        switch (action) {
        case LEFT_CLICK_BLOCK:
            action = Action.LEFT_CLICK_AIR;
            break;
        case RIGHT_CLICK_BLOCK:
            action = Action.RIGHT_CLICK_AIR;
            break;
        }
    }

    if (itemInHand.getType() == Material.AIR || itemInHand.getAmount() == 0) {
        itemInHand = null;
    }

    PlayerInteractEvent event = new PlayerInteractEvent(player, action, itemInHand, blockClicked, blockFace);
    craftServer.getPluginManager().callEvent(event);

    return event;
}
项目:Craft-city    文件:CraftEventFactory.java   
/**
 * BlockDamageEvent
 */
public static BlockDamageEvent callBlockDamageEvent(EntityHuman 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;
}
项目:Craft-city    文件:CraftEventFactory.java   
/**
 * EntityTameEvent
 */
public static EntityTameEvent callEntityTameEvent(EntityLiving entity, EntityHuman tamer) {
    org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity();
    org.bukkit.entity.AnimalTamer bukkitTamer = (tamer != null ? tamer.getBukkitEntity() : null);
    CraftServer craftServer = (CraftServer) bukkitEntity.getServer();

    entity.persistent = true;

    EntityTameEvent event = new EntityTameEvent((LivingEntity) bukkitEntity, bukkitTamer);
    craftServer.getPluginManager().callEvent(event);
    return event;
}
项目:CraftBukkit    文件:CraftHumanEntity.java   
public CraftHumanEntity(final CraftServer server, final EntityHuman entity) {
    super(server, entity);
    mode = server.getDefaultGameMode();
    this.inventory = new CraftInventoryPlayer(entity.inventory);
    enderChest = new CraftInventory(entity.getEnderChest());
}