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() { default World getReferenceWorld() {
return ((Entity)this).world; return ((Entity)this).getEntityWorld();
} }
@Nullable @Nullable
@Override @Override
default E getMaster() { default E getMaster() {
return getMasterReference().get(getWorld()); return getMasterReference().get(getReferenceWorld());
} }
@Override @Override

View file

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

View file

@ -54,18 +54,18 @@ public class BatEeeeAbility implements Ability<Hit> {
@Override @Override
public void apply(Pony player, Hit data) { public void apply(Pony player, Hit data) {
Random rng = player.getWorld().random; Random rng = player.getReferenceWorld().random;
int count = 1 + rng.nextInt(10); int count = 1 + rng.nextInt(10);
for (int i = 0; i < count; i++) { 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, 0.9F + (rng.nextFloat() - 0.5F) / 2F,
1.6F + (rng.nextFloat() - 0.5F) 1.6F + (rng.nextFloat() - 0.5F)
); );
} }
AwaitTickQueue.scheduleTask(player.getWorld(), w -> { AwaitTickQueue.scheduleTask(player.getReferenceWorld(), w -> {
for (int i = 0; i < count; i++) { 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, 0.9F + (rng.nextFloat() - 0.5F) / 2F,
1.6F + (rng.nextFloat() - 0.5F) 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); BlockPos poss = RayTraceHelper.doTrace(player.getMaster(), 3, 1, EntityPredicates.CAN_COLLIDE).getBlockPos().orElse(null);
if (poss != 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)) { if (air && player.canHangAt(poss)) {
return new Multi(poss, 1); 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() return RayTraceHelper.doTrace(player.getMaster(), 5, 1, EntityPredicates.EXCEPT_SPECTATOR).getBlockPos()
.map(BlockPos::down) .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)) .map(pos -> new Multi(pos, 1))
.orElse(null); .orElse(null);
} }

View file

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

View file

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

View file

@ -80,7 +80,7 @@ public class ChangelingFeedAbility implements Ability<Hit> {
} }
protected List<LivingEntity> getTargets(Pony player) { 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, RayTraceHelper.<LivingEntity>findEntity(player.getMaster(), 17, 1,
looked -> looked instanceof LivingEntity && !list.contains(looked) && canDrain(looked)) looked -> looked instanceof LivingEntity && !list.contains(looked) && canDrain(looked))
@ -162,7 +162,7 @@ public class ChangelingFeedAbility implements Ability<Hit> {
@Override @Override
public void postApply(Pony player, AbilitySlot slot) { 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); player.spawnParticles(ParticleTypes.HEART, 1);
} }
} }

View file

