Events are defined statically in normal classes and added handler for extensions to add their built-ins

This commit is contained in:
gnembon committed 2020-09-08 23:47:31 -03:00
1 parent 815c75b827
commit 3105d5bb71
11 files changed
+126 -113

No files matched your search

@@ -65,14 +65,14 @@ public abstract class Entity_scarpetEventsMixin implements EntityInterface
@Inject(method = "tick", at = @At("HEAD"))
private void onTickCall(CallbackInfo ci)
{
events.onEvent(EntityEventsGroup.EntityEventType.ON_TICK);
events.onEvent(EntityEventsGroup.Event.ON_TICK);
}
@Inject(method = "remove", at = @At("HEAD"))
private void onRemove(CallbackInfo ci)
{
if (!removed) events.onEvent(EntityEventsGroup.EntityEventType.ON_REMOVED);
if (!removed) events.onEvent(EntityEventsGroup.Event.ON_REMOVED);
}
@@ -23,6 +23,6 @@ public abstract class FallingBlockEntity_scarpetEventsMixin extends Entity
private void onTickCall(CallbackInfo ci)
{
// calling extra on_tick because falling blocks do not fall back to super tick call
((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.EntityEventType.ON_TICK);
((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.Event.ON_TICK);
}
}
@@ -34,7 +34,7 @@ public abstract class LivingEntity_scarpetEventsMixin extends Entity implements
@Inject(method = "onDeath", at = @At("HEAD"))
private void onDeathCall(DamageSource damageSource_1, CallbackInfo ci)
{
((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.EntityEventType.ON_DEATH, damageSource_1.name);
((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.Event.ON_DEATH, damageSource_1.name);
}
@Inject(method = "applyDamage", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(
@@ -44,7 +44,7 @@ public abstract class LivingEntity_scarpetEventsMixin extends Entity implements
))
private void entityTakingDamage(DamageSource source, float amount, CallbackInfo ci)
{
((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.EntityEventType.ON_DAMAGE, amount, source);
((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.Event.ON_DAMAGE, amount, source);
// this is not applicable since its not a playr for sure
//if (entity instanceof ServerPlayerEntity && PLAYER_TAKES_DAMAGE.isNeeded())
//{
@@ -32,7 +32,7 @@ public abstract class PlayerEntity_scarpetEventsMixin extends LivingEntity
private void playerTakingDamage(DamageSource source, float amount, CallbackInfo ci)
{
// version of LivingEntity_scarpetEventsMixin::entityTakingDamage
((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.EntityEventType.ON_DAMAGE, amount, source);
((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.Event.ON_DAMAGE, amount, source);
if (PLAYER_TAKES_DAMAGE.isNeeded())
{
PLAYER_TAKES_DAMAGE.onDamage(this, amount, source);
@@ -15,7 +15,6 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@@ -72,7 +71,7 @@ public abstract class ServerPlayerEntity_scarpetEventMixin extends PlayerEntity
@Inject(method = "onDeath", at = @At("HEAD"))
private void onDeathEvent(DamageSource source, CallbackInfo ci)
{
((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.EntityEventType.ON_DEATH, source.name);
((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.Event.ON_DEATH, source.name);
if (PLAYER_DIES.isNeeded())
{
PLAYER_DIES.onPlayerEvent((ServerPlayerEntity) (Object)this);