diff --git a/src/main/java/com/minelittlepony/unicopia/WeaklyOwned.java b/src/main/java/com/minelittlepony/unicopia/WeaklyOwned.java index c75cfa55..cc193afc 100644 --- a/src/main/java/com/minelittlepony/unicopia/WeaklyOwned.java +++ b/src/main/java/com/minelittlepony/unicopia/WeaklyOwned.java @@ -34,14 +34,14 @@ public interface WeaklyOwned extends Owned { } } - 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 diff --git a/src/main/java/com/minelittlepony/unicopia/ability/AbilityDispatcher.java b/src/main/java/com/minelittlepony/unicopia/ability/AbilityDispatcher.java index dfdf534e..4d66e3f3 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/AbilityDispatcher.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/AbilityDispatcher.java @@ -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)); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/BatEeeeAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/BatEeeeAbility.java index b1af8057..3f1f2fbe 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/BatEeeeAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/BatEeeeAbility.java @@ -54,18 +54,18 @@ public class BatEeeeAbility implements Ability { @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) ); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/BatPonyHangAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/BatPonyHangAbility.java index fcc70780..1b2e6dce 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/BatPonyHangAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/BatPonyHangAbility.java @@ -46,7 +46,7 @@ public class BatPonyHangAbility implements Ability { 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 { 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); } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/CarryAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/CarryAbility.java index c0b6b1dc..3e043206 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/CarryAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/CarryAbility.java @@ -55,7 +55,7 @@ public class CarryAbility implements Ability { @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(); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/ChangelingDisguiseAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/ChangelingDisguiseAbility.java index 8d13248d..43927e55 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/ChangelingDisguiseAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/ChangelingDisguiseAbility.java @@ -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)); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java index 31ad0cf6..1061f23f 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java @@ -80,7 +80,7 @@ public class ChangelingFeedAbility implements Ability { } protected List getTargets(Pony player) { - List list = VecHelper.findInRange(player.getMaster(), player.getWorld(), player.getOriginVector(), 3, this::canDrain); + List list = VecHelper.findInRange(player.getMaster(), player.getReferenceWorld(), player.getOriginVector(), 3, this::canDrain); RayTraceHelper.findEntity(player.getMaster(), 17, 1, looked -> looked instanceof LivingEntity && !list.contains(looked) && canDrain(looked)) @@ -162,7 +162,7 @@ public class ChangelingFeedAbility implements Ability { @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); } } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyGrowAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyGrowAbility.java index 408edbfd..7d7f797c 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyGrowAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyGrowAbility.java @@ -56,7 +56,7 @@ public class EarthPonyGrowAbility implements Ability { 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 { 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); } } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java index 5f125b9d..f067d254 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java @@ -58,7 +58,7 @@ public class EarthPonyKickAbility implements Ability { 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 { 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 { @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 { @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 { 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(); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java index d22cb49e..86c43419 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java @@ -81,7 +81,7 @@ public class EarthPonyStompAbility implements Ability { 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 { 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) { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/PegasusCaptureStormAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/PegasusCaptureStormAbility.java index ac5e42a7..022e58df 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/PegasusCaptureStormAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/PegasusCaptureStormAbility.java @@ -60,7 +60,7 @@ public class PegasusCaptureStormAbility implements Ability { @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(); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java index e73f354f..5c2a9112 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java @@ -90,7 +90,7 @@ public class UnicornCastingAbility implements Ability { 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 { 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 { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/UnicornDispellAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/UnicornDispellAbility.java index 70d4077e..ac52988d 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/UnicornDispellAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/UnicornDispellAbility.java @@ -76,7 +76,7 @@ public class UnicornDispellAbility implements Ability { @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(); }); } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java index 551533fb..68bef979 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java @@ -69,7 +69,7 @@ public class UnicornTeleportAbility implements Ability { 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 { 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; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/Caster.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/Caster.java index c28e73a1..522943d3 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/Caster.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/Caster.java @@ -42,7 +42,7 @@ public interface Caster extends Owned, Levelled, Affi * Gets the minecraft world */ @Override - default World getWorld() { + default World getReferenceWorld() { return getEntity().getEntityWorld(); } @@ -50,7 +50,7 @@ public interface Caster extends Owned, 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 extends Owned, 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 extends Owned, Levelled, Affi } default Stream findAllEntitiesInRange(double radius, @Nullable Predicate test) { - return VecHelper.findInRange(getEntity(), getWorld(), getOriginVector(), radius, test).stream(); + return VecHelper.findInRange(getEntity(), getReferenceWorld(), getOriginVector(), radius, test).stream(); } default Stream findAllEntitiesInRange(double radius) { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/DispersableDisguiseSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/DispersableDisguiseSpell.java index 727c6257..e94c4195 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/DispersableDisguiseSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/DispersableDisguiseSpell.java @@ -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); } } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/PlaceableSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/PlaceableSpell.java index c44e5f1e..00163209 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/PlaceableSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/PlaceableSpell.java @@ -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 getSpellEntity(Caster source) { return Optional.ofNullable(dimension) - .map(dim -> source.getWorld().getServer().getWorld(dimension)) + .map(dim -> source.getReferenceWorld().getServer().getWorld(dimension)) .map(castEntity::get); } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/RainboomAbilitySpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/RainboomAbilitySpell.java index a0812175..e3934a01 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/RainboomAbilitySpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/RainboomAbilitySpell.java @@ -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); } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ThrowableSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ThrowableSpell.java index 0c567290..66f3e2c4 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ThrowableSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ThrowableSpell.java @@ -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 throwProjectile(Caster caster, float divergance) { - World world = caster.getWorld(); + World world = caster.getReferenceWorld(); LivingEntity entity = caster.getMaster(); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java index 82f16e0e..6983f29e 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java @@ -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); } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AwkwardSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AwkwardSpell.java index d5757e96..8d1c9faa 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AwkwardSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AwkwardSpell.java @@ -29,7 +29,7 @@ public class AwkwardSpell extends AbstractSpell { List 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); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/CatapultSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/CatapultSpell.java index d167b19b..55a6bb97 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/CatapultSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/CatapultSpell.java @@ -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); } } } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DarkVortexSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DarkVortexSpell.java index 9ed429d1..b3892a39 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DarkVortexSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DarkVortexSpell.java @@ -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); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/FireBoltSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/FireBoltSpell.java index e9316bed..e9675cf6 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/FireBoltSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/FireBoltSpell.java @@ -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 diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/FireSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/FireSpell.java index cf0e3e8e..511d2c70 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/FireSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/FireSpell.java @@ -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) { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/IceSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/IceSpell.java index 57238e39..a30b9d4c 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/IceSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/IceSpell.java @@ -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) { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/InfernoSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/InfernoSpell.java index 5f762935..9402dccd 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/InfernoSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/InfernoSpell.java @@ -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); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/LightSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/LightSpell.java index 76cb3166..41d57573 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/LightSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/LightSpell.java @@ -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()); } } 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(); }); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/NecromancySpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/NecromancySpell.java index 854e5308..2f68e3de 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/NecromancySpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/NecromancySpell.java @@ -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 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(); } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/ScorchSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/ScorchSpell.java index cf22bf0f..2844940e 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/ScorchSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/ScorchSpell.java @@ -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); }); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SiphoningSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SiphoningSpell.java index 9f801b89..394bb5f4 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SiphoningSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SiphoningSpell.java @@ -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 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); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/TraitDiscovery.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/TraitDiscovery.java index 7bd33d95..e9452a0a 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/TraitDiscovery.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/TraitDiscovery.java @@ -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)); } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/CastSpellEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/CastSpellEntity.java index f71d9fea..0bae579e 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/CastSpellEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/CastSpellEntity.java @@ -135,4 +135,9 @@ public class CastSpellEntity extends LightEmittingEntity implements Caster createSpawnPacket() { return Channel.SERVER_SPAWN_PROJECTILE.toPacket(new MsgSpawnProjectile(this)); } + + @Override + public World getReferenceWorld() { + return WeaklyOwned.super.getReferenceWorld(); + } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/Creature.java b/src/main/java/com/minelittlepony/unicopia/entity/Creature.java index ad72e539..4cc60789 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/Creature.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/Creature.java @@ -84,8 +84,8 @@ public class Creature extends Living implements WeaklyOwned implements WeaklyOwned implements WeaklyOwned implements WeaklyOwned 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); } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerCamera.java b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerCamera.java index 9825b8ba..750e9b73 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerCamera.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerCamera.java @@ -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; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerLevelStore.java b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerLevelStore.java index 950a40a0..38a22725 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerLevelStore.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerLevelStore.java @@ -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); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java b/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java index b3dad401..452bbe17 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java @@ -142,7 +142,7 @@ public class Pony extends Living 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 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 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() { diff --git a/src/main/java/com/minelittlepony/unicopia/item/AlicornAmuletItem.java b/src/main/java/com/minelittlepony/unicopia/item/AlicornAmuletItem.java index f98f4fc3..21b90d2d 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/AlicornAmuletItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/AlicornAmuletItem.java @@ -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()); diff --git a/src/main/java/com/minelittlepony/unicopia/item/ZapAppleItem.java b/src/main/java/com/minelittlepony/unicopia/item/ZapAppleItem.java index 18e71194..f73c0f60 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/ZapAppleItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/ZapAppleItem.java @@ -119,7 +119,7 @@ public class ZapAppleItem extends Item implements ChameleonItem, ToxicHolder { public void appendStacks(ItemGroup tab, DefaultedList 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 -> { diff --git a/src/main/java/com/minelittlepony/unicopia/item/enchantment/GemFindingEnchantment.java b/src/main/java/com/minelittlepony/unicopia/item/enchantment/GemFindingEnchantment.java index bbfef41a..5b1ec818 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/enchantment/GemFindingEnchantment.java +++ b/src/main/java/com/minelittlepony/unicopia/item/enchantment/GemFindingEnchantment.java @@ -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); diff --git a/src/main/java/com/minelittlepony/unicopia/item/enchantment/PoisonedJokeEnchantment.java b/src/main/java/com/minelittlepony/unicopia/item/enchantment/PoisonedJokeEnchantment.java index 781c7215..408dd750 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/enchantment/PoisonedJokeEnchantment.java +++ b/src/main/java/com/minelittlepony/unicopia/item/enchantment/PoisonedJokeEnchantment.java @@ -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, diff --git a/src/main/java/com/minelittlepony/unicopia/item/enchantment/WantItNeedItEnchantment.java b/src/main/java/com/minelittlepony/unicopia/item/enchantment/WantItNeedItEnchantment.java index d25e46c4..9d0dbc0a 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/enchantment/WantItNeedItEnchantment.java +++ b/src/main/java/com/minelittlepony/unicopia/item/enchantment/WantItNeedItEnchantment.java @@ -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); } } diff --git a/src/main/java/com/minelittlepony/unicopia/network/MsgRequestSpeciesChange.java b/src/main/java/com/minelittlepony/unicopia/network/MsgRequestSpeciesChange.java index c3fbcb14..d165ee31 100644 --- a/src/main/java/com/minelittlepony/unicopia/network/MsgRequestSpeciesChange.java +++ b/src/main/java/com/minelittlepony/unicopia/network/MsgRequestSpeciesChange.java @@ -43,7 +43,7 @@ public class MsgRequestSpeciesChange implements Packet { 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); diff --git a/src/main/java/com/minelittlepony/unicopia/particle/ParticleHandle.java b/src/main/java/com/minelittlepony/unicopia/particle/ParticleHandle.java index 6fa7ccb3..0db8661e 100644 --- a/src/main/java/com/minelittlepony/unicopia/particle/ParticleHandle.java +++ b/src/main/java/com/minelittlepony/unicopia/particle/ParticleHandle.java @@ -28,7 +28,7 @@ public class ParticleHandle { public Optional update(UUID id, String partName, ParticleSource source, Consumer constructor) { return get(partName).or(() -> { - if (source.getWorld().isClient) { + if (source.getReferenceWorld().isClient) { new ClientHandle().addParticle(id, partName, source, constructor); } return get(partName); diff --git a/src/main/java/com/minelittlepony/unicopia/particle/ParticleSource.java b/src/main/java/com/minelittlepony/unicopia/particle/ParticleSource.java index 768f18fe..6997f440 100644 --- a/src/main/java/com/minelittlepony/unicopia/particle/ParticleSource.java +++ b/src/main/java/com/minelittlepony/unicopia/particle/ParticleSource.java @@ -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 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); } }