东极神帝 发表于 2021-8-5 13:43
使用 instanceof
刚看到 感谢大佬!
贺兰兰 发表于 2021-8-5 13:15
if(entity instanceof LivingEntity) 以判断 entity 类型为 LivingEntity
使用 EntityDamageByEntityEvent ...
谢谢大佬!
instanceof 可是Java基础
另外补充个获取弹射物发射者的复制代码
另外补充个获取弹射物发射者的
- Entity entity;
- if (entity instanceof Projectile){
- ProjectileSource source = (Projectile) entity).getShooter();
- if(source instanceof Player){
- Player player = (Player)source;
- }
- }