org.bukkit.craftbukkit.entity.CraftEntity Java Examples

The following examples show how to use org.bukkit.craftbukkit.entity.CraftEntity. 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: CustomProjectileEntity.java    From Thermos with GNU General Public License v3.0 6 votes vote down vote up
@Override
public LivingEntity _INVALID_getShooter() {
    if (shooter instanceof LivingEntity) { return (LivingEntity)shooter; }
    if (shooter instanceof BlockProjectileSource)
    {
        Block block = ((BlockProjectileSource)shooter).getBlock();
        if(!(block.getWorld() instanceof WorldServer))return null;
        int x = block.getX(), y = block.getY(), z = block.getZ();
        WorldServer ws = (WorldServer)block.getWorld();
        EntityPlayerMP fake_dropper = new EntityPlayerMP(MinecraftServer.getServer(), ws, dropper, new ItemInWorldManager(MinecraftServer.getServer().worldServerForDimension(0)));
        fake_dropper.posX = x; fake_dropper.posY = y; fake_dropper.posZ = z;
        CraftEntity ce = org.bukkit.craftbukkit.entity.CraftEntity.getEntity(MinecraftServer.getServer().server, fake_dropper);
        if(ce instanceof LivingEntity) return (LivingEntity)ce;
        return null;
    } return null;
}
 
Example #2
Source File: AllMobFilter.java    From CardinalPGM with MIT License 6 votes vote down vote up
@Override
public FilterState evaluate(final Object... objects) {
    boolean abstain = true;
    for (Object object : objects) {
        if (object instanceof Entity) {
            if (((CraftEntity)object).getHandle() instanceof EntityInsentient) {
                return allow ? FilterState.ALLOW : FilterState.DENY;
            }
            abstain = false;
        }
    }
    if (abstain) {
        return (getParent() == null ? ABSTAIN : getParent().evaluate(objects));
    }
    return allow ? FilterState.DENY : FilterState.ALLOW;
}
 
Example #3
Source File: CraftEventFactory.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Mob spawner event.
 */
public static SpawnerSpawnEvent callSpawnerSpawnEvent(Entity spawnee, BlockPos pos) {
    CraftEntity entity = spawnee.getBukkitEntity();
    BlockState state = entity.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()).getState();
    if (!(state instanceof org.bukkit.block.CreatureSpawner)) {
        state = null;
    }

    SpawnerSpawnEvent event = new SpawnerSpawnEvent(entity, (org.bukkit.block.CreatureSpawner) state);
    entity.getServer().getPluginManager().callEvent(event);
    return event;
}
 
Example #4
Source File: NMSHacks.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
public static String getTranslationKey(Entity entity) {
    if(entity instanceof TNTPrimed) {
        return "tile.tnt.name";
    } else if(entity instanceof Egg) {
        return "item.egg.name";
    } else {
        final String id = EntityTypes.b(((CraftEntity) entity).getHandle());
        return "entity." + (id != null ? id : "generic") + ".name";
    }
}
 
Example #5
Source File: MobFilter.java    From CardinalPGM with MIT License 5 votes vote down vote up
@Override
public FilterState evaluate(Object... objects) {
    for (Object object : objects) {
        if (object instanceof Entity) {
            if (((CraftEntity)object).getHandle() instanceof EntityInsentient && mobType.equals(((CraftEntity) object).getType()))
                return ALLOW;
            else
                return DENY;
        }
    }
    return (getParent() == null ? ABSTAIN : getParent().evaluate(objects));
}
 
Example #6
Source File: CraftWorld.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean createExplosion(Entity source, Location loc, float power, boolean setFire, boolean breakBlocks) {
    return !world.newExplosion(source != null ? ((CraftEntity) source).getHandle() : null, loc.getX(), loc.getY(), loc.getZ(), power, setFire, breakBlocks).wasCanceled;
}
 
Example #7
Source File: NMSHacks.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
private static EntityTrackerEntry getTrackerEntry(Entity entity) {
    return getTrackerEntry(((CraftEntity) entity).getHandle());
}
 
Example #8
Source File: NMSHacks.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
private static List<DataWatcher.Item<?>> copyEntityMetadata(Entity entity) {
    final List<DataWatcher.Item<?>> metadata = ((CraftEntity) entity).getHandle().getDataWatcher().c();
    DataWatcher.deepCopy(metadata);
    return metadata;
}
 
Example #9
Source File: NMSHacks.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
public static Packet entityMetadataPacket(int entityId, Entity entity, boolean complete) {
    return entityMetadataPacket(entityId, ((CraftEntity) entity).getHandle(), complete);
}
 
Example #10
Source File: NMSHacks.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
public static void createExplosion(Entity entity, Location loc, float power, boolean fire, boolean destroy) {
    ((CraftWorld) loc.getWorld()).getHandle().createExplosion(((CraftEntity) entity).getHandle(), loc.getX(), loc.getY(), loc.getZ(), power, fire, destroy);
}