mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Replace getEntity() with asEntity() and getReferenceWorld() with asWorld()
This commit is contained in:
parent
daa508ba73
commit
a239d30cab
79 changed files with 307 additions and 319 deletions
|
@ -1,6 +1,8 @@
|
|||
package com.minelittlepony.unicopia;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
/**
|
||||
* Interface for things that can be owned by an entity.
|
||||
|
@ -11,4 +13,17 @@ import net.minecraft.entity.Entity;
|
|||
*/
|
||||
public interface EntityConvertable<E extends Entity> {
|
||||
E asEntity();
|
||||
|
||||
/**
|
||||
* Gets the center position where this caster is located.
|
||||
*/
|
||||
default BlockPos getOrigin() {
|
||||
return asEntity().getBlockPos();
|
||||
}
|
||||
/**
|
||||
* Gets the center position where this caster is located.
|
||||
*/
|
||||
default Vec3d getOriginVector() {
|
||||
return asEntity().getPos();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import org.jetbrains.annotations.Nullable;
|
|||
import com.minelittlepony.unicopia.entity.EntityReference;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Interface for things that can be weakly owned (by an entity).
|
||||
|
@ -16,7 +15,7 @@ import net.minecraft.world.World;
|
|||
*
|
||||
* @param <E> The type of object that owns us.
|
||||
*/
|
||||
public interface WeaklyOwned<E extends Entity> extends Owned<E> {
|
||||
public interface WeaklyOwned<E extends Entity> extends Owned<E>, WorldConvertable {
|
||||
|
||||
EntityReference<E> getMasterReference();
|
||||
|
||||
|
@ -40,14 +39,10 @@ public interface WeaklyOwned<E extends Entity> extends Owned<E> {
|
|||
getMasterReference().set(master);
|
||||
}
|
||||
|
||||
default World getReferenceWorld() {
|
||||
return ((Entity)this).getEntityWorld();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
default E getMaster() {
|
||||
return getMasterReference().get(getReferenceWorld());
|
||||
return getMasterReference().get(asWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package com.minelittlepony.unicopia;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface WorldConvertable {
|
||||
/**
|
||||
* Gets the minecraft world
|
||||
*/
|
||||
World asWorld();
|
||||
}
|
|
@ -202,7 +202,7 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable {
|
|||
return;
|
||||
}
|
||||
|
||||
if (ability.canActivate(player.getReferenceWorld(), player)) {
|
||||
if (ability.canActivate(player.asWorld(), player)) {
|
||||
triggered = true;
|
||||
setCooldown(ability.getCooldownTime(player));
|
||||
|
||||
|
|
|
@ -54,18 +54,18 @@ public class BatEeeeAbility implements Ability<Hit> {
|
|||
|
||||
@Override
|
||||
public void apply(Pony player, Hit data) {
|
||||
Random rng = player.getReferenceWorld().random;
|
||||
Random rng = player.asWorld().random;
|
||||
int count = 1 + rng.nextInt(10);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
player.getReferenceWorld().playSound(null, player.getOrigin(), USounds.ENTITY_PLAYER_BATPONY_SCREECH, SoundCategory.PLAYERS,
|
||||
player.asWorld().playSound(null, player.getOrigin(), USounds.ENTITY_PLAYER_BATPONY_SCREECH, SoundCategory.PLAYERS,
|
||||
0.9F + (rng.nextFloat() - 0.5F) / 2F,
|
||||
1.6F + (rng.nextFloat() - 0.5F)
|
||||
);
|
||||
}
|
||||
AwaitTickQueue.scheduleTask(player.getReferenceWorld(), w -> {
|
||||
AwaitTickQueue.scheduleTask(player.asWorld(), w -> {
|
||||
for (int i = 0; i < count; i++) {
|
||||
player.getReferenceWorld().playSound(null, player.getOrigin(), USounds.ENTITY_PLAYER_BATPONY_SCREECH, SoundCategory.PLAYERS,
|
||||
player.asWorld().playSound(null, player.getOrigin(), USounds.ENTITY_PLAYER_BATPONY_SCREECH, SoundCategory.PLAYERS,
|
||||
0.9F + (rng.nextFloat() - 0.5F) / 2F,
|
||||
1.6F + (rng.nextFloat() - 0.5F)
|
||||
);
|
||||
|
|
|
@ -55,7 +55,7 @@ public class CarryAbility implements Ability<Hit> {
|
|||
public boolean onQuickAction(Pony player, ActivationType type) {
|
||||
|
||||
if (type == ActivationType.TAP && player.getPhysics().isFlying()) {
|
||||
player.getPhysics().dashForward((float)player.getReferenceWorld().random.nextTriangular(1, 0.3F));
|
||||
player.getPhysics().dashForward((float)player.asWorld().random.nextTriangular(1, 0.3F));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class CarryAbility implements Ability<Hit> {
|
|||
@Override
|
||||
public void apply(Pony iplayer, Hit data) {
|
||||
PlayerEntity player = iplayer.asEntity();
|
||||
LivingEntity rider = findRider(player, iplayer.getReferenceWorld());
|
||||
LivingEntity rider = findRider(player, iplayer.asWorld());
|
||||
|
||||
if (player.hasPassengers()) {
|
||||
player.removeAllPassengers();
|
||||
|
|
|
@ -42,8 +42,8 @@ public class ChangelingDisguiseAbility extends ChangelingFeedAbility {
|
|||
Trace trace = Trace.create(player, 10, 1, EquinePredicates.VALID_FOR_DISGUISE);
|
||||
|
||||
Entity looked = trace.getEntity().map(AbstractDisguiseSpell::getAppearance).orElseGet(() -> trace.getBlockPos().map(pos -> {
|
||||
if (!iplayer.getReferenceWorld().isAir(pos)) {
|
||||
return MixinFallingBlockEntity.createInstance(player.getEntityWorld(), 0, 0, 0, iplayer.getReferenceWorld().getBlockState(pos));
|
||||
if (!iplayer.asWorld().isAir(pos)) {
|
||||
return MixinFallingBlockEntity.createInstance(player.getEntityWorld(), 0, 0, 0, iplayer.asWorld().getBlockState(pos));
|
||||
}
|
||||
return null;
|
||||
}).orElse(null));
|
||||
|
|
|
@ -80,7 +80,7 @@ public class ChangelingFeedAbility implements Ability<Hit> {
|
|||
}
|
||||
|
||||
protected List<LivingEntity> getTargets(Pony player) {
|
||||
List<Entity> list = VecHelper.findInRange(player.asEntity(), player.getReferenceWorld(), player.getOriginVector(), 3, this::canDrain);
|
||||
List<Entity> list = VecHelper.findInRange(player.asEntity(), player.asWorld(), player.getOriginVector(), 3, this::canDrain);
|
||||
|
||||
TraceHelper.<LivingEntity>findEntity(player.asEntity(), 17, 1,
|
||||
looked -> looked instanceof LivingEntity && !list.contains(looked) && canDrain(looked))
|
||||
|
@ -162,7 +162,7 @@ public class ChangelingFeedAbility implements Ability<Hit> {
|
|||
|
||||
@Override
|
||||
public void postApply(Pony player, AbilitySlot slot) {
|
||||
if (player.getReferenceWorld().random.nextInt(10) == 0) {
|
||||
if (player.asWorld().random.nextInt(10) == 0) {
|
||||
player.spawnParticles(ParticleTypes.HEART, 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ public class EarthPonyGrowAbility implements Ability<Pos> {
|
|||
for (BlockPos pos : BlockPos.iterate(
|
||||
data.pos().add(-2, -2, -2),
|
||||
data.pos().add( 2, 2, 2))) {
|
||||
count += applySingle(player.getReferenceWorld(), player.getReferenceWorld().getBlockState(pos), pos);
|
||||
count += applySingle(player.asWorld(), player.asWorld().getBlockState(pos), pos);
|
||||
}
|
||||
|
||||
if (count > 0) {
|
||||
|
@ -80,7 +80,7 @@ public class EarthPonyGrowAbility implements Ability<Pos> {
|
|||
public void preApply(Pony player, AbilitySlot slot) {
|
||||
player.getMagicalReserves().getExertion().add(30);
|
||||
|
||||
if (player.getReferenceWorld().isClient()) {
|
||||
if (player.asWorld().isClient()) {
|
||||
player.spawnParticles(MagicParticleEffect.UNICORN, 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public class EarthPonyKickAbility implements Ability<Pos> {
|
|||
double distance = MineLPDelegate.getInstance().getPlayerPonyRace(player.asEntity()).isDefault() ? 6 : -6;
|
||||
|
||||
return TraceHelper.findBlock(player.asEntity(), distance, 1)
|
||||
.filter(pos -> TreeType.at(pos, player.getReferenceWorld()) != TreeType.NONE)
|
||||
.filter(pos -> TreeType.at(pos, player.asWorld()) != TreeType.NONE)
|
||||
.isPresent() ? 3 : 1;
|
||||
}
|
||||
|
||||
|
@ -77,12 +77,12 @@ public class EarthPonyKickAbility implements Ability<Pos> {
|
|||
if (!player.isClient()) {
|
||||
data.ifPresent(kickLocation -> {
|
||||
Vec3d origin = player.getOriginVector();
|
||||
World w = player.getReferenceWorld();
|
||||
World w = player.asWorld();
|
||||
|
||||
for (var e : VecHelper.findInRange(player.asEntity(), w, kickLocation.vec(), 2, EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR)) {
|
||||
if (e instanceof LivingEntity entity) {
|
||||
float calculatedStrength = 0.5F * (1 + player.getLevel().getScaled(9));
|
||||
entity.damage(MagicalDamageSource.KICK, player.getReferenceWorld().random.nextBetween(2, 10) + calculatedStrength);
|
||||
entity.damage(MagicalDamageSource.KICK, player.asWorld().random.nextBetween(2, 10) + calculatedStrength);
|
||||
entity.takeKnockback(calculatedStrength, origin.x - entity.getX(), origin.z - entity.getZ());
|
||||
Living.updateVelocity(entity);
|
||||
player.subtractEnergyCost(3);
|
||||
|
@ -107,7 +107,7 @@ public class EarthPonyKickAbility implements Ability<Pos> {
|
|||
@Override
|
||||
public Pos tryActivate(Pony player) {
|
||||
return TraceHelper.findBlock(player.asEntity(), 6 * getKickDirection(player), 1)
|
||||
.filter(pos -> TreeType.at(pos, player.getReferenceWorld()) != TreeType.NONE)
|
||||
.filter(pos -> TreeType.at(pos, player.asWorld()) != TreeType.NONE)
|
||||
.map(Pos::new)
|
||||
.orElseGet(() -> getDefaultKickLocation(player));
|
||||
}
|
||||
|
@ -128,10 +128,10 @@ public class EarthPonyKickAbility implements Ability<Pos> {
|
|||
@Override
|
||||
public boolean canApply(Pony player, Pos data) {
|
||||
BlockPos pos = data.pos();
|
||||
TreeType tree = TreeType.at(pos, player.getReferenceWorld());
|
||||
TreeType tree = TreeType.at(pos, player.asWorld());
|
||||
|
||||
return tree == TreeType.NONE || tree.findBase(player.getReferenceWorld(), pos)
|
||||
.map(base -> tree.countBlocks(player.getReferenceWorld(), pos) > 0)
|
||||
return tree == TreeType.NONE || tree.findBase(player.asWorld(), pos)
|
||||
.map(base -> tree.countBlocks(player.asWorld(), pos) > 0)
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ public class EarthPonyKickAbility implements Ability<Pos> {
|
|||
@Override
|
||||
public void apply(Pony iplayer, Pos data) {
|
||||
BlockPos pos = data.pos();
|
||||
TreeType tree = TreeType.at(pos, iplayer.getReferenceWorld());
|
||||
TreeType tree = TreeType.at(pos, iplayer.asWorld());
|
||||
|
||||
iplayer.setAnimation(Animation.KICK);
|
||||
iplayer.subtractEnergyCost(tree == TreeType.NONE ? 1 : 3);
|
||||
|
@ -151,7 +151,7 @@ public class EarthPonyKickAbility implements Ability<Pos> {
|
|||
if (tree == TreeType.NONE) {
|
||||
return;
|
||||
} else {
|
||||
ParticleUtils.spawnParticle(iplayer.getReferenceWorld(), UParticles.GROUND_POUND, data.vec(), Vec3d.ZERO);
|
||||
ParticleUtils.spawnParticle(iplayer.asWorld(), UParticles.GROUND_POUND, data.vec(), Vec3d.ZERO);
|
||||
}
|
||||
|
||||
PlayerEntity player = iplayer.asEntity();
|
||||
|
|
|
@ -84,7 +84,7 @@ public class EarthPonyStompAbility implements Ability<Hit> {
|
|||
|
||||
private void thrustDownwards(Pony player) {
|
||||
BlockPos ppos = player.getOrigin();
|
||||
BlockPos pos = PosHelper.findSolidGroundAt(player.getReferenceWorld(), ppos, player.getPhysics().getGravitySignum());
|
||||
BlockPos pos = PosHelper.findSolidGroundAt(player.asWorld(), ppos, player.getPhysics().getGravitySignum());
|
||||
|
||||
double downV = Math.sqrt(ppos.getSquaredDistance(pos)) * player.getPhysics().getGravitySignum();
|
||||
player.asEntity().addVelocity(0, -downV, 0);
|
||||
|
@ -104,7 +104,7 @@ public class EarthPonyStompAbility implements Ability<Hit> {
|
|||
|
||||
float heavyness = 1 + EnchantmentHelper.getEquipmentLevel(UEnchantments.HEAVY, player);
|
||||
|
||||
iplayer.getReferenceWorld().getOtherEntities(player, areaOfEffect.offset(iplayer.getOriginVector())).forEach(i -> {
|
||||
iplayer.asWorld().getOtherEntities(player, areaOfEffect.offset(iplayer.getOriginVector())).forEach(i -> {
|
||||
double dist = Math.sqrt(center.getSquaredDistance(i.getBlockPos()));
|
||||
|
||||
if (dist <= rad + 3) {
|
||||
|
|
|
@ -60,7 +60,7 @@ public class PegasusCaptureStormAbility implements Ability<Hit> {
|
|||
@Override
|
||||
public void apply(Pony player, Hit data) {
|
||||
|
||||
World w = player.getReferenceWorld();
|
||||
World w = player.asWorld();
|
||||
ItemStack stack = player.asEntity().getStackInHand(Hand.MAIN_HAND);
|
||||
boolean thundering = w.isThundering();
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ public class PegasusRainboomAbility implements Ability<Hit> {
|
|||
public boolean onQuickAction(Pony player, ActivationType type) {
|
||||
|
||||
if (type == ActivationType.TAP && player.getPhysics().isFlying() && player.getMagicalReserves().getMana().get() > 40) {
|
||||
player.getPhysics().dashForward((float)player.getReferenceWorld().random.nextTriangular(2.5F, 0.3F));
|
||||
player.getPhysics().dashForward((float)player.asWorld().random.nextTriangular(2.5F, 0.3F));
|
||||
player.subtractEnergyCost(4);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ public class UnicornCastingAbility implements Ability<Hit> {
|
|||
if (amount < 0) {
|
||||
AmuletItem.consumeEnergy(stack, amount);
|
||||
player.getMagicalReserves().getMana().add(amount * player.getMagicalReserves().getMana().getMax());
|
||||
player.getReferenceWorld().playSoundFromEntity(null, player.asEntity(), USounds.ITEM_AMULET_RECHARGE, SoundCategory.PLAYERS, 1, 1);
|
||||
player.asWorld().playSoundFromEntity(null, player.asEntity(), USounds.ITEM_AMULET_RECHARGE, SoundCategory.PLAYERS, 1, 1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -152,7 +152,7 @@ public class UnicornCastingAbility implements Ability<Hit> {
|
|||
|
||||
float i = player.getAbilities().getStat(slot).getFillProgress();
|
||||
|
||||
Random rng = player.getReferenceWorld().random;
|
||||
Random rng = player.asWorld().random;
|
||||
player.addParticle(i > 0.5F ? ParticleTypes.LARGE_SMOKE : ParticleTypes.CLOUD, eyes, VecHelper.supply(() -> (rng.nextGaussian() - 0.5) / 10));
|
||||
player.playSound(USounds.ITEM_AMULET_CHARGING, 1, i / 20);
|
||||
} else {
|
||||
|
|
|
@ -85,7 +85,7 @@ public class UnicornDispellAbility implements Ability<Pos> {
|
|||
@Override
|
||||
public void apply(Pony player, Pos data) {
|
||||
player.setAnimation(Animation.WOLOLO);
|
||||
Caster.stream(VecHelper.findInRange(player.asEntity(), player.getReferenceWorld(), data.vec(), 3, EquinePredicates.IS_PLACED_SPELL).stream()).forEach(target -> {
|
||||
Caster.stream(VecHelper.findInRange(player.asEntity(), player.asWorld(), data.vec(), 3, EquinePredicates.IS_PLACED_SPELL).stream()).forEach(target -> {
|
||||
target.getSpellSlot().clear();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public class UnicornTeleportAbility implements Ability<Pos> {
|
|||
int maxDistance = player.asEntity().isCreative() ? 1000 : 100;
|
||||
|
||||
|
||||
World w = player.getReferenceWorld();
|
||||
World w = player.asWorld();
|
||||
|
||||
Trace trace = Trace.create(player.asEntity(), maxDistance, 1, EntityPredicates.EXCEPT_SPECTATOR);
|
||||
return trace.getBlockOrEntityPos().map(pos -> {
|
||||
|
@ -133,7 +133,7 @@ public class UnicornTeleportAbility implements Ability<Pos> {
|
|||
return;
|
||||
}
|
||||
|
||||
teleportee.getReferenceWorld().playSound(null, teleportee.getOrigin(), USounds.ENTITY_PLAYER_UNICORN_TELEPORT, SoundCategory.PLAYERS, 1, 1);
|
||||
teleportee.asWorld().playSound(null, teleportee.getOrigin(), USounds.ENTITY_PLAYER_UNICORN_TELEPORT, SoundCategory.PLAYERS, 1, 1);
|
||||
|
||||
double distance = destination.distanceTo(teleportee) / 10;
|
||||
|
||||
|
|
|
@ -47,6 +47,6 @@ public class Pos extends Hit {
|
|||
}
|
||||
|
||||
public double distanceTo(Caster<?> caster) {
|
||||
return Math.sqrt(caster.getEntity().squaredDistanceTo(x, y, z));
|
||||
return Math.sqrt(caster.asEntity().squaredDistanceTo(x, y, z));
|
||||
}
|
||||
}
|
|
@ -6,8 +6,7 @@ import java.util.stream.Stream;
|
|||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.EquinePredicates;
|
||||
import com.minelittlepony.unicopia.Owned;
|
||||
import com.minelittlepony.unicopia.*;
|
||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
||||
import com.minelittlepony.unicopia.block.data.ModificationType;
|
||||
import com.minelittlepony.unicopia.entity.Physics;
|
||||
|
@ -27,38 +26,35 @@ import net.minecraft.world.World;
|
|||
/**
|
||||
* Interface for any magically capable entities that can cast or persist spells.
|
||||
*/
|
||||
public interface Caster<E extends LivingEntity> extends Owned<LivingEntity>, Levelled, Affine, ParticleSource, SoundEmitter {
|
||||
public interface Caster<E extends Entity> extends Owned<LivingEntity>,
|
||||
Levelled,
|
||||
Affine,
|
||||
ParticleSource<E>,
|
||||
SoundEmitter<E>,
|
||||
EntityConvertable<E>,
|
||||
WorldConvertable {
|
||||
|
||||
Physics getPhysics();
|
||||
|
||||
SpellContainer getSpellSlot();
|
||||
|
||||
/**
|
||||
* Gets the entity directly responsible for casting.
|
||||
* Removes the desired amount of mana or health from this caster in exchange for a spell's benefits.
|
||||
* <p>
|
||||
* @return False if the transaction has depleted the caster's reserves.
|
||||
*/
|
||||
@Override
|
||||
Entity getEntity();
|
||||
boolean subtractEnergyCost(double amount);
|
||||
|
||||
/**
|
||||
* Gets the minecraft world
|
||||
*/
|
||||
@Override
|
||||
default World getReferenceWorld() {
|
||||
return getEntity().getEntityWorld();
|
||||
default World asWorld() {
|
||||
return asEntity().world;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if we're executing on the client.
|
||||
*/
|
||||
default boolean isClient() {
|
||||
return getReferenceWorld().isClient();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the center position where this caster is located.
|
||||
*/
|
||||
default BlockPos getOrigin() {
|
||||
return getEntity().getBlockPos();
|
||||
return asWorld().isClient();
|
||||
}
|
||||
|
||||
default boolean canModifyAt(BlockPos pos) {
|
||||
|
@ -69,11 +65,11 @@ public interface Caster<E extends LivingEntity> extends Owned<LivingEntity>, Lev
|
|||
|
||||
if (mod.checkPhysical()) {
|
||||
if (getMaster() instanceof PlayerEntity player) {
|
||||
if (!getReferenceWorld().canPlayerModifyAt(player, pos)) {
|
||||
if (!asWorld().canPlayerModifyAt(player, pos)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!getReferenceWorld().getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING)) {
|
||||
if (!asWorld().getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -82,13 +78,6 @@ public interface Caster<E extends LivingEntity> extends Owned<LivingEntity>, Lev
|
|||
return !mod.checkMagical() || canCastAt(Vec3d.ofCenter(pos));
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the desired amount of mana or health from this caster in exchange for a spell's benefits.
|
||||
* <p>
|
||||
* @return False if the transaction has depleted the caster's reserves.
|
||||
*/
|
||||
boolean subtractEnergyCost(double amount);
|
||||
|
||||
default Stream<Caster<?>> findAllSpellsInRange(double radius) {
|
||||
return findAllSpellsInRange(radius, null);
|
||||
}
|
||||
|
@ -98,7 +87,7 @@ public interface Caster<E extends LivingEntity> extends Owned<LivingEntity>, Lev
|
|||
}
|
||||
|
||||
default Stream<Entity> findAllEntitiesInRange(double radius, @Nullable Predicate<Entity> test) {
|
||||
return VecHelper.findInRange(getEntity(), getReferenceWorld(), getOriginVector(), radius, test).stream();
|
||||
return VecHelper.findInRange(asEntity(), asWorld(), getOriginVector(), radius, test).stream();
|
||||
}
|
||||
|
||||
default Stream<Entity> findAllEntitiesInRange(double radius) {
|
||||
|
|
|
@ -28,8 +28,8 @@ public abstract class AbstractDisguiseSpell extends AbstractSpell implements Dis
|
|||
|
||||
@Override
|
||||
public void onDestroyed(Caster<?> caster) {
|
||||
caster.getEntity().calculateDimensions();
|
||||
caster.getEntity().setInvisible(false);
|
||||
caster.asEntity().calculateDimensions();
|
||||
caster.asEntity().setInvisible(false);
|
||||
if (caster instanceof Pony) {
|
||||
((Pony) caster).setInvisible(false);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class DispersableDisguiseSpell extends AbstractDisguiseSpell implements I
|
|||
if (isSuppressed()) {
|
||||
source.spawnParticles(MagicParticleEffect.UNICORN, 5);
|
||||
source.spawnParticles(UParticles.CHANGELING_MAGIC, 5);
|
||||
} else if (source.getReferenceWorld().random.nextInt(30) == 0) {
|
||||
} else if (source.asWorld().random.nextInt(30) == 0) {
|
||||
source.spawnParticles(UParticles.CHANGELING_MAGIC, 2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ public class PlaceableSpell extends AbstractDelegatingSpell implements OrientedS
|
|||
if (!source.isClient()) {
|
||||
|
||||
if (dimension == null) {
|
||||
dimension = source.getReferenceWorld().getRegistryKey();
|
||||
dimension = source.asWorld().getRegistryKey();
|
||||
setDirty();
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ public class PlaceableSpell extends AbstractDelegatingSpell implements OrientedS
|
|||
}
|
||||
|
||||
if (situation == Situation.GROUND_ENTITY) {
|
||||
if (!source.isClient() && Ether.get(source.getReferenceWorld()).getEntry(getType(), source).isEmpty()) {
|
||||
if (!source.isClient() && Ether.get(source.asWorld()).getEntry(getType(), source).isEmpty()) {
|
||||
setDead();
|
||||
return false;
|
||||
}
|
||||
|
@ -119,9 +119,9 @@ public class PlaceableSpell extends AbstractDelegatingSpell implements OrientedS
|
|||
}
|
||||
|
||||
private void spawnPlacedEntity(Caster<?> source) {
|
||||
CastSpellEntity entity = UEntities.CAST_SPELL.create(source.getReferenceWorld());
|
||||
CastSpellEntity entity = UEntities.CAST_SPELL.create(source.asWorld());
|
||||
Vec3d pos = castEntity.getPosition().orElse(source.getOriginVector());
|
||||
entity.updatePositionAndAngles(pos.x, pos.y, pos.z, source.getEntity().getYaw(), source.getEntity().getPitch());
|
||||
entity.updatePositionAndAngles(pos.x, pos.y, pos.z, source.asEntity().getYaw(), source.asEntity().getPitch());
|
||||
PlaceableSpell copy = spell.toPlaceable();
|
||||
if (spell instanceof PlacementDelegate delegate) {
|
||||
delegate.onPlaced(source, copy, entity);
|
||||
|
@ -157,8 +157,8 @@ public class PlaceableSpell extends AbstractDelegatingSpell implements OrientedS
|
|||
castEntity.set(null);
|
||||
});
|
||||
|
||||
if (source.getEntity() instanceof CastSpellEntity spellcast) {
|
||||
Ether.get(source.getReferenceWorld()).remove(getType(), source);
|
||||
if (source.asEntity() instanceof CastSpellEntity spellcast) {
|
||||
Ether.get(source.asWorld()).remove(getType(), source);
|
||||
}
|
||||
}
|
||||
super.onDestroyed(source);
|
||||
|
@ -180,7 +180,7 @@ public class PlaceableSpell extends AbstractDelegatingSpell implements OrientedS
|
|||
|
||||
protected Optional<World> getWorld(Caster<?> source) {
|
||||
return Optional.ofNullable(dimension)
|
||||
.map(dim -> source.getReferenceWorld().getServer().getWorld(dim));
|
||||
.map(dim -> source.asWorld().getServer().getWorld(dim));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -65,25 +65,25 @@ public class RainboomAbilitySpell extends AbstractSpell {
|
|||
e.damage(MagicalDamageSource.create("rainboom", source).setBreakSunglasses(), 6);
|
||||
});
|
||||
EFFECT_RANGE.translate(source.getOrigin()).getBlockPositions().forEach(pos -> {
|
||||
BlockState state = source.getReferenceWorld().getBlockState(pos);
|
||||
BlockState state = source.asWorld().getBlockState(pos);
|
||||
if (state.isIn(UTags.FRAGILE) && source.canModifyAt(pos, ModificationType.PHYSICAL)) {
|
||||
owner.world.breakBlock(pos, true);
|
||||
}
|
||||
});
|
||||
|
||||
Vec3d motion = source.getEntity().getRotationVec(1).multiply(1.5);
|
||||
Vec3d velocity = source.getEntity().getVelocity().add(motion);
|
||||
Vec3d motion = source.asEntity().getRotationVec(1).multiply(1.5);
|
||||
Vec3d velocity = source.asEntity().getVelocity().add(motion);
|
||||
|
||||
while (velocity.length() > 3) {
|
||||
velocity = velocity.multiply(0.6);
|
||||
}
|
||||
|
||||
source.getEntity().setVelocity(velocity);
|
||||
source.asEntity().setVelocity(velocity);
|
||||
if (source instanceof Pony pony) {
|
||||
pony.getMagicalReserves().getExhaustion().multiply(0.2F);
|
||||
}
|
||||
|
||||
return !source.getEntity().isRemoved() && age++ < 90 + 7 * source.getLevel().getScaled(9);
|
||||
return !source.asEntity().isRemoved() && age++ < 90 + 7 * source.getLevel().getScaled(9);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -49,7 +49,7 @@ public final class ThrowableSpell extends AbstractDelegatingSpell {
|
|||
* Returns the resulting projectile entity for customization (or null if on the client).
|
||||
*/
|
||||
public Optional<MagicProjectileEntity> throwProjectile(Caster<?> caster, float divergance) {
|
||||
World world = caster.getReferenceWorld();
|
||||
World world = caster.asWorld();
|
||||
|
||||
LivingEntity entity = caster.getMaster();
|
||||
|
||||
|
|
|
@ -38,14 +38,14 @@ public class AreaProtectionSpell extends AbstractAreaEffectSpell {
|
|||
Vec3d origin = source.getOriginVector();
|
||||
|
||||
source.spawnParticles(origin, new Sphere(true, radius), (int)(radius * 6), pos -> {
|
||||
if (!source.getReferenceWorld().isAir(new BlockPos(pos))) {
|
||||
if (!source.asWorld().isAir(new BlockPos(pos))) {
|
||||
source.addParticle(new MagicParticleEffect(getType().getColor()), pos, Vec3d.ZERO);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
source.findAllSpellsInRange(radius, e -> isValidTarget(source, e)).filter(caster -> !caster.hasCommonOwner(source)).forEach(caster -> {
|
||||
caster.getEntity().kill();
|
||||
caster.asEntity().kill();
|
||||
});
|
||||
|
||||
return !isDead();
|
||||
|
@ -65,7 +65,7 @@ public class AreaProtectionSpell extends AbstractAreaEffectSpell {
|
|||
}
|
||||
|
||||
public boolean blocksMagicFor(Caster<?> source, Caster<?> other, Vec3d position) {
|
||||
return !FriendshipBraceletItem.isComrade(other, other.getEntity())
|
||||
return !FriendshipBraceletItem.isComrade(other, other.asEntity())
|
||||
&& source.getOriginVector().distanceTo(position) <= getDrawDropOffRange(source);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,8 +47,8 @@ public class AttractiveSpell extends ShieldSpell implements HomingSpell, TimedSp
|
|||
setDirty();
|
||||
|
||||
Vec3d pos = caster.getOriginVector();
|
||||
if (target.isPresent(caster.getReferenceWorld()) && target.get(caster.getReferenceWorld()).distanceTo(caster.getEntity()) > getDrawDropOffRange(caster)) {
|
||||
target.get(caster.getReferenceWorld()).requestTeleport(pos.x, pos.y, pos.z);
|
||||
if (target.isPresent(caster.asWorld()) && target.get(caster.asWorld()).distanceTo(caster.asEntity()) > getDrawDropOffRange(caster)) {
|
||||
target.get(caster.asWorld()).requestTeleport(pos.x, pos.y, pos.z);
|
||||
}
|
||||
|
||||
return super.tick(caster, situation);
|
||||
|
@ -60,7 +60,7 @@ public class AttractiveSpell extends ShieldSpell implements HomingSpell, TimedSp
|
|||
|
||||
source.spawnParticles(getOrigin(source), new Sphere(false, range), 7, p -> {
|
||||
source.addParticle(
|
||||
new FollowingParticleEffect(UParticles.HEALTH_DRAIN, source.getEntity(), 0.4F)
|
||||
new FollowingParticleEffect(UParticles.HEALTH_DRAIN, source.asEntity(), 0.4F)
|
||||
.withChild(new MagicParticleEffect(getType().getColor())),
|
||||
p,
|
||||
Vec3d.ZERO
|
||||
|
@ -92,8 +92,8 @@ public class AttractiveSpell extends ShieldSpell implements HomingSpell, TimedSp
|
|||
force *= AttractionUtils.getForceAdjustment(target);
|
||||
}
|
||||
|
||||
if (!isGood && source.getReferenceWorld().random.nextInt(4500) == 0) {
|
||||
source.getEntity().damage(MagicalDamageSource.create("vortex"), 4);
|
||||
if (!isGood && source.asWorld().random.nextInt(4500) == 0) {
|
||||
source.asEntity().damage(MagicalDamageSource.create("vortex"), 4);
|
||||
}
|
||||
|
||||
AttractionUtils.applyForce(getOrigin(source), target, -force, 0, false);
|
||||
|
@ -138,7 +138,7 @@ public class AttractiveSpell extends ShieldSpell implements HomingSpell, TimedSp
|
|||
|
||||
@Override
|
||||
public void onDestroyed(Caster<?> caster) {
|
||||
target.getOrEmpty(caster.getReferenceWorld()).ifPresent(target -> target.setGlowing(false));
|
||||
target.getOrEmpty(caster.asWorld()).ifPresent(target -> target.setGlowing(false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -49,7 +49,7 @@ public class AwkwardSpell extends AbstractSpell implements TimedSpell {
|
|||
|
||||
List<Identifier> names = new ArrayList<>(Registries.PARTICLE_TYPE.getIds());
|
||||
|
||||
int index = (int)MathHelper.nextDouble(source.getReferenceWorld().random, 0, names.size());
|
||||
int index = (int)MathHelper.nextDouble(source.asWorld().random, 0, names.size());
|
||||
|
||||
Identifier id = names.get(index);
|
||||
ParticleType<?> type = Registries.PARTICLE_TYPE.get(id);
|
||||
|
|
|
@ -65,14 +65,14 @@ public class CatapultSpell extends AbstractSpell implements ProjectileDelegate.B
|
|||
}
|
||||
|
||||
protected void apply(Caster<?> caster, Entity e) {
|
||||
Vec3d vel = caster.getEntity().getVelocity();
|
||||
Vec3d vel = caster.asEntity().getVelocity();
|
||||
if (Math.abs(e.getVelocity().y) > 0.5) {
|
||||
e.setVelocity(caster.getEntity().getVelocity());
|
||||
e.setVelocity(caster.asEntity().getVelocity());
|
||||
} else {
|
||||
e.addVelocity(
|
||||
((caster.getReferenceWorld().random.nextFloat() * HORIZONTAL_VARIANCE) - HORIZONTAL_VARIANCE + vel.x * 0.8F) * 0.1F,
|
||||
((caster.asWorld().random.nextFloat() * HORIZONTAL_VARIANCE) - HORIZONTAL_VARIANCE + vel.x * 0.8F) * 0.1F,
|
||||
0.1F + (getTraits().get(Trait.STRENGTH, -MAX_STRENGTH, MAX_STRENGTH) - 40) / 16D,
|
||||
((caster.getReferenceWorld().random.nextFloat() * HORIZONTAL_VARIANCE) - HORIZONTAL_VARIANCE + vel.z * 0.8F) * 0.1F
|
||||
((caster.asWorld().random.nextFloat() * HORIZONTAL_VARIANCE) - HORIZONTAL_VARIANCE + vel.z * 0.8F) * 0.1F
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -84,11 +84,11 @@ public class CatapultSpell extends AbstractSpell implements ProjectileDelegate.B
|
|||
|
||||
double maxDistance = 2 + (getTraits().get(Trait.FOCUS) - 50) * 8;
|
||||
|
||||
Trace trace = Trace.create(caster.getEntity(), maxDistance, 1, EntityPredicates.EXCEPT_SPECTATOR);
|
||||
Trace trace = Trace.create(caster.asEntity(), maxDistance, 1, EntityPredicates.EXCEPT_SPECTATOR);
|
||||
trace.getEntity().ifPresentOrElse(apply, () -> {
|
||||
trace.ifBlock(pos -> {
|
||||
if (caster.canModifyAt(pos)) {
|
||||
createBlockEntity(caster.getReferenceWorld(), pos, apply);
|
||||
createBlockEntity(caster.asWorld(), pos, apply);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -86,13 +86,13 @@ public class DarkVortexSpell extends AttractiveSpell implements ProjectileDelega
|
|||
setDirty();
|
||||
|
||||
if (age % 20 == 0) {
|
||||
source.getReferenceWorld().playSound(null, source.getOrigin(), USounds.AMBIENT_DARK_VORTEX_ADDITIONS, SoundCategory.AMBIENT, 1, 1);
|
||||
source.asWorld().playSound(null, source.getOrigin(), USounds.AMBIENT_DARK_VORTEX_ADDITIONS, SoundCategory.AMBIENT, 1, 1);
|
||||
}
|
||||
|
||||
source.subtractEnergyCost(-accumulatedMass);
|
||||
|
||||
if (!source.isClient() && source.getReferenceWorld().random.nextInt(300) == 0) {
|
||||
ParticleUtils.spawnParticle(source.getReferenceWorld(), UParticles.LIGHTNING_BOLT, getOrigin(source), Vec3d.ZERO);
|
||||
if (!source.isClient() && source.asWorld().random.nextInt(300) == 0) {
|
||||
ParticleUtils.spawnParticle(source.asWorld(), UParticles.LIGHTNING_BOLT, getOrigin(source), Vec3d.ZERO);
|
||||
}
|
||||
|
||||
return super.tick(source, situation);
|
||||
|
@ -161,9 +161,9 @@ public class DarkVortexSpell extends AttractiveSpell implements ProjectileDelega
|
|||
return;
|
||||
}
|
||||
if (source.getOrigin().isWithinDistance(i, getEventHorizonRadius() / 2)) {
|
||||
source.getReferenceWorld().breakBlock(i, false);
|
||||
source.asWorld().breakBlock(i, false);
|
||||
} else {
|
||||
CatapultSpell.createBlockEntity(source.getReferenceWorld(), i, e -> {
|
||||
CatapultSpell.createBlockEntity(source.asWorld(), i, e -> {
|
||||
applyRadialEffect(source, e, e.getPos().distanceTo(origin), radius);
|
||||
});
|
||||
}
|
||||
|
@ -177,8 +177,8 @@ public class DarkVortexSpell extends AttractiveSpell implements ProjectileDelega
|
|||
|
||||
protected boolean canAffect(Caster<?> source, BlockPos pos) {
|
||||
return source.canModifyAt(pos)
|
||||
&& source.getReferenceWorld().getFluidState(pos).isEmpty()
|
||||
&& source.getReferenceWorld().getBlockState(pos).getHardness(source.getReferenceWorld(), pos) >= 0;
|
||||
&& source.asWorld().getFluidState(pos).isEmpty()
|
||||
&& source.asWorld().getBlockState(pos).getHardness(source.asWorld(), pos) >= 0;
|
||||
}
|
||||
|
||||
// 1. force decreases with distance: distance scale 1 -> 0
|
||||
|
@ -234,7 +234,7 @@ public class DarkVortexSpell extends AttractiveSpell implements ProjectileDelega
|
|||
}
|
||||
|
||||
source.subtractEnergyCost(-massOfTarget * 10);
|
||||
source.getReferenceWorld().playSound(null, source.getOrigin(), USounds.AMBIENT_DARK_VORTEX_MOOD, SoundCategory.AMBIENT, 2, 0.02F);
|
||||
source.asWorld().playSound(null, source.getOrigin(), USounds.AMBIENT_DARK_VORTEX_MOOD, SoundCategory.AMBIENT, 2, 0.02F);
|
||||
} else {
|
||||
double force = getAttractiveForce(source, target);
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ public class DisplacementSpell extends AbstractSpell implements HomingSpell, Pla
|
|||
}
|
||||
|
||||
if (ticks == 0) {
|
||||
target.ifPresent(source.getReferenceWorld(), target -> {
|
||||
target.ifPresent(source.asWorld(), target -> {
|
||||
|
||||
Vec3d destinationPos = target.getPos();
|
||||
Vec3d destinationVel = target.getVelocity();
|
||||
|
@ -95,7 +95,7 @@ public class DisplacementSpell extends AbstractSpell implements HomingSpell, Pla
|
|||
@Override
|
||||
public void onDestroyed(Caster<?> caster) {
|
||||
caster.getMaster().setGlowing(false);
|
||||
target.ifPresent(caster.getReferenceWorld(), e -> e.setGlowing(false));
|
||||
target.ifPresent(caster.asWorld(), e -> e.setGlowing(false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -67,8 +67,8 @@ public class FeatherFallSpell extends AbstractSpell implements TimedSpell {
|
|||
final float strength = 1F / (getTraits().get(Trait.STRENGTH, 2, 9) / targets.size());
|
||||
final float generosity = getTraits().get(Trait.GENEROSITY, 1, MAX_GENEROSITY_FACTOR) / MAX_GENEROSITY_FACTOR;
|
||||
|
||||
Entity entity = caster.getEntity();
|
||||
Vec3d masterVelocity = caster.getEntity().getVelocity().multiply(0.1);
|
||||
Entity entity = caster.asEntity();
|
||||
Vec3d masterVelocity = entity.getVelocity().multiply(0.1);
|
||||
targets.forEach(target -> {
|
||||
if (target.getVelocity().y < 0) {
|
||||
|
||||
|
@ -84,7 +84,7 @@ public class FeatherFallSpell extends AbstractSpell implements TimedSpell {
|
|||
((PlayerEntity)target).getAbilities().flying = false;
|
||||
}
|
||||
target.setVelocity(target.getVelocity().multiply(1, delta, 1));
|
||||
if (situation == Situation.PROJECTILE && target != caster.getEntity()) {
|
||||
if (situation == Situation.PROJECTILE && target != entity) {
|
||||
target.addVelocity(masterVelocity.x, 0, masterVelocity.z);
|
||||
}
|
||||
}
|
||||
|
@ -114,8 +114,7 @@ public class FeatherFallSpell extends AbstractSpell implements TimedSpell {
|
|||
}
|
||||
|
||||
protected Stream<Entity> getTargets(Caster<?> caster) {
|
||||
Entity owner = caster.getEntity();// , EquinePredicates.IS_PLAYER
|
||||
return Stream.concat(Stream.of(owner), caster.findAllEntitiesInRange(getEffectRange()).sorted((a, b) -> {
|
||||
return Stream.concat(Stream.of(caster.asEntity()), caster.findAllEntitiesInRange(getEffectRange()).sorted((a, b) -> {
|
||||
return Integer.compare(
|
||||
FriendshipBraceletItem.isComrade(caster, a) ? 1 : 0,
|
||||
FriendshipBraceletItem.isComrade(caster, b) ? 1 : 0
|
||||
|
|
|
@ -57,7 +57,7 @@ public class FireBoltSpell extends AbstractSpell implements HomingSpell,
|
|||
return true;
|
||||
}
|
||||
|
||||
if (getTraits().get(Trait.FOCUS) >= 50 && !target.isPresent(caster.getReferenceWorld())) {
|
||||
if (getTraits().get(Trait.FOCUS) >= 50 && !target.isPresent(caster.asWorld())) {
|
||||
target.set(caster.findAllEntitiesInRange(
|
||||
getTraits().get(Trait.FOCUS) - 49,
|
||||
EntityPredicates.VALID_LIVING_ENTITY.and(TargetSelecter.notOwnerOrFriend(this, caster))
|
||||
|
@ -66,10 +66,10 @@ public class FireBoltSpell extends AbstractSpell implements HomingSpell,
|
|||
|
||||
for (int i = 0; i < getNumberOfBalls(caster); i++) {
|
||||
getTypeAndTraits().create().toThrowable().throwProjectile(caster, 2).ifPresent(c -> {
|
||||
target.ifPresent(caster.getReferenceWorld(), c::setHomingTarget);
|
||||
target.ifPresent(caster.asWorld(), c::setHomingTarget);
|
||||
});
|
||||
|
||||
caster.playSound(USounds.SPELL_FIRE_BOLT_SHOOT, 0.7F, 0.4F / (caster.getReferenceWorld().random.nextFloat() * 0.4F + 0.8F));
|
||||
caster.playSound(USounds.SPELL_FIRE_BOLT_SHOOT, 0.7F, 0.4F / (caster.asWorld().random.nextFloat() * 0.4F + 0.8F));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ public class FireBoltSpell extends AbstractSpell implements HomingSpell,
|
|||
}
|
||||
|
||||
protected int getNumberOfBalls(Caster<?> caster) {
|
||||
return 1 + caster.getReferenceWorld().random.nextInt(3) + (int)getTraits().get(Trait.EARTH) * 3;
|
||||
return 1 + caster.asWorld().random.nextInt(3) + (int)getTraits().get(Trait.EARTH) * 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -52,7 +52,7 @@ public class FireSpell extends AbstractAreaEffectSpell implements ProjectileDele
|
|||
public void onImpact(MagicProjectileEntity projectile, BlockHitResult hit) {
|
||||
if (!projectile.isClient()) {
|
||||
Vec3d pos = hit.getPos();
|
||||
projectile.getReferenceWorld().createExplosion(projectile.getOwner(), pos.getX(), pos.getY(), pos.getZ(), 2, ExplosionSourceType.MOB);
|
||||
projectile.asWorld().createExplosion(projectile.getOwner(), pos.getX(), pos.getY(), pos.getZ(), 2, ExplosionSourceType.MOB);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ public class FireSpell extends AbstractAreaEffectSpell implements ProjectileDele
|
|||
public void onImpact(MagicProjectileEntity projectile, EntityHitResult hit) {
|
||||
if (!projectile.isClient()) {
|
||||
Entity entity = hit.getEntity();
|
||||
projectile.getReferenceWorld().createExplosion(projectile.getOwner(), entity.getX(), entity.getY(), entity.getZ(), 2, ExplosionSourceType.MOB);
|
||||
projectile.asWorld().createExplosion(projectile.getOwner(), entity.getX(), entity.getY(), entity.getZ(), 2, ExplosionSourceType.MOB);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,9 +71,9 @@ public class FireSpell extends AbstractAreaEffectSpell implements ProjectileDele
|
|||
}
|
||||
|
||||
return new Sphere(false, Math.max(0, 4 + getTraits().get(Trait.POWER))).translate(source.getOrigin()).getBlockPositions().reduce(false,
|
||||
(r, i) -> source.canModifyAt(i) && applyBlocks(source.getReferenceWorld(), i),
|
||||
(r, i) -> source.canModifyAt(i) && applyBlocks(source.asWorld(), i),
|
||||
(a, b) -> a || b)
|
||||
|| applyEntities(null, source.getReferenceWorld(), source.getOriginVector());
|
||||
|| applyEntities(null, source.asWorld(), source.getOriginVector());
|
||||
}
|
||||
|
||||
protected void generateParticles(Caster<?> source) {
|
||||
|
|
|
@ -50,7 +50,7 @@ public class HydrophobicSpell extends AbstractSpell {
|
|||
public boolean tick(Caster<?> source, Situation situation) {
|
||||
|
||||
if (!source.isClient()) {
|
||||
World world = source.getReferenceWorld();
|
||||
World world = source.asWorld();
|
||||
|
||||
Shape area = new Sphere(false, getRange(source)).translate(source.getOriginVector());
|
||||
|
||||
|
@ -83,12 +83,12 @@ public class HydrophobicSpell extends AbstractSpell {
|
|||
source.subtractEnergyCost(storedFluidPositions.isEmpty() ? 0.001F : 0.02F);
|
||||
source.spawnParticles(new Sphere(true, getRange(source)), 10, pos -> {
|
||||
BlockPos bp = new BlockPos(pos);
|
||||
if (source.getReferenceWorld().getFluidState(bp.up()).isIn(affectedFluid)) {
|
||||
if (source.asWorld().getFluidState(bp.up()).isIn(affectedFluid)) {
|
||||
source.addParticle(UParticles.RAIN_DROPS, pos, Vec3d.ZERO);
|
||||
}
|
||||
});
|
||||
|
||||
if (source.getEntity().age % 200 == 0) {
|
||||
if (source.asEntity().age % 200 == 0) {
|
||||
source.playSound(USounds.SPELL_AMBIENT, 0.5F);
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ public class HydrophobicSpell extends AbstractSpell {
|
|||
@Override
|
||||
public void onDestroyed(Caster<?> caster) {
|
||||
storedFluidPositions.removeIf(entry -> {
|
||||
entry.restore(caster.getReferenceWorld());
|
||||
entry.restore(caster.asWorld());
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -40,24 +40,24 @@ public class IceSpell extends AbstractSpell {
|
|||
|
||||
@Override
|
||||
public boolean tick(Caster<?> source, Situation situation) {
|
||||
boolean submerged = source.getEntity().isSubmergedInWater() || source.getEntity().isSubmergedIn(FluidTags.LAVA);
|
||||
boolean submerged = source.asEntity().isSubmergedInWater() || source.asEntity().isSubmergedIn(FluidTags.LAVA);
|
||||
|
||||
long blocksAffected = OUTER_RANGE.translate(source.getOrigin()).getBlockPositions().filter(i -> {
|
||||
if (source.canModifyAt(i) && applyBlockSingle(source.getEntity(), source.getReferenceWorld(), i, situation)) {
|
||||
if (source.canModifyAt(i) && applyBlockSingle(source.asEntity(), source.asWorld(), i, situation)) {
|
||||
|
||||
if (submerged & source.getOrigin().isWithinDistance(i, RADIUS - 1)) {
|
||||
BlockState state = source.getReferenceWorld().getBlockState(i);
|
||||
BlockState state = source.asWorld().getBlockState(i);
|
||||
if (state.isIn(BlockTags.ICE) || state.isOf(Blocks.OBSIDIAN)) {
|
||||
source.getReferenceWorld().setBlockState(i, Blocks.AIR.getDefaultState(), Block.NOTIFY_NEIGHBORS);
|
||||
source.asWorld().setBlockState(i, Blocks.AIR.getDefaultState(), Block.NOTIFY_NEIGHBORS);
|
||||
} else if (!state.getFluidState().isEmpty()) {
|
||||
source.getReferenceWorld().setBlockState(i, state.with(Properties.WATERLOGGED, false), Block.NOTIFY_NEIGHBORS);
|
||||
source.asWorld().setBlockState(i, state.with(Properties.WATERLOGGED, false), Block.NOTIFY_NEIGHBORS);
|
||||
}
|
||||
}
|
||||
|
||||
ParticleUtils.spawnParticle(source.getReferenceWorld(), ParticleTypes.SPLASH, new Vec3d(
|
||||
i.getX() + source.getReferenceWorld().random.nextFloat(),
|
||||
ParticleUtils.spawnParticle(source.asWorld(), ParticleTypes.SPLASH, new Vec3d(
|
||||
i.getX() + source.asWorld().random.nextFloat(),
|
||||
i.getY() + 1,
|
||||
i.getZ() + source.getReferenceWorld().random.nextFloat()), Vec3d.ZERO);
|
||||
i.getZ() + source.asWorld().random.nextFloat()), Vec3d.ZERO);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class IceSpell extends AbstractSpell {
|
|||
|
||||
source.subtractEnergyCost(Math.min(10, blocksAffected));
|
||||
|
||||
return applyEntities(source.getMaster(), source.getReferenceWorld(), source.getOriginVector()) && situation == Situation.PROJECTILE;
|
||||
return applyEntities(source.getMaster(), source.asWorld(), source.getOriginVector()) && situation == Situation.PROJECTILE;
|
||||
}
|
||||
|
||||
protected boolean applyEntities(LivingEntity owner, World world, Vec3d pos) {
|
||||
|
|
|
@ -30,7 +30,7 @@ public class InfernoSpell extends FireSpell {
|
|||
generateParticles(source);
|
||||
}
|
||||
|
||||
World w = source.getReferenceWorld();
|
||||
World w = source.asWorld();
|
||||
|
||||
if (!w.isClient) {
|
||||
float radius = 4 + (source.getLevel().getScaled(4) * 4);
|
||||
|
|
|
@ -56,17 +56,17 @@ public class LightSpell extends AbstractSpell implements TimedSpell {
|
|||
|
||||
if (!caster.isClient()) {
|
||||
if (lights.isEmpty()) {
|
||||
int size = 2 + caster.getReferenceWorld().random.nextInt(2) + (int)(getTraits().get(Trait.LIFE, 10, 20) - 10)/10;
|
||||
int size = 2 + caster.asWorld().random.nextInt(2) + (int)(getTraits().get(Trait.LIFE, 10, 20) - 10)/10;
|
||||
while (lights.size() < size) {
|
||||
lights.add(new EntityReference<FairyEntity>());
|
||||
}
|
||||
}
|
||||
|
||||
lights.forEach(ref -> {
|
||||
if (!ref.isPresent(caster.getReferenceWorld())) {
|
||||
FairyEntity entity = UEntities.TWITTERMITE.create(caster.getReferenceWorld());
|
||||
if (!ref.isPresent(caster.asWorld())) {
|
||||
FairyEntity entity = UEntities.TWITTERMITE.create(caster.asWorld());
|
||||
entity.setPosition(ref.getPosition().orElseGet(() -> {
|
||||
return caster.getOriginVector().add(VecHelper.supply(() -> caster.getReferenceWorld().random.nextInt(3) - 1));
|
||||
return caster.getOriginVector().add(VecHelper.supply(() -> caster.asWorld().random.nextInt(3) - 1));
|
||||
}));
|
||||
entity.setMaster(caster);
|
||||
entity.world.spawnEntity(entity);
|
||||
|
@ -86,7 +86,7 @@ public class LightSpell extends AbstractSpell implements TimedSpell {
|
|||
return;
|
||||
}
|
||||
lights.forEach(ref -> {
|
||||
ref.ifPresent(caster.getReferenceWorld(), e -> {
|
||||
ref.ifPresent(caster.asWorld(), e -> {
|
||||
e.world.sendEntityStatus(e, (byte)60);
|
||||
e.discard();
|
||||
});
|
||||
|
|
|
@ -33,7 +33,7 @@ public class MindSwapSpell extends MimicSpell {
|
|||
public void onDestroyed(Caster<?> caster) {
|
||||
super.onDestroyed(caster);
|
||||
if (initialized && !caster.isClient()) {
|
||||
counterpart.ifPresent(caster.getReferenceWorld(), e -> {
|
||||
counterpart.ifPresent(caster.asWorld(), e -> {
|
||||
EntitySwap.ALL.accept(e, caster.getMaster());
|
||||
Inventory.swapInventories(
|
||||
e, myStoredInventory.or(() -> Inventory.of(e)),
|
||||
|
@ -59,7 +59,7 @@ public class MindSwapSpell extends MimicSpell {
|
|||
if (!initialized) {
|
||||
initialized = true;
|
||||
setDirty();
|
||||
counterpart.ifPresent(caster.getReferenceWorld(), e -> {
|
||||
counterpart.ifPresent(caster.asWorld(), e -> {
|
||||
setDisguise(e);
|
||||
Caster<?> other = Caster.of(e).get();
|
||||
SpellType.MIMIC.withTraits().apply(other).setDisguise(caster.getMaster());
|
||||
|
@ -77,14 +77,14 @@ public class MindSwapSpell extends MimicSpell {
|
|||
});
|
||||
}
|
||||
|
||||
if (counterpart.getId().isPresent() && counterpart.get(caster.getReferenceWorld()) == null) {
|
||||
if (counterpart.getId().isPresent() && counterpart.get(caster.asWorld()) == null) {
|
||||
caster.getMaster().damage(DamageSource.MAGIC, Float.MAX_VALUE);
|
||||
setDead();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!caster.getEntity().isAlive()) {
|
||||
counterpart.ifPresent(caster.getReferenceWorld(), e -> {
|
||||
if (!caster.asEntity().isAlive()) {
|
||||
counterpart.ifPresent(caster.asWorld(), e -> {
|
||||
e.damage(DamageSource.MAGIC, Float.MAX_VALUE);
|
||||
});
|
||||
onDestroyed(caster);
|
||||
|
|
|
@ -56,24 +56,24 @@ public class NecromancySpell extends AbstractAreaEffectSpell {
|
|||
return false;
|
||||
}
|
||||
|
||||
boolean rainy = source.getReferenceWorld().hasRain(source.getOrigin());
|
||||
boolean rainy = source.asWorld().hasRain(source.getOrigin());
|
||||
|
||||
if (source.isClient()) {
|
||||
source.spawnParticles(new Sphere(true, radius * 2), rainy ? 98 : 125, pos -> {
|
||||
BlockPos bpos = new BlockPos(pos);
|
||||
|
||||
if (!source.getReferenceWorld().isAir(bpos.down())) {
|
||||
source.addParticle(source.getReferenceWorld().hasRain(bpos) ? ParticleTypes.SMOKE : ParticleTypes.FLAME, pos, Vec3d.ZERO);
|
||||
if (!source.asWorld().isAir(bpos.down())) {
|
||||
source.addParticle(source.asWorld().hasRain(bpos) ? ParticleTypes.SMOKE : ParticleTypes.FLAME, pos, Vec3d.ZERO);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
if (source.getReferenceWorld().getDifficulty() == Difficulty.PEACEFUL) {
|
||||
if (source.asWorld().getDifficulty() == Difficulty.PEACEFUL) {
|
||||
return true;
|
||||
}
|
||||
|
||||
summonedEntities.removeIf(ref -> ref.getOrEmpty(source.getReferenceWorld()).filter(e -> {
|
||||
summonedEntities.removeIf(ref -> ref.getOrEmpty(source.asWorld()).filter(e -> {
|
||||
if (e.getPos().distanceTo(source.getOriginVector()) > radius * 2) {
|
||||
e.world.sendEntityStatus(e, (byte)60);
|
||||
e.discard();
|
||||
|
@ -82,13 +82,13 @@ public class NecromancySpell extends AbstractAreaEffectSpell {
|
|||
return true;
|
||||
}).isEmpty());
|
||||
|
||||
float additional = source.getReferenceWorld().getLocalDifficulty(source.getOrigin()).getLocalDifficulty() + getTraits().get(Trait.CHAOS, 0, 10);
|
||||
float additional = source.asWorld().getLocalDifficulty(source.getOrigin()).getLocalDifficulty() + getTraits().get(Trait.CHAOS, 0, 10);
|
||||
|
||||
setDirty();
|
||||
if (--spawnCountdown > 0 && !summonedEntities.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
spawnCountdown = 1200 + source.getReferenceWorld().random.nextInt(rainy ? 2000 : 1000);
|
||||
spawnCountdown = 1200 + source.asWorld().random.nextInt(rainy ? 2000 : 1000);
|
||||
|
||||
if (summonedEntities.size() > 10 + additional) {
|
||||
return true;
|
||||
|
@ -97,11 +97,11 @@ public class NecromancySpell extends AbstractAreaEffectSpell {
|
|||
Shape affectRegion = new Sphere(false, radius);
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Vec3d pos = affectRegion.computePoint(source.getReferenceWorld().random).add(source.getOriginVector());
|
||||
Vec3d pos = affectRegion.computePoint(source.asWorld().random).add(source.getOriginVector());
|
||||
|
||||
BlockPos loc = new BlockPos(pos);
|
||||
|
||||
if (source.getReferenceWorld().isAir(loc.up()) && !source.getReferenceWorld().isAir(loc)) {
|
||||
if (source.asWorld().isAir(loc.up()) && !source.asWorld().isAir(loc)) {
|
||||
spawnPool.get().ifPresent(type -> {
|
||||
spawnMonster(source, pos, type);
|
||||
});
|
||||
|
@ -118,7 +118,7 @@ public class NecromancySpell extends AbstractAreaEffectSpell {
|
|||
}
|
||||
LivingEntity master = caster.getMaster();
|
||||
summonedEntities.forEach(ref -> {
|
||||
ref.ifPresent(caster.getReferenceWorld(), e -> {
|
||||
ref.ifPresent(caster.asWorld(), e -> {
|
||||
if (master != null) {
|
||||
master.applyDamageEffects(master, e);
|
||||
}
|
||||
|
@ -129,14 +129,14 @@ public class NecromancySpell extends AbstractAreaEffectSpell {
|
|||
}
|
||||
|
||||
protected void spawnMonster(Caster<?> source, Vec3d pos, EntityType<? extends LivingEntity> type) {
|
||||
LivingEntity minion = type.create(source.getReferenceWorld());
|
||||
LivingEntity minion = type.create(source.asWorld());
|
||||
|
||||
source.subtractEnergyCost(3);
|
||||
|
||||
minion.updatePositionAndAngles(pos.x, pos.y, pos.z, 0, 0);
|
||||
minion.setVelocity(0, 0.3, 0);
|
||||
|
||||
source.getReferenceWorld().syncWorldEvent(WorldEvents.DRAGON_BREATH_CLOUD_SPAWNS, minion.getBlockPos(), 0);
|
||||
source.asWorld().syncWorldEvent(WorldEvents.DRAGON_BREATH_CLOUD_SPAWNS, minion.getBlockPos(), 0);
|
||||
source.playSound(SoundEvents.BLOCK_BELL_USE, 1, 0.3F);
|
||||
source.spawnParticles(ParticleTypes.LARGE_SMOKE, 10);
|
||||
minion.equipStack(EquipmentSlot.HEAD, Items.IRON_HELMET.getDefaultStack());
|
||||
|
@ -145,7 +145,7 @@ public class NecromancySpell extends AbstractAreaEffectSpell {
|
|||
((Creature)eq).setMaster(source);
|
||||
});
|
||||
|
||||
source.getReferenceWorld().spawnEntity(minion);
|
||||
source.asWorld().spawnEntity(minion);
|
||||
summonedEntities.add(new EntityReference<>(minion));
|
||||
setDirty();
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public class PortalSpell extends AbstractSpell implements PlaceableSpell.Placeme
|
|||
|
||||
@Override
|
||||
public boolean apply(Caster<?> caster) {
|
||||
setOrientation(caster.getEntity().getPitch(), caster.getEntity().getYaw());
|
||||
setOrientation(caster.asEntity().getPitch(), caster.asEntity().getYaw());
|
||||
return toPlaceable().apply(caster);
|
||||
}
|
||||
|
||||
|
@ -82,11 +82,11 @@ public class PortalSpell extends AbstractSpell implements PlaceableSpell.Placeme
|
|||
});
|
||||
} else {
|
||||
teleportationTarget.getId().ifPresent(id -> {
|
||||
if (Ether.get(source.getReferenceWorld()).getEntry(getType(), id).isEmpty()) {
|
||||
if (Ether.get(source.asWorld()).getEntry(getType(), id).isEmpty()) {
|
||||
Unicopia.LOGGER.debug("Lost sibling, breaking connection to " + id);
|
||||
teleportationTarget.set(null);
|
||||
setDirty();
|
||||
source.getReferenceWorld().syncWorldEvent(WorldEvents.BLOCK_BROKEN, source.getOrigin(), Block.getRawIdFromState(Blocks.GLASS.getDefaultState()));
|
||||
source.asWorld().syncWorldEvent(WorldEvents.BLOCK_BROKEN, source.getOrigin(), Block.getRawIdFromState(Blocks.GLASS.getDefaultState()));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -98,7 +98,7 @@ public class PortalSpell extends AbstractSpell implements PlaceableSpell.Placeme
|
|||
|
||||
if (!publishedPosition) {
|
||||
publishedPosition = true;
|
||||
Ether.Entry entry = Ether.get(source.getReferenceWorld()).put(getType(), source);
|
||||
Ether.Entry entry = Ether.get(source.asWorld()).put(getType(), source);
|
||||
entry.pitch = pitch;
|
||||
entry.yaw = yaw;
|
||||
}
|
||||
|
@ -140,10 +140,10 @@ public class PortalSpell extends AbstractSpell implements PlaceableSpell.Placeme
|
|||
return;
|
||||
}
|
||||
|
||||
Ether ether = Ether.get(source.getReferenceWorld());
|
||||
Ether ether = Ether.get(source.asWorld());
|
||||
ether.getEntries(getType())
|
||||
.stream()
|
||||
.filter(entry -> entry.isAvailable() && !entry.entity.referenceEquals(source.getEntity()) && entry.entity.getId().isPresent())
|
||||
.filter(entry -> entry.isAvailable() && !entry.entity.referenceEquals(source.asEntity()) && entry.entity.getId().isPresent())
|
||||
.findAny()
|
||||
.ifPresent(entry -> {
|
||||
entry.setTaken(true);
|
||||
|
@ -153,7 +153,7 @@ public class PortalSpell extends AbstractSpell implements PlaceableSpell.Placeme
|
|||
}
|
||||
|
||||
private Optional<Ether.Entry> getTarget(Caster<?> source) {
|
||||
return teleportationTarget.getId().flatMap(id -> Ether.get(source.getReferenceWorld()).getEntry(getType(), id));
|
||||
return teleportationTarget.getId().flatMap(id -> Ether.get(source.asWorld()).getEntry(getType(), id));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -185,8 +185,8 @@ public class PortalSpell extends AbstractSpell implements PlaceableSpell.Placeme
|
|||
|
||||
@Override
|
||||
public void onDestroyed(Caster<?> caster) {
|
||||
Ether ether = Ether.get(caster.getReferenceWorld());
|
||||
ether.remove(getType(), caster.getEntity().getUuid());
|
||||
Ether ether = Ether.get(caster.asWorld());
|
||||
ether.remove(getType(), caster.asEntity().getUuid());
|
||||
getTarget(caster).ifPresent(e -> e.setTaken(false));
|
||||
}
|
||||
|
||||
|
|
|
@ -31,9 +31,9 @@ public class ScorchSpell extends FireSpell implements ProjectileDelegate.Configu
|
|||
|
||||
@Override
|
||||
public boolean tick(Caster<?> source, Situation situation) {
|
||||
BlockPos pos = PosHelper.findSolidGroundAt(source.getReferenceWorld(), source.getOrigin(), source.getPhysics().getGravitySignum());
|
||||
BlockPos pos = PosHelper.findSolidGroundAt(source.asWorld(), source.getOrigin(), source.getPhysics().getGravitySignum());
|
||||
|
||||
if (source.canModifyAt(pos) && StateMaps.FIRE_AFFECTED.convert(source.getReferenceWorld(), pos)) {
|
||||
if (source.canModifyAt(pos) && StateMaps.FIRE_AFFECTED.convert(source.asWorld(), pos)) {
|
||||
source.spawnParticles(new Sphere(false, Math.max(1, getTraits().get(Trait.POWER))), 5, p -> {
|
||||
source.addParticle(ParticleTypes.SMOKE, PosHelper.offset(p, pos), Vec3d.ZERO);
|
||||
});
|
||||
|
|
|
@ -55,7 +55,7 @@ public class SiphoningSpell extends AbstractAreaEffectSpell {
|
|||
int direction = isFriendlyTogether(source) ? 1 : -1;
|
||||
|
||||
source.spawnParticles(new Sphere(true, radius, 1, 0, 1), 1, pos -> {
|
||||
if (!source.getReferenceWorld().isAir(new BlockPos(pos).down())) {
|
||||
if (!source.asWorld().isAir(new BlockPos(pos).down())) {
|
||||
|
||||
double dist = pos.distanceTo(source.getOriginVector());
|
||||
Vec3d velocity = pos.subtract(source.getOriginVector()).normalize().multiply(direction * dist);
|
||||
|
@ -64,7 +64,7 @@ public class SiphoningSpell extends AbstractAreaEffectSpell {
|
|||
}
|
||||
});
|
||||
} else {
|
||||
if (source.getReferenceWorld().getTime() % 10 != 0) {
|
||||
if (source.asWorld().getTime() % 10 != 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ public class SiphoningSpell extends AbstractAreaEffectSpell {
|
|||
}
|
||||
|
||||
private Stream<LivingEntity> getTargets(Caster<?> source) {
|
||||
return VecHelper.findInRange(null, source.getReferenceWorld(), source.getOriginVector(), 4 + source.getLevel().getScaled(6), EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR.and(e -> e instanceof LivingEntity))
|
||||
return VecHelper.findInRange(null, source.asWorld(), source.getOriginVector(), 4 + source.getLevel().getScaled(6), EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR.and(e -> e instanceof LivingEntity))
|
||||
.stream()
|
||||
.map(e -> (LivingEntity)e);
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public class SiphoningSpell extends AbstractAreaEffectSpell {
|
|||
source.subtractEnergyCost(0.2F);
|
||||
|
||||
if (ticksUpset > 0 || maxHealthGain <= 0) {
|
||||
if (source.getReferenceWorld().random.nextInt(3000) == 0) {
|
||||
if (source.asWorld().random.nextInt(3000) == 0) {
|
||||
setDead();
|
||||
} else {
|
||||
e.damage(damage, e.getHealth() / 4);
|
||||
|
|
|
@ -75,7 +75,7 @@ public class TraitDiscovery implements NbtSerialisable {
|
|||
});
|
||||
unreadTraits.addAll(newTraits);
|
||||
pony.setDirty();
|
||||
if (!newTraits.isEmpty() && !pony.getReferenceWorld().isClient) {
|
||||
if (!newTraits.isEmpty() && !pony.asWorld().isClient) {
|
||||
Channel.UNLOCK_TRAITS.send((ServerPlayerEntity)pony.asEntity(), new MsgUnlockTraits(newTraits));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ public class Ether extends PersistentState implements CasterView {
|
|||
}
|
||||
|
||||
public void remove(SpellType<?> spellType, Caster<?> caster) {
|
||||
remove(spellType, caster.getEntity().getUuid());
|
||||
remove(spellType, caster.asEntity().getUuid());
|
||||
}
|
||||
|
||||
public Set<Entry> getEntries(SpellType<?> spellType) {
|
||||
|
@ -109,7 +109,7 @@ public class Ether extends PersistentState implements CasterView {
|
|||
|
||||
public Optional<Entry> getEntry(SpellType<?> spellType, Caster<?> caster) {
|
||||
synchronized (locker) {
|
||||
return getEntries(spellType).stream().filter(e -> e.entity.referenceEquals(caster.getEntity())).findFirst();
|
||||
return getEntries(spellType).stream().filter(e -> e.entity.referenceEquals(caster.asEntity())).findFirst();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ public class Ether extends PersistentState implements CasterView {
|
|||
}
|
||||
|
||||
public Entry(Caster<?> caster) {
|
||||
entity = new EntityReference<>(caster.getEntity());
|
||||
entity = new EntityReference<>(caster.asEntity());
|
||||
}
|
||||
|
||||
boolean isAlive() {
|
||||
|
|
|
@ -166,7 +166,7 @@ public class RunesParticle extends OrientedBillboardParticle implements Attachme
|
|||
public void tick() {
|
||||
super.tick();
|
||||
|
||||
link.flatMap(Link::get).map(Caster::getEntity).ifPresentOrElse(e -> {
|
||||
link.flatMap(Link::get).map(Caster::asEntity).ifPresentOrElse(e -> {
|
||||
if (getAlphaScale() >= 0.9F) {
|
||||
if (stasisAge < 0) {
|
||||
stasisAge = age;
|
||||
|
|
|
@ -101,7 +101,7 @@ public class SphereParticle extends Particle implements Attachment {
|
|||
super.tick();
|
||||
|
||||
if (link.isPresent()) {
|
||||
link.flatMap(Link::get).map(Caster::getEntity).ifPresentOrElse(e -> {
|
||||
link.flatMap(Link::get).map(Caster::asEntity).ifPresentOrElse(e -> {
|
||||
Vec3d offset = parameters.getOffset();
|
||||
setPos(e.getX() + offset.getX(), e.getY() + offset.getY(), e.getZ() + offset.getZ());
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import net.minecraft.network.listener.ClientPlayPacketListener;
|
|||
import net.minecraft.text.Text;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class CastSpellEntity extends LightEmittingEntity implements Caster<LivingEntity>, WeaklyOwned<LivingEntity> {
|
||||
public class CastSpellEntity extends LightEmittingEntity implements Caster<CastSpellEntity>, WeaklyOwned<LivingEntity> {
|
||||
private static final TrackedData<Float> GRAVITY = DataTracker.registerData(CastSpellEntity.class, TrackedDataHandlerRegistry.FLOAT);
|
||||
private static final TrackedData<NbtCompound> EFFECT = DataTracker.registerData(CastSpellEntity.class, TrackedDataHandlerRegistry.NBT_COMPOUND);
|
||||
|
||||
|
@ -78,12 +78,7 @@ public class CastSpellEntity extends LightEmittingEntity implements Caster<Livin
|
|||
}
|
||||
|
||||
@Override
|
||||
public World getReferenceWorld() {
|
||||
return WeaklyOwned.super.getReferenceWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity getEntity() {
|
||||
public CastSpellEntity asEntity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,8 +76,8 @@ public class Creature extends Living<LivingEntity> implements WeaklyOwned<Living
|
|||
}
|
||||
|
||||
@Override
|
||||
public World getReferenceWorld() {
|
||||
return super.getReferenceWorld();
|
||||
public World asWorld() {
|
||||
return super.asWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -85,7 +85,7 @@ public class Creature extends Living<LivingEntity> implements WeaklyOwned<Living
|
|||
public LivingEntity getMaster() {
|
||||
NbtCompound data = entity.getDataTracker().get(MASTER);
|
||||
owner.fromNBT(data);
|
||||
return owner.getOrEmpty(getReferenceWorld()).orElse(entity);
|
||||
return owner.getOrEmpty(asWorld()).orElse(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -116,7 +116,7 @@ public class Creature extends Living<LivingEntity> implements WeaklyOwned<Living
|
|||
goals.add(3, eatMuffinGoal);
|
||||
}
|
||||
|
||||
if (owner.isPresent(getReferenceWorld())) {
|
||||
if (owner.isPresent(asWorld())) {
|
||||
initMinionAi();
|
||||
}
|
||||
|
||||
|
@ -241,7 +241,7 @@ public class Creature extends Living<LivingEntity> implements WeaklyOwned<Living
|
|||
}
|
||||
if (compound.contains("master", NbtElement.COMPOUND_TYPE)) {
|
||||
owner.fromNBT(compound.getCompound("master"));
|
||||
if (owner.isPresent(getReferenceWorld()) && targets != null) {
|
||||
if (owner.isPresent(asWorld()) && targets != null) {
|
||||
initMinionAi();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,6 +104,11 @@ public class FairyEntity extends PathAwareEntity implements DynamicLightSource,
|
|||
return owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World asWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleFallDamage(float fallDistance, float damageMultiplier, DamageSource damageSource) {
|
||||
return false;
|
||||
|
|
|
@ -75,7 +75,7 @@ public class ItemTracker implements NbtSerialisable, Copyable<ItemTracker> {
|
|||
if (!(living instanceof Pony)) {
|
||||
foundStacks.forEach(stack -> {
|
||||
if (getTicks((Trackable)stack.getItem()) == 1) {
|
||||
stack.inventoryTick(living.getReferenceWorld(), living.asEntity(), 0, false);
|
||||
stack.inventoryTick(living.asWorld(), living.asEntity(), 0, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -98,15 +98,6 @@ public abstract class Living<T extends LivingEntity> implements Equine<T>, Caste
|
|||
return armour;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use asEntity()
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
@Override
|
||||
public final Entity getEntity() {
|
||||
return asEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final T asEntity() {
|
||||
return entity;
|
||||
|
|
|
@ -2,20 +2,20 @@ package com.minelittlepony.unicopia.entity.behaviour;
|
|||
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
import com.minelittlepony.unicopia.entity.Living;
|
||||
|
||||
import net.minecraft.entity.passive.AxolotlEntity;
|
||||
|
||||
public class AxolotlBehaviour extends EntityBehaviour<AxolotlEntity> {
|
||||
private static final float toRad = 0.017453292F;
|
||||
@Override
|
||||
public void update(Caster<?> source, AxolotlEntity entity, Disguise spell) {
|
||||
public void update(Living<?> source, AxolotlEntity entity, Disguise spell) {
|
||||
if (entity.getModelAngles().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Vector3f current = entity.getModelAngles().get("body");
|
||||
entity.getModelAngles().put("body", new Vector3f(
|
||||
source.getEntity().isSubmergedInWater() ? source.getEntity().getPitch() * toRad : 0,
|
||||
source.asEntity().isSubmergedInWater() ? source.asEntity().getPitch() * toRad : 0,
|
||||
0,
|
||||
current == null ? 0 : current.z
|
||||
));
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.minelittlepony.unicopia.entity.behaviour;
|
||||
|
||||
import com.minelittlepony.unicopia.InteractionManager;
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
import com.minelittlepony.unicopia.entity.Living;
|
||||
|
||||
import net.minecraft.entity.passive.BeeEntity;
|
||||
|
||||
|
@ -16,8 +16,8 @@ public class BeeBehaviour extends EntityBehaviour<BeeEntity> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void update(Caster<?> source, BeeEntity entity, Disguise spell) {
|
||||
if (source.getMaster().isSneaking()) {
|
||||
public void update(Living<?> source, BeeEntity entity, Disguise spell) {
|
||||
if (source.asEntity().isSneaking()) {
|
||||
entity.setAngerTime(10);
|
||||
} else {
|
||||
entity.setAngerTime(0);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.minelittlepony.unicopia.entity.behaviour;
|
||||
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
import com.minelittlepony.unicopia.entity.Living;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.mixin.MixinBlazeEntity;
|
||||
|
||||
|
@ -14,10 +14,10 @@ import net.minecraft.world.WorldEvents;
|
|||
|
||||
public class BlazeBehaviour extends EntityBehaviour<BlazeEntity> {
|
||||
@Override
|
||||
public void update(Caster<?> source, BlazeEntity entity, Disguise spell) {
|
||||
public void update(Living<?> source, BlazeEntity entity, Disguise spell) {
|
||||
super.update(source, entity, spell);
|
||||
|
||||
Entity src = source.getEntity();
|
||||
Entity src = source.asEntity();
|
||||
|
||||
if (src.isOnGround() || src instanceof PlayerEntity player && player.getAbilities().flying) {
|
||||
return;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.minelittlepony.unicopia.entity.behaviour;
|
||||
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
import com.minelittlepony.unicopia.entity.Living;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
|
@ -20,7 +20,7 @@ public class ChickenBehaviour extends EntityBehaviour<ChickenEntity> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void update(Caster<?> source, ChickenEntity entity, Disguise spell) {
|
||||
public void update(Living<?> source, ChickenEntity entity, Disguise spell) {
|
||||
entity.eggLayTime = Integer.MAX_VALUE;
|
||||
|
||||
if (source instanceof Pony player) {
|
||||
|
@ -48,7 +48,7 @@ public class ChickenBehaviour extends EntityBehaviour<ChickenEntity> {
|
|||
}
|
||||
}
|
||||
|
||||
Entity src = source.getEntity();
|
||||
Entity src = source.asEntity();
|
||||
|
||||
if (src.isOnGround() || src instanceof PlayerEntity player && player.getAbilities().flying) {
|
||||
return;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package com.minelittlepony.unicopia.entity.behaviour;
|
||||
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
import com.minelittlepony.unicopia.entity.Living;
|
||||
|
||||
import net.minecraft.entity.mob.CreeperEntity;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
public class CreeperBehaviour extends EntityBehaviour<CreeperEntity> {
|
||||
@Override
|
||||
public void update(Caster<?> source, CreeperEntity entity, Disguise spell) {
|
||||
public void update(Living<?> source, CreeperEntity entity, Disguise spell) {
|
||||
int fuseCountDown = spell.getDisguise().getOrCreateTag().getInt("fuseCountdown");
|
||||
|
||||
boolean trigger = isSneakingOnGround(source);
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.jetbrains.annotations.Nullable;
|
|||
import com.minelittlepony.unicopia.FlightType;
|
||||
import com.minelittlepony.unicopia.Owned;
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
import com.minelittlepony.unicopia.entity.Living;
|
||||
import com.minelittlepony.unicopia.entity.duck.LivingEntityDuck;
|
||||
import com.minelittlepony.unicopia.entity.player.PlayerDimensions;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
|
@ -56,9 +57,14 @@ public interface Disguise extends FlightType.Provider, PlayerDimensions.Provider
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
default boolean update(Caster<?> source, boolean tick) {
|
||||
default boolean update(Caster<?> caster, boolean tick) {
|
||||
|
||||
LivingEntity owner = source.getMaster();
|
||||
if (!(caster instanceof Living)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Living<?> source = (Living<?>)caster;
|
||||
LivingEntity owner = source.asEntity();
|
||||
|
||||
if (owner == null) {
|
||||
return true;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.minelittlepony.unicopia.entity.behaviour;
|
||||
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
import com.minelittlepony.unicopia.entity.Living;
|
||||
|
||||
import net.minecraft.entity.mob.EndermanEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
|
@ -9,8 +9,8 @@ import net.minecraft.util.Hand;
|
|||
|
||||
public class EndermanBehaviour extends EntityBehaviour<EndermanEntity> {
|
||||
@Override
|
||||
public void update(Caster<?> source, EndermanEntity entity, Disguise spell) {
|
||||
if (source.getMaster().isSneaking() || source.getMaster().isSprinting()) {
|
||||
public void update(Living<?> source, EndermanEntity entity, Disguise spell) {
|
||||
if (source.asEntity().isSneaking() || source.asEntity().isSprinting()) {
|
||||
entity.setTarget(entity);
|
||||
} else {
|
||||
entity.setTarget(null);
|
||||
|
|
|
@ -133,7 +133,7 @@ public class EntityAppearance implements NbtSerialisable, PlayerDimensions.Provi
|
|||
private synchronized void createPlayer(NbtCompound nbt, GameProfile profile, Caster<?> source) {
|
||||
remove();
|
||||
|
||||
entity = InteractionManager.instance().createPlayer(source.getEntity(), profile);
|
||||
entity = InteractionManager.instance().createPlayer(source.asEntity(), profile);
|
||||
entity.setCustomName(source.getMaster().getName());
|
||||
((PlayerEntity)entity).readNbt(nbt.getCompound("playerNbt"));
|
||||
if (nbt.contains("playerVisibleParts", NbtElement.BYTE_TYPE)) {
|
||||
|
@ -164,7 +164,7 @@ public class EntityAppearance implements NbtSerialisable, PlayerDimensions.Provi
|
|||
), p -> createPlayer(nbt, p, source));
|
||||
} else {
|
||||
if (source.isClient()) {
|
||||
entity = EntityType.fromNbt(nbt).map(type -> type.create(source.getReferenceWorld())).orElse(null);
|
||||
entity = EntityType.fromNbt(nbt).map(type -> type.create(source.asWorld())).orElse(null);
|
||||
if (entity != null) {
|
||||
try {
|
||||
entity.readNbt(nbt);
|
||||
|
@ -174,7 +174,7 @@ public class EntityAppearance implements NbtSerialisable, PlayerDimensions.Provi
|
|||
entity = EntityBehaviour.forEntity(entity).onCreate(entity, this, true);
|
||||
}
|
||||
} else {
|
||||
entity = EntityType.loadEntityWithPassengers(nbt, source.getReferenceWorld(), e -> {
|
||||
entity = EntityType.loadEntityWithPassengers(nbt, source.asWorld(), e -> {
|
||||
return EntityBehaviour.forEntity(e).onCreate(e, this, true);
|
||||
});
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ public class EntityAppearance implements NbtSerialisable, PlayerDimensions.Provi
|
|||
}
|
||||
|
||||
private void onEntityLoaded(Caster<?> source) {
|
||||
source.getEntity().calculateDimensions();
|
||||
source.asEntity().calculateDimensions();
|
||||
|
||||
if (entity == null) {
|
||||
return;
|
||||
|
@ -202,7 +202,7 @@ public class EntityAppearance implements NbtSerialisable, PlayerDimensions.Provi
|
|||
}
|
||||
|
||||
if (source.isClient()) {
|
||||
source.getReferenceWorld().spawnEntity(entity);
|
||||
source.asWorld().spawnEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.jetbrains.annotations.Nullable;
|
|||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
import com.minelittlepony.unicopia.entity.duck.LivingEntityDuck;
|
||||
import com.minelittlepony.unicopia.entity.Living;
|
||||
import com.minelittlepony.unicopia.entity.duck.EntityDuck;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.util.RegistryUtils;
|
||||
|
@ -45,7 +46,7 @@ public class EntityBehaviour<T extends Entity> {
|
|||
* <br>
|
||||
* We use this to add entity-specific behaviours.
|
||||
*/
|
||||
public void update(Caster<?> source, T entity, Disguise spell) {
|
||||
public void update(Living<?> source, T entity, Disguise spell) {
|
||||
if (source instanceof Pony) {
|
||||
update((Pony)source, entity, spell);
|
||||
}
|
||||
|
@ -249,7 +250,7 @@ public class EntityBehaviour<T extends Entity> {
|
|||
}
|
||||
|
||||
protected boolean isSneakingOnGround(Caster<?> source) {
|
||||
Entity e = source.getEntity();
|
||||
Entity e = source.asEntity();
|
||||
return e.isSneaking() && (e.isOnGround() && !(e instanceof PlayerEntity player && player.getAbilities().flying));
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||
import java.util.Optional;
|
||||
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
import com.minelittlepony.unicopia.entity.Living;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.mixin.MixinFallingBlock;
|
||||
import com.minelittlepony.unicopia.mixin.MixinFallingBlockEntity;
|
||||
|
@ -41,8 +42,8 @@ public class FallingBlockBehaviour extends EntityBehaviour<FallingBlockEntity> {
|
|||
|
||||
@Override
|
||||
public void onImpact(Caster<?> source, FallingBlockEntity entity, float distance, float damageMultiplier, DamageSource cause) {
|
||||
if (source.getEntity().fallDistance > 3) {
|
||||
entity.fallDistance = source.getEntity().fallDistance;
|
||||
if (source.asEntity().fallDistance > 3) {
|
||||
entity.fallDistance = source.asEntity().fallDistance;
|
||||
entity.handleFallDamage(distance, damageMultiplier, cause);
|
||||
|
||||
BlockState state = entity.getBlockState();
|
||||
|
@ -85,7 +86,7 @@ public class FallingBlockBehaviour extends EntityBehaviour<FallingBlockEntity> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void update(Caster<?> source, FallingBlockEntity entity, Disguise spell) {
|
||||
public void update(Living<?> source, FallingBlockEntity entity, Disguise spell) {
|
||||
|
||||
BlockState state = entity.getBlockState();
|
||||
if (state.contains(Properties.WATERLOGGED)) {
|
||||
|
@ -101,7 +102,7 @@ public class FallingBlockBehaviour extends EntityBehaviour<FallingBlockEntity> {
|
|||
EntityAppearance disguise = spell.getDisguise();
|
||||
List<Entity> attachments = disguise.getAttachments();
|
||||
if (attachments.size() > 0) {
|
||||
copyBaseAttributes(source.getMaster(), attachments.get(0), UP);
|
||||
copyBaseAttributes(source.asEntity(), attachments.get(0), UP);
|
||||
}
|
||||
|
||||
BlockEntity be = disguise.getBlockEntity();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.minelittlepony.unicopia.entity.behaviour;
|
||||
|
||||
import com.minelittlepony.unicopia.InteractionManager;
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
import com.minelittlepony.unicopia.entity.Living;
|
||||
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.vehicle.AbstractMinecartEntity;
|
||||
|
@ -18,19 +18,18 @@ public class MinecartBehaviour extends EntityBehaviour<AbstractMinecartEntity> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void update(Caster<?> source, AbstractMinecartEntity entity, Disguise spell) {
|
||||
public void update(Living<?> source, AbstractMinecartEntity entity, Disguise spell) {
|
||||
entity.setYaw(entity.getYaw() - 90);
|
||||
entity.prevYaw -= 90;
|
||||
|
||||
entity.setPitch(0);
|
||||
entity.prevPitch = 0;
|
||||
|
||||
if (source.getEntity() instanceof LivingEntity living) {
|
||||
if (living.hurtTime > 0) {
|
||||
entity.setDamageWobbleTicks(living.hurtTime);
|
||||
entity.setDamageWobbleStrength(1);
|
||||
entity.setDamageWobbleSide(20 + (int)source.getEntity().fallDistance / 10);
|
||||
}
|
||||
LivingEntity living = source.asEntity();
|
||||
if (living.hurtTime > 0) {
|
||||
entity.setDamageWobbleTicks(living.hurtTime);
|
||||
entity.setDamageWobbleStrength(1);
|
||||
entity.setDamageWobbleSide(20 + (int)source.asEntity().fallDistance / 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.minelittlepony.unicopia.entity.behaviour;
|
||||
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
import com.minelittlepony.unicopia.entity.Living;
|
||||
import com.minelittlepony.unicopia.entity.duck.*;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
|
||||
|
@ -8,7 +8,7 @@ import net.minecraft.entity.player.PlayerEntity;
|
|||
|
||||
public class PlayerBehaviour extends EntityBehaviour<PlayerEntity> {
|
||||
@Override
|
||||
public void update(Caster<?> source, PlayerEntity entity, Disguise spell) {
|
||||
public void update(Living<?> source, PlayerEntity entity, Disguise spell) {
|
||||
if (source instanceof Pony pony) {
|
||||
PlayerEntity pFrom = pony.asEntity();
|
||||
|
||||
|
@ -22,14 +22,15 @@ public class PlayerBehaviour extends EntityBehaviour<PlayerEntity> {
|
|||
((PlayerEntityDuck)entity).callUpdateCapeAngles();
|
||||
}
|
||||
|
||||
if (source.getEntity().getPose() != entity.getPose()) {
|
||||
entity.setPose(source.getEntity().getPose());
|
||||
if (source.asEntity().getPose() != entity.getPose()) {
|
||||
entity.setPose(source.asEntity().getPose());
|
||||
}
|
||||
if (source.getEntity().isSwimming() != entity.isSwimming()) {
|
||||
entity.setSwimming(source.getEntity().isSwimming());
|
||||
if (source.asEntity().isSwimming() != entity.isSwimming()) {
|
||||
entity.setSwimming(source.asEntity().isSwimming());
|
||||
}
|
||||
if (source.getEntity() instanceof LivingEntityDuck duck) {
|
||||
duck.copyLeaningAnglesFrom(((LivingEntityDuck)source.getEntity()));
|
||||
if (source.asEntity() instanceof LivingEntityDuck duck) {
|
||||
// TODO: CopyAngles
|
||||
duck.copyLeaningAnglesFrom(((LivingEntityDuck)entity));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.minelittlepony.unicopia.entity.behaviour;
|
||||
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
import com.minelittlepony.unicopia.entity.Living;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.mixin.MixinShulkerEntity;
|
||||
|
||||
|
@ -14,7 +14,7 @@ import net.minecraft.util.math.Vec3d;
|
|||
|
||||
public class ShulkerBehaviour extends EntityBehaviour<ShulkerEntity> {
|
||||
@Override
|
||||
public void update(Caster<?> source, ShulkerEntity shulker, Disguise spell) {
|
||||
public void update(Living<?> source, ShulkerEntity shulker, Disguise spell) {
|
||||
shulker.setYaw(0);
|
||||
shulker.prevBodyYaw = 0;
|
||||
shulker.bodyYaw = 0;
|
||||
|
@ -27,11 +27,11 @@ public class ShulkerBehaviour extends EntityBehaviour<ShulkerEntity> {
|
|||
boolean noGravity = !shulker.isOnGround() && !shulker.world.isAir(pos)
|
||||
&& (attachmentFace == Direction.UP || attachmentFace.getAxis() != Axis.Y);
|
||||
|
||||
source.getEntity().setNoGravity(noGravity);
|
||||
if (noGravity && source.getEntity().isSneaking()) {
|
||||
Vec3d vel = source.getEntity().getVelocity();
|
||||
source.asEntity().setNoGravity(noGravity);
|
||||
if (noGravity && source.asEntity().isSneaking()) {
|
||||
Vec3d vel = source.asEntity().getVelocity();
|
||||
if (vel.y > 0) {
|
||||
source.getEntity().setVelocity(vel.multiply(1, 0.8, 1));
|
||||
source.asEntity().setVelocity(vel.multiply(1, 0.8, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
package com.minelittlepony.unicopia.entity.behaviour;
|
||||
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
import com.minelittlepony.unicopia.entity.Living;
|
||||
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.entity.mob.WaterCreatureEntity;
|
||||
|
||||
public class WaterCreatureBehaviour extends EntityBehaviour<WaterCreatureEntity> {
|
||||
@Override
|
||||
public void update(Caster<?> source, WaterCreatureEntity entity, Disguise spell) {
|
||||
public void update(Living<?> source, WaterCreatureEntity entity, Disguise spell) {
|
||||
|
||||
if (source.getEntity().isInsideWaterOrBubbleColumn()) {
|
||||
source.getEntity().setAir(source.getEntity().getAir() - 1);
|
||||
if (source.getEntity().getAir() == -20) {
|
||||
source.getEntity().setAir(0);
|
||||
source.getEntity().damage(DamageSource.DRYOUT, 2);
|
||||
if (source.asEntity().isInsideWaterOrBubbleColumn()) {
|
||||
source.asEntity().setAir(source.asEntity().getAir() - 1);
|
||||
if (source.asEntity().getAir() == -20) {
|
||||
source.asEntity().setAir(0);
|
||||
source.asEntity().damage(DamageSource.DRYOUT, 2);
|
||||
}
|
||||
} else {
|
||||
source.getEntity().setAir(300);
|
||||
source.asEntity().setAir(300);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ public class PlayerCamera extends MotionCompositor {
|
|||
return 0;
|
||||
}
|
||||
|
||||
float energyAddition = (player.getReferenceWorld().random.nextInt(maxE) - maxE/2) / 100F;
|
||||
float energyAddition = (player.asWorld().random.nextInt(maxE) - maxE/2) / 100F;
|
||||
|
||||
if (Math.abs(energyAddition) <= 0.001) {
|
||||
return 0;
|
||||
|
|
|
@ -30,7 +30,7 @@ class PlayerLevelStore implements Levelled.LevelStore {
|
|||
if (upgradeMana) {
|
||||
pony.getMagicalReserves().getMana().add(pony.getMagicalReserves().getMana().getMax() / 2);
|
||||
}
|
||||
pony.getReferenceWorld().playSound(null, pony.getOrigin(), levelUpSound, SoundCategory.PLAYERS, 1, 2);
|
||||
pony.asWorld().playSound(null, pony.getOrigin(), levelUpSound, SoundCategory.PLAYERS, 1, 2);
|
||||
}
|
||||
Levelled.LevelStore.super.add(levels);
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
|||
this.animationMaxDuration = animationDuration;
|
||||
|
||||
if (!isClient()) {
|
||||
Channel.SERVER_PLAYER_ANIMATION_CHANGE.send(getReferenceWorld(), new MsgPlayerAnimationChange(this, animation, animationDuration));
|
||||
Channel.SERVER_PLAYER_ANIMATION_CHANGE.send(asWorld(), new MsgPlayerAnimationChange(this, animation, animationDuration));
|
||||
}
|
||||
|
||||
animation.getSound().ifPresent(sound -> {
|
||||
|
@ -369,14 +369,14 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
|||
}
|
||||
|
||||
public boolean canHangAt(BlockPos pos) {
|
||||
if (!getReferenceWorld().isAir(pos) || !getReferenceWorld().isAir(pos.down())) {
|
||||
if (!asWorld().isAir(pos) || !asWorld().isAir(pos.down())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
pos = pos.up();
|
||||
BlockState state = getReferenceWorld().getBlockState(pos);
|
||||
BlockState state = asWorld().getBlockState(pos);
|
||||
|
||||
return state.isSolidSurface(getReferenceWorld(), pos, entity, Direction.DOWN);
|
||||
return state.isSolidSurface(asWorld(), pos, entity, Direction.DOWN);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -122,7 +122,7 @@ public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackab
|
|||
|
||||
float attachedTime = timeWorn / 100F;
|
||||
|
||||
LocalDifficulty difficulty = wearer.getReferenceWorld().getLocalDifficulty(wearer.getOrigin());
|
||||
LocalDifficulty difficulty = wearer.asWorld().getLocalDifficulty(wearer.getOrigin());
|
||||
float amount = attachedTime * (1 + difficulty.getClampedLocalDifficulty());
|
||||
|
||||
amount = Math.min(amount, wearer.getMaster().getMaxHealth());
|
||||
|
|
|
@ -101,7 +101,7 @@ public class ZapAppleItem extends Item implements ChameleonItem, ToxicHolder, Mu
|
|||
|
||||
@Override
|
||||
public List<ItemStack> getDefaultStacks() {
|
||||
return Unicopia.SIDE.getPony().map(Pony::getReferenceWorld)
|
||||
return Unicopia.SIDE.getPony().map(Pony::asWorld)
|
||||
.stream()
|
||||
.flatMap(world -> RegistryUtils.valuesForTag(world, UTags.APPLES))
|
||||
.filter(a -> a != this).map(item -> {
|
||||
|
|
|
@ -23,7 +23,7 @@ public class GemFindingEnchantment extends SimpleEnchantment {
|
|||
|
||||
BlockPos origin = user.getOrigin();
|
||||
|
||||
double volume = BlockPos.findClosest(origin, radius, radius, pos -> user.getReferenceWorld().getBlockState(pos).isIn(UTags.INTERESTING))
|
||||
double volume = BlockPos.findClosest(origin, radius, radius, pos -> user.asWorld().getBlockState(pos).isIn(UTags.INTERESTING))
|
||||
.map(p -> user.getOriginVector().squaredDistanceTo(p.getX(), p.getY(), p.getZ()))
|
||||
.map(find -> (1 - (Math.sqrt(find) / radius)))
|
||||
.orElse(-1D);
|
||||
|
@ -37,7 +37,7 @@ public class GemFindingEnchantment extends SimpleEnchantment {
|
|||
@Override
|
||||
public void onEquipped(Living<?> user) {
|
||||
if (user.isClient()) {
|
||||
MinecraftClient.getInstance().getSoundManager().play(new MagicAuraSoundInstance(user.asEntity().getSoundCategory(), user, user.getReferenceWorld().getRandom()));
|
||||
MinecraftClient.getInstance().getSoundManager().play(new MagicAuraSoundInstance(user.asEntity().getSoundCategory(), user, user.asWorld().getRandom()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,19 +36,19 @@ public class PoisonedJokeEnchantment extends SimpleEnchantment implements Identi
|
|||
|
||||
@Override
|
||||
public void onUserTick(Living<?> user, int level) {
|
||||
if (sounds.isEmpty() || user.getReferenceWorld().isClient) {
|
||||
if (sounds.isEmpty() || user.asWorld().isClient) {
|
||||
return;
|
||||
}
|
||||
|
||||
int light = user.getReferenceWorld().getLightLevel(user.asEntity().getRootVehicle().getBlockPos());
|
||||
Random rng = user.getReferenceWorld().random;
|
||||
int light = user.asWorld().getLightLevel(user.asEntity().getRootVehicle().getBlockPos());
|
||||
Random rng = user.asWorld().random;
|
||||
Data data = user.getEnchants().computeIfAbsent(this, Data::new);
|
||||
|
||||
data.level -= rng.nextFloat() * 0.8F;
|
||||
if (rng.nextInt(Math.max(1, (light * 9) + (int)data.level)) == 0) {
|
||||
data.level = rng.nextInt(5000);
|
||||
|
||||
user.getReferenceWorld().playSoundFromEntity(
|
||||
user.asWorld().playSoundFromEntity(
|
||||
null,
|
||||
user.asEntity(),
|
||||
sounds.get(rng.nextInt(sounds.size())), SoundCategory.HOSTILE,
|
||||
|
|
|
@ -16,7 +16,7 @@ public class WantItNeedItEnchantment extends SimpleEnchantment {
|
|||
|
||||
@Override
|
||||
public void onUserTick(Living<?> user, int level) {
|
||||
if (user instanceof Creature && user.getReferenceWorld().random.nextInt(10) == 0) {
|
||||
if (user instanceof Creature && user.asWorld().random.nextInt(10) == 0) {
|
||||
ParticleUtils.spawnParticles(new FollowingParticleEffect(UParticles.HEALTH_DRAIN, user.asEntity(), 0.2F), user.asEntity(), 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class MsgRequestSpeciesChange implements Packet<ServerPlayerEntity> {
|
|||
public void handle(ServerPlayerEntity sender) {
|
||||
Pony player = Pony.of(sender);
|
||||
|
||||
Race worldDefaultRace = WorldTribeManager.forWorld((ServerWorld)player.getReferenceWorld()).getDefaultRace();
|
||||
Race worldDefaultRace = WorldTribeManager.forWorld((ServerWorld)player.asWorld()).getDefaultRace();
|
||||
|
||||
if (force || player.getActualSpecies().isDefault() || (player.getActualSpecies() == worldDefaultRace && !player.isSpeciesPersisted())) {
|
||||
player.setSpecies(newRace.isPermitted(sender) ? newRace : worldDefaultRace);
|
||||
|
|
|
@ -113,8 +113,8 @@ public class EffectSync implements SpellContainer, NbtSerialisable {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends Spell> Stream<T> read(@Nullable SpellPredicate<T> type, boolean synchronize, boolean sendUpdate) {
|
||||
if (synchronize && spells.fromNbt(owner.getEntity().getDataTracker().get(param)) && sendUpdate) {
|
||||
owner.getEntity().getDataTracker().set(param, spells.toNbt());
|
||||
if (synchronize && spells.fromNbt(owner.asEntity().getDataTracker().get(param)) && sendUpdate) {
|
||||
owner.asEntity().getDataTracker().set(param, spells.toNbt());
|
||||
}
|
||||
|
||||
if (type == null) {
|
||||
|
@ -135,7 +135,7 @@ public class EffectSync implements SpellContainer, NbtSerialisable {
|
|||
|
||||
private void write() {
|
||||
if (spells.isDirty()) {
|
||||
owner.getEntity().getDataTracker().set(param, spells.toNbt());
|
||||
owner.asEntity().getDataTracker().set(param, spells.toNbt());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,13 +22,13 @@ import net.minecraft.world.World;
|
|||
public class ParticleHandle {
|
||||
private final Map<String, Attachment> loadedEffects = new WeakHashMap<>();
|
||||
|
||||
public Optional<Attachment> update(UUID id, ParticleSource source, Consumer<ParticleSpawner> constructor) {
|
||||
public Optional<Attachment> update(UUID id, ParticleSource<?> source, Consumer<ParticleSpawner> constructor) {
|
||||
return update(id, "prime", source, constructor);
|
||||
}
|
||||
|
||||
public Optional<Attachment> update(UUID id, String partName, ParticleSource source, Consumer<ParticleSpawner> constructor) {
|
||||
public Optional<Attachment> update(UUID id, String partName, ParticleSource<?> source, Consumer<ParticleSpawner> constructor) {
|
||||
return get(partName).or(() -> {
|
||||
if (source.getReferenceWorld().isClient) {
|
||||
if (source.asEntity().world.isClient) {
|
||||
new ClientHandle().addParticle(id, partName, source, constructor);
|
||||
}
|
||||
return get(partName);
|
||||
|
@ -50,7 +50,7 @@ public class ParticleHandle {
|
|||
private Particle pp;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
private void addParticle(UUID id, String partName, ParticleSource source, Consumer<ParticleSpawner> constructor) {
|
||||
private void addParticle(UUID id, String partName, ParticleSource<?> source, Consumer<ParticleSpawner> constructor) {
|
||||
SPAWNED_PARTICLES.values().removeIf(set -> {
|
||||
set.values().removeIf(particle -> particle.get() == null);
|
||||
return set.isEmpty();
|
||||
|
@ -110,7 +110,7 @@ public class ParticleHandle {
|
|||
}
|
||||
|
||||
public Optional<Caster<?>> get() {
|
||||
caster = caster.filter(r -> r.get() != null && r.get().getSpellSlot().contains(effect) && r.get().getEntity().isAlive());
|
||||
caster = caster.filter(r -> r.get() != null && r.get().getSpellSlot().contains(effect) && r.get().asEntity().isAlive());
|
||||
return caster.map(WeakReference::get);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,31 +2,17 @@ package com.minelittlepony.unicopia.particle;
|
|||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.minelittlepony.unicopia.EntityConvertable;
|
||||
import com.minelittlepony.unicopia.util.shape.PointGenerator;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.particle.ParticleEffect;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface ParticleSource extends ParticleSpawner {
|
||||
|
||||
/**
|
||||
* gets the minecraft world
|
||||
*/
|
||||
World getReferenceWorld();
|
||||
|
||||
Entity getEntity();
|
||||
|
||||
/**
|
||||
* Gets the center position where this caster is located.
|
||||
*/
|
||||
default Vec3d getOriginVector() {
|
||||
return getEntity().getPos();
|
||||
}
|
||||
public interface ParticleSource<E extends Entity> extends ParticleSpawner, EntityConvertable<E> {
|
||||
|
||||
default void spawnParticles(ParticleEffect particleId, int count) {
|
||||
ParticleUtils.spawnParticles(particleId, getEntity(), count);
|
||||
ParticleUtils.spawnParticles(particleId, asEntity(), count);
|
||||
}
|
||||
|
||||
default void spawnParticles(PointGenerator area, int count, Consumer<Vec3d> particleSpawner) {
|
||||
|
@ -34,11 +20,11 @@ public interface ParticleSource extends ParticleSpawner {
|
|||
}
|
||||
|
||||
default void spawnParticles(Vec3d pos, PointGenerator area, int count, Consumer<Vec3d> particleSpawner) {
|
||||
area.translate(pos).randomPoints(count, getReferenceWorld().random).forEach(particleSpawner);
|
||||
area.translate(pos).randomPoints(count, asEntity().world.random).forEach(particleSpawner);
|
||||
}
|
||||
|
||||
@Override
|
||||
default void addParticle(ParticleEffect effect, Vec3d position, Vec3d velocity) {
|
||||
ParticleUtils.spawnParticle(getReferenceWorld(), effect, position, velocity);
|
||||
ParticleUtils.spawnParticle(asEntity().world, effect, position, velocity);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import java.util.function.Function;
|
|||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.Affinity;
|
||||
import com.minelittlepony.unicopia.Owned;
|
||||
import com.minelittlepony.unicopia.ability.magic.Affine;
|
||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||
import com.minelittlepony.unicopia.ability.magic.Levelled;
|
||||
|
@ -53,7 +52,7 @@ import net.minecraft.world.World;
|
|||
*
|
||||
* Can also carry a spell if needed.
|
||||
*/
|
||||
public class MagicProjectileEntity extends ThrownItemEntity implements Caster<LivingEntity>, Owned<LivingEntity> {
|
||||
public class MagicProjectileEntity extends ThrownItemEntity implements Caster<MagicProjectileEntity> {
|
||||
private static final TrackedData<Float> DAMAGE = DataTracker.registerData(MagicProjectileEntity.class, TrackedDataHandlerRegistry.FLOAT);
|
||||
private static final TrackedData<Float> GRAVITY = DataTracker.registerData(MagicProjectileEntity.class, TrackedDataHandlerRegistry.FLOAT);
|
||||
private static final TrackedData<Boolean> HYDROPHOBIC = DataTracker.registerData(MagicProjectileEntity.class, TrackedDataHandlerRegistry.BOOLEAN);
|
||||
|
@ -98,7 +97,7 @@ public class MagicProjectileEntity extends ThrownItemEntity implements Caster<Li
|
|||
}
|
||||
|
||||
@Override
|
||||
public Entity getEntity() {
|
||||
public MagicProjectileEntity asEntity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public class MagicalDamageSource extends EntityDamageSource {
|
|||
}
|
||||
|
||||
public static MagicalDamageSource create(String type, Caster<?> caster) {
|
||||
return new MagicalDamageSource(type, caster.getMaster(), caster.getEntity(), false, false);
|
||||
return new MagicalDamageSource(type, caster.getMaster(), caster.asEntity(), false, false);
|
||||
}
|
||||
|
||||
private Entity spell;
|
||||
|
|
|
@ -1,20 +1,16 @@
|
|||
package com.minelittlepony.unicopia.util;
|
||||
|
||||
import com.minelittlepony.unicopia.EntityConvertable;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.math.random.Random;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface SoundEmitter {
|
||||
|
||||
World getReferenceWorld();
|
||||
|
||||
Entity getEntity();
|
||||
|
||||
public interface SoundEmitter<E extends Entity> extends EntityConvertable<E> {
|
||||
|
||||
default void playSound(SoundEvent sound, float volume, float pitch) {
|
||||
playSoundAt(getEntity(), sound, volume, pitch);
|
||||
playSoundAt(asEntity(), sound, volume, pitch);
|
||||
}
|
||||
|
||||
default void playSound(SoundEvent sound, float volume) {
|
||||
|
@ -22,7 +18,7 @@ public interface SoundEmitter {
|
|||
}
|
||||
|
||||
default float getRandomPitch() {
|
||||
return getRandomPitch(getReferenceWorld().getRandom());
|
||||
return getRandomPitch(asEntity().world.getRandom());
|
||||
}
|
||||
|
||||
static void playSoundAt(Entity entity, SoundEvent sound, float volume, float pitch) {
|
||||
|
|
Loading…
Reference in a new issue