Clean up warnings

This commit is contained in:
Sollace 2024-04-12 01:23:43 +01:00
parent 3489c47d63
commit 86faeeaa43
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
34 changed files with 75 additions and 61 deletions

View file

@ -10,6 +10,7 @@ public enum Affinity implements StringIdentifiable {
NEUTRAL(Formatting.LIGHT_PURPLE, 0, 0.5F), NEUTRAL(Formatting.LIGHT_PURPLE, 0, 0.5F),
BAD(Formatting.RED, 1, 1); BAD(Formatting.RED, 1, 1);
@SuppressWarnings("deprecation")
public static final Codec<Affinity> CODEC = StringIdentifiable.createCodec(Affinity::values); public static final Codec<Affinity> CODEC = StringIdentifiable.createCodec(Affinity::values);
private final Formatting color; private final Formatting color;

View file

@ -9,6 +9,7 @@ public enum Availability implements StringIdentifiable {
COMMANDS, COMMANDS,
NONE; NONE;
@SuppressWarnings("deprecation")
public static final Codec<Availability> CODEC = StringIdentifiable.createCodec(Availability::values); public static final Codec<Availability> CODEC = StringIdentifiable.createCodec(Availability::values);
private final String name = name().toLowerCase(Locale.ROOT); private final String name = name().toLowerCase(Locale.ROOT);

View file

@ -31,7 +31,7 @@ public interface EquineContext {
static EquineContext of(ShapeContext context) { static EquineContext of(ShapeContext context) {
if (context == ShapeContext.absent()) { if (context == ShapeContext.absent()) {
return Unicopia.SIDE.getPony().map(EquineContext.class::cast).orElse(ABSENT); return InteractionManager.getInstance().getClientPony().map(EquineContext.class::cast).orElse(ABSENT);
} }
EquineContext result = context instanceof Container c ? c.get() : ABSENT; EquineContext result = context instanceof Container c ? c.get() : ABSENT;
return result == null ? ABSENT : result; return result == null ? ABSENT : result;

View file

@ -13,6 +13,7 @@ public enum FlightType implements StringIdentifiable {
INSECTOID, INSECTOID,
ARTIFICIAL; ARTIFICIAL;
@SuppressWarnings("deprecation")
public static final Codec<FlightType> CODEC = StringIdentifiable.createCodec(FlightType::values); public static final Codec<FlightType> CODEC = StringIdentifiable.createCodec(FlightType::values);
private final String name = name().toLowerCase(Locale.ROOT); private final String name = name().toLowerCase(Locale.ROOT);

View file

@ -1,11 +1,13 @@
package com.minelittlepony.unicopia; package com.minelittlepony.unicopia;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.entity.player.dummy.DummyPlayerEntity; import com.minelittlepony.unicopia.entity.player.dummy.DummyPlayerEntity;
import com.minelittlepony.unicopia.particle.ParticleSpawner; import com.minelittlepony.unicopia.particle.ParticleSpawner;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
@ -30,12 +32,16 @@ public class InteractionManager {
public static final int SCREEN_DISPELL_ABILITY = 0; public static final int SCREEN_DISPELL_ABILITY = 0;
public static InteractionManager INSTANCE = new InteractionManager(); private static InteractionManager INSTANCE = new InteractionManager();
public static InteractionManager instance() { public static InteractionManager getInstance() {
return INSTANCE; return INSTANCE;
} }
public InteractionManager() {
INSTANCE = this;
}
public ParticleSpawner createBoundParticle(UUID id) { public ParticleSpawner createBoundParticle(UUID id) {
return ParticleSpawner.EMPTY; return ParticleSpawner.EMPTY;
} }
@ -96,4 +102,12 @@ public class InteractionManager {
public void addBlockBreakingParticles(BlockPos pos, Direction direction) { public void addBlockBreakingParticles(BlockPos pos, Direction direction) {
} }
public Optional<Pony> getClientPony() {
return Optional.empty();
}
public final Race getClientSpecies() {
return getClientPony().map(Pony::getSpecies).orElse(Race.HUMAN);
}
} }

View file

@ -6,8 +6,6 @@ import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.minecraft.resource.ResourceType; import net.minecraft.resource.ResourceType;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import java.util.Optional;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -27,7 +25,6 @@ import com.minelittlepony.unicopia.diet.affliction.AfflictionType;
import com.minelittlepony.unicopia.entity.damage.UDamageTypes; import com.minelittlepony.unicopia.entity.damage.UDamageTypes;
import com.minelittlepony.unicopia.entity.effect.UPotions; import com.minelittlepony.unicopia.entity.effect.UPotions;
import com.minelittlepony.unicopia.entity.mob.UEntities; import com.minelittlepony.unicopia.entity.mob.UEntities;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.item.UItems; import com.minelittlepony.unicopia.item.UItems;
import com.minelittlepony.unicopia.item.enchantment.UEnchantments; import com.minelittlepony.unicopia.item.enchantment.UEnchantments;
import com.minelittlepony.unicopia.network.Channel; import com.minelittlepony.unicopia.network.Channel;
@ -43,8 +40,6 @@ public class Unicopia implements ModInitializer {
public static final String DEFAULT_NAMESPACE = "unicopia"; public static final String DEFAULT_NAMESPACE = "unicopia";
public static final Logger LOGGER = LogManager.getLogger(); public static final Logger LOGGER = LogManager.getLogger();
public static SidedAccess SIDE = Optional::empty;
private static Config CONFIG; private static Config CONFIG;
public static Config getConfig() { public static Config getConfig() {
@ -111,12 +106,4 @@ public class Unicopia implements ModInitializer {
registry.registerReloadListener(SpellbookChapterLoader.INSTANCE); registry.registerReloadListener(SpellbookChapterLoader.INSTANCE);
registry.registerReloadListener(new DietsLoader()); registry.registerReloadListener(new DietsLoader());
} }
public interface SidedAccess {
Optional<Pony> getPony();
default Race.Composite getPlayerSpecies() {
return getPony().map(Pony::getCompositeRace).orElse(Race.HUMAN.composite());
}
}
} }

View file

@ -209,7 +209,7 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable {
warmup = 0; warmup = 0;
if (data.isPresent()) { if (data.isPresent()) {
InteractionManager.instance().sendPlayerLookAngles(player.asEntity()); InteractionManager.getInstance().sendPlayerLookAngles(player.asEntity());
Channel.CLIENT_PLAYER_ABILITY.sendToServer(new MsgPlayerAbility<>(ability, data, ActivationType.NONE)); Channel.CLIENT_PLAYER_ABILITY.sendToServer(new MsgPlayerAbility<>(ability, data, ActivationType.NONE));
} else { } else {
player.asEntity().playSound(USounds.GUI_ABILITY_FAIL, 1, 1); player.asEntity().playSound(USounds.GUI_ABILITY_FAIL, 1, 1);

View file

@ -64,7 +64,7 @@ public class UnicornDispellAbility implements Ability<Pos> {
} }
if (type == ActivationType.TAP && player.isClient()) { if (type == ActivationType.TAP && player.isClient()) {
InteractionManager.instance().openScreen(InteractionManager.SCREEN_DISPELL_ABILITY); InteractionManager.getInstance().openScreen(InteractionManager.SCREEN_DISPELL_ABILITY);
return true; return true;
} }
} }

View file

@ -209,7 +209,7 @@ public class PlaceableSpell extends AbstractDelegatingSpell implements OrientedS
castEntity.set(null); castEntity.set(null);
}); });
if (source.asEntity() instanceof CastSpellEntity spellcast) { if (source.asEntity() instanceof CastSpellEntity) {
Ether.get(source.asWorld()).remove(this, source); Ether.get(source.asWorld()).remove(this, source);
} }
} }

