Upstream: Add ArrowBodyCountChangeEvent
This commit is contained in:
parent
a401ef3111
commit
56547dd0ca
|
@ -170,6 +170,8 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt
|
|||
@Shadow protected abstract void damageArmor(DamageSource damageSource, float damage);
|
||||
@Shadow protected abstract void playEquipSound(ItemStack stack);
|
||||
@Shadow public abstract boolean getShouldBeDead();
|
||||
@Shadow public abstract int getArrowCountInEntity();
|
||||
@Shadow @Final private static DataParameter<Integer> ARROW_COUNT_IN_ENTITY;
|
||||
// @formatter:on
|
||||
|
||||
public int expToDrop;
|
||||
|
@ -1055,4 +1057,22 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt
|
|||
arclight$cause = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "setArrowCountInEntity", cancellable = true, at = @At("HEAD"))
|
||||
private void arclight$onArrowChange(int count, CallbackInfo ci) {
|
||||
if (arclight$callArrowCountChange(count, false)) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
public final void setArrowCount(int count, boolean reset) {
|
||||
if (arclight$callArrowCountChange(count, reset)) {
|
||||
return;
|
||||
}
|
||||
this.dataManager.set(ARROW_COUNT_IN_ENTITY, count);
|
||||
}
|
||||
|
||||
private boolean arclight$callArrowCountChange(int newCount, boolean reset) {
|
||||
return CraftEventFactory.callArrowBodyCountChangeEvent((LivingEntity) (Object) this, this.getArrowCountInEntity(), newCount, reset).isCancelled();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -891,7 +891,8 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntityMixin implemen
|
|||
this.experienceLevel = this.newLevel;
|
||||
this.experienceTotal = this.newTotalExp;
|
||||
this.experience = 0.0f;
|
||||
this.setArrowCountInEntity(this.deathTime = 0);
|
||||
this.deathTime = 0;
|
||||
this.setArrowCount(0, true);
|
||||
this.removeAllEffects(EntityPotionEffectEvent.Cause.DEATH);
|
||||
this.potionsNeedUpdate = true;
|
||||
this.openContainer = this.container;
|
||||
|
|
Loading…
Reference in New Issue
Block a user