entity events will execute as that entity
This commit is contained in:
1 parent
e2f48d6d16
commit
ce19dbe505
7 files changed
+28
-19
No files matched your search
@@ -24,7 +24,7 @@ public abstract class DamageTracker_scarpetEventMixin
|
||||
@Inject(method = "onDamage", at = @At("HEAD"))
|
||||
private void onDamageTaken(DamageSource damageSource_1, float float_1, float float_2, CallbackInfo ci)
|
||||
{
|
||||
((EntityInterface)entity).getEventContainer().onEvent(EntityEventsGroup.EntityEventType.ON_DAMAGE, entity, float_2, damageSource_1);
|
||||
((EntityInterface)entity).getEventContainer().onEvent(EntityEventsGroup.EntityEventType.ON_DAMAGE, float_2, damageSource_1);
|
||||
if (entity instanceof ServerPlayerEntity && PLAYER_TAKES_DAMAGE.isNeeded())
|
||||
{
|
||||
PLAYER_TAKES_DAMAGE.onDamage(entity, float_2, damageSource_1);
|
||||
|
||||
@@ -17,7 +17,7 @@ public abstract class Entity_scarpetEventsMixin implements EntityInterface
|
||||
@Shadow protected int netherPortalTime;
|
||||
private boolean permanentVehicle;
|
||||
|
||||
private final EntityEventsGroup events = new EntityEventsGroup();
|
||||
private final EntityEventsGroup events = new EntityEventsGroup((Entity) (Object)this);
|
||||
|
||||
@Override
|
||||
public EntityEventsGroup getEventContainer()
|
||||
@@ -52,14 +52,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, (Entity) (Object) this);
|
||||
events.onEvent(EntityEventsGroup.EntityEventType.ON_TICK);
|
||||
}
|
||||
|
||||
|
||||
@Inject(method = "remove", at = @At("HEAD"))
|
||||
private void onRemove(CallbackInfo ci)
|
||||
{
|
||||
if (!removed) events.onEvent(EntityEventsGroup.EntityEventType.ON_REMOVED, (Entity) (Object) this);
|
||||
if (!removed) events.onEvent(EntityEventsGroup.EntityEventType.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, this);
|
||||
((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.EntityEventType.ON_TICK);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.fakes.EntityInterface;
|
||||
import carpet.fakes.LivingEntityInterface;
|
||||
import carpet.script.EntityEventsGroup;
|
||||
@@ -8,17 +7,12 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(LivingEntity.class)
|
||||
public abstract class LivingEntity_scarpetEventsMixin extends Entity implements LivingEntityInterface
|
||||
@@ -36,7 +30,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, this, damageSource_1.name);
|
||||
((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.EntityEventType.ON_DEATH, damageSource_1.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -68,7 +68,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, this, source.name);
|
||||
((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.EntityEventType.ON_DEATH, source.name);
|
||||
if (PLAYER_DIES.isNeeded())
|
||||
{
|
||||
PLAYER_DIES.onPlayerEvent((ServerPlayerEntity) (Object)this);
|
||||
|
||||
Reference in new issue
Block a user