View file

@ -108,7 +108,7 @@ public class RageAbilitySpell extends AbstractSpell {
if (source instanceof Pony pony) { if (source instanceof Pony pony) {
if (pony.isClientPlayer() && pony.asEntity().getAttackCooldownProgress(0) == 0) { if (pony.isClientPlayer() && pony.asEntity().getAttackCooldownProgress(0) == 0) {
InteractionManager.instance().playLoopingSound(source.asEntity(), InteractionManager.SOUND_KIRIN_RAGE, source.asWorld().random.nextLong()); InteractionManager.getInstance().playLoopingSound(source.asEntity(), InteractionManager.SOUND_KIRIN_RAGE, source.asWorld().random.nextLong());
} }
Bar energyBar = pony.getMagicalReserves().getEnergy(); Bar energyBar = pony.getMagicalReserves().getEnergy();
var energy = Math.min(1.01F, 0.5F + (age / 1000F)); var energy = Math.min(1.01F, 0.5F + (age / 1000F));

View file

@ -50,7 +50,7 @@ public class RainboomAbilitySpell extends AbstractSpell {
if (source.isClient()) { if (source.isClient()) {
if (boundParticle == null) { if (boundParticle == null) {
boundParticle = InteractionManager.INSTANCE.createBoundParticle(getUuid()); boundParticle = InteractionManager.getInstance().createBoundParticle(getUuid());
} }
boundParticle.addParticle(new TargetBoundParticleEffect(UParticles.RAINBOOM_TRAIL, source.asEntity()), source.getOriginVector(), Vec3d.ZERO); boundParticle.addParticle(new TargetBoundParticleEffect(UParticles.RAINBOOM_TRAIL, source.asEntity()), source.getOriginVector(), Vec3d.ZERO);

View file

@ -2,6 +2,7 @@ package com.minelittlepony.unicopia.client;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.function.Supplier; import java.util.function.Supplier;
@ -168,4 +169,9 @@ public class ClientInteractionManager extends InteractionManager {
public void addBlockBreakingParticles(BlockPos pos, Direction direction) { public void addBlockBreakingParticles(BlockPos pos, Direction direction) {
client.particleManager.addBlockBreakingParticles(pos, direction); client.particleManager.addBlockBreakingParticles(pos, direction);
} }
@Override
public Optional<Pony> getClientPony() {
return Optional.ofNullable(client.player).map(Pony::of);
}
} }

View file

@ -8,7 +8,6 @@ import org.joml.Vector3f;
import com.minelittlepony.common.client.gui.element.Button; import com.minelittlepony.common.client.gui.element.Button;
import com.minelittlepony.common.event.ScreenInitCallback; import com.minelittlepony.common.event.ScreenInitCallback;
import com.minelittlepony.common.event.ScreenInitCallback.ButtonList; import com.minelittlepony.common.event.ScreenInitCallback.ButtonList;
import com.minelittlepony.unicopia.InteractionManager;
import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.Unicopia; import com.minelittlepony.unicopia.Unicopia;
import com.minelittlepony.unicopia.client.gui.LanSettingsScreen; import com.minelittlepony.unicopia.client.gui.LanSettingsScreen;
@ -51,6 +50,11 @@ public class UnicopiaClient implements ClientModInitializer {
return instance; return instance;
} }
@Nullable
public static Pony getClientPony() {
return Pony.of(MinecraftClient.getInstance().player);
}
@Nullable @Nullable
private Float originalRainGradient; private Float originalRainGradient;
private final Lerp rainGradient = new Lerp(0); private final Lerp rainGradient = new Lerp(0);
@ -61,18 +65,23 @@ public class UnicopiaClient implements ClientModInitializer {
private ZapAppleStageStore.Stage zapAppleStage = ZapAppleStageStore.Stage.HIBERNATING; private ZapAppleStageStore.Stage zapAppleStage = ZapAppleStageStore.Stage.HIBERNATING;
public static Optional<PlayerCamera> getCamera() { public static Optional<PlayerCamera> getCamera() {
return Optional.of(getNullableCamera());
}
@Nullable
private static PlayerCamera getNullableCamera() {
PlayerEntity player = MinecraftClient.getInstance().player; PlayerEntity player = MinecraftClient.getInstance().player;
if (player != null && MinecraftClient.getInstance().cameraEntity == player) { if (player != null && MinecraftClient.getInstance().cameraEntity == player) {
return Optional.of(Pony.of(player).getCamera()); return Pony.of(player).getCamera();
} }
return Optional.empty(); return null;
} }
public static Vec3d getAdjustedSoundPosition(Vec3d pos) { public static Vec3d getAdjustedSoundPosition(Vec3d pos) {
PlayerCamera cam = getCamera().orElse(null); PlayerCamera cam = getNullableCamera();
if (cam == null) { if (cam == null) {
return pos; return pos;
} }
@ -124,7 +133,7 @@ public class UnicopiaClient implements ClientModInitializer {
@Override @Override
public void onInitializeClient() { public void onInitializeClient() {
InteractionManager.INSTANCE = new ClientInteractionManager(); new ClientInteractionManager();
new ClientNetworkHandlerImpl(); new ClientNetworkHandlerImpl();
KeyBindingsHandler.bootstrap(); KeyBindingsHandler.bootstrap();
@ -140,8 +149,6 @@ public class UnicopiaClient implements ClientModInitializer {
ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(ViewportShader.INSTANCE); ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(ViewportShader.INSTANCE);
ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(SpellEffectsRenderDispatcher.INSTANCE); ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(SpellEffectsRenderDispatcher.INSTANCE);
Unicopia.SIDE = () -> Optional.ofNullable(MinecraftClient.getInstance().player).map(Pony::of);
} }
private void onTick(MinecraftClient client) { private void onTick(MinecraftClient client) {

View file

@ -104,7 +104,7 @@ public class DisguiseCommand {
} }
static Entity loadPlayer(ServerCommandSource source, String username) { static Entity loadPlayer(ServerCommandSource source, String username) {
return InteractionManager.instance().createPlayer(source.getWorld(), new GameProfile(null, username)); return InteractionManager.getInstance().createPlayer(source.getWorld(), new GameProfile(null, username));
} }
static int reveal(ServerCommandSource source, PlayerEntity player) { static int reveal(ServerCommandSource source, PlayerEntity player) {

View file

@ -37,7 +37,7 @@ public class MagicalShapedEmiRecipe extends EmiCraftingRecipe {
ItemStack[] stacks = ingredient.getMatchingStacks(); ItemStack[] stacks = ingredient.getMatchingStacks();
for (int i = 0; i < stacks.length; i++) { for (int i = 0; i < stacks.length; i++) {
if (stacks[i].getItem() instanceof EnchantableItem e) { if (stacks[i].getItem() instanceof EnchantableItem) {
stacks = Arrays.copyOf(stacks, stacks.length); stacks = Arrays.copyOf(stacks, stacks.length);
stacks[i] = EnchantableItem.enchant(stacks[i].copy(), spellEffect.type()); stacks[i] = EnchantableItem.enchant(stacks[i].copy(), spellEffect.type());
return EmiIngredient.of(Arrays.stream(stacks).map(EmiStack::of).toList()); return EmiIngredient.of(Arrays.stream(stacks).map(EmiStack::of).toList());

View file

@ -90,7 +90,7 @@ public class FleeExplosionGoal extends Goal {
public static void notifySurroundings(Entity explosionSource, float radius) { public static void notifySurroundings(Entity explosionSource, float radius) {
explosionSource.getWorld().getOtherEntities(explosionSource, explosionSource.getBoundingBox().expand(radius), e -> { explosionSource.getWorld().getOtherEntities(explosionSource, explosionSource.getBoundingBox().expand(radius), e -> {
return Living.getOrEmpty(e).filter(l -> l instanceof Creature c).isPresent(); return Living.getOrEmpty(e).filter(l -> l instanceof Creature).isPresent();
}).forEach(e -> { }).forEach(e -> {
getGoals((Creature)Living.living(e)).forEach(goal -> goal.setFleeTarget(explosionSource)); getGoals((Creature)Living.living(e)).forEach(goal -> goal.setFleeTarget(explosionSource));
}); });

View file

@ -10,7 +10,7 @@ public class BeeBehaviour extends EntityBehaviour<BeeEntity> {
public BeeEntity onCreate(BeeEntity entity, EntityAppearance context, boolean replaceOld) { public BeeEntity onCreate(BeeEntity entity, EntityAppearance context, boolean replaceOld) {
super.onCreate(entity, context, replaceOld); super.onCreate(entity, context, replaceOld);
if (replaceOld && entity.getWorld().isClient) { if (replaceOld && entity.getWorld().isClient) {
InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_BEE, entity.getId()); InteractionManager.getInstance().playLoopingSound(entity, InteractionManager.SOUND_BEE, entity.getId());
} }
return entity; return entity;
} }

View file

@ -141,7 +141,7 @@ public class EntityAppearance implements NbtSerialisable, PlayerDimensions.Provi
private synchronized void createPlayer(NbtCompound nbt, GameProfile profile, Caster<?> source) { private synchronized void createPlayer(NbtCompound nbt, GameProfile profile, Caster<?> source) {
remove(); remove();
entity = InteractionManager.instance().createPlayer(source.asEntity(), profile); entity = InteractionManager.getInstance().createPlayer(source.asEntity(), profile);
entity.setCustomName(source.asEntity().getName()); entity.setCustomName(source.asEntity().getName());
((PlayerEntity)entity).readNbt(nbt.getCompound("playerNbt")); ((PlayerEntity)entity).readNbt(nbt.getCompound("playerNbt"));
if (nbt.contains("playerVisibleParts", NbtElement.BYTE_TYPE)) { if (nbt.contains("playerVisibleParts", NbtElement.BYTE_TYPE)) {

View file

@ -12,7 +12,7 @@ public class MinecartBehaviour extends EntityBehaviour<AbstractMinecartEntity> {
public AbstractMinecartEntity onCreate(AbstractMinecartEntity entity, EntityAppearance context, boolean replaceOld) { public AbstractMinecartEntity onCreate(AbstractMinecartEntity entity, EntityAppearance context, boolean replaceOld) {
super.onCreate(entity, context, replaceOld); super.onCreate(entity, context, replaceOld);
if (replaceOld && entity.getWorld().isClient) { if (replaceOld && entity.getWorld().isClient) {
InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_MINECART, entity.getId()); InteractionManager.getInstance().playLoopingSound(entity, InteractionManager.SOUND_MINECART, entity.getId());
} }
return entity; return entity;
} }

View file

@ -366,7 +366,7 @@ public class AirBalloonEntity extends MobEntity implements EntityCollisions.Comp
protected ActionResult interactMob(PlayerEntity player, Hand hand) { protected ActionResult interactMob(PlayerEntity player, Hand hand) {
ItemStack stack = player.getStackInHand(hand); ItemStack stack = player.getStackInHand(hand);
if (stack.getItem() instanceof HotAirBalloonItem balloon && !hasBalloon()) { if (stack.getItem() instanceof HotAirBalloonItem && !hasBalloon()) {
if (!player.getAbilities().creativeMode) { if (!player.getAbilities().creativeMode) {
stack.decrement(1); stack.decrement(1);
} }

View file

@ -75,7 +75,7 @@ public class CorruptionHandler implements Tickable {
private void recover(float percentage) { private void recover(float percentage) {
pony.getCorruption().set((int)(pony.getCorruption().get() * (1 - percentage))); pony.getCorruption().set((int)(pony.getCorruption().get() * (1 - percentage)));
InteractionManager.INSTANCE.playLoopingSound(pony.asEntity(), InteractionManager.SOUND_HEART_BEAT, 0); InteractionManager.getInstance().playLoopingSound(pony.asEntity(), InteractionManager.SOUND_HEART_BEAT, 0);
MagicReserves reserves = pony.getMagicalReserves(); MagicReserves reserves = pony.getMagicalReserves();
reserves.getExertion().addPercent(10); reserves.getExertion().addPercent(10);
reserves.getEnergy().add(10); reserves.getEnergy().add(10);

View file

@ -459,13 +459,13 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
if (type.isAvian()) { if (type.isAvian()) {
if (!SpellPredicate.IS_DISGUISE.isOn(pony) && pony.isClient()) { if (!SpellPredicate.IS_DISGUISE.isOn(pony) && pony.isClient()) {
if (ticksInAir % GLIDING_SOUND_INTERVAL == 5) { if (ticksInAir % GLIDING_SOUND_INTERVAL == 5) {
InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_GLIDING, entity.getId()); InteractionManager.getInstance().playLoopingSound(entity, InteractionManager.SOUND_GLIDING, entity.getId());
} }
} }
} else if (type == FlightType.INSECTOID && !SpellPredicate.IS_DISGUISE.isOn(pony)) { } else if (type == FlightType.INSECTOID && !SpellPredicate.IS_DISGUISE.isOn(pony)) {
if (entity.getWorld().isClient && !soundPlaying) { if (entity.getWorld().isClient && !soundPlaying) {
soundPlaying = true; soundPlaying = true;
InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_CHANGELING_BUZZ, entity.getId()); InteractionManager.getInstance().playLoopingSound(entity, InteractionManager.SOUND_CHANGELING_BUZZ, entity.getId());
} }
} }

View file

@ -564,7 +564,7 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
entity.addStatusEffect(new StatusEffectInstance(UEffects.SUN_BLINDNESS, SunBlindnessStatusEffect.MAX_DURATION, 2, true, false)); entity.addStatusEffect(new StatusEffectInstance(UEffects.SUN_BLINDNESS, SunBlindnessStatusEffect.MAX_DURATION, 2, true, false));
UCriteria.LOOK_INTO_SUN.trigger(entity); UCriteria.LOOK_INTO_SUN.trigger(entity);
} else if (isClientPlayer()) { } else if (isClientPlayer()) {
InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_EARS_RINGING, entity.getId()); InteractionManager.getInstance().playLoopingSound(entity, InteractionManager.SOUND_EARS_RINGING, entity.getId());
} }
} }
@ -577,7 +577,7 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
if (!isClient()) { if (!isClient()) {
entity.addStatusEffect(new StatusEffectInstance(UEffects.SUN_BLINDNESS, SunBlindnessStatusEffect.MAX_DURATION, 1, true, false)); entity.addStatusEffect(new StatusEffectInstance(UEffects.SUN_BLINDNESS, SunBlindnessStatusEffect.MAX_DURATION, 1, true, false));
} else if (isClientPlayer()) { } else if (isClientPlayer()) {
InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_EARS_RINGING, entity.getId()); InteractionManager.getInstance().playLoopingSound(entity, InteractionManager.SOUND_EARS_RINGING, entity.getId());
} }
} }
} else if (ticksInSun > 0) { } else if (ticksInSun > 0) {
@ -966,7 +966,7 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
} }
public boolean isClientPlayer() { public boolean isClientPlayer() {
return InteractionManager.instance().isClientPlayer(asEntity()); return InteractionManager.getInstance().isClientPlayer(asEntity());
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")

View file

@ -65,7 +65,7 @@ public class DummyClientPlayerEntity extends AbstractClientPlayerEntity implemen
@Override @Override
public boolean shouldRenderName() { public boolean shouldRenderName() {
return !InteractionManager.instance().isClientPlayer(getMaster()); return !InteractionManager.getInstance().isClientPlayer(getMaster());
} }
@Override @Override

View file

@ -53,7 +53,7 @@ public class DummyPlayerEntity extends PlayerEntity implements Owned<PlayerEntit
@Override @Override
public boolean shouldRenderName() { public boolean shouldRenderName() {
return !InteractionManager.instance().isClientPlayer(getMaster()); return !InteractionManager.getInstance().isClientPlayer(getMaster());
} }
@Override @Override

View file

@ -271,7 +271,7 @@ public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackab
pony.playSound(USounds.ITEM_ALICORN_AMULET_HALLUCINATION, 3, 1); pony.playSound(USounds.ITEM_ALICORN_AMULET_HALLUCINATION, 3, 1);
} else if (attachedTicks < 2 || (attachedTicks % (10 * ItemTracker.SECONDS) < 9 && world.random.nextInt(90) == 0)) { } else if (attachedTicks < 2 || (attachedTicks % (10 * ItemTracker.SECONDS) < 9 && world.random.nextInt(90) == 0)) {
if (attachedTicks % 5 == 0) { if (attachedTicks % 5 == 0) {
InteractionManager.INSTANCE.playLoopingSound(player, InteractionManager.SOUND_HEART_BEAT, 0); InteractionManager.getInstance().playLoopingSound(player, InteractionManager.SOUND_HEART_BEAT, 0);
} }
reserves.getExertion().addPercent(10); reserves.getExertion().addPercent(10);

View file

@ -49,7 +49,7 @@ public class ForageableItem extends Item {
if (state.isIn(BlockTags.LEAVES)) { if (state.isIn(BlockTags.LEAVES)) {
player.swingHand(hand); player.swingHand(hand);
world.playSound(player, pos, state.getSoundGroup().getHitSound(), SoundCategory.BLOCKS); world.playSound(player, pos, state.getSoundGroup().getHitSound(), SoundCategory.BLOCKS);
InteractionManager.instance().addBlockBreakingParticles(pos, hitResult.getSide()); InteractionManager.getInstance().addBlockBreakingParticles(pos, hitResult.getSide());
int miningLevel = (stack.getItem() instanceof HoeItem hoe ? hoe.getMaterial().getMiningLevel() : 59); int miningLevel = (stack.getItem() instanceof HoeItem hoe ? hoe.getMaterial().getMiningLevel() : 59);

View file

@ -5,7 +5,7 @@ import java.util.List;
import java.util.function.Predicate; import java.util.function.Predicate;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.Unicopia; import com.minelittlepony.unicopia.InteractionManager;
import com.minelittlepony.unicopia.ability.magic.spell.effect.CustomisedSpellType; import com.minelittlepony.unicopia.ability.magic.spell.effect.CustomisedSpellType;
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType; import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
import com.minelittlepony.unicopia.client.TextHelper; import com.minelittlepony.unicopia.client.TextHelper;
@ -84,7 +84,7 @@ public class GemstoneItem extends Item implements MultiItem, EnchantableItem {
MutableText line = Text.translatable(key.getTranslationKey() + ".lore").formatted(key.getAffinity().getColor()); MutableText line = Text.translatable(key.getTranslationKey() + ".lore").formatted(key.getAffinity().getColor());
if (!Unicopia.SIDE.getPlayerSpecies().canCast()) { if (!InteractionManager.getInstance().getClientSpecies().canCast()) {
line = line.formatted(Formatting.OBFUSCATED); line = line.formatted(Formatting.OBFUSCATED);
} }
@ -105,13 +105,13 @@ public class GemstoneItem extends Item implements MultiItem, EnchantableItem {
@Override @Override
public boolean hasGlint(ItemStack stack) { public boolean hasGlint(ItemStack stack) {
return super.hasGlint(stack) || (Unicopia.SIDE.getPlayerSpecies().canCast() && EnchantableItem.isEnchanted(stack)); return super.hasGlint(stack) || (InteractionManager.getInstance().getClientSpecies().canCast() && EnchantableItem.isEnchanted(stack));
} }
@Override @Override
public Text getName(ItemStack stack) { public Text getName(ItemStack stack) {
if (EnchantableItem.isEnchanted(stack)) { if (EnchantableItem.isEnchanted(stack)) {
if (!Unicopia.SIDE.getPlayerSpecies().canCast()) { if (!InteractionManager.getInstance().getClientSpecies().canCast()) {
return Text.translatable(getTranslationKey(stack) + ".obfuscated"); return Text.translatable(getTranslationKey(stack) + ".obfuscated");
} }

View file

@ -6,9 +6,9 @@ import org.jetbrains.annotations.Nullable;
import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.minelittlepony.unicopia.InteractionManager;
import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.USounds; import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.Unicopia;
import com.minelittlepony.unicopia.entity.damage.UDamageTypes; import com.minelittlepony.unicopia.entity.damage.UDamageTypes;
import com.minelittlepony.unicopia.entity.mob.UEntityAttributes; import com.minelittlepony.unicopia.entity.mob.UEntityAttributes;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
@ -53,18 +53,15 @@ public class HorseShoeItem extends HeavyProjectileItem {
float inaccuracy = projectileInnacuracy + degradation * 30; float inaccuracy = projectileInnacuracy + degradation * 30;
tooltip.add(Text.empty()); tooltip.add(Text.empty());
Pony pony = Unicopia.SIDE.getPony().orElse(null); var race = InteractionManager.getInstance().getClientPony().map(Pony::getCompositeRace).orElse(null);
float speed = baseProjectileSpeed; float speed = baseProjectileSpeed;
if (pony != null) { if (race != null) {
var race = pony.getCompositeRace();
if (race.any(Race::canUseEarth)) { if (race.any(Race::canUseEarth)) {
speed += 0.5F; speed += 0.5F;
} }
if (!race.includes(Race.ALICORN) && race.physical().canFly()) { if (!race.includes(Race.ALICORN) && race.physical().canFly()) {
speed /= 1.5F; speed /= 1.5F;
} }
} }
speed /= 1.5F; speed /= 1.5F;
speed *= 1 - (0.6F * degradation); speed *= 1 - (0.6F * degradation);

View file

@ -2,8 +2,8 @@ package com.minelittlepony.unicopia.item;
import java.util.List; import java.util.List;
import com.minelittlepony.unicopia.InteractionManager;
import com.minelittlepony.unicopia.UConventionalTags; import com.minelittlepony.unicopia.UConventionalTags;
import com.minelittlepony.unicopia.Unicopia;
import com.minelittlepony.unicopia.advancement.UCriteria; import com.minelittlepony.unicopia.advancement.UCriteria;
import com.minelittlepony.unicopia.entity.Living; import com.minelittlepony.unicopia.entity.Living;
import com.minelittlepony.unicopia.entity.damage.UDamageTypes; import com.minelittlepony.unicopia.entity.damage.UDamageTypes;
@ -101,7 +101,7 @@ public class ZapAppleItem extends Item implements ChameleonItem, MultiItem {
@Override @Override
public List<ItemStack> getDefaultStacks() { public List<ItemStack> getDefaultStacks() {
return Unicopia.SIDE.getPony().map(Pony::asWorld) return InteractionManager.getInstance().getClientPony().map(Pony::asWorld)
.stream() .stream()
.flatMap(world -> RegistryUtils.valuesForTag(world, UConventionalTags.Items.APPLES)) .flatMap(world -> RegistryUtils.valuesForTag(world, UConventionalTags.Items.APPLES))
.filter(a -> a != this).map(item -> { .filter(a -> a != this).map(item -> {

View file

@ -31,7 +31,7 @@ public class CloudBlockItem extends BlockItem {
@Override @Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) { public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
InteractionManager.instance().sendPlayerLookAngles(user); InteractionManager.getInstance().sendPlayerLookAngles(user);
Vec3d targetPos = user.getEyePos().add(user.getRotationVec(1).multiply(1, 1.5, 1).normalize().multiply(2)); Vec3d targetPos = user.getEyePos().add(user.getRotationVec(1).multiply(1, 1.5, 1).normalize().multiply(2));
ItemPlacementContext context = new ItemPlacementContext(user, hand, user.getStackInHand(hand), new BlockHitResult( ItemPlacementContext context = new ItemPlacementContext(user, hand, user.getStackInHand(hand), new BlockHitResult(
targetPos, targetPos,

View file

@ -31,7 +31,7 @@ public record MsgServerResources (
public MsgServerResources(PacketByteBuf buffer) { public MsgServerResources(PacketByteBuf buffer) {
this( this(
buffer.readMap(PacketByteBuf::readIdentifier, SpellTraits::fromPacket), buffer.readMap(PacketByteBuf::readIdentifier, SpellTraits::fromPacket),
InteractionManager.instance().readChapters(buffer), InteractionManager.getInstance().readChapters(buffer),
buffer.readMap(PacketByteBuf::readIdentifier, TreeTypeLoader.TreeTypeDef::new), buffer.readMap(PacketByteBuf::readIdentifier, TreeTypeLoader.TreeTypeDef::new),
new PonyDiets(buffer) new PonyDiets(buffer)
); );

View file

@ -131,7 +131,7 @@ public class MagicBeamEntity extends MagicProjectileEntity implements Caster<Mag
@Override @Override
public void onSpawnPacket(EntitySpawnS2CPacket packet) { public void onSpawnPacket(EntitySpawnS2CPacket packet) {
super.onSpawnPacket(packet); super.onSpawnPacket(packet);
InteractionManager.instance().playLoopingSound(this, InteractionManager.SOUND_MAGIC_BEAM, getId()); InteractionManager.getInstance().playLoopingSound(this, InteractionManager.SOUND_MAGIC_BEAM, getId());
} }
@Override @Override

View file

@ -181,7 +181,7 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl
BlockPos belowPos = buttonPos.down(); BlockPos belowPos = buttonPos.down();
BlockState below = getWorld().getBlockState(belowPos); BlockState below = getWorld().getBlockState(belowPos);
ItemStack stack = getStack(); ItemStack stack = getStack();
if (below.getBlock() instanceof HopperBlock hopper) { if (below.getBlock() instanceof HopperBlock) {
BlockEntity e = getWorld().getBlockEntity(belowPos); BlockEntity e = getWorld().getBlockEntity(belowPos);
if (e instanceof Inventory inventory) { if (e instanceof Inventory inventory) {
for (int i = 0; i < inventory.size(); i++) { for (int i = 0; i < inventory.size(); i++) {