Fixed crash due to naming conflict

This commit is contained in:
Sollace 2022-06-23 16:24:45 +02:00
parent d94626e094
commit 9e1b9161b8
46 changed files with 129 additions and 124 deletions

View file

@ -34,14 +34,14 @@ public interface WeaklyOwned<E extends Entity> extends Owned<E> {
}
}
default World getWorld() {
return ((Entity)this).world;
default World getReferenceWorld() {
return ((Entity)this).getEntityWorld();
}
@Nullable
@Override
default E getMaster() {
return getMasterReference().get(getWorld());
return getMasterReference().get(getReferenceWorld());
}
@Override

View file

@ -201,7 +201,7 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable {
return;
}
if (ability.canActivate(player.getWorld(), player)) {
if (ability.canActivate(player.getReferenceWorld(), player)) {
triggered = true;
setCooldown(ability.getCooldownTime(player));

View file

@ -54,18 +54,18 @@ public class BatEeeeAbility implements Ability<Hit> {
@Override
public void apply(Pony player, Hit data) {
Random rng = player.getWorld().random;
Random rng = player.getReferenceWorld().random;
int count = 1 + rng.nextInt(10);
for (int i = 0; i < count; i++) {
player.getWorld().playSound(null, player.getOrigin(), USounds.ENTITY_PLAYER_BATPONY_SCREECH, SoundCategory.PLAYERS,
player.getReferenceWorld().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.getWorld(), w -> {
AwaitTickQueue.scheduleTask(player.getReferenceWorld(), w -> {
for (int i = 0; i < count; i++) {
player.getWorld().playSound(null, player.getOrigin(), USounds.ENTITY_PLAYER_BATPONY_SCREECH, SoundCategory.PLAYERS,
player.getReferenceWorld().playSound(null, player.getOrigin(), USounds.ENTITY_PLAYER_BATPONY_SCREECH, SoundCategory.PLAYERS,
0.9F + (rng.nextFloat() - 0.5F) / 2F,
1.6F + (rng.nextFloat() - 0.5F)
);

View file

@ -46,7 +46,7 @@ public class BatPonyHangAbility implements Ability<Multi> {
BlockPos poss = RayTraceHelper.doTrace(player.getMaster(), 3, 1, EntityPredicates.CAN_COLLIDE).getBlockPos().orElse(null);
if (poss != null) {
boolean air = player.getWorld().isAir(poss.down()) && player.getWorld().isAir(poss.down(2));
boolean air = player.getReferenceWorld().isAir(poss.down()) && player.getReferenceWorld().isAir(poss.down(2));
if (air && player.canHangAt(poss)) {
return new Multi(poss, 1);
@ -55,7 +55,7 @@ public class BatPonyHangAbility implements Ability<Multi> {
return RayTraceHelper.doTrace(player.getMaster(), 5, 1, EntityPredicates.EXCEPT_SPECTATOR).getBlockPos()
.map(BlockPos::down)
.filter(pos -> player.getWorld().isAir(pos) && player.getWorld().isAir(pos.down()) && player.canHangAt(pos))
.filter(pos -> player.getReferenceWorld().isAir(pos) && player.getReferenceWorld().isAir(pos.down()) && player.canHangAt(pos))
.map(pos -> new Multi(pos, 1))
.orElse(null);
}

View file

@ -55,7 +55,7 @@ public class CarryAbility implements Ability<Hit> {
@Override
public void apply(Pony iplayer, Hit data) {
PlayerEntity player = iplayer.getMaster();
LivingEntity rider = findRider(player, iplayer.getWorld());
LivingEntity rider = findRider(player, iplayer.getReferenceWorld());
if (player.hasPassengers()) {
player.removeAllPassengers();

View file

@ -52,8 +52,8 @@ public class ChangelingDisguiseAbility extends ChangelingFeedAbility {
.map(EntityAppearance::getAppearance)
.orElse(e) : e;
}).orElseGet(() -> trace.getBlockPos().map(pos -> {
if (!iplayer.getWorld().isAir(pos)) {
return MixinFallingBlockEntity.createInstance(player.getEntityWorld(), 0, 0, 0, iplayer.getWorld().getBlockState(pos));
if (!iplayer.getReferenceWorld().isAir(pos)) {
return MixinFallingBlockEntity.createInstance(player.getEntityWorld(), 0, 0, 0, iplayer.getReferenceWorld().getBlockState(pos));
}
return null;
}).orElse(null));

View file

@ -80,7 +80,7 @@ public class ChangelingFeedAbility implements Ability<Hit> {
}
protected List<LivingEntity> getTargets(Pony player) {
List<Entity> list = VecHelper.findInRange(player.getMaster(), player.getWorld(), player.getOriginVector(), 3, this::canDrain);
List<Entity> list = VecHelper.findInRange(player.getMaster(), player.getReferenceWorld(), player.getOriginVector(), 3, this::canDrain);
RayTraceHelper.<LivingEntity>findEntity(player.getMaster(), 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.getWorld().random.nextInt(10) == 0) {
if (player.getReferenceWorld().random.nextInt(10) == 0) {
player.spawnParticles(ParticleTypes.HEART, 1);
}
}

View file

@ -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.getWorld(), player.getWorld().getBlockState(pos), pos);
count += applySingle(player.getReferenceWorld(), player.getReferenceWorld().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.getWorld().isClient()) {
if (player.getReferenceWorld().isClient()) {
player.spawnParticles(MagicParticleEffect.UNICORN, 1);
}
}

View file

@ -58,7 +58,7 @@ public class EarthPonyKickAbility implements Ability<Pos> {
return RayTraceHelper.doTrace(player.getMaster(), distance, 1)
.getBlockPos()
.filter(pos -> TreeType.at(pos, player.getWorld()) != TreeType.NONE)
.filter(pos -> TreeType.at(pos, player.getReferenceWorld()) != TreeType.NONE)
.isPresent() ? 3 : 1;
}
@ -69,7 +69,7 @@ public class EarthPonyKickAbility implements Ability<Pos> {
return RayTraceHelper.doTrace(player.getMaster(), distance, 1)
.getBlockPos()
.filter(pos -> TreeType.at(pos, player.getWorld()) != TreeType.NONE)
.filter(pos -> TreeType.at(pos, player.getReferenceWorld()) != TreeType.NONE)
.map(Pos::new)
.orElseGet(() -> getDefaultKickLocation(player));
}
@ -85,10 +85,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.getWorld());
TreeType tree = TreeType.at(pos, player.getReferenceWorld());
return tree == TreeType.NONE || tree.findBase(player.getWorld(), pos)
.map(base -> tree.countBlocks(player.getWorld(), pos) > 0)
return tree == TreeType.NONE || tree.findBase(player.getReferenceWorld(), pos)
.map(base -> tree.countBlocks(player.getReferenceWorld(), pos) > 0)
.orElse(false);
}
@ -100,7 +100,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.getWorld());
TreeType tree = TreeType.at(pos, iplayer.getReferenceWorld());
iplayer.setAnimation(Animation.KICK);
iplayer.subtractEnergyCost(tree == TreeType.NONE ? 1 : 3);
@ -108,7 +108,7 @@ public class EarthPonyKickAbility implements Ability<Pos> {
if (tree == TreeType.NONE) {
return;
} else {
ParticleUtils.spawnParticle(iplayer.getWorld(), UParticles.GROUND_POUND, data.vec(), Vec3d.ZERO);
ParticleUtils.spawnParticle(iplayer.getReferenceWorld(), UParticles.GROUND_POUND, data.vec(), Vec3d.ZERO);
}
PlayerEntity player = iplayer.getMaster();

View file

@ -81,7 +81,7 @@ public class EarthPonyStompAbility implements Ability<Hit> {
private void thrustDownwards(Pony player) {
BlockPos ppos = player.getOrigin();
BlockPos pos = PosHelper.findSolidGroundAt(player.getWorld(), ppos, player.getPhysics().getGravitySignum());
BlockPos pos = PosHelper.findSolidGroundAt(player.getReferenceWorld(), ppos, player.getPhysics().getGravitySignum());
double downV = Math.sqrt(ppos.getSquaredDistance(pos)) * player.getPhysics().getGravitySignum();
player.getMaster().addVelocity(0, -downV, 0);
@ -100,7 +100,7 @@ public class EarthPonyStompAbility implements Ability<Hit> {
float heavyness = 1 + EnchantmentHelper.getEquipmentLevel(UEnchantments.HEAVY, player);
iplayer.getWorld().getOtherEntities(player, areaOfEffect.offset(iplayer.getOriginVector())).forEach(i -> {
iplayer.getReferenceWorld().getOtherEntities(player, areaOfEffect.offset(iplayer.getOriginVector())).forEach(i -> {
double dist = Math.sqrt(center.getSquaredDistance(i.getBlockPos()));
if (dist <= rad + 3) {

View file

@ -60,7 +60,7 @@ public class PegasusCaptureStormAbility implements Ability<Hit> {
@Override
public void apply(Pony player, Hit data) {
World w = player.getWorld();
World w = player.getReferenceWorld();
ItemStack stack = player.getMaster().getStackInHand(Hand.MAIN_HAND);
boolean thundering = w.isThundering();

View file

@ -90,7 +90,7 @@ public class UnicornCastingAbility implements Ability<Hit> {
if (amount < 0) {
AmuletItem.consumeEnergy(stack, amount);
player.getMagicalReserves().getMana().add(amount * player.getMagicalReserves().getMana().getMax());
player.getWorld().playSoundFromEntity(null, player.getMaster(), USounds.ITEM_AMULET_RECHARGE, SoundCategory.PLAYERS, 1, 1);
player.getReferenceWorld().playSoundFromEntity(null, player.getMaster(), USounds.ITEM_AMULET_RECHARGE, SoundCategory.PLAYERS, 1, 1);
}
}
} else {
@ -144,7 +144,7 @@ public class UnicornCastingAbility implements Ability<Hit> {
float i = player.getAbilities().getStat(slot).getFillProgress();
Random rng = player.getWorld().random;
Random rng = player.getReferenceWorld().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 {

View file

@ -76,7 +76,7 @@ public class UnicornDispellAbility implements Ability<Pos> {
@Override
public void apply(Pony player, Pos data) {
player.setAnimation(Animation.WOLOLO);
Caster.stream(VecHelper.findInRange(player.getEntity(), player.getWorld(), data.vec(), 2, EquinePredicates.IS_PLACED_SPELL).stream()).forEach(target -> {
Caster.stream(VecHelper.findInRange(player.getEntity(), player.getReferenceWorld(), data.vec(), 2, EquinePredicates.IS_PLACED_SPELL).stream()).forEach(target -> {
target.getSpellSlot().clear();
});
}

View file

@ -69,7 +69,7 @@ public class UnicornTeleportAbility implements Ability<Pos> {
int maxDistance = player.getMaster().isCreative() ? 1000 : 100;
HitResult ray = RayTraceHelper.doTrace(player.getMaster(), maxDistance, 1, EntityPredicates.CAN_COLLIDE).getResult();
World w = player.getWorld();
World w = player.getReferenceWorld();
if (ray.getType() == HitResult.Type.MISS) {
return null;
@ -136,7 +136,7 @@ public class UnicornTeleportAbility implements Ability<Pos> {
return;
}
teleportee.getWorld().playSound(null, teleportee.getOrigin(), USounds.ENTITY_PLAYER_UNICORN_TELEPORT, SoundCategory.PLAYERS, 1, 1);
teleportee.getReferenceWorld().playSound(null, teleportee.getOrigin(), USounds.ENTITY_PLAYER_UNICORN_TELEPORT, SoundCategory.PLAYERS, 1, 1);
double distance = destination.distanceTo(teleportee) / 10;

View file

@ -42,7 +42,7 @@ public interface Caster<E extends LivingEntity> extends Owned<E>, Levelled, Affi
* Gets the minecraft world
*/
@Override
default World getWorld() {
default World getReferenceWorld() {
return getEntity().getEntityWorld();
}
@ -50,7 +50,7 @@ public interface Caster<E extends LivingEntity> extends Owned<E>, Levelled, Affi
* Returns true if we're executing on the client.
*/
default boolean isClient() {
return getWorld().isClient();
return getReferenceWorld().isClient();
}
/**
@ -62,13 +62,13 @@ public interface Caster<E extends LivingEntity> extends Owned<E>, Levelled, Affi
default boolean canModifyAt(BlockPos pos) {
if (getMaster() instanceof PlayerEntity) {
return getWorld().canPlayerModifyAt((PlayerEntity)getMaster(), pos);
return getReferenceWorld().canPlayerModifyAt((PlayerEntity)getMaster(), pos);
}
return getWorld().getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING);
return getReferenceWorld().getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING);
}
default void playSound(SoundEvent sound, float volume, float pitch) {
getWorld().playSound(null, getEntity().getX(), getEntity().getY(), getEntity().getZ(), sound, getEntity().getSoundCategory(), volume, pitch);
getReferenceWorld().playSound(null, getEntity().getX(), getEntity().getY(), getEntity().getZ(), sound, getEntity().getSoundCategory(), volume, pitch);
}
/**
@ -87,7 +87,7 @@ public interface Caster<E extends LivingEntity> extends Owned<E>, Levelled, Affi
}
default Stream<Entity> findAllEntitiesInRange(double radius, @Nullable Predicate<Entity> test) {
return VecHelper.findInRange(getEntity(), getWorld(), getOriginVector(), radius, test).stream();
return VecHelper.findInRange(getEntity(), getReferenceWorld(), getOriginVector(), radius, test).stream();
}
default Stream<Entity> findAllEntitiesInRange(double radius) {

View file

@ -51,7 +51,7 @@ public class DispersableDisguiseSpell extends AbstractDisguiseSpell implements I
if (isSuppressed()) {
source.spawnParticles(MagicParticleEffect.UNICORN, 5);
source.spawnParticles(UParticles.CHANGELING_MAGIC, 5);
} else if (source.getWorld().random.nextInt(30) == 0) {
} else if (source.getReferenceWorld().random.nextInt(30) == 0) {
source.spawnParticles(UParticles.CHANGELING_MAGIC, 2);
}
}

View file

@ -77,12 +77,12 @@ public class PlaceableSpell extends AbstractDelegatingSpell {
if (!source.isClient()) {
if (dimension == null) {
dimension = source.getWorld().getRegistryKey();
dimension = source.getReferenceWorld().getRegistryKey();
setDirty();
}
if (getSpellEntity(source).isEmpty()) {
CastSpellEntity entity = UEntities.CAST_SPELL.create(source.getWorld());
CastSpellEntity entity = UEntities.CAST_SPELL.create(source.getReferenceWorld());
Vec3d pos = castEntity.getPosition().orElse(source.getOriginVector());
entity.updatePositionAndAngles(pos.x, pos.y, pos.z, 0, 0);
entity.getSpellSlot().put(spell.toPlaceable());
@ -123,7 +123,7 @@ public class PlaceableSpell extends AbstractDelegatingSpell {
protected Optional<CastSpellEntity> getSpellEntity(Caster<?> source) {
return Optional.ofNullable(dimension)
.map(dim -> source.getWorld().getServer().getWorld(dimension))
.map(dim -> source.getReferenceWorld().getServer().getWorld(dimension))
.map(castEntity::get);
}

View file

@ -70,7 +70,7 @@ public class RainboomAbilitySpell extends AbstractSpell {
e.damage(MagicalDamageSource.create("rainboom", source), 6);
});
PosHelper.getAllInRegionMutable(source.getOrigin(), effect_range).forEach(pos -> {
BlockState state = source.getWorld().getBlockState(pos);
BlockState state = source.getReferenceWorld().getBlockState(pos);
if (state.isIn(UTags.FRAGILE) && canBreak(pos, owner)) {
owner.world.breakBlock(pos, true);
}

View file

@ -50,7 +50,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.getWorld();
World world = caster.getReferenceWorld();
LivingEntity entity = caster.getMaster();

View file

@ -55,7 +55,7 @@ public class AttractiveSpell extends ShieldSpell implements ProjectileSpell {
force *= AttractionUtils.getForceAdjustment(target);
}
if (!isGood && source.getWorld().random.nextInt(4500) == 0) {
if (!isGood && source.getReferenceWorld().random.nextInt(4500) == 0) {
source.getEntity().damage(MagicalDamageSource.create("vortex"), 4);
}

View file

@ -29,7 +29,7 @@ public class AwkwardSpell extends AbstractSpell {
List<Identifier> names = new ArrayList<>(Registry.PARTICLE_TYPE.getIds());
int index = (int)MathHelper.nextDouble(source.getWorld().random, 0, names.size());
int index = (int)MathHelper.nextDouble(source.getReferenceWorld().random, 0, names.size());
Identifier id = names.get(index);
ParticleType<?> type = Registry.PARTICLE_TYPE.get(id);

View file

@ -73,9 +73,9 @@ public class CatapultSpell extends AbstractSpell implements ProjectileSpell {
e.setVelocity(caster.getEntity().getVelocity());
} else {
e.addVelocity(
((caster.getWorld().random.nextFloat() * HORIZONTAL_VARIANCE) - HORIZONTAL_VARIANCE + vel.x * 0.8F) * 0.1F,
((caster.getReferenceWorld().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.getWorld().random.nextFloat() * HORIZONTAL_VARIANCE) - HORIZONTAL_VARIANCE + vel.z * 0.8F) * 0.1F
((caster.getReferenceWorld().random.nextFloat() * HORIZONTAL_VARIANCE) - HORIZONTAL_VARIANCE + vel.z * 0.8F) * 0.1F
);
}
}
@ -94,7 +94,7 @@ public class CatapultSpell extends AbstractSpell implements ProjectileSpell {
Optional.ofNullable(result.getEntity()).ifPresent(apply);
} else if (ray.getType() == HitResult.Type.BLOCK) {
if (caster.canModifyAt(((BlockHitResult)ray).getBlockPos())) {
createBlockEntity(caster.getWorld(), ((BlockHitResult)ray).getBlockPos(), apply);
createBlockEntity(caster.getReferenceWorld(), ((BlockHitResult)ray).getBlockPos(), apply);
}
}
}

View file

@ -86,13 +86,13 @@ public class DarkVortexSpell extends AttractiveSpell implements ProjectileSpell
setDirty();
if (age % 20 == 0) {
source.getWorld().playSound(null, source.getOrigin(), USounds.AMBIENT_DARK_VORTEX_ADDITIONS, SoundCategory.AMBIENT, 1, 1);
source.getReferenceWorld().playSound(null, source.getOrigin(), USounds.AMBIENT_DARK_VORTEX_ADDITIONS, SoundCategory.AMBIENT, 1, 1);
}
source.subtractEnergyCost(-accumulatedMass);
if (!source.isClient() && source.getWorld().random.nextInt(300) == 0) {
ParticleUtils.spawnParticle(source.getWorld(), UParticles.LIGHTNING_BOLT, getOrigin(source), Vec3d.ZERO);
if (!source.isClient() && source.getReferenceWorld().random.nextInt(300) == 0) {
ParticleUtils.spawnParticle(source.getReferenceWorld(), UParticles.LIGHTNING_BOLT, getOrigin(source), Vec3d.ZERO);
}
return super.tick(source, situation);
@ -161,9 +161,9 @@ public class DarkVortexSpell extends AttractiveSpell implements ProjectileSpell
return;
}
if (source.getOrigin().isWithinDistance(i, getEventHorizonRadius() / 2)) {
source.getWorld().breakBlock(i, false);
source.getReferenceWorld().breakBlock(i, false);
} else {
CatapultSpell.createBlockEntity(source.getWorld(), i, e -> {
CatapultSpell.createBlockEntity(source.getReferenceWorld(), i, e -> {
applyRadialEffect(source, e, e.getPos().distanceTo(origin), radius);
});
}
@ -177,8 +177,8 @@ public class DarkVortexSpell extends AttractiveSpell implements ProjectileSpell
protected boolean canAffect(Caster<?> source, BlockPos pos) {
return source.canModifyAt(pos)
&& source.getWorld().getFluidState(pos).isEmpty()
&& source.getWorld().getBlockState(pos).getHardness(source.getWorld(), pos) >= 0;
&& source.getReferenceWorld().getFluidState(pos).isEmpty()
&& source.getReferenceWorld().getBlockState(pos).getHardness(source.getReferenceWorld(), pos) >= 0;
}
// 1. force decreases with distance: distance scale 1 -> 0
@ -235,7 +235,7 @@ public class DarkVortexSpell extends AttractiveSpell implements ProjectileSpell
}
source.subtractEnergyCost(-massOfTarget * 10);
source.getWorld().playSound(null, source.getOrigin(), USounds.AMBIENT_DARK_VORTEX_MOOD, SoundCategory.AMBIENT, 2, 0.02F);
source.getReferenceWorld().playSound(null, source.getOrigin(), USounds.AMBIENT_DARK_VORTEX_MOOD, SoundCategory.AMBIENT, 2, 0.02F);
} else {
double force = getAttractiveForce(source, target);

View file

@ -67,7 +67,7 @@ public class FireBoltSpell extends AbstractSpell implements ProjectileSpell, Hom
c.setHomingTarget(target);
});
caster.playSound(USounds.SPELL_FIRE_BOLT_SHOOT, 0.7F, 0.4F / (caster.getWorld().random.nextFloat() * 0.4F + 0.8F));
caster.playSound(USounds.SPELL_FIRE_BOLT_SHOOT, 0.7F, 0.4F / (caster.getReferenceWorld().random.nextFloat() * 0.4F + 0.8F));
}
return false;
}
@ -81,7 +81,7 @@ public class FireBoltSpell extends AbstractSpell implements ProjectileSpell, Hom
}
protected int getNumberOfBalls(Caster<?> caster) {
return 1 + caster.getWorld().random.nextInt(3) + (int)getTraits().get(Trait.EARTH) * 3;
return 1 + caster.getReferenceWorld().random.nextInt(3) + (int)getTraits().get(Trait.EARTH) * 3;
}
@Override

View file

@ -50,7 +50,7 @@ public class FireSpell extends AbstractAreaEffectSpell implements ProjectileSpel
@Override
public void onImpact(MagicProjectileEntity projectile, BlockPos pos, BlockState state) {
if (!projectile.isClient()) {
projectile.getWorld().createExplosion(projectile.getEntity(), pos.getX(), pos.getY(), pos.getZ(), 2, DestructionType.DESTROY);
projectile.getReferenceWorld().createExplosion(projectile.getEntity(), pos.getX(), pos.getY(), pos.getZ(), 2, DestructionType.DESTROY);
}
}
@ -61,9 +61,9 @@ public class FireSpell extends AbstractAreaEffectSpell implements ProjectileSpel
}
return PosHelper.getAllInRegionMutable(source.getOrigin(), new Sphere(false, Math.max(0, 4 + getTraits().get(Trait.POWER)))).reduce(false,
(r, i) -> source.canModifyAt(i) && applyBlocks(source.getWorld(), i),
(r, i) -> source.canModifyAt(i) && applyBlocks(source.getReferenceWorld(), i),
(a, b) -> a || b)
|| applyEntities(null, source.getWorld(), source.getOriginVector());
|| applyEntities(null, source.getReferenceWorld(), source.getOriginVector());
}
protected void generateParticles(Caster<?> source) {

View file

@ -46,21 +46,21 @@ public class IceSpell extends AbstractSpell {
boolean submerged = source.getEntity().isSubmergedInWater() || source.getEntity().isSubmergedIn(FluidTags.LAVA);
long blocksAffected = PosHelper.getAllInRegionMutable(source.getOrigin(), outerRange).filter(i -> {
if (source.canModifyAt(i) && applyBlockSingle(source.getEntity(), source.getWorld(), i, situation)) {
if (source.canModifyAt(i) && applyBlockSingle(source.getEntity(), source.getReferenceWorld(), i, situation)) {
if (submerged & source.getOrigin().isWithinDistance(i, rad - 1)) {
BlockState state = source.getWorld().getBlockState(i);
BlockState state = source.getReferenceWorld().getBlockState(i);
if (state.isIn(BlockTags.ICE) || state.isOf(Blocks.OBSIDIAN)) {
source.getWorld().setBlockState(i, Blocks.AIR.getDefaultState(), Block.NOTIFY_NEIGHBORS);
source.getReferenceWorld().setBlockState(i, Blocks.AIR.getDefaultState(), Block.NOTIFY_NEIGHBORS);
} else if (!state.getFluidState().isEmpty()) {
source.getWorld().setBlockState(i, state.with(Properties.WATERLOGGED, false), Block.NOTIFY_NEIGHBORS);
source.getReferenceWorld().setBlockState(i, state.with(Properties.WATERLOGGED, false), Block.NOTIFY_NEIGHBORS);
}
}
ParticleUtils.spawnParticle(source.getWorld(), ParticleTypes.SPLASH, new Vec3d(
i.getX() + source.getWorld().random.nextFloat(),
ParticleUtils.spawnParticle(source.getReferenceWorld(), ParticleTypes.SPLASH, new Vec3d(
i.getX() + source.getReferenceWorld().random.nextFloat(),
i.getY() + 1,
i.getZ() + source.getWorld().random.nextFloat()), Vec3d.ZERO);
i.getZ() + source.getReferenceWorld().random.nextFloat()), Vec3d.ZERO);
return true;
}
@ -70,7 +70,7 @@ public class IceSpell extends AbstractSpell {
source.subtractEnergyCost(Math.min(10, blocksAffected));
return applyEntities(source.getMaster(), source.getWorld(), source.getOriginVector()) && situation == Situation.PROJECTILE;
return applyEntities(source.getMaster(), source.getReferenceWorld(), source.getOriginVector()) && situation == Situation.PROJECTILE;
}
protected boolean applyEntities(LivingEntity owner, World world, Vec3d pos) {

View file

@ -31,7 +31,7 @@ public class InfernoSpell extends FireSpell {
generateParticles(source);
}
World w = source.getWorld();
World w = source.getReferenceWorld();
if (!w.isClient) {
int radius = 4 + (source.getLevel().get() * 4);

View file

@ -53,17 +53,17 @@ public class LightSpell extends AbstractSpell {
if (!caster.isClient()) {
if (lights.isEmpty()) {
int size = 2 + caster.getWorld().random.nextInt(2) + (int)(getTraits().get(Trait.LIFE, 10, 20) - 10)/10;
int size = 2 + caster.getReferenceWorld().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.getWorld())) {
FairyEntity entity = UEntities.TWITTERMITE.create(caster.getWorld());
if (!ref.isPresent(caster.getReferenceWorld())) {
FairyEntity entity = UEntities.TWITTERMITE.create(caster.getReferenceWorld());
entity.setPosition(ref.getPosition().orElseGet(() -> {
return caster.getOriginVector().add(VecHelper.supply(() -> caster.getWorld().random.nextInt(3) - 1));
return caster.getOriginVector().add(VecHelper.supply(() -> caster.getReferenceWorld().random.nextInt(3) - 1));
}));
entity.setMaster(caster);
entity.world.spawnEntity(entity);
@ -83,7 +83,7 @@ public class LightSpell extends AbstractSpell {
return;
}
lights.forEach(ref -> {
ref.ifPresent(caster.getWorld(), e -> {
ref.ifPresent(caster.getReferenceWorld(), e -> {
e.world.sendEntityStatus(e, (byte)60);
e.discard();
});

View file

@ -56,24 +56,24 @@ public class NecromancySpell extends AbstractAreaEffectSpell {
return false;
}
boolean rainy = source.getWorld().hasRain(source.getOrigin());
boolean rainy = source.getReferenceWorld().hasRain(source.getOrigin());
if (source.isClient()) {
source.spawnParticles(new Sphere(true, radius * 2), rainy ? 98 : 125, pos -> {
BlockPos bpos = new BlockPos(pos);
if (!source.getWorld().isAir(bpos.down())) {
source.addParticle(source.getWorld().hasRain(bpos) ? ParticleTypes.SMOKE : ParticleTypes.FLAME, pos, Vec3d.ZERO);
if (!source.getReferenceWorld().isAir(bpos.down())) {
source.addParticle(source.getReferenceWorld().hasRain(bpos) ? ParticleTypes.SMOKE : ParticleTypes.FLAME, pos, Vec3d.ZERO);
}
});
return true;
}
if (source.getWorld().getDifficulty() == Difficulty.PEACEFUL) {
if (source.getReferenceWorld().getDifficulty() == Difficulty.PEACEFUL) {
return true;
}
summonedEntities.removeIf(ref -> ref.getOrEmpty(source.getWorld()).filter(e -> {
summonedEntities.removeIf(ref -> ref.getOrEmpty(source.getReferenceWorld()).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.getWorld().getLocalDifficulty(source.getOrigin()).getLocalDifficulty() + getTraits().get(Trait.CHAOS, 0, 10);
float additional = source.getReferenceWorld().getLocalDifficulty(source.getOrigin()).getLocalDifficulty() + getTraits().get(Trait.CHAOS, 0, 10);
setDirty();
if (--spawnCountdown > 0 && !summonedEntities.isEmpty()) {
return true;
}
spawnCountdown = 1200 + source.getWorld().random.nextInt(rainy ? 2000 : 1000);
spawnCountdown = 1200 + source.getReferenceWorld().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.getWorld().random).add(source.getOriginVector());
Vec3d pos = affectRegion.computePoint(source.getReferenceWorld().random).add(source.getOriginVector());
BlockPos loc = new BlockPos(pos);
if (source.getWorld().isAir(loc.up()) && !source.getWorld().isAir(loc)) {
if (source.getReferenceWorld().isAir(loc.up()) && !source.getReferenceWorld().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.getWorld(), e -> {
ref.ifPresent(caster.getReferenceWorld(), 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.getWorld());
LivingEntity minion = type.create(source.getReferenceWorld());
source.subtractEnergyCost(3);
minion.updatePositionAndAngles(pos.x, pos.y, pos.z, 0, 0);
minion.setVelocity(0, 0.3, 0);
source.getWorld().syncWorldEvent(WorldEvents.DRAGON_BREATH_CLOUD_SPAWNS, minion.getBlockPos(), 0);
source.getReferenceWorld().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.getWorld().spawnEntity(minion);
source.getReferenceWorld().spawnEntity(minion);
summonedEntities.add(new EntityReference<>(minion));
setDirty();
}

View file

@ -27,9 +27,9 @@ public class ScorchSpell extends FireSpell {
@Override
public boolean tick(Caster<?> source, Situation situation) {
BlockPos pos = PosHelper.findSolidGroundAt(source.getWorld(), source.getOrigin(), source.getPhysics().getGravitySignum());
BlockPos pos = PosHelper.findSolidGroundAt(source.getReferenceWorld(), source.getOrigin(), source.getPhysics().getGravitySignum());
if (source.canModifyAt(pos) && StateMaps.FIRE_AFFECTED.convert(source.getWorld(), pos)) {
if (source.canModifyAt(pos) && StateMaps.FIRE_AFFECTED.convert(source.getReferenceWorld(), 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);
});

View file

@ -56,7 +56,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.getWorld().isAir(new BlockPos(pos).down())) {
if (!source.getReferenceWorld().isAir(new BlockPos(pos).down())) {
double dist = pos.distanceTo(source.getOriginVector());
Vec3d velocity = pos.subtract(source.getOriginVector()).normalize().multiply(direction * dist);
@ -65,7 +65,7 @@ public class SiphoningSpell extends AbstractAreaEffectSpell {
}
});
} else {
if (source.getWorld().getTime() % 10 != 0) {
if (source.getReferenceWorld().getTime() % 10 != 0) {
return true;
}
@ -79,7 +79,7 @@ public class SiphoningSpell extends AbstractAreaEffectSpell {
}
private Stream<LivingEntity> getTargets(Caster<?> source) {
return VecHelper.findInRange(null, source.getWorld(), source.getOriginVector(), 4 + source.getLevel().get(), EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR.and(e -> e instanceof LivingEntity))
return VecHelper.findInRange(null, source.getReferenceWorld(), source.getOriginVector(), 4 + source.getLevel().get(), EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR.and(e -> e instanceof LivingEntity))
.stream()
.map(e -> (LivingEntity)e);
}
@ -93,7 +93,7 @@ public class SiphoningSpell extends AbstractAreaEffectSpell {
source.subtractEnergyCost(0.2F);
if (ticksUpset > 0 || maxHealthGain <= 0) {
if (source.getWorld().random.nextInt(3000) == 0) {
if (source.getReferenceWorld().random.nextInt(3000) == 0) {
setDead();
} else {
e.damage(damage, e.getHealth() / 4);

View file

@ -74,7 +74,7 @@ public class TraitDiscovery implements NbtSerialisable {
});
unreadTraits.addAll(newTraits);
pony.setDirty();
if (!newTraits.isEmpty() && !pony.getWorld().isClient) {
if (!newTraits.isEmpty() && !pony.getReferenceWorld().isClient) {
Channel.UNLOCK_TRAITS.send((ServerPlayerEntity)pony.getMaster(), new MsgUnlockTraits(newTraits));
}
}

View file

@ -135,4 +135,9 @@ public class CastSpellEntity extends LightEmittingEntity implements Caster<Livin
public Packet<?> createSpawnPacket() {
return Channel.SERVER_SPAWN_PROJECTILE.toPacket(new MsgSpawnProjectile(this));
}
@Override
public World getReferenceWorld() {
return WeaklyOwned.super.getReferenceWorld();
}
}

View file

@ -84,8 +84,8 @@ public class Creature extends Living<LivingEntity> implements WeaklyOwned<Living
}
@Override
public World getWorld() {
return super.getWorld();
public World getReferenceWorld() {
return super.getReferenceWorld();
}
@Override
@ -93,7 +93,7 @@ public class Creature extends Living<LivingEntity> implements WeaklyOwned<Living
public LivingEntity getMaster() {
NbtCompound data = entity.getDataTracker().get(MASTER);
master.fromNBT(data);
return master.getOrEmpty(getWorld()).orElse(entity);
return master.getOrEmpty(getReferenceWorld()).orElse(entity);
}
@Override
@ -129,7 +129,7 @@ public class Creature extends Living<LivingEntity> implements WeaklyOwned<Living
goals.add(3, eatMuffinGoal);
}
if (master.isPresent(getWorld())) {
if (master.isPresent(getReferenceWorld())) {
initMinionAi();
}
}
@ -242,7 +242,7 @@ public class Creature extends Living<LivingEntity> implements WeaklyOwned<Living
}
if (compound.contains("master", NbtElement.COMPOUND_TYPE)) {
master.fromNBT(compound.getCompound("master"));
if (master.isPresent(getWorld()) && targets != null) {
if (master.isPresent(getReferenceWorld()) && targets != null) {
initMinionAi();
}
}

View file

@ -162,7 +162,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.getWorld())).orElse(null);
entity = EntityType.fromNbt(nbt).map(type -> type.create(source.getReferenceWorld())).orElse(null);
if (entity != null) {
try {
entity.readNbt(nbt);
@ -172,7 +172,7 @@ public class EntityAppearance implements NbtSerialisable, PlayerDimensions.Provi
entity = EntityBehaviour.forEntity(entity).onCreate(entity, this, true);
}
} else {
entity = EntityType.loadEntityWithPassengers(nbt, source.getWorld(), e -> {
entity = EntityType.loadEntityWithPassengers(nbt, source.getReferenceWorld(), e -> {
return EntityBehaviour.forEntity(e).onCreate(e, this, true);
});
}
@ -202,7 +202,7 @@ public class EntityAppearance implements NbtSerialisable, PlayerDimensions.Provi
}
if (source.isClient()) {
source.getWorld().spawnEntity(entity);
source.getReferenceWorld().spawnEntity(entity);
}
}

View file

@ -68,7 +68,7 @@ public class PlayerCamera extends MotionCompositor {
return 0;
}
float energyAddition = (player.getWorld().random.nextInt(maxE) - maxE/2) / 100F;
float energyAddition = (player.getReferenceWorld().random.nextInt(maxE) - maxE/2) / 100F;
if (Math.abs(energyAddition) <= 0.001) {
return 0;

View file

@ -25,7 +25,7 @@ class PlayerLevelStore implements Levelled.LevelStore {
public void add(int levels) {
if (levels > 0) {
pony.getMagicalReserves().getMana().add(pony.getMagicalReserves().getMana().getMax() / 2);
pony.getWorld().playSound(null, pony.getOrigin(), SoundEvents.ENTITY_PLAYER_LEVELUP, SoundCategory.PLAYERS, 1, 2);
pony.getReferenceWorld().playSound(null, pony.getOrigin(), SoundEvents.ENTITY_PLAYER_LEVELUP, SoundCategory.PLAYERS, 1, 2);
}
Levelled.LevelStore.super.add(levels);
}

View file

@ -142,7 +142,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
this.animationMaxDuration = animationDuration;
if (!isClient()) {
Channel.SERVER_PLAYER_ANIMATION_CHANGE.send(getWorld(), new MsgPlayerAnimationChange(this, animation, animationDuration));
Channel.SERVER_PLAYER_ANIMATION_CHANGE.send(getReferenceWorld(), new MsgPlayerAnimationChange(this, animation, animationDuration));
}
animation.getSound().ifPresent(sound -> {
@ -271,8 +271,8 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
@Override
public boolean beforeUpdate() {
if (!speciesSet && getWorld() instanceof ServerWorld) {
setSpecies(WorldTribeManager.forWorld((ServerWorld)getWorld()).getDefaultRace());
if (!speciesSet && getReferenceWorld() instanceof ServerWorld) {
setSpecies(WorldTribeManager.forWorld((ServerWorld)getReferenceWorld()).getDefaultRace());
setDirty();
}
@ -321,9 +321,9 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
}
public boolean canHangAt(BlockPos pos) {
BlockState state = getWorld().getBlockState(pos);
BlockState state = getReferenceWorld().getBlockState(pos);
return state.isSolidSurface(getWorld(), pos, getEntity(), Direction.DOWN);
return state.isSolidSurface(getReferenceWorld(), pos, getEntity(), Direction.DOWN);
}
private BlockPos getHangingPos() {

View file

@ -123,7 +123,7 @@ public class AlicornAmuletItem extends AmuletItem implements PlayerCharmTracker.
public void onRemoved(Pony pony, int timeWorn) {
float attachedTime = timeWorn / 100F;
LocalDifficulty difficulty = pony.getWorld().getLocalDifficulty(pony.getOrigin());
LocalDifficulty difficulty = pony.getReferenceWorld().getLocalDifficulty(pony.getOrigin());
float amount = attachedTime * (1 + difficulty.getClampedLocalDifficulty());
amount = Math.min(amount, pony.getMaster().getMaxHealth());

View file

@ -119,7 +119,7 @@ public class ZapAppleItem extends Item implements ChameleonItem, ToxicHolder {
public void appendStacks(ItemGroup tab, DefaultedList<ItemStack> items) {
super.appendStacks(tab, items);
if (isIn(tab)) {
Unicopia.SIDE.getPony().map(Pony::getWorld)
Unicopia.SIDE.getPony().map(Pony::getReferenceWorld)
.stream()
.flatMap(world -> Registries.valuesForTag(world, UTags.APPLES))
.filter(a -> a != this).forEach(item -> {

View file

@ -23,7 +23,7 @@ public class GemFindingEnchantment extends SimpleEnchantment {
BlockPos origin = user.getOrigin();
double volume = BlockPos.findClosest(origin, radius, radius, pos -> user.getWorld().getBlockState(pos).isIn(UTags.INTERESTING))
double volume = BlockPos.findClosest(origin, radius, radius, pos -> user.getReferenceWorld().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);

View file

@ -36,19 +36,19 @@ public class PoisonedJokeEnchantment extends SimpleEnchantment implements Identi
@Override
public void onUserTick(Living<?> user, int level) {
if (sounds.isEmpty() || user.getWorld().isClient) {
if (sounds.isEmpty() || user.getReferenceWorld().isClient) {
return;
}
int light = user.getWorld().getLightLevel(user.getEntity().getRootVehicle().getBlockPos());
Random rng = user.getWorld().random;
int light = user.getReferenceWorld().getLightLevel(user.getEntity().getRootVehicle().getBlockPos());
Random rng = user.getReferenceWorld().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.getWorld().playSoundFromEntity(
user.getReferenceWorld().playSoundFromEntity(
null,
user.getEntity(),
sounds.get(rng.nextInt(sounds.size())), SoundCategory.HOSTILE,

View file

@ -16,7 +16,7 @@ public class WantItNeedItEnchantment extends SimpleEnchantment {
@Override
public void onUserTick(Living<?> user, int level) {
if (user instanceof Creature && user.getWorld().random.nextInt(10) == 0) {
if (user instanceof Creature && user.getReferenceWorld().random.nextInt(10) == 0) {
ParticleUtils.spawnParticles(new FollowingParticleEffect(UParticles.HEALTH_DRAIN, user.getEntity(), 0.2F), user.getEntity(), 1);
}
}

View file

@ -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.getWorld()).getDefaultRace();
Race worldDefaultRace = WorldTribeManager.forWorld((ServerWorld)player.getReferenceWorld()).getDefaultRace();
if (force || player.getSpecies().isDefault() || (player.getSpecies() == worldDefaultRace && !player.isSpeciesPersisted())) {
player.setSpecies(newRace.isPermitted(sender) ? newRace : worldDefaultRace);

View file

@ -28,7 +28,7 @@ public class ParticleHandle {
public Optional<Attachment> update(UUID id, String partName, ParticleSource source, Consumer<ParticleSpawner> constructor) {
return get(partName).or(() -> {
if (source.getWorld().isClient) {
if (source.getReferenceWorld().isClient) {
new ClientHandle().addParticle(id, partName, source, constructor);
}
return get(partName);

View file

@ -14,7 +14,7 @@ public interface ParticleSource extends ParticleSpawner {
/**
* gets the minecraft world
*/
World getWorld();
World getReferenceWorld();
Entity getEntity();
@ -34,13 +34,13 @@ public interface ParticleSource extends ParticleSpawner {
}
default void spawnParticles(Vec3d pos, Shape area, int count, Consumer<Vec3d> particleSpawner) {
area.randomPoints(count, getWorld().random)
area.randomPoints(count, getReferenceWorld().random)
.map(point -> point.add(pos))
.forEach(particleSpawner);
}
@Override
default void addParticle(ParticleEffect effect, Vec3d position, Vec3d velocity) {
getWorld().addParticle(effect, position.x, position.y, position.z, velocity.x, velocity.y, velocity.z);
getReferenceWorld().addParticle(effect, position.x, position.y, position.z, velocity.x, velocity.y, velocity.z);
}
}