mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Fix build
This commit is contained in:
parent
6175605069
commit
d1b3e8702a
3 changed files with 98 additions and 27 deletions
|
@ -3,6 +3,7 @@ package com.minelittlepony.unicopia.ability.magic.spell;
|
|||
import java.util.*;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
import com.minelittlepony.unicopia.ability.magic.SpellPredicate;
|
||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.CustomisedSpellType;
|
||||
|
@ -28,6 +29,10 @@ public abstract class AbstractDelegatingSpell implements Spell {
|
|||
return delegate.get();
|
||||
}
|
||||
|
||||
private Spell getOrEmpty() {
|
||||
return MoreObjects.firstNonNull(delegate.get(), EmptySpell.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsOrContains(UUID id) {
|
||||
return Spell.super.equalsOrContains(id) || delegate.equalsOrContains(id);
|
||||
|
@ -50,26 +55,22 @@ public abstract class AbstractDelegatingSpell implements Spell {
|
|||
|
||||
@Override
|
||||
public void setDead() {
|
||||
if (delegate.get() != null) {
|
||||
delegate.get().setDead();
|
||||
}
|
||||
getOrEmpty().setDead();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickDying(Caster<?> caster) {
|
||||
if (delegate.get() != null) {
|
||||
delegate.get().tickDying(caster);
|
||||
}
|
||||
getOrEmpty().tickDying(caster);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDead() {
|
||||
return delegate.get() == null;
|
||||
return getOrEmpty().isDead();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDying() {
|
||||
return delegate.get() != null && delegate.get().isDying();
|
||||
return getOrEmpty().isDying();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -84,12 +85,12 @@ public abstract class AbstractDelegatingSpell implements Spell {
|
|||
|
||||
@Override
|
||||
public boolean isHidden() {
|
||||
return hidden || (delegate.get() != null && delegate.get().isHidden());
|
||||
return hidden || getOrEmpty().isHidden();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHidden(boolean hidden) {
|
||||
this.hidden = hidden;
|
||||
getOrEmpty().setHidden(hidden);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -106,21 +107,17 @@ public abstract class AbstractDelegatingSpell implements Spell {
|
|||
if (!caster.isClient()) {
|
||||
Ether.get(caster.asWorld()).remove(this, caster);
|
||||
}
|
||||
if (delegate.get() instanceof Spell s) {
|
||||
s.destroy(caster);
|
||||
}
|
||||
getOrEmpty().destroy(caster);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tick(Caster<?> source, Situation situation) {
|
||||
if (delegate.get() instanceof Spell s) {
|
||||
if (s.isDying()) {
|
||||
s.tickDying(source);
|
||||
return !s.isDead();
|
||||
}
|
||||
return s.tick(source, situation) && !isDead();
|
||||
Spell s = getOrEmpty();
|
||||
if (s.isDying()) {
|
||||
s.tickDying(source);
|
||||
return !s.isDead();
|
||||
}
|
||||
return !isDead();
|
||||
return s.tick(source, situation);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
package com.minelittlepony.unicopia.ability.magic.spell;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.CustomisedSpellType;
|
||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
||||
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.util.Util;
|
||||
|
||||
public final class EmptySpell implements Spell {
|
||||
public static final EmptySpell INSTANCE = new EmptySpell();
|
||||
|
||||
private EmptySpell() {}
|
||||
|
||||
@Override
|
||||
public void toNBT(NbtCompound compound) { }
|
||||
|
||||
@Override
|
||||
public void fromNBT(NbtCompound compound) { }
|
||||
|
||||
@Override
|
||||
public CustomisedSpellType<?> getTypeAndTraits() {
|
||||
return SpellType.EMPTY_KEY.withTraits();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUuid() {
|
||||
return Util.NIL_UUID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDead() { }
|
||||
|
||||
@Override
|
||||
public boolean isDead() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDying() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tick(Caster<?> caster, Situation situation) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickDying(Caster<?> caster) { }
|
||||
|
||||
@Override
|
||||
public void setDirty() { }
|
||||
|
||||
@Override
|
||||
public boolean isHidden() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHidden(boolean hidden) { }
|
||||
|
||||
@Override
|
||||
public void destroy(Caster<?> caster) { }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EmptySpell{}";
|
||||
}
|
||||
}
|
|
@ -64,11 +64,10 @@ public interface Disguise extends FlightType.Provider, PlayerDimensions.Provider
|
|||
@SuppressWarnings("unchecked")
|
||||
default boolean update(Caster<?> caster, boolean tick) {
|
||||
|
||||
if (!(caster instanceof Living)) {
|
||||
if (!(caster instanceof Living<?> source)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Living<?> source = (Living<?>)caster;
|
||||
LivingEntity owner = source.asEntity();
|
||||
|
||||
if (owner == null) {
|
||||
|
@ -89,8 +88,8 @@ public interface Disguise extends FlightType.Provider, PlayerDimensions.Provider
|
|||
|
||||
entity.noClip = true;
|
||||
|
||||
if (entity instanceof MobEntity) {
|
||||
((MobEntity)entity).setAiDisabled(true);
|
||||
if (entity instanceof MobEntity mob) {
|
||||
mob.setAiDisabled(true);
|
||||
}
|
||||
|
||||
entity.setInvisible(false);
|
||||
|
@ -117,9 +116,7 @@ public interface Disguise extends FlightType.Provider, PlayerDimensions.Provider
|
|||
|
||||
behaviour.update(source, entity, this);
|
||||
|
||||
if (source instanceof Pony) {
|
||||
Pony player = (Pony)source;
|
||||
|
||||
if (source instanceof Pony player) {
|
||||
source.asEntity().setInvisible(true);
|
||||
player.setInvisible(true);
|
||||
|
||||
|
|
Loading…
Reference in a new issue