org.bukkit.entity.Fish Java Examples

The following examples show how to use org.bukkit.entity.Fish. 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: FishData.java    From Skript with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Class<? extends Fish> getType() {
	if (!init && wildcard)
		return Fish.class;
	init = false;
	switch (pattern) {
		case 1:
			return Cod.class;
		case 2:
			return PufferFish.class;
		case 3:
			return Salmon.class;
		case 4:
			return TropicalFish.class;
	}
	return Fish.class;
}
 
Example #2
Source File: FishData.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected boolean init(@Nullable Class<? extends Fish> c, @Nullable Fish e) {
	int matchedPattern = getInitPattern(e);
	if (matchedPattern == 0)
		wildcard = true;
	pattern = (matchedPattern == 0) ? ThreadLocalRandom.current().nextInt(1, 5) : matchedPattern;
	return true;
}
 
Example #3
Source File: FishData.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
private static int getInitPattern(@Nullable Fish f) {
	if (f == null)
		return 0;
	else if (f instanceof Cod)
		return 1;
	else if (f instanceof PufferFish)
		return 2;
	else if (f instanceof Salmon)
		return 3;
	else if (f instanceof TropicalFish)
		return 4;
	return 0;
}
 
Example #4
Source File: PlayerFishEvent.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public PlayerFishEvent(final Player player, final Entity entity, final Fish hookEntity, final State state) {
    super(player);
    this.entity = entity;
    this.hookEntity = hookEntity;
    this.state = state;
}
 
Example #5
Source File: FishData.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void set(Fish entity) {
	// Setting of entity already handled by init() functions 
}
 
Example #6
Source File: FishData.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected boolean match(Fish entity) {
	return wildcard ? true : getPattern(entity) == pattern;
}
 
Example #7
Source File: FishData.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected boolean equals_i(EntityData<?> obj) {
	return obj instanceof Fish ? (wildcard ? true : getPattern((Fish) obj) == pattern) : false;
}
 
Example #8
Source File: FishData.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean isSupertypeOf(EntityData<?> e) {
	return e instanceof Fish ? (wildcard ? true : getPattern((Fish) e) == pattern) : false;
}
 
Example #9
Source File: FishData.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
private int getPattern(@Nullable Fish f) {
	int p = getInitPattern(f);
	return p == 0 ? pattern : p;
}
 
Example #10
Source File: CraftLivingEntity.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity) {
    net.minecraft.world.World world = ((CraftWorld) getWorld()).getHandle();
    net.minecraft.entity.Entity launch = null;

    if (Snowball.class.isAssignableFrom(projectile)) {
        launch = new net.minecraft.entity.projectile.EntitySnowball(world, getHandle());
    } else if (Egg.class.isAssignableFrom(projectile)) {
        launch = new net.minecraft.entity.projectile.EntityEgg(world, getHandle());
    } else if (EnderPearl.class.isAssignableFrom(projectile)) {
        launch = new net.minecraft.entity.item.EntityEnderPearl(world, getHandle());
    } else if (Arrow.class.isAssignableFrom(projectile)) {
        launch = new net.minecraft.entity.projectile.EntityArrow(world, getHandle(), 1);
    } else if (ThrownPotion.class.isAssignableFrom(projectile)) {
        launch = new net.minecraft.entity.projectile.EntityPotion(world, getHandle(), CraftItemStack.asNMSCopy(new ItemStack(Material.POTION, 1)));
    } else if (ThrownExpBottle.class.isAssignableFrom(projectile)) {
        launch = new net.minecraft.entity.item.EntityExpBottle(world, getHandle());
    } else if (Fish.class.isAssignableFrom(projectile) && getHandle() instanceof net.minecraft.entity.player.EntityPlayer) {
        launch = new net.minecraft.entity.projectile.EntityFishHook(world, (net.minecraft.entity.player.EntityPlayer) getHandle());
    } else if (Fireball.class.isAssignableFrom(projectile)) {
        Location location = getEyeLocation();
        Vector direction = location.getDirection().multiply(10);

        if (SmallFireball.class.isAssignableFrom(projectile)) {
            launch = new net.minecraft.entity.projectile.EntitySmallFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
        } else if (WitherSkull.class.isAssignableFrom(projectile)) {
            launch = new net.minecraft.entity.projectile.EntityWitherSkull(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
        } else {
            launch = new net.minecraft.entity.projectile.EntityLargeFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
        }

        ((net.minecraft.entity.projectile.EntityFireball) launch).projectileSource = this;
        launch.setLocationAndAngles(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    }

    Validate.notNull(launch, "Projectile not supported");

    if (velocity != null) {
        ((T) launch.getBukkitEntity()).setVelocity(velocity);
    }

    world.spawnEntityInWorld(launch);
    return (T) launch.getBukkitEntity();
}
 
Example #11
Source File: PlayerFishEvent.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Gets the fishing hook.
 *
 * @return Fish the entity representing the fishing hook/bobber.
 */
public Fish getHook() {
    return hookEntity;
}