use of org.spongepowered.common.event.tracking.PhaseTracker in project SpongeCommon by SpongePowered.
the class EntityMixin_Tracker method tracker$logEntityDropTransactionIfNecessary.
@Inject(method = "spawnAtLocation(Lnet/minecraft/world/item/ItemStack;F)Lnet/minecraft/world/entity/item/ItemEntity;", at = @At("HEAD"))
private void tracker$logEntityDropTransactionIfNecessary(final ItemStack stack, final float offsetY, final CallbackInfoReturnable<ItemEntity> cir) {
final PhaseTracker instance = PhaseTracker.SERVER;
if (!instance.onSidedThread()) {
return;
}
if (((LevelBridge) this.level).bridge$isFake()) {
return;
}
final PhaseContext<@NonNull ?> context = instance.getPhaseContext();
if (!context.doesBlockEventTracking()) {
return;
}
if (this.tracker$dropsTransactor == null) {
this.tracker$dropsTransactor = context.getTransactor().ensureEntityDropTransactionEffect((Entity) (Object) this);
}
}
use of org.spongepowered.common.event.tracking.PhaseTracker in project SpongeCommon by SpongePowered.
the class LivingEntityMixin_Tracker method tracker$wrapOnDeathWithState.
/**
* @author gabizou
* @reason Instead of inlining the onDeath method with the main mixin, we can "toggle"
* the usage of the death state control in the tracker mixin.
*/
@Redirect(method = "hurt", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;die(Lnet/minecraft/world/damagesource/DamageSource;)V"))
private void tracker$wrapOnDeathWithState(final LivingEntity thisEntity, final DamageSource cause) {
// Sponge Start - notify the cause tracker
final PhaseTracker instance = PhaseTracker.SERVER;
if (!instance.onSidedThread()) {
return;
}
if (((LevelBridge) this.level).bridge$isFake()) {
return;
}
final PhaseContext<@NonNull ?> context = instance.getPhaseContext();
if (!context.doesBlockEventTracking()) {
return;
}
try (final EffectTransactor ignored = context.getTransactor().ensureEntityDropTransactionEffect((LivingEntity) (Object) this)) {
// Create new EntityDeathTransaction
// Add new EntityDeathEffect
this.shadow$die(cause);
}
// Sponge End
}
Aggregations