added player_collides_with_entity event

This commit is contained in:
gnembon committed 2020-09-17 21:29:35 -03:00
1 parent 755f3a7840
commit c0707fe544
6 files changed
+38 -6

No files matched your search

@@ -2,6 +2,7 @@ package carpet.mixins;
import carpet.fakes.EntityInterface;
import carpet.script.EntityEventsGroup;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
@@ -16,6 +17,7 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import static carpet.script.CarpetEventServer.Event.PLAYER_DEALS_DAMAGE;
import static carpet.script.CarpetEventServer.Event.PLAYER_TAKES_DAMAGE;
import static carpet.script.CarpetEventServer.Event.PLAYER_COLLIDES_WITH_ENTITY;
@Mixin(PlayerEntity.class)
public abstract class PlayerEntity_scarpetEventsMixin extends LivingEntity
@@ -42,4 +44,13 @@ public abstract class PlayerEntity_scarpetEventsMixin extends LivingEntity
PLAYER_DEALS_DAMAGE.onDamage(this, amount, source);
}
}
@Inject(method = "collideWithEntity", at = @At("HEAD"))
private void onEntityCollision(Entity entity, CallbackInfo ci)
{
if (PLAYER_COLLIDES_WITH_ENTITY.isNeeded() && !world.isClient)
{
PLAYER_COLLIDES_WITH_ENTITY.onEntityAction((ServerPlayerEntity)(Object)this, entity, null);
}
}
}