|
本帖最后由 xm94732568960 于 2023-1-8 14:46 编辑
这么写更好,可以继承玩家使用箭矢的攻击判定
public static void on(LivingAttackEvent e){
DamageSource source=e.getSource();
if (source==null)return;
Entity target=e.getEntity();
if (target.getLevel()instanceof ClientLevel)return;
Entity attacker=source.getEntity();
Entity useEntity=source.getDirectEntity();
if (useEntity instanceof Arrow){
source.bypassArmor().bypassInvul();
try {
Field f=DamageSource.class.getDeclaredField("msgId");
f.setAccessible(true);
f.set(source,"outOfWorld");
}catch (Exception exception){
}
}
} |
|