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);
|
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
|
protected @Nullable
|
||||||
GameProfile getPlayerName() {
|
GameProfile getPlayerName() {
|
||||||
Player player = getStoredPlayer();
|
Player player = getStoredPlayer();
|
||||||
|
|
|
@ -33,7 +33,6 @@ class OpCreateSentinel(val extendsRange: Boolean) : SpellAction {
|
||||||
IXplatAbstractions.INSTANCE.setSentinel(
|
IXplatAbstractions.INSTANCE.setSentinel(
|
||||||
ctx.caster,
|
ctx.caster,
|
||||||
Sentinel(
|
Sentinel(
|
||||||
true,
|
|
||||||
extendsRange,
|
extendsRange,
|
||||||
target,
|
target,
|
||||||
ctx.world.dimension()
|
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.misc.MediaConstants
|
||||||
|
|
||||||
import at.petrak.hexcasting.api.player.Sentinel
|
|
||||||
import at.petrak.hexcasting.api.casting.ParticleSpray
|
import at.petrak.hexcasting.api.casting.ParticleSpray
|
||||||
import at.petrak.hexcasting.api.casting.RenderedSpell
|
import at.petrak.hexcasting.api.casting.RenderedSpell
|
||||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||||
|
@ -16,9 +15,9 @@ object OpDestroySentinel : SpellAction {
|
||||||
override fun execute(
|
override fun execute(
|
||||||
args: List<Iota>,
|
args: List<Iota>,
|
||||||
ctx: CastingEnvironment
|
ctx: CastingEnvironment
|
||||||
): Triple<RenderedSpell, Int, List<ParticleSpray>> {
|
): Triple<RenderedSpell, Int, List<ParticleSpray>>? {
|
||||||
val particles = mutableListOf<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?
|
// TODO why can't you remove things from other dimensions?
|
||||||
if (sentinel.dimension != ctx.world.dimension())
|
if (sentinel.dimension != ctx.world.dimension())
|
||||||
throw MishapLocationInWrongDimension(sentinel.dimension.location())
|
throw MishapLocationInWrongDimension(sentinel.dimension.location())
|
||||||
|
@ -33,7 +32,7 @@ object OpDestroySentinel : SpellAction {
|
||||||
|
|
||||||
private object Spell : RenderedSpell {
|
private object Spell : RenderedSpell {
|
||||||
override fun cast(ctx: CastingEnvironment) {
|
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 argc = 0
|
||||||
override val mediaCost = MediaConstants.DUST_UNIT / 10
|
override val mediaCost = MediaConstants.DUST_UNIT / 10
|
||||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
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())
|
if (sentinel.dimension != ctx.world.dimension())
|
||||||
throw MishapLocationInWrongDimension(sentinel.dimension.location())
|
throw MishapLocationInWrongDimension(sentinel.dimension.location())
|
||||||
return if (sentinel.hasSentinel)
|
return sentinel.position.asActionResult
|
||||||
sentinel.position.asActionResult
|
|
||||||
else
|
|
||||||
listOf(NullIota())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,14 +18,11 @@ object OpGetSentinelWayfind : ConstMediaAction {
|
||||||
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
|
||||||
val from = args.getVec3(0, argc)
|
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())
|
if (sentinel.dimension != ctx.world.dimension())
|
||||||
throw MishapLocationInWrongDimension(sentinel.dimension.location())
|
throw MishapLocationInWrongDimension(sentinel.dimension.location())
|
||||||
|
|
||||||
return if (!sentinel.hasSentinel)
|
return sentinel.position.subtract(from).normalize().asActionResult
|
||||||
listOf(NullIota())
|
|
||||||
else
|
|
||||||
sentinel.position.subtract(from).normalize().asActionResult
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ public interface IXplatAbstractions {
|
||||||
|
|
||||||
void setColorizer(Player target, FrozenColorizer colorizer);
|
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);
|
void setFlight(ServerPlayer target, @Nullable FlightAbility flight);
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ public interface IXplatAbstractions {
|
||||||
|
|
||||||
FrozenColorizer getColorizer(Player player);
|
FrozenColorizer getColorizer(Player player);
|
||||||
|
|
||||||
Sentinel getSentinel(Player player);
|
@Nullable Sentinel getSentinel(Player player);
|
||||||
|
|
||||||
CastingVM getStaffcastVM(ServerPlayer player, InteractionHand hand);
|
CastingVM getStaffcastVM(ServerPlayer player, InteractionHand hand);
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,8 @@ import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class CCSentinel implements Component, AutoSyncedComponent {
|
public class CCSentinel implements Component, AutoSyncedComponent {
|
||||||
public static final String
|
public static final String
|
||||||
TAG_HAS_SENTINEL = "has_sentinel",
|
TAG_HAS_SENTINEL = "has_sentinel",
|
||||||
|
@ -18,13 +20,13 @@ public class CCSentinel implements Component, AutoSyncedComponent {
|
||||||
TAG_DIMENSION = "dimension";
|
TAG_DIMENSION = "dimension";
|
||||||
|
|
||||||
private final Player owner;
|
private final Player owner;
|
||||||
private Sentinel sentinel = Sentinel.none();
|
private @Nullable Sentinel sentinel = null;
|
||||||
|
|
||||||
public CCSentinel(Player owner) {
|
public CCSentinel(Player owner) {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Sentinel getSentinel() {
|
public @Nullable Sentinel getSentinel() {
|
||||||
return sentinel;
|
return sentinel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,16 +43,16 @@ public class CCSentinel implements Component, AutoSyncedComponent {
|
||||||
var position = HexUtils.vecFromNBT(tag.getLongArray(TAG_POSITION));
|
var position = HexUtils.vecFromNBT(tag.getLongArray(TAG_POSITION));
|
||||||
var dim = ResourceKey.create(Registry.DIMENSION_REGISTRY,
|
var dim = ResourceKey.create(Registry.DIMENSION_REGISTRY,
|
||||||
new ResourceLocation(tag.getString(TAG_DIMENSION)));
|
new ResourceLocation(tag.getString(TAG_DIMENSION)));
|
||||||
this.sentinel = new Sentinel(true, extendsRange, position, dim);
|
this.sentinel = new Sentinel(extendsRange, position, dim);
|
||||||
} else {
|
} else {
|
||||||
this.sentinel = Sentinel.none();
|
this.sentinel = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNbt(CompoundTag tag) {
|
public void writeToNbt(CompoundTag tag) {
|
||||||
tag.putBoolean(TAG_HAS_SENTINEL, this.sentinel.hasSentinel());
|
tag.putBoolean(TAG_HAS_SENTINEL, this.sentinel != null);
|
||||||
if (this.sentinel.hasSentinel()) {
|
if (this.sentinel != null) {
|
||||||
tag.putBoolean(TAG_EXTENDS_RANGE, this.sentinel.extendsRange());
|
tag.putBoolean(TAG_EXTENDS_RANGE, this.sentinel.extendsRange());
|
||||||
tag.put(TAG_POSITION, HexUtils.serializeToNBT(this.sentinel.position()));
|
tag.put(TAG_POSITION, HexUtils.serializeToNBT(this.sentinel.position()));
|
||||||
tag.putString(TAG_DIMENSION, this.sentinel.dimension().location().toString());
|
tag.putString(TAG_DIMENSION, this.sentinel.dimension().location().toString());
|
||||||
|
|
|
@ -155,7 +155,7 @@ public class FabricXplatImpl implements IXplatAbstractions {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSentinel(Player target, Sentinel sentinel) {
|
public void setSentinel(Player target, @Nullable Sentinel sentinel) {
|
||||||
var cc = HexCardinalComponents.SENTINEL.get(target);
|
var cc = HexCardinalComponents.SENTINEL.get(target);
|
||||||
cc.setSentinel(sentinel);
|
cc.setSentinel(sentinel);
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,7 +195,7 @@ public class ForgeXplatImpl implements IXplatAbstractions {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSentinel(Player player, Sentinel sentinel) {
|
public void setSentinel(Player player, @Nullable Sentinel sentinel) {
|
||||||
CompoundTag tag = player.getPersistentData();
|
CompoundTag tag = player.getPersistentData();
|
||||||
tag.putBoolean(TAG_SENTINEL_EXISTS, sentinel.hasSentinel());
|
tag.putBoolean(TAG_SENTINEL_EXISTS, sentinel.hasSentinel());
|
||||||
if (sentinel.hasSentinel()) {
|
if (sentinel.hasSentinel()) {
|
||||||
|
|
Loading…
Reference in a new issue