removed unused methods from BlockEntityStoredPlayerImpetus, fixed sentinel now being nullable, and using null to indicate no sentinel.
This commit is contained in:
parent
7c712adac6
commit
a51aead089
9 changed files with 19 additions and 36 deletions
|
@ -35,17 +35,6 @@ public class BlockEntityStoredPlayerImpetus extends BlockEntityAbstractImpetus {
|
|||
super(HexBlockEntities.IMPETUS_STOREDPLAYER_TILE, pWorldPosition, pBlockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean activatorAlwaysInRange() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable
|
||||
Player getPlayer() {
|
||||
return this.storedPlayer == null ? null : this.level.getPlayerByUUID(this.storedPlayer);
|
||||
}
|
||||
|
||||
protected @Nullable
|
||||
GameProfile getPlayerName() {
|
||||
Player player = getStoredPlayer();
|
||||
|
|
|
@ -33,7 +33,6 @@ class OpCreateSentinel(val extendsRange: Boolean) : SpellAction {
|
|||
IXplatAbstractions.INSTANCE.setSentinel(
|
||||
ctx.caster,
|
||||
Sentinel(
|
||||
true,
|
||||
extendsRange,
|
||||
target,
|
||||
ctx.world.dimension()
|
||||
|
|
|
@ -2,7 +2,6 @@ package at.petrak.hexcasting.common.casting.operators.spells.sentinel
|
|||
|
||||
import at.petrak.hexcasting.api.misc.MediaConstants
|
||||
|
||||
import at.petrak.hexcasting.api.player.Sentinel
|
||||
import at.petrak.hexcasting.api.casting.ParticleSpray
|
||||
import at.petrak.hexcasting.api.casting.RenderedSpell
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
|
@ -16,9 +15,9 @@ object OpDestroySentinel : SpellAction {
|
|||
override fun execute(
|
||||
args: List<Iota>,
|
||||
ctx: CastingEnvironment
|
||||
): Triple<RenderedSpell, Int, List<ParticleSpray>> {
|
||||
): Triple<RenderedSpell, Int, List<ParticleSpray>>? {
|
||||
val particles = mutableListOf<ParticleSpray>()
|
||||
val sentinel = IXplatAbstractions.INSTANCE.getSentinel(ctx.caster)
|
||||
val sentinel = IXplatAbstractions.INSTANCE.getSentinel(ctx.caster) ?: return null
|
||||
// TODO why can't you remove things from other dimensions?
|
||||
if (sentinel.dimension != ctx.world.dimension())
|
||||
throw MishapLocationInWrongDimension(sentinel.dimension.location())
|
||||
|
@ -33,7 +32,7 @@ object OpDestroySentinel : SpellAction {
|
|||
|
||||
private object Spell : RenderedSpell {
|
||||
override fun cast(ctx: CastingEnvironment) {
|
||||
IXplatAbstractions.INSTANCE.setSentinel(ctx.caster, Sentinel.none())
|
||||
IXplatAbstractions.INSTANCE.setSentinel(ctx.caster, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,12 +13,9 @@ object OpGetSentinelPos : ConstMediaAction {
|
|||
override val argc = 0
|
||||
override val mediaCost = MediaConstants.DUST_UNIT / 10
|
||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val sentinel = IXplatAbstractions.INSTANCE.getSentinel(ctx.caster)
|
||||
val sentinel = IXplatAbstractions.INSTANCE.getSentinel(ctx.caster) ?: return listOf(NullIota())
|
||||
if (sentinel.dimension != ctx.world.dimension())
|
||||
throw MishapLocationInWrongDimension(sentinel.dimension.location())
|
||||
return if (sentinel.hasSentinel)
|
||||
sentinel.position.asActionResult
|
||||
else
|
||||
listOf(NullIota())
|
||||
return sentinel.position.asActionResult
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,14 +18,11 @@ object OpGetSentinelWayfind : ConstMediaAction {
|
|||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||
val from = args.getVec3(0, argc)
|
||||
|
||||
val sentinel = IXplatAbstractions.INSTANCE.getSentinel(ctx.caster)
|
||||
val sentinel = IXplatAbstractions.INSTANCE.getSentinel(ctx.caster) ?: return listOf(NullIota())
|
||||
|
||||
if (sentinel.dimension != ctx.world.dimension())
|
||||
throw MishapLocationInWrongDimension(sentinel.dimension.location())
|
||||
|
||||
return if (!sentinel.hasSentinel)
|
||||
listOf(NullIota())
|
||||
else
|
||||
sentinel.position.subtract(from).normalize().asActionResult
|
||||
return sentinel.position.subtract(from).normalize().asActionResult
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ public interface IXplatAbstractions {
|
|||
|
||||
void setColorizer(Player target, FrozenColorizer colorizer);
|
||||
|
||||
void setSentinel(Player target, Sentinel sentinel);
|
||||
void setSentinel(Player target, @Nullable Sentinel sentinel);
|
||||
|
||||
void setFlight(ServerPlayer target, @Nullable FlightAbility flight);
|
||||
|
||||
|
@ -95,7 +95,7 @@ public interface IXplatAbstractions {
|
|||
|
||||
FrozenColorizer getColorizer(Player player);
|
||||
|
||||
Sentinel getSentinel(Player player);
|
||||
@Nullable Sentinel getSentinel(Player player);
|
||||
|
||||
CastingVM getStaffcastVM(ServerPlayer player, InteractionHand hand);
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ import net.minecraft.resources.ResourceKey;
|
|||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class CCSentinel implements Component, AutoSyncedComponent {
|
||||
public static final String
|
||||
TAG_HAS_SENTINEL = "has_sentinel",
|
||||
|
@ -18,13 +20,13 @@ public class CCSentinel implements Component, AutoSyncedComponent {
|
|||
TAG_DIMENSION = "dimension";
|
||||
|
||||
private final Player owner;
|
||||
private Sentinel sentinel = Sentinel.none();
|
||||
private @Nullable Sentinel sentinel = null;
|
||||
|
||||
public CCSentinel(Player owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public Sentinel getSentinel() {
|
||||
public @Nullable Sentinel getSentinel() {
|
||||
return sentinel;
|
||||
}
|
||||
|
||||
|
@ -41,16 +43,16 @@ public class CCSentinel implements Component, AutoSyncedComponent {
|
|||
var position = HexUtils.vecFromNBT(tag.getLongArray(TAG_POSITION));
|
||||
var dim = ResourceKey.create(Registry.DIMENSION_REGISTRY,
|
||||
new ResourceLocation(tag.getString(TAG_DIMENSION)));
|
||||
this.sentinel = new Sentinel(true, extendsRange, position, dim);
|
||||
this.sentinel = new Sentinel(extendsRange, position, dim);
|
||||
} else {
|
||||
this.sentinel = Sentinel.none();
|
||||
this.sentinel = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNbt(CompoundTag tag) {
|
||||
tag.putBoolean(TAG_HAS_SENTINEL, this.sentinel.hasSentinel());
|
||||
if (this.sentinel.hasSentinel()) {
|
||||
tag.putBoolean(TAG_HAS_SENTINEL, this.sentinel != null);
|
||||
if (this.sentinel != null) {
|
||||
tag.putBoolean(TAG_EXTENDS_RANGE, this.sentinel.extendsRange());
|
||||
tag.put(TAG_POSITION, HexUtils.serializeToNBT(this.sentinel.position()));
|
||||
tag.putString(TAG_DIMENSION, this.sentinel.dimension().location().toString());
|
||||
|
|
|
@ -155,7 +155,7 @@ public class FabricXplatImpl implements IXplatAbstractions {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setSentinel(Player target, Sentinel sentinel) {
|
||||
public void setSentinel(Player target, @Nullable Sentinel sentinel) {
|
||||
var cc = HexCardinalComponents.SENTINEL.get(target);
|
||||
cc.setSentinel(sentinel);
|
||||
}
|
||||
|
|
|
@ -195,7 +195,7 @@ public class ForgeXplatImpl implements IXplatAbstractions {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setSentinel(Player player, Sentinel sentinel) {
|
||||
public void setSentinel(Player player, @Nullable Sentinel sentinel) {
|
||||
CompoundTag tag = player.getPersistentData();
|
||||
tag.putBoolean(TAG_SENTINEL_EXISTS, sentinel.hasSentinel());
|
||||
if (sentinel.hasSentinel()) {
|
||||
|
|
Loading…
Reference in a new issue