@ -56,7 +56,7 @@ public class EarthPonyGrowAbility implements Ability<Pos> {
for (BlockPos pos : BlockPos.iterate( for (BlockPos pos : BlockPos.iterate(
data.pos().add(-2, -2, -2), data.pos().add(-2, -2, -2),
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) { if (count > 0) {
@ -80,7 +80,7 @@ public class EarthPonyGrowAbility implements Ability<Pos> {
public void preApply(Pony player, AbilitySlot slot) { public void preApply(Pony player, AbilitySlot slot) {
player.getMagicalReserves().getExertion().add(30); player.getMagicalReserves().getExertion().add(30);
if (player.getWorld().isClient()) { if (player.getReferenceWorld().isClient()) {
player.spawnParticles(MagicParticleEffect.UNICORN, 1); player.spawnParticles(MagicParticleEffect.UNICORN, 1);
} }
} }

View file

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

View file

@ -81,7 +81,7 @@ public class EarthPonyStompAbility implements Ability<Hit> {
private void thrustDownwards(Pony player) { private void thrustDownwards(Pony player) {
BlockPos ppos = player.getOrigin(); 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(); double downV = Math.sqrt(ppos.getSquaredDistance(pos)) * player.getPhysics().getGravitySignum();
player.getMaster().addVelocity(0, -downV, 0); player.getMaster().addVelocity(0, -downV, 0);
@ -100,7 +100,7 @@ public class EarthPonyStompAbility implements Ability<Hit> {
float heavyness = 1 + EnchantmentHelper.getEquipmentLevel(UEnchantments.HEAVY, player); 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())); double dist = Math.sqrt(center.getSquaredDistance(i.getBlockPos()));
if (dist <= rad + 3) { if (dist <= rad + 3) {

View file

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

View file

@ -90,7 +90,7 @@ public class UnicornCastingAbility implements Ability<Hit> {
if (amount < 0) { if (amount < 0) {
AmuletItem.consumeEnergy(stack, amount); AmuletItem.consumeEnergy(stack, amount);
player.getMagicalReserves().getMana().add(amount * player.getMagicalReserves().getMana().getMax()); 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 { } else {
@ -144,7 +144,7 @@ public class UnicornCastingAbility implements Ability<Hit> {
float i = player.getAbilities().getStat(slot).getFillProgress(); 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.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); player.playSound(USounds.ITEM_AMULET_CHARGING, 1, i / 20);
} else { } else {

View file

@ -76,7 +76,7 @@ public class UnicornDispellAbility implements Ability<Pos> {
@Override @Override
public void apply(Pony player, Pos data) { public void apply(Pony player, Pos data) {
player.setAnimation(Animation.WOLOLO); 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(); target.getSpellSlot().clear();
}); });
} }

View file

@ -69,7 +69,7 @@ public class UnicornTeleportAbility implements Ability<Pos> {
int maxDistance = player.getMaster().isCreative() ? 1000 : 100; int maxDistance = player.getMaster().isCreative() ? 1000 : 100;
HitResult ray = RayTraceHelper.doTrace(player.getMaster(), maxDistance, 1, EntityPredicates.CAN_COLLIDE).getResult(); 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) { if (ray.getType() == HitResult.Type.MISS) {
return null; return null;
@ -136,7 +136,7 @@ public class UnicornTeleportAbility implements Ability<Pos> {
return; 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; 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 * Gets the minecraft world
*/ */
@Override @Override
default World getWorld() { default World getReferenceWorld() {
return getEntity().getEntityWorld(); 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. * Returns true if we're executing on the client.
*/ */
default boolean isClient() { 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) { default boolean canModifyAt(BlockPos pos) {
if (getMaster() instanceof PlayerEntity) { 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) { 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) { 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) { default Stream<Entity> findAllEntitiesInRange(double radius) {

View file

@ -51,7 +51,7 @@ public class DispersableDisguiseSpell extends AbstractDisguiseSpell implements I
if (isSuppressed()) { if (isSuppressed()) {
source.spawnParticles(MagicParticleEffect.UNICORN, 5); source.spawnParticles(MagicParticleEffect.UNICORN, 5);
source.spawnParticles(UParticles.CHANGELING_MAGIC, 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); source.spawnParticles(UParticles.CHANGELING_MAGIC, 2);
} }
} }

View file

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

View file

@ -70,7 +70,7 @@ public class RainboomAbilitySpell extends AbstractSpell {
e.damage(MagicalDamageSource.create("rainboom", source), 6); e.damage(MagicalDamageSource.create("rainboom", source), 6);
}); });
PosHelper.getAllInRegionMutable(source.getOrigin(), effect_range).forEach(pos -> { 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)) { if (state.isIn(UTags.FRAGILE) && canBreak(pos, owner)) {
owner.world.breakBlock(pos, true); 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). * Returns the resulting projectile entity for customization (or null if on the client).
*/ */
public Optional<MagicProjectileEntity> throwProjectile(Caster<?> caster, float divergance) { public Optional<MagicProjectileEntity> throwProjectile(Caster<?> caster, float divergance) {
World world = caster.getWorld(); World world = caster.getReferenceWorld();
LivingEntity entity = caster.getMaster(); LivingEntity entity = caster.getMaster();

View file

@ -55,7 +55,7 @@ public class AttractiveSpell extends ShieldSpell implements ProjectileSpell {
force *= AttractionUtils.getForceAdjustment(target); 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); 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()); 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); Identifier id = names.get(index);
ParticleType<?> type = Registry.PARTICLE_TYPE.get(id); 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()); e.setVelocity(caster.getEntity().getVelocity());
} else { } else {
e.addVelocity( 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, 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); Optional.ofNullable(result.getEntity()).ifPresent(apply);
} else if (ray.getType() == HitResult.Type.BLOCK) { } else if (ray.getType() == HitResult.Type.BLOCK) {
if (caster.canModifyAt(((BlockHitResult)ray).getBlockPos())) { 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(); setDirty();
if (age % 20 == 0) { 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); source.subtractEnergyCost(-accumulatedMass);
if (!source.isClient() && source.getWorld().random.nextInt(300) == 0) { if (!source.isClient() && source.getReferenceWorld().random.nextInt(300) == 0) {
ParticleUtils.spawnParticle(source.getWorld(), UParticles.LIGHTNING_BOLT, getOrigin(source), Vec3d.ZERO); ParticleUtils.spawnParticle(source.getReferenceWorld(), UParticles.LIGHTNING_BOLT, getOrigin(source), Vec3d.ZERO);
} }
return super.tick(source, situation); return super.tick(source, situation);
@ -161,9 +161,9 @@ public class DarkVortexSpell extends AttractiveSpell implements ProjectileSpell
return; return;
} }
if (source.getOrigin().isWithinDistance(i, getEventHorizonRadius() / 2)) { if (source.getOrigin().isWithinDistance(i, getEventHorizonRadius() / 2)) {
source.getWorld().breakBlock(i, false); source.getReferenceWorld().breakBlock(i, false);
} else { } else {
CatapultSpell.createBlockEntity(source.getWorld(), i, e -> { CatapultSpell.createBlockEntity(source.getReferenceWorld(), i, e -> {
applyRadialEffect(source, e, e.getPos().distanceTo(origin), radius); 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) { protected boolean canAffect(Caster<?> source, BlockPos pos) {
return source.canModifyAt(pos) return source.canModifyAt(pos)
&& source.getWorld().getFluidState(pos).isEmpty() && source.getReferenceWorld().getFluidState(pos).isEmpty()
&& source.getWorld().getBlockState(pos).getHardness(source.getWorld(), pos) >= 0; && source.getReferenceWorld().getBlockState(pos).getHardness(source.getReferenceWorld(), pos) >= 0;
} }
// 1. force decreases with distance: distance scale 1 -> 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.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 { } else {
double force = getAttractiveForce(source, target); double force = getAttractiveForce(source, target);

View file

@ -67,7 +67,7 @@ public class FireBoltSpell extends AbstractSpell implements ProjectileSpell, Hom
c.setHomingTarget(target); 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; return false;
} }
@ -81,7 +81,7 @@ public class FireBoltSpell extends AbstractSpell implements ProjectileSpell, Hom
} }
protected int getNumberOfBalls(Caster<?> caster) { 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 @Override

View file

@ -50,7 +50,7 @@ public class FireSpell extends AbstractAreaEffectSpell implements ProjectileSpel
@Override @Override
public void onImpact(MagicProjectileEntity projectile, BlockPos pos, BlockState state) { public void onImpact(MagicProjectileEntity projectile, BlockPos pos, BlockState state) {
if (!projectile.isClient()) { 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, 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) (a, b) -> a || b)
|| applyEntities(null, source.getWorld(), source.getOriginVector()); || applyEntities(null, source.getReferenceWorld(), source.getOriginVector());
} }
protected void generateParticles(Caster<?> source) { 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); boolean submerged = source.getEntity().isSubmergedInWater() || source.getEntity().isSubmergedIn(FluidTags.LAVA);
long blocksAffected = PosHelper.getAllInRegionMutable(source.getOrigin(), outerRange).filter(i -> { 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)) { 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)) { 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()) { } 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( ParticleUtils.spawnParticle(source.getReferenceWorld(), ParticleTypes.SPLASH, new Vec3d(
i.getX() + source.getWorld().random.nextFloat(), i.getX() + source.getReferenceWorld().random.nextFloat(),
i.getY() + 1, i.getY() + 1,
i.getZ() + source.getWorld().random.nextFloat()), Vec3d.ZERO); i.getZ() + source.getReferenceWorld().random.nextFloat()), Vec3d.ZERO);
return true; return true;
} }
@ -70,7 +70,7 @@ public class IceSpell extends AbstractSpell {
source.subtractEnergyCost(Math.min(10, blocksAffected)); 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) { protected boolean applyEntities(LivingEntity owner, World world, Vec3d pos) {

View file

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

View file

@ -53,17 +53,17 @@ public class LightSpell extends AbstractSpell {
if (!caster.isClient()) { if (!caster.isClient()) {
if (lights.isEmpty()) { 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) { while (lights.size() < size) {
lights.add(new EntityReference<FairyEntity>()); lights.add(new EntityReference<FairyEntity>());
} }
} }
lights.forEach(ref -> { lights.forEach(ref -> {
if (!ref.isPresent(caster.getWorld())) { if (!ref.isPresent(caster.getReferenceWorld())) {
FairyEntity entity = UEntities.TWITTERMITE.create(caster.getWorld()); FairyEntity entity = UEntities.TWITTERMITE.create(caster.getReferenceWorld());
entity.setPosition(ref.getPosition().orElseGet(() -> { 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.setMaster(caster);
entity.world.spawnEntity(entity); entity.world.spawnEntity(entity);
@ -83,7 +83,7 @@ public class LightSpell extends AbstractSpell {
return; return;
} }
lights.forEach(ref -> { lights.forEach(ref -> {
ref.ifPresent(caster.getWorld(), e -> { ref.ifPresent(caster.getReferenceWorld(), e -> {
e.world.sendEntityStatus(e, (byte)60); e.world.sendEntityStatus(e, (byte)60);
e.discard(); e.discard();
}); });

View file

@ -56,24 +56,24 @@ public class NecromancySpell extends AbstractAreaEffectSpell {
return false; return false;
} }
boolean rainy = source.getWorld().hasRain(source.getOrigin()); boolean rainy = source.getReferenceWorld().hasRain(source.getOrigin());
if (source.isClient()) { if (source.isClient()) {
source.spawnParticles(new Sphere(true, radius * 2), rainy ? 98 : 125, pos -> { source.spawnParticles(new Sphere(true, radius * 2), rainy ? 98 : 125, pos -> {
BlockPos bpos = new BlockPos(pos); BlockPos bpos = new BlockPos(pos);
if (!source.getWorld().isAir(bpos.down())) { if (!source.getReferenceWorld().isAir(bpos.down())) {
source.addParticle(source.getWorld().hasRain(bpos) ? ParticleTypes.SMOKE : ParticleTypes.FLAME, pos, Vec3d.ZERO); source.addParticle(source.getReferenceWorld().hasRain(bpos) ? ParticleTypes.SMOKE : ParticleTypes.FLAME, pos, Vec3d.ZERO);
} }
}); });
return true; return true;
} }
if (source.getWorld().getDifficulty() == Difficulty.PEACEFUL) { if (source.getReferenceWorld().getDifficulty() == Difficulty.PEACEFUL) {
return true; 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) { if (e.getPos().distanceTo(source.getOriginVector()) > radius * 2) {
e.world.sendEntityStatus(e, (byte)60); e.world.sendEntityStatus(e, (byte)60);
e.discard(); e.discard();
@ -82,13 +82,13 @@ public class NecromancySpell extends AbstractAreaEffectSpell {
return true; return true;
}).isEmpty()); }).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(); setDirty();
if (--spawnCountdown > 0 && !summonedEntities.isEmpty()) { if (--spawnCountdown > 0 && !summonedEntities.isEmpty()) {
return true; 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) { if (summonedEntities.size() > 10 + additional) {
return true; return true;
@ -97,11 +97,11 @@ public class NecromancySpell extends AbstractAreaEffectSpell {
Shape affectRegion = new Sphere(false, radius); Shape affectRegion = new Sphere(false, radius);
for (int i = 0; i < 10; i++) { 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); 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 -> { spawnPool.get().ifPresent(type -> {
spawnMonster(source, pos, type); spawnMonster(source, pos, type);
}); });
@ -118,7 +118,7 @@ public class NecromancySpell extends AbstractAreaEffectSpell {
} }
LivingEntity master = caster.getMaster(); LivingEntity master = caster.getMaster();
summonedEntities.forEach(ref -> { summonedEntities.forEach(ref -> {
ref.ifPresent(caster.getWorld(), e -> { ref.ifPresent(caster.getReferenceWorld(), e -> {
if (master != null) { if (master != null) {
master.applyDamageEffects(master, e); master.applyDamageEffects(master, e);
} }
@ -129,14 +129,14 @@ public class NecromancySpell extends AbstractAreaEffectSpell {
} }
protected void spawnMonster(Caster<?> source, Vec3d pos, EntityType<? extends LivingEntity> type) { 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); source.subtractEnergyCost(3);
minion.updatePositionAndAngles(pos.x, pos.y, pos.z, 0, 0); minion.updatePositionAndAngles(pos.x, pos.y, pos.z, 0, 0);
minion.setVelocity(0, 0.3, 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.playSound(SoundEvents.BLOCK_BELL_USE, 1, 0.3F);
source.spawnParticles(ParticleTypes.LARGE_SMOKE, 10); source.spawnParticles(ParticleTypes.LARGE_SMOKE, 10);
minion.equipStack(EquipmentSlot.HEAD, Items.IRON_HELMET.getDefaultStack()); minion.equipStack(EquipmentSlot.HEAD, Items.IRON_HELMET.getDefaultStack());
@ -145,7 +145,7 @@ public class NecromancySpell extends AbstractAreaEffectSpell {
((Creature)eq).setMaster(source); ((Creature)eq).setMaster(source);
}); });
source.getWorld().spawnEntity(minion); source.getReferenceWorld().spawnEntity(minion);
summonedEntities.add(new EntityReference<>(minion)); summonedEntities.add(new EntityReference<>(minion));
setDirty(); setDirty();
} }

View file

@ -27,9 +27,9 @@ public class ScorchSpell extends FireSpell {
@Override @Override
public boolean tick(Caster<?> source, Situation situation) { 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.spawnParticles(new Sphere(false, Math.max(1, getTraits().get(Trait.POWER))), 5, p -> {
source.addParticle(ParticleTypes.SMOKE, PosHelper.offset(p, pos), Vec3d.ZERO); 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; int direction = isFriendlyTogether(source) ? 1 : -1;
source.spawnParticles(new Sphere(true, radius, 1, 0, 1), 1, pos -> { 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()); double dist = pos.distanceTo(source.getOriginVector());
Vec3d velocity = pos.subtract(source.getOriginVector()).normalize().multiply(direction * dist); Vec3d velocity = pos.subtract(source.getOriginVector()).normalize().multiply(direction * dist);
@ -65,7 +65,7 @@ public class SiphoningSpell extends AbstractAreaEffectSpell {
} }
}); });
} else { } else {
if (source.getWorld().getTime() % 10 != 0) { if (source.getReferenceWorld().getTime() % 10 != 0) {
return true; return true;
} }
@ -79,7 +79,7 @@ public class SiphoningSpell extends AbstractAreaEffectSpell {
} }
private Stream<LivingEntity> getTargets(Caster<?> source) { 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() .stream()
.map(e -> (LivingEntity)e); .map(e -> (LivingEntity)e);
} }
@ -93,7 +93,7 @@ public class SiphoningSpell extends AbstractAreaEffectSpell {
source.subtractEnergyCost(0.2F); source.subtractEnergyCost(0.2F);
if (ticksUpset > 0 || maxHealthGain <= 0) { if (ticksUpset > 0 || maxHealthGain <= 0) {
if (source.getWorld().random.nextInt(3000) == 0) { if (source.getReferenceWorld().random.nextInt(3000) == 0) {
setDead(); setDead();
} else { } else {
e.damage(damage, e.getHealth() / 4); e.damage(damage, e.getHealth() / 4);

View file

@ -74,7 +74,7 @@ public class TraitDiscovery implements NbtSerialisable {
}); });
unreadTraits.addAll(newTraits); unreadTraits.addAll(newTraits);
pony.setDirty(); pony.setDirty();
if (!newTraits.isEmpty() && !pony.getWorld().isClient) { if (!newTraits.isEmpty() && !pony.getReferenceWorld().isClient) {
Channel.UNLOCK_TRAITS.send((ServerPlayerEntity)pony.getMaster(), new MsgUnlockTraits(newTraits)); 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() { public Packet<?> createSpawnPacket() {
return Channel.SERVER_SPAWN_PROJECTILE.toPacket(new MsgSpawnProjectile(this)); 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 @Override
public World getWorld() { public World getReferenceWorld() {
return super.getWorld(); return super.getReferenceWorld();
} }
@Override @Override
@ -93,7 +93,7 @@ public class Creature extends Living<LivingEntity> implements WeaklyOwned<Living
public LivingEntity getMaster() { public LivingEntity getMaster() {
NbtCompound data = entity.getDataTracker().get(MASTER); NbtCompound data = entity.getDataTracker().get(MASTER);
master.fromNBT(data); master.fromNBT(data);
return master.getOrEmpty(getWorld()).orElse(entity); return master.getOrEmpty(getReferenceWorld()).orElse(entity);
} }
@Override @Override
@ -129,7 +129,7 @@ public class Creature extends Living<LivingEntity> implements WeaklyOwned<Living
goals.add(3, eatMuffinGoal); goals.add(3, eatMuffinGoal);
} }
if (master.isPresent(getWorld())) { if (master.isPresent(getReferenceWorld())) {
initMinionAi(); initMinionAi();
} }
} }
@ -242,7 +242,7 @@ public class Creature extends Living<LivingEntity> implements WeaklyOwned<Living
} }
if (compound.contains("master", NbtElement.COMPOUND_TYPE)) { if (compound.contains("master", NbtElement.COMPOUND_TYPE)) {
master.fromNBT(compound.getCompound("master")); master.fromNBT(compound.getCompound("master"));
if (master.isPresent(getWorld()) && targets != null) { if (master.isPresent(getReferenceWorld()) && targets != null) {
initMinionAi(); initMinionAi();
} }
} }

View file

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

View file

@ -68,7 +68,7 @@ public class PlayerCamera extends MotionCompositor {
return 0; 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) { if (Math.abs(energyAddition) <= 0.001) {
return 0; return 0;

View file

@ -25,7 +25,7 @@ class PlayerLevelStore implements Levelled.LevelStore {
public void add(int levels) { public void add(int levels) {
if (levels > 0) { if (levels > 0) {
pony.getMagicalReserves().getMana().add(pony.getMagicalReserves().getMana().getMax() / 2); 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); Levelled.LevelStore.super.add(levels);
} }

View file

@ -142,7 +142,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
this.animationMaxDuration = animationDuration; this.animationMaxDuration = animationDuration;
if (!isClient()) { 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 -> { animation.getSound().ifPresent(sound -> {
@ -271,8 +271,8 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
@Override @Override
public boolean beforeUpdate() { public boolean beforeUpdate() {
if (!speciesSet && getWorld() instanceof ServerWorld) { if (!speciesSet && getReferenceWorld() instanceof ServerWorld) {
setSpecies(WorldTribeManager.forWorld((ServerWorld)getWorld()).getDefaultRace()); setSpecies(WorldTribeManager.forWorld((ServerWorld)getReferenceWorld()).getDefaultRace());
setDirty(); setDirty();
} }
@ -321,9 +321,9 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
} }
public boolean canHangAt(BlockPos pos) { 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() { private BlockPos getHangingPos() {

View file

@ -123,7 +123,7 @@ public class AlicornAmuletItem extends AmuletItem implements PlayerCharmTracker.
public void onRemoved(Pony pony, int timeWorn) { public void onRemoved(Pony pony, int timeWorn) {
float attachedTime = timeWorn / 100F; float attachedTime = timeWorn / 100F;
LocalDifficulty difficulty = pony.getWorld().getLocalDifficulty(pony.getOrigin()); LocalDifficulty difficulty = pony.getReferenceWorld().getLocalDifficulty(pony.getOrigin());
float amount = attachedTime * (1 + difficulty.getClampedLocalDifficulty()); float amount = attachedTime * (1 + difficulty.getClampedLocalDifficulty());
amount = Math.min(amount, pony.getMaster().getMaxHealth()); 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) { public void appendStacks(ItemGroup tab, DefaultedList<ItemStack> items) {
super.appendStacks(tab, items); super.appendStacks(tab, items);
if (isIn(tab)) { if (isIn(tab)) {
Unicopia.SIDE.getPony().map(Pony::getWorld) Unicopia.SIDE.getPony().map(Pony::getReferenceWorld)
.stream() .stream()
.flatMap(world -> Registries.valuesForTag(world, UTags.APPLES)) .flatMap(world -> Registries.valuesForTag(world, UTags.APPLES))
.filter(a -> a != this).forEach(item -> { .filter(a -> a != this).forEach(item -> {

View file

@ -23,7 +23,7 @@ public class GemFindingEnchantment extends SimpleEnchantment {
BlockPos origin = user.getOrigin(); 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(p -> user.getOriginVector().squaredDistanceTo(p.getX(), p.getY(), p.getZ()))
.map(find -> (1 - (Math.sqrt(find) / radius))) .map(find -> (1 - (Math.sqrt(find) / radius)))
.orElse(-1D); .orElse(-1D);

View file

@ -36,19 +36,19 @@ public class PoisonedJokeEnchantment extends SimpleEnchantment implements Identi
@Override @Override
public void onUserTick(Living<?> user, int level) { public void onUserTick(Living<?> user, int level) {
if (sounds.isEmpty() || user.getWorld().isClient) { if (sounds.isEmpty() || user.getReferenceWorld().isClient) {
return; return;
} }
int light = user.getWorld().getLightLevel(user.getEntity().getRootVehicle().getBlockPos()); int light = user.getReferenceWorld().getLightLevel(user.getEntity().getRootVehicle().getBlockPos());
Random rng = user.getWorld().random; Random rng = user.getReferenceWorld().random;
Data data = user.getEnchants().computeIfAbsent(this, Data::new); Data data = user.getEnchants().computeIfAbsent(this, Data::new);
data.level -= rng.nextFloat() * 0.8F; data.level -= rng.nextFloat() * 0.8F;
if (rng.nextInt(Math.max(1, (light * 9) + (int)data.level)) == 0) { if (rng.nextInt(Math.max(1, (light * 9) + (int)data.level)) == 0) {
data.level = rng.nextInt(5000); data.level = rng.nextInt(5000);
user.getWorld().playSoundFromEntity( user.getReferenceWorld().playSoundFromEntity(
null, null,
user.getEntity(), user.getEntity(),
sounds.get(rng.nextInt(sounds.size())), SoundCategory.HOSTILE, sounds.get(rng.nextInt(sounds.size())), SoundCategory.HOSTILE,

View file

@ -16,7 +16,7 @@ public class WantItNeedItEnchantment extends SimpleEnchantment {
@Override @Override
public void onUserTick(Living<?> user, int level) { 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); 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) { public void handle(ServerPlayerEntity sender) {
Pony player = Pony.of(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())) { if (force || player.getSpecies().isDefault() || (player.getSpecies() == worldDefaultRace && !player.isSpeciesPersisted())) {
player.setSpecies(newRace.isPermitted(sender) ? newRace : worldDefaultRace); 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) { public Optional<Attachment> update(UUID id, String partName, ParticleSource source, Consumer<ParticleSpawner> constructor) {
return get(partName).or(() -> { return get(partName).or(() -> {
if (source.getWorld().isClient) { if (source.getReferenceWorld().isClient) {
new ClientHandle().addParticle(id, partName, source, constructor); new ClientHandle().addParticle(id, partName, source, constructor);
} }
return get(partName); return get(partName);

View file

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