forked from Sollace/Unicopia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
29 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 25 additions & 3 deletions
28
src/main/java/com/minelittlepony/unicopia/entity/behaviour/Guest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters