mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 07:17:58 +01:00
Fix build
This commit is contained in:
parent
c0cff59963
commit
ae8068ccb4
3 changed files with 29 additions and 7 deletions
|
@ -483,8 +483,8 @@ public abstract class Living<T extends LivingEntity> implements Equine<T>, Caste
|
|||
|
||||
public Optional<Boolean> onDamage(DamageSource source, float amount) {
|
||||
|
||||
if ((source.getAttacker() instanceof Guest guest && guest.getHost() instanceof Living l && l == this)
|
||||
|| (source.getSource() instanceof Guest guest && guest.getHost() instanceof Living l && l == this)) {
|
||||
if (Guest.of(source.getAttacker()).hostIs(this)
|
||||
|| Guest.of(source.getSource()).hostIs(this)) {
|
||||
var type = source.getTypeRegistryEntry();
|
||||
return Optional.of(entity.damage(
|
||||
type.matchesKey(DamageTypes.FIREBALL) ? entity.getDamageSources().create(DamageTypes.UNATTRIBUTED_FIREBALL) :
|
||||
|
@ -492,7 +492,7 @@ public abstract class Living<T extends LivingEntity> implements Equine<T>, Caste
|
|||
new DamageSource(type, entity, entity), amount));
|
||||
}
|
||||
|
||||
if (entity instanceof Guest guest && guest.getHost() instanceof Living l) {
|
||||
if (Guest.of(entity).getHost() instanceof Living l) {
|
||||
l.asEntity().damage(source, amount);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,37 @@
|
|||
package com.minelittlepony.unicopia.entity.behaviour;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
public interface Guest {
|
||||
void setHost(Caster<?> host);
|
||||
Guest NULL = new Guest() {
|
||||
@Override
|
||||
public void setHost(@Nullable Caster<?> host) { }
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Caster<?> getHost() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
void setHost(@Nullable Caster<?> host);
|
||||
|
||||
@Nullable
|
||||
Caster<?> getHost();
|
||||
|
||||
static boolean hasHost(Entity entity) {
|
||||
return ((Guest)entity).getHost() != null;
|
||||
static Guest of(@Nullable Entity entity) {
|
||||
return entity == null ? NULL : (Guest)entity;
|
||||
}
|
||||
|
||||
default boolean hasHost() {
|
||||
return getHost() != null;
|
||||
}
|
||||
|
||||
default boolean hostIs(Caster<?> self) {
|
||||
return getHost() == self;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ public class CrystalShardsEntity extends StationaryObjectEntity {
|
|||
}
|
||||
}
|
||||
|
||||
if (!Guest.hasHost(this)) {
|
||||
if (!Guest.of(this).hasHost()) {
|
||||
if (isDead() || isInvalid(getWorld(), getBlockPos(), getAttachmentFace())) {
|
||||
kill();
|
||||
ParticleUtils.spawnParticles(ParticleTypes.CLOUD, this, 10);
|
||||
|
|
Loading…
Reference in a new issue