• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FishHook类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.bukkit.entity.FishHook的典型用法代码示例。如果您正苦于以下问题:Java FishHook类的具体用法?Java FishHook怎么用?Java FishHook使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FishHook类属于org.bukkit.entity包,在下文中一共展示了FishHook类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onRodLand

import org.bukkit.entity.FishHook; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onRodLand(ProjectileHitEvent e) {

	Entity hookEntity = e.getEntity();
	World world = hookEntity.getWorld();

	if (!isEnabled(world)) return;

	if (e.getEntityType() != EntityType.FISHING_HOOK)
		return;


	Entity hitent = null;

	try{
		hitent = e.getHitEntity();
	}
	catch(NoSuchMethodError e1){ //For older version that don't have such method
		Collection<Entity> entities = world.getNearbyEntities(hookEntity.getLocation(), 0.25, 0.25, 0.25);

		for (Entity entity : entities) {
			if (entity instanceof Player)
				hitent = entity;
			break;

		}
	}

	if(hitent == null) return;
	if(!(hitent instanceof Player)) return;

	FishHook hook = (FishHook) hookEntity;
	Player rodder = (Player) hook.getShooter();
	Player player = (Player) hitent;

	debug("You were hit by a fishing rod!", player);

	if (player.getUniqueId().equals(rodder.getUniqueId()))
		return;

	if(player.getGameMode() == GameMode.CREATIVE) return;

	double damage = module().getDouble("damage");
	if(damage < 0) damage = 0.2;

	EntityDamageEvent event = makeEvent(rodder, player, damage);
	Bukkit.getPluginManager().callEvent(event);

	if(module().getBoolean("checkCancelled") && event.isCancelled()){

		//This is to check what plugins are listening to the event
		if(plugin.getConfig().getBoolean("debug.enabled")){
			debug("You can't do that here!", rodder);
			HandlerList hl = event.getHandlers();

			for(RegisteredListener rl : hl.getRegisteredListeners())
				debug("Plugin Listening: " + rl.getPlugin().getName(), rodder);
		}

		return;
	}

	player.damage(damage);

	Location loc = player.getLocation().add(0, 0.5, 0);
	player.teleport(loc);
	player.setVelocity(loc.subtract(rodder.getLocation()).toVector().normalize().multiply(0.4));
}
 
开发者ID:gvlfm78,项目名称:BukkitOldCombatMechanics,代码行数:69,代码来源:ModuleFishingKnockback.java


示例2: reelVelocity

import org.bukkit.entity.FishHook; //导入依赖的package包/类
private Vector reelVelocity(Player player, FishHook hook) {
    double x = player.getLocation().getX() - hook.getLocation().getX();
    double y = player.getLocation().getY() - hook.getLocation().getY();
    double z = player.getLocation().getZ() - hook.getLocation().getZ();
    return new Vector(x * 0.1D, y * 0.1D + Math.sqrt(Math.sqrt(x * x + y * y + z * z)) * 0.08D, z * 0.1D);
}
 
开发者ID:WaywardRealms,项目名称:Wayward,代码行数:7,代码来源:PlayerFishListener.java


示例3: Bullet

import org.bukkit.entity.FishHook; //导入依赖的package包/类
public Bullet(SwornGuns plugin, GunPlayer shooter, Gun shotFrom, Vector velocity)
{
	this.plugin = plugin;
	this.shotFrom = shotFrom;
	this.shooter = shooter;
	this.velocity = velocity;
	this.active = true;

	if (shotFrom.isThrowable())
	{
		ItemStack thrown = shotFrom.getMaterial().newItemStack(1);

		this.projectile = shooter.getPlayer().getWorld().dropItem(shooter.getPlayer().getEyeLocation(), thrown);
		this.id = projectile.getEntityId();

		((Item) projectile).setPickupDelay(9999999);
		this.startLocation = projectile.getLocation();
	}
	else
	{
		Class<? extends Projectile> mclass = Snowball.class;

		String check = shotFrom.getProjType().toLowerCase().replaceAll("_", "").replaceAll(" ", "");
		switch (check)
		{
			case "arrow":
				mclass = Arrow.class;
				break;
			case "egg":
				mclass = Egg.class;
				break;
			case "enderpearl":
				mclass = EnderPearl.class;
				break;
			case "fireball":
				mclass = Fireball.class;
				break;
			case "fish":
			case "fishhook":
				mclass = FishHook.class;
				break;
			case "largefireball":
				mclass = LargeFireball.class;
				break;
			case "smallfireball":
				mclass = SmallFireball.class;
				break;
			case "thrownexpbottle":
				mclass = ThrownExpBottle.class;
				break;
			case "thrownpotion":
				mclass = ThrownPotion.class;
				break;
			case "witherskull":
				mclass = WitherSkull.class;
				break;
			default:
				break;
		}

		this.projectile = shooter.getPlayer().launchProjectile(mclass);
		this.id = projectile.getEntityId();

		((Projectile) projectile).setShooter(shooter.getPlayer());
		this.startLocation = projectile.getLocation();
	}

	if (shotFrom.getReleaseTime() == -1)
	{
		this.releaseTime = 80 + (shotFrom.isThrowable() ? 0 : 1) * 400;
	}
	else
	{
		this.releaseTime = shotFrom.getReleaseTime();
	}
}
 
开发者ID:dmulloy2,项目名称:SwornGuns,代码行数:77,代码来源:Bullet.java



注:本文中的org.bukkit.entity.FishHook类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HornetQJMSClient类代码示例发布时间:2022-05-23
下一篇:
Java SqlDialect类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap