From 9b08e1701025cccb53a9f67e4cf94056627cab07 Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 15 Sep 2022 01:48:40 +0200 Subject: [PATCH] 1.19.2 -> 1.18.2 --- .../com/minelittlepony/unicopia/Race.java | 7 ++-- .../unicopia/WorldTribeManager.java | 5 +-- .../unicopia/ability/Ability.java | 3 +- .../unicopia/ability/BatEeeeAbility.java | 3 +- .../ability/EarthPonyKickAbility.java | 2 +- .../ability/EarthPonyStompAbility.java | 2 +- .../ability/PegasusCaptureStormAbility.java | 4 +- .../ability/UnicornCastingAbility.java | 3 +- .../ability/UnicornDispellAbility.java | 6 +-- .../magic/spell/effect/InfernoSpell.java | 2 +- .../magic/spell/effect/PortalSpell.java | 4 +- .../ability/magic/spell/effect/SpellType.java | 3 +- .../ability/magic/spell/trait/Trait.java | 12 +++--- .../magic/spell/trait/TraitLoader.java | 2 +- .../unicopia/block/FrostedObsidianBlock.java | 2 +- .../unicopia/block/RockCropBlock.java | 3 +- .../unicopia/block/state/StateMapLoader.java | 38 ++++++++++--------- .../client/ClientInteractionManager.java | 8 ++-- .../unicopia/client/DiscoveryToast.java | 5 ++- .../unicopia/client/FlowingText.java | 4 +- .../unicopia/client/KeyBindingsHandler.java | 4 +- .../client/ModifierTooltipRenderer.java | 23 ++++++----- .../unicopia/client/UnicopiaClient.java | 4 +- .../client/gui/DismissSpellScreen.java | 27 +++++++------ .../unicopia/client/gui/DrawableUtil.java | 9 +++-- .../client/gui/ItemTraitsTooltipRenderer.java | 19 ++++++---- .../client/gui/LanSettingsScreen.java | 6 +-- .../client/gui/ParagraphWrappingVisitor.java | 6 +-- .../unicopia/client/gui/SettingsScreen.java | 13 ++++--- .../unicopia/client/gui/TribeButton.java | 4 +- .../client/gui/TribeConfirmationScreen.java | 17 +++++---- .../client/gui/TribeSelectionScreen.java | 10 ++--- .../unicopia/client/gui/UHud.java | 2 +- .../client/gui/spellbook/DynamicContent.java | 11 +++--- .../client/gui/spellbook/PageElement.java | 2 +- .../client/gui/spellbook/ProfileTooltip.java | 10 ++--- .../SpellbookCraftingPageContent.java | 7 ++-- .../SpellbookProfilePageContent.java | 4 +- .../client/gui/spellbook/SpellbookScreen.java | 5 +++ .../SpellbookTraitDexPageContent.java | 8 ++-- .../particle/LightningBoltParticle.java | 6 +-- .../render/IcarusWingsFeatureRenderer.java | 2 +- .../client/sound/FadeOutSoundInstance.java | 7 ++-- .../LoopedEntityTrackingSoundInstance.java | 2 +- .../client/sound/LoopingSoundInstance.java | 2 +- .../client/sound/MagicAuraSoundInstance.java | 2 +- .../sound/MotionBasedSoundInstance.java | 3 +- .../unicopia/command/Commands.java | 12 +++--- .../unicopia/command/DisguiseCommand.java | 16 ++++---- .../unicopia/command/EnumArgumentType.java | 38 +++---------------- .../unicopia/command/GravityCommand.java | 12 +++--- .../unicopia/command/ManaCommand.java | 6 +-- .../unicopia/command/RacelistCommand.java | 3 +- .../unicopia/command/SpeciesCommand.java | 27 +++++++------ .../unicopia/command/TraitCommand.java | 10 ++--- .../container/SpellbookChapterLoader.java | 7 ++-- .../unicopia/container/UScreenHandlers.java | 2 +- .../unicopia/entity/ButterflyEntity.java | 5 +-- .../unicopia/entity/CastSpellEntity.java | 3 +- .../entity/FloatingArtefactEntity.java | 2 +- .../unicopia/entity/ItemImpl.java | 2 +- .../unicopia/entity/Living.java | 4 +- .../unicopia/entity/UTradeOffers.java | 3 +- .../unicopia/entity/behaviour/Disguise.java | 2 +- .../entity/behaviour/SheepBehaviour.java | 3 +- .../entity/behaviour/SteedBehaviour.java | 2 +- .../entity/effect/RaceChangeStatusEffect.java | 3 +- .../effect/SunBlindnessStatusEffect.java | 2 +- .../entity/player/PlayerCharmTracker.java | 2 +- .../unicopia/entity/player/PlayerPhysics.java | 4 +- .../unicopia/entity/player/Pony.java | 8 ++-- .../player/dummy/DummyClientPlayerEntity.java | 10 ++--- .../player/dummy/DummyPlayerEntity.java | 4 +- .../player/dummy/DummyServerPlayerEntity.java | 4 +- .../unicopia/item/AlicornAmuletItem.java | 3 +- .../unicopia/item/AmuletItem.java | 13 +++---- .../unicopia/item/FilledJarItem.java | 3 +- .../unicopia/item/FriendshipBraceletItem.java | 5 ++- .../unicopia/item/GemstoneItem.java | 9 ++--- .../minelittlepony/unicopia/item/UItems.java | 2 +- .../unicopia/item/URecipes.java | 9 ++--- .../enchantment/PoisonedJokeEnchantment.java | 17 +++++---- .../unicopia/item/toxin/Toxicity.java | 3 +- .../unicopia/item/toxin/Toxin.java | 7 ++-- .../unicopia/mixin/MixinBoatEntity.java | 2 +- .../unicopia/mixin/MixinDamageSource.java | 5 ++- .../mixin/MixinServerPlayerEntity.java | 2 +- .../unicopia/mixin/MixinServerWorld.java | 2 +- .../mixin/client/MixinKeyboardInput.java | 4 +- .../network/MsgPlayerCapabilities.java | 4 +- .../network/MsgRequestSpeciesChange.java | 4 +- .../unicopia/network/MsgTribeSelect.java | 4 +- .../particle/MagicParticleEffect.java | 2 +- .../unicopia/util/MagicalDamageSource.java | 3 +- .../unicopia/util/Resources.java | 2 +- .../unicopia/util/shape/Cylinder.java | 3 +- .../unicopia/util/shape/Line.java | 3 +- .../unicopia/util/shape/PointGenerator.java | 2 +- .../unicopia/util/shape/Sphere.java | 3 +- 99 files changed, 324 insertions(+), 321 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/Race.java b/src/main/java/com/minelittlepony/unicopia/Race.java index 61277735..5b5412c6 100644 --- a/src/main/java/com/minelittlepony/unicopia/Race.java +++ b/src/main/java/com/minelittlepony/unicopia/Race.java @@ -15,6 +15,7 @@ import net.minecraft.command.argument.RegistryKeyArgumentType; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.RegistryKey; @@ -23,7 +24,7 @@ public final class Race implements Affine { public static final String DEFAULT_ID = "unicopia:human"; public static final Registry REGISTRY = Registries.createDefaulted(Unicopia.id("race"), DEFAULT_ID); public static final RegistryKey> REGISTRY_KEY = REGISTRY.getKey(); - private static final DynamicCommandExceptionType UNKNOWN_RACE_EXCEPTION = new DynamicCommandExceptionType(id -> Text.translatable("race.unknown", id)); + private static final DynamicCommandExceptionType UNKNOWN_RACE_EXCEPTION = new DynamicCommandExceptionType(id -> new TranslatableText("race.unknown", id)); public static Race register(String name, boolean magic, FlightType flight, boolean earth) { return register(Unicopia.id(name), magic, flight, earth); @@ -103,11 +104,11 @@ public final class Race implements Affine { } public Text getDisplayName() { - return Text.translatable(getTranslationKey()); + return new TranslatableText(getTranslationKey()); } public Text getAltDisplayName() { - return Text.translatable(getTranslationKey() + ".alt"); + return new TranslatableText(getTranslationKey() + ".alt"); } public String getTranslationKey() { diff --git a/src/main/java/com/minelittlepony/unicopia/WorldTribeManager.java b/src/main/java/com/minelittlepony/unicopia/WorldTribeManager.java index 961f4555..91f81d14 100644 --- a/src/main/java/com/minelittlepony/unicopia/WorldTribeManager.java +++ b/src/main/java/com/minelittlepony/unicopia/WorldTribeManager.java @@ -5,7 +5,6 @@ import net.minecraft.server.world.ServerWorld; import net.minecraft.util.registry.RegistryEntry; import net.minecraft.world.PersistentState; import net.minecraft.world.dimension.DimensionType; -import net.minecraft.world.dimension.DimensionTypes; public class WorldTribeManager extends PersistentState { @@ -32,13 +31,13 @@ public class WorldTribeManager extends PersistentState { } public static String nameFor(RegistryEntry dimension) { - if (dimension.matchesKey(DimensionTypes.THE_END)) { + if (dimension.matchesKey(DimensionType.THE_END_REGISTRY_KEY)) { return "unicopia:tribes_end"; } return "unicopia:tribes"; } public static WorldTribeManager forWorld(ServerWorld world) { - return world.getPersistentStateManager().getOrCreate(WorldTribeManager::new, WorldTribeManager::new, nameFor(world.getDimensionEntry())); + return world.getPersistentStateManager().getOrCreate(WorldTribeManager::new, WorldTribeManager::new, nameFor(world.method_40134())); } } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/Ability.java b/src/main/java/com/minelittlepony/unicopia/ability/Ability.java index b604379d..4c9a0d74 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/Ability.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/Ability.java @@ -7,6 +7,7 @@ import com.minelittlepony.unicopia.ability.data.Hit; import com.minelittlepony.unicopia.entity.player.Pony; import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; import net.minecraft.util.Identifier; import net.minecraft.world.World; @@ -78,7 +79,7 @@ public interface Ability { */ default Text getName() { Identifier id = Abilities.REGISTRY.getId(this); - return Text.translatable("ability." + id.getNamespace() + "." + id.getPath().replace('/', '.')); + return new TranslatableText("ability." + id.getNamespace() + "." + id.getPath().replace('/', '.')); } /** diff --git a/src/main/java/com/minelittlepony/unicopia/ability/BatEeeeAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/BatEeeeAbility.java index b2d2947e..3f1f2fbe 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/BatEeeeAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/BatEeeeAbility.java @@ -1,5 +1,7 @@ package com.minelittlepony.unicopia.ability; +import java.util.Random; + import com.minelittlepony.unicopia.AwaitTickQueue; import com.minelittlepony.unicopia.EquinePredicates; import com.minelittlepony.unicopia.Race; @@ -13,7 +15,6 @@ import com.minelittlepony.unicopia.util.MagicalDamageSource; import net.minecraft.entity.LivingEntity; import net.minecraft.sound.SoundCategory; import net.minecraft.util.math.Vec3d; -import net.minecraft.util.math.random.Random; /** * A magic casting ability for unicorns. diff --git a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java index 4b1c7410..349c42cf 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java @@ -77,7 +77,7 @@ public class EarthPonyKickAbility implements Ability { for (var e : VecHelper.findInRange(player.getEntity(), w, kickLocation.vec(), 2, EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR)) { if (e instanceof LivingEntity entity) { float calculatedStrength = 0.5F * (1 + player.getLevel().getScaled(9)); - entity.damage(MagicalDamageSource.KICK, player.getReferenceWorld().random.nextBetween(2, 10) + calculatedStrength); + entity.damage(MagicalDamageSource.KICK, 2 + player.getReferenceWorld().random.nextInt(8) + calculatedStrength); entity.takeKnockback(calculatedStrength, origin.x - entity.getX(), origin.z - entity.getZ()); player.subtractEnergyCost(3); player.setAnimation(Animation.KICK); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java index 7ccc4257..6be27405 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java @@ -189,7 +189,7 @@ public class EarthPonyStompAbility implements Ability { ItemStack stack = UItems.PEBBLES.getDefaultStack(); stack.setCount(1 + w.getRandom().nextInt(2)); Block.dropStack(w, pos, stack); - state.onStacksDropped((ServerWorld)w, pos, stack, true); + state.onStacksDropped((ServerWorld)w, pos, stack); } } } else { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/PegasusCaptureStormAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/PegasusCaptureStormAbility.java index 1fb893eb..022e58df 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/PegasusCaptureStormAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/PegasusCaptureStormAbility.java @@ -11,7 +11,7 @@ import com.minelittlepony.unicopia.particle.MagicParticleEffect; import net.minecraft.item.ItemStack; import net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket; import net.minecraft.server.world.ServerWorld; -import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; import net.minecraft.util.Hand; import net.minecraft.world.World; import net.minecraft.world.level.ServerWorldProperties; @@ -109,7 +109,7 @@ public class PegasusCaptureStormAbility implements Ability { } private void tell(Pony player, String translation) { - player.getMaster().sendMessage(Text.translatable(translation), true); + player.getMaster().sendMessage(new TranslatableText(translation), true); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java index a60a1d9d..17a3a1e8 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java @@ -1,5 +1,7 @@ package com.minelittlepony.unicopia.ability; +import java.util.Random; + import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.Race; @@ -24,7 +26,6 @@ import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.TypedActionResult; import net.minecraft.util.math.Vec3d; -import net.minecraft.util.math.random.Random; /** * Casts magic onto the user directly, or uses the item in the main hand slot. diff --git a/src/main/java/com/minelittlepony/unicopia/ability/UnicornDispellAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/UnicornDispellAbility.java index 0880e713..6014fcf3 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/UnicornDispellAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/UnicornDispellAbility.java @@ -13,7 +13,7 @@ import com.minelittlepony.unicopia.particle.MagicParticleEffect; import com.minelittlepony.unicopia.util.RayTraceHelper; import com.minelittlepony.unicopia.util.VecHelper; -import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; /** * Dispells an active spell @@ -46,9 +46,9 @@ public class UnicornDispellAbility implements Ability { if (type.getTapCount() > 1) { player.setAnimation(Animation.WOLOLO, 10); if (player.getSpellSlot().clear()) { - player.getMaster().sendMessage(Text.translatable("gui.unicopia.action.spells_cleared"), true); + player.getMaster().sendMessage(new TranslatableText("gui.unicopia.action.spells_cleared"), true); } else { - player.getMaster().sendMessage(Text.translatable("gui.unicopia.action.no_spells_cleared"), true); + player.getMaster().sendMessage(new TranslatableText("gui.unicopia.action.no_spells_cleared"), true); } return true; } 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 41c24c57..77c9a6f5 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 @@ -38,7 +38,7 @@ public class InfernoSpell extends FireSpell { Vec3d origin = source.getOriginVector(); - BlockStateConverter converter = w.getDimension().ultrawarm() ? StateMaps.HELLFIRE_AFFECTED.getInverse() : StateMaps.HELLFIRE_AFFECTED; + BlockStateConverter converter = w.getDimension().isUltrawarm() ? StateMaps.HELLFIRE_AFFECTED.getInverse() : StateMaps.HELLFIRE_AFFECTED; for (int i = 0; i < radius; i++) { BlockPos pos = new BlockPos(shape.computePoint(w.random).add(origin)); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/PortalSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/PortalSpell.java index 2be2caf5..ab1bd1e3 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/PortalSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/PortalSpell.java @@ -111,12 +111,12 @@ public class PortalSpell extends AbstractSpell implements PlaceableSpell.Placeme destination.entity.getPosition().ifPresent(targetPos -> { source.findAllEntitiesInRange(1).forEach(entity -> { - if (!entity.hasPortalCooldown() && entity.timeUntilRegen <= 0) { + if (!entity.hasNetherPortalCooldown() && entity.timeUntilRegen <= 0) { Vec3d offset = entity.getPos().subtract(source.getOriginVector()); float yawDifference = pitch < 15 ? (180 - yaw + destination.yaw) : 0; Vec3d dest = targetPos.add(offset.rotateY(yawDifference * MathHelper.RADIANS_PER_DEGREE)).add(0, 0.05, 0); - entity.resetPortalCooldown(); + entity.resetNetherPortalCooldown(); entity.timeUntilRegen = 100; entity.setYaw(entity.getYaw() + yawDifference); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SpellType.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SpellType.java index 5c87fa24..f1ba2598 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SpellType.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SpellType.java @@ -25,6 +25,7 @@ import com.minelittlepony.unicopia.util.Registries; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NbtCompound; import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; import net.minecraft.util.Identifier; import net.minecraft.util.Util; import net.minecraft.util.registry.Registry; @@ -127,7 +128,7 @@ public final class SpellType implements Affine, SpellPredicate< } public Text getName() { - return Text.translatable(getTranslationKey()); + return new TranslatableText(getTranslationKey()); } public CustomisedSpellType withTraits() { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/Trait.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/Trait.java index cb8e3944..ce93edce 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/Trait.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/Trait.java @@ -91,14 +91,14 @@ public enum Trait { : Formatting.WHITE; return Tooltip.of( - Text.translatable("gui.unicopia.trait.label", - Text.translatable("trait." + getId().getNamespace() + "." + getId().getPath() + ".name") + new TranslatableText("gui.unicopia.trait.label", + new TranslatableText("trait." + getId().getNamespace() + "." + getId().getPath() + ".name") ).formatted(Formatting.YELLOW) - .append(Text.translatable("gui.unicopia.trait.group", getGroup().name().toLowerCase()).formatted(Formatting.ITALIC, Formatting.GRAY)) - .append(Text.literal("\n\n").formatted(Formatting.WHITE) - .append(Text.translatable("trait." + getId().getNamespace() + "." + getId().getPath() + ".description").formatted(Formatting.GRAY)) + .append(new TranslatableText("gui.unicopia.trait.group", getGroup().name().toLowerCase()).formatted(Formatting.ITALIC, Formatting.GRAY)) + .append(new LiteralText("\n\n").formatted(Formatting.WHITE) + .append(new TranslatableText("trait." + getId().getNamespace() + "." + getId().getPath() + ".description").formatted(Formatting.GRAY)) .append("\n") - .append(Text.translatable("gui.unicopia.trait.corruption", ItemStack.MODIFIER_FORMAT.format(getGroup().getCorruption())).formatted(Formatting.ITALIC, corruptionColor))), 200); + .append(new TranslatableText("gui.unicopia.trait.corruption", ItemStack.MODIFIER_FORMAT.format(getGroup().getCorruption())).formatted(Formatting.ITALIC, corruptionColor))), 200); } public static Collection all() { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/TraitLoader.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/TraitLoader.java index 7a626fcc..0cc2d6bf 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/TraitLoader.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/trait/TraitLoader.java @@ -42,7 +42,7 @@ public class TraitLoader extends SinglePreparationResourceReloader prepared = HashMultimap.create(); - for (var path : manager.findResources("traits", p -> p.getPath().endsWith(".json")).keySet()) { + for (var path : manager.findResources("traits", p -> p.endsWith(".json"))) { profiler.push(path.toString()); try { for (Resource resource : manager.getAllResources(path)) { diff --git a/src/main/java/com/minelittlepony/unicopia/block/FrostedObsidianBlock.java b/src/main/java/com/minelittlepony/unicopia/block/FrostedObsidianBlock.java index 4cc23ee9..b57c84b3 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/FrostedObsidianBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/FrostedObsidianBlock.java @@ -28,7 +28,7 @@ public class FrostedObsidianBlock extends FrostedIceBlock { @Override protected void melt(BlockState state, World world, BlockPos pos) { - if (world.getDimension().ultrawarm()) { + if (world.getDimension().isUltrawarm()) { world.removeBlock(pos, false); return; } diff --git a/src/main/java/com/minelittlepony/unicopia/block/RockCropBlock.java b/src/main/java/com/minelittlepony/unicopia/block/RockCropBlock.java index 3b1860c4..8d9c2901 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/RockCropBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/RockCropBlock.java @@ -1,5 +1,7 @@ package com.minelittlepony.unicopia.block; +import java.util.Random; + import com.minelittlepony.unicopia.EquinePredicates; import com.minelittlepony.unicopia.item.UItems; @@ -9,7 +11,6 @@ import net.minecraft.block.ShapeContext; import net.minecraft.item.ItemConvertible; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.random.Random; import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; import net.minecraft.world.BlockView; diff --git a/src/main/java/com/minelittlepony/unicopia/block/state/StateMapLoader.java b/src/main/java/com/minelittlepony/unicopia/block/state/StateMapLoader.java index e47cfc4d..20ee5c5f 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/state/StateMapLoader.java +++ b/src/main/java/com/minelittlepony/unicopia/block/state/StateMapLoader.java @@ -1,6 +1,7 @@ package com.minelittlepony.unicopia.block.state; import java.io.*; +import java.nio.charset.StandardCharsets; import java.util.*; import java.util.stream.Collectors; @@ -48,34 +49,37 @@ public class StateMapLoader extends JsonDataLoader implements IdentifiableResour Map map = Maps.newHashMap(); int i = DATA_TYPE.length() + 1; - resourceManager.findAllResources(DATA_TYPE, id -> id.getPath().endsWith(FILE_SUFFIX)).entrySet().stream().forEach(entry -> { - Identifier resId = entry.getKey(); + resourceManager.findResources(DATA_TYPE, id -> id.endsWith(FILE_SUFFIX)).stream().forEach(entry -> { + Identifier resId = entry; String path = resId.getPath(); Identifier id = new Identifier(resId.getNamespace(), path.substring(i, path.length() - FILE_SUFFIX_LENGTH)); JsonArray entries = new JsonArray(); - for (var resource : entry.getValue()) { - try (BufferedReader reader = resource.getReader()) { - JsonObject json = JsonHelper.deserialize(Resources.GSON, reader, JsonObject.class); + try { + for (var resource : resourceManager.getAllResources(entry)) { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8))) { + JsonObject json = JsonHelper.deserialize(Resources.GSON, reader, JsonObject.class); - if (json != null) { - if (json.has("entries")) { + if (json != null) { + if (json.has("entries")) { - JsonArray incoming = JsonHelper.getArray(json, "entries"); - if (json.has("replace") && json.get("replace").getAsBoolean()) { - entries = incoming; - } else { - entries.addAll(incoming); + JsonArray incoming = JsonHelper.getArray(json, "entries"); + if (json.has("replace") && json.get("replace").getAsBoolean()) { + entries = incoming; + } else { + entries.addAll(incoming); + } } + + continue; } - continue; + LOGGER.error("Couldn't load data file {} from {} as it's null or empty", id, resId); + } catch (JsonParseException | IOException | IllegalArgumentException e) { + LOGGER.error("Couldn't parse data file {} from {}", id, resId, e); } - - LOGGER.error("Couldn't load data file {} from {} as it's null or empty", id, resId); - } catch (JsonParseException | IOException | IllegalArgumentException e) { - LOGGER.error("Couldn't parse data file {} from {}", id, resId, e); } + } catch (IOException e) { } map.put(id, entries); diff --git a/src/main/java/com/minelittlepony/unicopia/client/ClientInteractionManager.java b/src/main/java/com/minelittlepony/unicopia/client/ClientInteractionManager.java index ff0887d9..87d71e15 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/ClientInteractionManager.java +++ b/src/main/java/com/minelittlepony/unicopia/client/ClientInteractionManager.java @@ -1,5 +1,6 @@ package com.minelittlepony.unicopia.client; +import java.util.Random; import java.util.function.Predicate; import org.jetbrains.annotations.NotNull; @@ -33,7 +34,6 @@ import net.minecraft.entity.passive.BeeEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.vehicle.AbstractMinecartEntity; import net.minecraft.sound.SoundEvents; -import net.minecraft.util.math.random.Random; import net.minecraft.world.World; public class ClientInteractionManager extends InteractionManager { @@ -60,7 +60,7 @@ public class ClientInteractionManager extends InteractionManager { if (type == SOUND_EARS_RINGING && source instanceof LivingEntity) { soundManager.play(new LoopingSoundInstance<>((LivingEntity)source, createTicker(100).and(e -> e.hasStatusEffect(UEffects.SUN_BLINDNESS)), - USounds.ENTITY_PLAYER_EARS_RINGING, 0.01F, 2, Random.create(seed)).setFadeIn() + USounds.ENTITY_PLAYER_EARS_RINGING, 0.01F, 2, new Random(seed)).setFadeIn() ); } else if (type == SOUND_BEE && source instanceof BeeEntity) { soundManager.playNextTick( @@ -74,9 +74,9 @@ public class ClientInteractionManager extends InteractionManager { soundManager.play(new LoopingSoundInstance<>((PlayerEntity)source, e -> { PlayerPhysics physics = Pony.of(e).getPhysics(); return physics.isFlying() && physics.getFlightType() == FlightType.INSECTOID; - }, USounds.ENTITY_PLAYER_CHANGELING_BUZZ, 1F, 1F, Random.create(seed))); + }, USounds.ENTITY_PLAYER_CHANGELING_BUZZ, 1F, 1F, new Random(seed))); } else if (type == SOUND_GLIDING && source instanceof PlayerEntity) { - soundManager.play(new MotionBasedSoundInstance(SoundEvents.ITEM_ELYTRA_FLYING, (PlayerEntity)source, Random.create(seed))); + soundManager.play(new MotionBasedSoundInstance(SoundEvents.ITEM_ELYTRA_FLYING, (PlayerEntity)source, new Random(seed))); } else if (type == SOUND_MAGIC_BEAM) { soundManager.play(new LoopedEntityTrackingSoundInstance(USounds.SPELL_CAST_SHOOT, 0.3F, 1F, source, seed)); } diff --git a/src/main/java/com/minelittlepony/unicopia/client/DiscoveryToast.java b/src/main/java/com/minelittlepony/unicopia/client/DiscoveryToast.java index b66fd55a..2aa9b0d9 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/DiscoveryToast.java +++ b/src/main/java/com/minelittlepony/unicopia/client/DiscoveryToast.java @@ -13,12 +13,13 @@ import net.minecraft.client.toast.Toast; import net.minecraft.client.toast.ToastManager; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; import net.minecraft.util.Identifier; public class DiscoveryToast implements Toast { private static final long MAX_AGE = 5000L; - private static final Text TITLE = Text.translatable("unicopia.toast.discoveries.title"); - private static final Text DESCRIPTION = Text.translatable("unicopia.toast.discoveries.description"); + private static final Text TITLE = new TranslatableText("unicopia.toast.discoveries.title"); + private static final Text DESCRIPTION = new TranslatableText("unicopia.toast.discoveries.description"); private final List discoveries = new ArrayList<>(); private long startTime; diff --git a/src/main/java/com/minelittlepony/unicopia/client/FlowingText.java b/src/main/java/com/minelittlepony/unicopia/client/FlowingText.java index 1d820649..35657d5e 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/FlowingText.java +++ b/src/main/java/com/minelittlepony/unicopia/client/FlowingText.java @@ -9,9 +9,9 @@ import net.minecraft.text.*; public interface FlowingText { static Stream wrap(Text text, int maxWidth) { return MinecraftClient.getInstance().textRenderer.getTextHandler().wrapLines(text, maxWidth, Style.EMPTY).stream().map(line -> { - MutableText compiled = Text.literal(""); + MutableText compiled = new LiteralText(""); line.visit((s, t) -> { - compiled.append(Text.literal(t).setStyle(s)); + compiled.append(new LiteralText(t).setStyle(s)); return Optional.empty(); }, text.getStyle()); return compiled; diff --git a/src/main/java/com/minelittlepony/unicopia/client/KeyBindingsHandler.java b/src/main/java/com/minelittlepony/unicopia/client/KeyBindingsHandler.java index ea7c7ac6..0bc77a70 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/KeyBindingsHandler.java +++ b/src/main/java/com/minelittlepony/unicopia/client/KeyBindingsHandler.java @@ -19,7 +19,7 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.KeyBinding; import net.minecraft.client.sound.PositionedSoundInstance; import net.minecraft.sound.SoundEvents; -import net.minecraft.text.Text; +import net.minecraft.text.*; import net.minecraft.util.math.MathHelper; public class KeyBindingsHandler { @@ -105,7 +105,7 @@ public class KeyBindingsHandler { private void changePage(MinecraftClient client, long max, int sigma) { page += sigma; client.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.75F + (0.25F * sigma))); - UHud.INSTANCE.setMessage(Text.translatable("gui.unicopia.page_num", page + 1, max + 1)); + UHud.INSTANCE.setMessage(new TranslatableText("gui.unicopia.page_num", page + 1, max + 1)); } public class Binding { diff --git a/src/main/java/com/minelittlepony/unicopia/client/ModifierTooltipRenderer.java b/src/main/java/com/minelittlepony/unicopia/client/ModifierTooltipRenderer.java index c444ef81..e6404d1c 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/ModifierTooltipRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/client/ModifierTooltipRenderer.java @@ -26,8 +26,7 @@ import net.minecraft.entity.attribute.EntityAttributeModifier.Operation; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NbtCompound; -import net.minecraft.screen.ScreenTexts; -import net.minecraft.text.Text; +import net.minecraft.text.*; import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; import net.minecraft.util.Pair; @@ -59,10 +58,10 @@ public class ModifierTooltipRenderer implements ItemTooltipCallback { .forEach(entry -> describeModifiers(entry.getKey(), entry.getValue(), null, newLines)); if (!newLines.isEmpty()) { - Text find = Text.translatable("item.modifiers." + slot.getName()).formatted(Formatting.GRAY); + Text find = new TranslatableText("item.modifiers." + slot.getName()).formatted(Formatting.GRAY); int insertPosition = getInsertPosition(stack, find, flags, lines, context.isAdvanced()); if (insertPosition == -1) { - lines.add(ScreenTexts.EMPTY); + lines.add(LiteralText.EMPTY); lines.add(find); lines.addAll(newLines); } else { @@ -86,23 +85,23 @@ public class ModifierTooltipRenderer implements ItemTooltipCallback { if (insertPosition == -1 && stack.hasNbt()) { if (isShowing(flags, ItemStack.TooltipSection.MODIFIERS) && stack.getNbt().getBoolean("Unbreakable")) { - insertPosition = checkFor(lines, Text.translatable("item.unbreakable").formatted(Formatting.BLUE)); + insertPosition = checkFor(lines, new TranslatableText("item.unbreakable").formatted(Formatting.BLUE)); } if (insertPosition == -1 && isShowing(flags, ItemStack.TooltipSection.CAN_DESTROY) && stack.getNbt().contains("CanDestroy", 9)) { - insertPosition = checkFor(lines, Text.translatable("item.canBreak").formatted(Formatting.GRAY)); + insertPosition = checkFor(lines, new TranslatableText("item.canBreak").formatted(Formatting.GRAY)); } if (insertPosition == -1 && isShowing(flags, ItemStack.TooltipSection.CAN_PLACE) && stack.getNbt().contains("CanPlaceOn", 9)) { - insertPosition = checkFor(lines, Text.translatable("item.canPlace").formatted(Formatting.GRAY)); + insertPosition = checkFor(lines, new TranslatableText("item.canPlace").formatted(Formatting.GRAY)); } } if (insertPosition == -1 && advanced) { if (stack.isDamaged()) { - insertPosition = checkFor(lines, Text.translatable("item.durability", stack.getMaxDamage() - stack.getDamage(), stack.getMaxDamage())); + insertPosition = checkFor(lines, new TranslatableText("item.durability", stack.getMaxDamage() - stack.getDamage(), stack.getMaxDamage())); } else { - insertPosition = checkFor(lines, Text.literal(Registry.ITEM.getId(stack.getItem()).toString()).formatted(Formatting.DARK_GRAY)); + insertPosition = checkFor(lines, new LiteralText(Registry.ITEM.getId(stack.getItem()).toString()).formatted(Formatting.DARK_GRAY)); } } @@ -131,7 +130,7 @@ public class ModifierTooltipRenderer implements ItemTooltipCallback { } if (baseAdjusted) { - lines.add(Text.literal(" ").append(getModifierLineBase("equals", displayValue, op, attribute, Formatting.DARK_GREEN))); + lines.add(new LiteralText(" ").append(getModifierLineBase("equals", displayValue, op, attribute, Formatting.DARK_GREEN))); } else if (value > 0) { lines.add(getModifierLineBase("plus", displayValue, op, attribute, attribute == UEntityAttributes.ENTITY_GRAVTY_MODIFIER ? Formatting.RED : Formatting.BLUE)); } else if (value < 0) { @@ -140,9 +139,9 @@ public class ModifierTooltipRenderer implements ItemTooltipCallback { } private Text getModifierLineBase(String root, double displayValue, Operation op, EntityAttribute attribute, Formatting color) { - return Text.translatable("attribute.modifier." + root + "." + op.getId(), + return new TranslatableText("attribute.modifier." + root + "." + op.getId(), ItemStack.MODIFIER_FORMAT.format(displayValue), - Text.translatable(attribute.getTranslationKey()) + new TranslatableText(attribute.getTranslationKey()) ).formatted(color); } diff --git a/src/main/java/com/minelittlepony/unicopia/client/UnicopiaClient.java b/src/main/java/com/minelittlepony/unicopia/client/UnicopiaClient.java index f83a4c9a..3853e4b4 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/UnicopiaClient.java +++ b/src/main/java/com/minelittlepony/unicopia/client/UnicopiaClient.java @@ -24,7 +24,7 @@ import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.ingame.HandledScreens; import net.minecraft.client.gui.screen.world.CreateWorldScreen; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; public class UnicopiaClient implements ClientModInitializer { @@ -83,7 +83,7 @@ public class UnicopiaClient implements ClientModInitializer { if (screen instanceof OpenToLanScreen) { buttons.addButton(new Button(screen.width / 2 - 155, 130, 150, 20)) .onClick(b -> MinecraftClient.getInstance().setScreen(new LanSettingsScreen(screen))) - .getStyle().setText(Text.translatable("unicopia.options.title")); + .getStyle().setText(new TranslatableText("unicopia.options.title")); } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/DismissSpellScreen.java b/src/main/java/com/minelittlepony/unicopia/client/gui/DismissSpellScreen.java index c2dc992d..3a1c5deb 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/DismissSpellScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/DismissSpellScreen.java @@ -16,12 +16,11 @@ import net.minecraft.client.gui.*; import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; import net.minecraft.client.sound.PositionedSoundInstance; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.screen.ScreenTexts; import net.minecraft.sound.SoundEvents; -import net.minecraft.text.MutableText; -import net.minecraft.text.Text; +import net.minecraft.text.*; import net.minecraft.util.StringHelper; import net.minecraft.util.math.*; +import net.minecraft.util.math.Vector4f; public class DismissSpellScreen extends GameGui { private final Pony pony = Pony.of(MinecraftClient.getInstance().player); @@ -30,7 +29,7 @@ public class DismissSpellScreen extends GameGui { private int relativeMouseY; public DismissSpellScreen() { - super(Text.translatable("gui.unicopia.dismiss_spell")); + super(new TranslatableText("gui.unicopia.dismiss_spell")); } @Override @@ -92,7 +91,7 @@ public class DismissSpellScreen extends GameGui { matrices.push(); matrices.translate(0, 0, 300); - Text cancel = Text.literal("Press ESC to cancel"); + Text cancel = new LiteralText("Press ESC to cancel"); getFont().drawWithShadow(matrices, cancel, (width - getFont().getWidth(cancel)) / 2, height - 30, 0xFFFFFFFF); matrices.pop(); } @@ -185,18 +184,18 @@ public class DismissSpellScreen extends GameGui { MutableText name = actualSpell.getType().getName().copy(); color = actualSpell.getType().getColor(); name.setStyle(name.getStyle().withColor(color == 0 ? 0xFFAAAAAA : color)); - tooltip.add(Text.translatable("Spell Type: %s", name)); + tooltip.add(new TranslatableText("Spell Type: %s", name)); actualSpell.getType().getTraits().appendTooltip(tooltip); - tooltip.add(ScreenTexts.EMPTY); - tooltip.add(Text.translatable("Affinity: %s", actualSpell.getAffinity().name()).formatted(actualSpell.getAffinity().getColor())); - tooltip.add(ScreenTexts.EMPTY); - tooltip.addAll(FlowingText.wrap(Text.translatable(actualSpell.getType().getTranslationKey() + ".lore").formatted(actualSpell.getAffinity().getColor()), 180).toList()); + tooltip.add(LiteralText.EMPTY); + tooltip.add(new TranslatableText("Affinity: %s", actualSpell.getAffinity().name()).formatted(actualSpell.getAffinity().getColor())); + tooltip.add(LiteralText.EMPTY); + tooltip.addAll(FlowingText.wrap(new TranslatableText(actualSpell.getType().getTranslationKey() + ".lore").formatted(actualSpell.getAffinity().getColor()), 180).toList()); if (spell instanceof TimedSpell timed) { - tooltip.add(ScreenTexts.EMPTY); - tooltip.add(Text.translatable("Time Left: %s", StringHelper.formatTicks(timed.getTimer().getTicksRemaining()))); + tooltip.add(LiteralText.EMPTY); + tooltip.add(new TranslatableText("Time Left: %s", StringHelper.formatTicks(timed.getTimer().getTicksRemaining()))); } - tooltip.add(ScreenTexts.EMPTY); - tooltip.add(Text.translatable("[Click to Discard]")); + tooltip.add(LiteralText.EMPTY); + tooltip.add(new TranslatableText("[Click to Discard]")); renderTooltip(matrices, tooltip, 0, 0); if (!lastMouseOver) { diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/DrawableUtil.java b/src/main/java/com/minelittlepony/unicopia/client/gui/DrawableUtil.java index edb7b19f..3c4d9a2c 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/DrawableUtil.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/DrawableUtil.java @@ -71,7 +71,8 @@ public interface DrawableUtil { bufferBuilder.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR); bufferBuilder.vertex(matrix, x1, y1, 0).color(r, g, b, k).next(); bufferBuilder.vertex(matrix, x2, y2, 0).color(r, g, b, k).next(); - BufferRenderer.drawWithShader(bufferBuilder.end()); + bufferBuilder.end(); + BufferRenderer.draw(bufferBuilder); RenderSystem.enableTexture(); RenderSystem.disableBlend(); } @@ -119,7 +120,8 @@ public interface DrawableUtil { cylendricalVertex(bufferBuilder, model, innerRadius, angle + INCREMENT, r, g, b, k); } - BufferRenderer.drawWithShader(bufferBuilder.end()); + bufferBuilder.end(); + BufferRenderer.draw(bufferBuilder); RenderSystem.enableTexture(); } @@ -185,7 +187,8 @@ public interface DrawableUtil { } } - BufferRenderer.drawWithShader(bufferBuilder.end()); + bufferBuilder.end(); + BufferRenderer.draw(bufferBuilder); RenderSystem.enableTexture(); } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/ItemTraitsTooltipRenderer.java b/src/main/java/com/minelittlepony/unicopia/client/gui/ItemTraitsTooltipRenderer.java index a6f9ae36..cd18e52e 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/ItemTraitsTooltipRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/ItemTraitsTooltipRenderer.java @@ -73,7 +73,7 @@ public class ItemTraitsTooltipRenderer implements Text, OrderedText, TooltipComp @Override public MutableText copy() { - return Text.empty(); + return new LiteralText(""); } public static void renderTraitIcon(Trait trait, float value, MatrixStack matrices, int xx, int yy) { @@ -104,16 +104,21 @@ public class ItemTraitsTooltipRenderer implements Text, OrderedText, TooltipComp @Override public Style getStyle() { - return Text.empty().getStyle(); - } - - @Override - public TextContent getContent() { - return Text.empty().getContent(); + return Style.EMPTY; } @Override public List getSiblings() { return new ArrayList<>(); } + + @Override + public String asString() { + return ""; + } + + @Override + public MutableText shallowCopy() { + return copy(); + } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/LanSettingsScreen.java b/src/main/java/com/minelittlepony/unicopia/client/gui/LanSettingsScreen.java index 6fa16e87..f85e8b19 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/LanSettingsScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/LanSettingsScreen.java @@ -21,7 +21,7 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.server.integrated.IntegratedServer; -import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; import net.minecraft.util.Formatting; public class LanSettingsScreen extends GameGui { @@ -40,7 +40,7 @@ public class LanSettingsScreen extends GameGui { private boolean forceHideWhitelist; public LanSettingsScreen(Screen parent) { - super(Text.translatable("unicopia.options.title"), parent); + super(new TranslatableText("unicopia.options.title"), parent); content.margin.setVertical(30); content.getContentPadding().setHorizontal(10); @@ -103,7 +103,7 @@ public class LanSettingsScreen extends GameGui { if (whitelistEnabled) { - content.addButton(new Label(LEFT, row += 20)).getStyle().setText(Text.translatable("unicopia.options.whitelist.details").formatted(Formatting.DARK_GREEN)); + content.addButton(new Label(LEFT, row += 20)).getStyle().setText(new TranslatableText("unicopia.options.whitelist.details").formatted(Formatting.DARK_GREEN)); row += 20; WHITELIST_GRID_PACKER.start(); diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/ParagraphWrappingVisitor.java b/src/main/java/com/minelittlepony/unicopia/client/gui/ParagraphWrappingVisitor.java index 9051dbf5..513084d1 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/ParagraphWrappingVisitor.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/ParagraphWrappingVisitor.java @@ -18,7 +18,7 @@ public class ParagraphWrappingVisitor implements StyledVisitor { private final TextHandler handler = font.getTextHandler(); private float currentLineCollectedLength = 0; - private MutableText currentLine = Text.empty(); + private MutableText currentLine = new LiteralText(""); private boolean progressedNonEmpty; private final Int2IntFunction widthSupplier; @@ -57,7 +57,7 @@ public class ParagraphWrappingVisitor implements StyledVisitor { trimmedLength = lastSpace > 0 ? Math.min(lastSpace, trimmedLength) : trimmedLength; } - Text fragment = Text.literal(s.substring(0, trimmedLength).trim()).setStyle(style); + Text fragment = new LiteralText(s.substring(0, trimmedLength).trim()).setStyle(style); float grabbedWidth = handler.getWidth(fragment); // advance if appending the next segment would cause an overflow @@ -100,7 +100,7 @@ public class ParagraphWrappingVisitor implements StyledVisitor { lineConsumer.accept(currentLine, (++line) * font.fontHeight); } pageWidth = widthSupplier.applyAsInt((++line) * font.fontHeight); - currentLine = Text.empty(); + currentLine = new LiteralText(""); currentLineCollectedLength = 0; } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/SettingsScreen.java b/src/main/java/com/minelittlepony/unicopia/client/gui/SettingsScreen.java index 8a0ccd25..29a150aa 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/SettingsScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/SettingsScreen.java @@ -17,6 +17,7 @@ import net.minecraft.client.util.math.MatrixStack; import net.minecraft.server.integrated.IntegratedServer; import net.minecraft.server.world.ServerWorld; import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; import net.minecraft.util.Formatting; public class SettingsScreen extends GameGui { @@ -28,7 +29,7 @@ public class SettingsScreen extends GameGui { private Style mineLpStatus; public SettingsScreen(Screen parent) { - super(Text.translatable("unicopia.options.title"), parent); + super(new TranslatableText("unicopia.options.title"), parent); content.margin.setVertical(30); content.getContentPadding().setHorizontal(10); @@ -73,7 +74,7 @@ public class SettingsScreen extends GameGui { content.addButton(new Slider(LEFT, row += 25, 0, races.size(), races.indexOf(config.preferredRace.get()))) .onChange(races.createSetter(config.preferredRace::set)) - .setTextFormat(v -> Text.translatable("unicopia.options.preferred_race", races.valueOf(v.getValue()).getDisplayName())); + .setTextFormat(v -> new TranslatableText("unicopia.options.preferred_race", races.valueOf(v.getValue()).getDisplayName())); IntegratedServer server = client.getServer(); if (server != null) { @@ -84,7 +85,7 @@ public class SettingsScreen extends GameGui { content.addButton(new Slider(LEFT, row += 20, 0, races.size(), races.indexOf(tribes.getDefaultRace()))) .onChange(races.createSetter(tribes::setDefaultRace)) - .setTextFormat(v -> Text.translatable("unicopia.options.world.default_race", races.valueOf(v.getValue()).getDisplayName())) + .setTextFormat(v -> new TranslatableText("unicopia.options.world.default_race", races.valueOf(v.getValue()).getDisplayName())) .setEnabled(client.isInSingleplayer()); } } @@ -94,13 +95,13 @@ public class SettingsScreen extends GameGui { if (hasMineLP) { if (config.ignoreMineLP.get()) { - return Text.translatable("unicopia.options.ignore_mine_lp.undetected").formatted(Formatting.DARK_GREEN); + return new TranslatableText("unicopia.options.ignore_mine_lp.undetected").formatted(Formatting.DARK_GREEN); } - return Text.translatable("unicopia.options.ignore_mine_lp.detected", MineLPDelegate.getInstance().getPlayerPonyRace().getDisplayName()).formatted(Formatting.GREEN); + return new TranslatableText("unicopia.options.ignore_mine_lp.detected", MineLPDelegate.getInstance().getPlayerPonyRace().getDisplayName()).formatted(Formatting.GREEN); } - return Text.translatable("unicopia.options.ignore_mine_lp.missing").formatted(Formatting.RED); + return new TranslatableText("unicopia.options.ignore_mine_lp.missing").formatted(Formatting.RED); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/TribeButton.java b/src/main/java/com/minelittlepony/unicopia/client/gui/TribeButton.java index 7fe3a956..f9777c25 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/TribeButton.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/TribeButton.java @@ -10,7 +10,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.GameRenderer; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; @@ -47,7 +47,7 @@ public class TribeButton extends Button { if (hovered && screenWidth > 0) { Identifier id = Race.REGISTRY.getId(race); - drawCenteredText(matrices, getFont(), Text.translatable("gui.unicopia.tribe_selection.describe." + id.getNamespace() + "." + id.getPath()), screenWidth / 2, y + height, 0xFFFFFFFF); + drawCenteredText(matrices, getFont(), new TranslatableText("gui.unicopia.tribe_selection.describe." + id.getNamespace() + "." + id.getPath()), screenWidth / 2, y + height, 0xFFFFFFFF); } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/TribeConfirmationScreen.java b/src/main/java/com/minelittlepony/unicopia/client/gui/TribeConfirmationScreen.java index 9697afe9..3c72a4f9 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/TribeConfirmationScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/TribeConfirmationScreen.java @@ -11,6 +11,7 @@ import it.unimi.dsi.fastutil.booleans.BooleanConsumer; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; import net.minecraft.util.*; public class TribeConfirmationScreen extends GameGui implements HidesHud { @@ -19,7 +20,7 @@ public class TribeConfirmationScreen extends GameGui implements HidesHud { private final BooleanConsumer callback; public TribeConfirmationScreen(BooleanConsumer callback, Race selection) { - super(Text.translatable("gui.unicopia.tribe_selection")); + super(new TranslatableText("gui.unicopia.tribe_selection")); this.callback = callback; this.selection = selection; } @@ -33,10 +34,10 @@ public class TribeConfirmationScreen extends GameGui implements HidesHud { int top = (height - columnHeight) / 2; - addDrawableChild(new ButtonWidget(width / 2 + 5, top + columnHeight + padding, 100, 20, Text.translatable("Join Tribe"), b -> callback.accept(true))); - addDrawableChild(new ButtonWidget(width / 2 - 105, top + columnHeight + padding, 100, 20, Text.translatable("Go Back"), b -> callback.accept(false))); + addDrawableChild(new ButtonWidget(width / 2 + 5, top + columnHeight + padding, 100, 20, new TranslatableText("Join Tribe"), b -> callback.accept(true))); + addDrawableChild(new ButtonWidget(width / 2 - 105, top + columnHeight + padding, 100, 20, new TranslatableText("Go Back"), b -> callback.accept(false))); - addDrawable(new Label(width / 2, top - 30).setCentered()).getStyle().setText(Text.translatable("gui.unicopia.tribe_selection.confirm", selection.getDisplayName().copy().formatted(Formatting.YELLOW))); + addDrawable(new Label(width / 2, top - 30).setCentered()).getStyle().setText(new TranslatableText("gui.unicopia.tribe_selection.confirm", selection.getDisplayName().copy().formatted(Formatting.YELLOW))); addDrawable(new TribeButton((width - 70) / 2, top, 0, selection)); @@ -46,7 +47,7 @@ public class TribeConfirmationScreen extends GameGui implements HidesHud { Text race = selection.getAltDisplayName().copy().formatted(Formatting.YELLOW); - addDrawable(new Label(left - 3, top += 10)).getStyle().setText(Text.translatable("gui.unicopia.tribe_selection.confirm.goods", race).formatted(Formatting.YELLOW)); + addDrawable(new Label(left - 3, top += 10)).getStyle().setText(new TranslatableText("gui.unicopia.tribe_selection.confirm.goods", race).formatted(Formatting.YELLOW)); top += 15; @@ -58,12 +59,12 @@ public class TribeConfirmationScreen extends GameGui implements HidesHud { String key = String.format("gui.unicopia.tribe_selection.confirm.goods.%d.%s.%s", i, id.getNamespace(), id.getPath()); if (Language.getInstance().hasTranslation(key)) { TextBlock block = addDrawable(new TextBlock(left, top, maxWidth)); - block.getStyle().setText(Text.translatable(key)); + block.getStyle().setText(new TranslatableText(key)); top += block.getBounds().height; } } - addDrawable(new Label(left - 3, top += 5)).getStyle().setText(Text.translatable("gui.unicopia.tribe_selection.confirm.bads", race).formatted(Formatting.YELLOW)); + addDrawable(new Label(left - 3, top += 5)).getStyle().setText(new TranslatableText("gui.unicopia.tribe_selection.confirm.bads", race).formatted(Formatting.YELLOW)); top += 15; @@ -71,7 +72,7 @@ public class TribeConfirmationScreen extends GameGui implements HidesHud { String key = String.format("gui.unicopia.tribe_selection.confirm.bads.%d.%s.%s", i, id.getNamespace(), id.getPath()); if (Language.getInstance().hasTranslation(key)) { TextBlock block = addDrawable(new TextBlock(left, top, maxWidth)); - block.getStyle().setText(Text.translatable(key)); + block.getStyle().setText(new TranslatableText(key)); top += block.getBounds().height; } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/TribeSelectionScreen.java b/src/main/java/com/minelittlepony/unicopia/client/gui/TribeSelectionScreen.java index 0d12cee8..d0ddf673 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/TribeSelectionScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/TribeSelectionScreen.java @@ -12,7 +12,7 @@ import com.minelittlepony.unicopia.network.Channel; import com.minelittlepony.unicopia.network.MsgRequestSpeciesChange; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; @@ -24,7 +24,7 @@ public class TribeSelectionScreen extends GameGui implements HidesHud { private boolean finished; public TribeSelectionScreen(Set allowedRaces) { - super(Text.translatable("gui.unicopia.tribe_selection")); + super(new TranslatableText("gui.unicopia.tribe_selection")); this.allowedRaces = allowedRaces; } @@ -40,11 +40,11 @@ public class TribeSelectionScreen extends GameGui implements HidesHud { top += height / 8; TextBlock block = addDrawable(new TextBlock(left, top += 10, pageWidth)); - block.getStyle().setText(Text.translatable("gui.unicopia.tribe_selection.welcome.journey")); + block.getStyle().setText(new TranslatableText("gui.unicopia.tribe_selection.welcome.journey")); top += block.getBounds().height; block = addDrawable(new TextBlock(left, top += 7, pageWidth)); - block.getStyle().setText(Text.translatable("gui.unicopia.tribe_selection.welcome.choice")); + block.getStyle().setText(new TranslatableText("gui.unicopia.tribe_selection.welcome.choice")); top += block.getBounds().height; Race preference = UnicopiaClient.getPreferredRace(); @@ -67,7 +67,7 @@ public class TribeSelectionScreen extends GameGui implements HidesHud { top = height - 20; if (!preference.isDefault()) { - addDrawable(new Label(width / 2, top).setCentered()).getStyle().setText(Text.translatable("gui.unicopia.tribe_selection.preference", preference.getDisplayName().copy().formatted(Formatting.YELLOW))); + addDrawable(new Label(width / 2, top).setCentered()).getStyle().setText(new TranslatableText("gui.unicopia.tribe_selection.preference", preference.getDisplayName().copy().formatted(Formatting.YELLOW))); } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java b/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java index 4415ae95..5743abf0 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java @@ -1,6 +1,7 @@ package com.minelittlepony.unicopia.client.gui; import java.util.List; +import java.util.Random; import org.jetbrains.annotations.Nullable; @@ -35,7 +36,6 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Quaternion; import net.minecraft.util.math.Vec3f; -import net.minecraft.util.math.random.Random; public class UHud extends DrawableHelper { diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/DynamicContent.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/DynamicContent.java index 80657620..2101eb03 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/DynamicContent.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/DynamicContent.java @@ -13,12 +13,13 @@ import com.minelittlepony.unicopia.entity.player.Pony; import net.minecraft.client.MinecraftClient; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.network.PacketByteBuf; +import net.minecraft.text.LiteralText; import net.minecraft.text.Text; import net.minecraft.util.*; public class DynamicContent implements Content { private static final Text UNKNOWN = Text.of("???"); - private static final Text UNKNOWN_LEVEL = Text.literal("Level: ???").formatted(Formatting.DARK_GREEN); + private static final Text UNKNOWN_LEVEL = new LiteralText("Level: ???").formatted(Formatting.DARK_GREEN); private SpellbookState.PageState state = new SpellbookState.PageState(); private final List pages; @@ -96,7 +97,7 @@ public class DynamicContent implements Content { return (bounds.width - 10) - elements.stream() .filter(PageElement::isFloating) .map(PageElement::bounds) - .filter(b -> b.containsY(yPosition)) + .filter(b -> b.contains(b.left + b.width / 2, yPosition)) .mapToInt(b -> b.width) .sum(); } @@ -105,7 +106,7 @@ public class DynamicContent implements Content { return elements.stream() .filter(p -> p.flow() == Flow.LEFT) .map(PageElement::bounds) - .filter(b -> b.containsY(yPosition)) + .filter(b -> b.contains(b.left + b.width / 2, yPosition)) .mapToInt(b -> b.width) .sum(); } @@ -143,14 +144,14 @@ public class DynamicContent implements Content { int headerColor = mouseY % 255; DrawableUtil.drawScaledText(matrices, needsMoreXp ? UNKNOWN : title, bounds.left, bounds.top - 10, 1.3F, headerColor); - DrawableUtil.drawScaledText(matrices, level < 0 ? UNKNOWN_LEVEL : Text.literal("Level: " + (level + 1)).formatted(Formatting.DARK_GREEN), bounds.left, bounds.top - 10 + 12, 0.8F, headerColor); + DrawableUtil.drawScaledText(matrices, level < 0 ? UNKNOWN_LEVEL : new LiteralText("Level: " + (level + 1)).formatted(Formatting.DARK_GREEN), bounds.left, bounds.top - 10 + 12, 0.8F, headerColor); matrices.push(); matrices.translate(bounds.left, bounds.top + 16, 0); elements.stream().filter(PageElement::isFloating).forEach(element -> { Bounds bounds = element.bounds(); matrices.push(); - bounds.translate(matrices); + matrices.translate(bounds.left, bounds.top, 0); element.draw(matrices, mouseX, mouseY, container); matrices.pop(); }); diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/PageElement.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/PageElement.java index 9694812e..45c89d10 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/PageElement.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/PageElement.java @@ -101,7 +101,7 @@ interface PageElement extends Drawable { boolean needsMoreXp = page.getLevel() < 0 || Pony.of(MinecraftClient.getInstance().player).getLevel().get() < page.getLevel(); matrices.push(); wrappedText.forEach(line -> { - font.draw(matrices, needsMoreXp ? line.text().copy().formatted(Formatting.OBFUSCATED) : line.text().copy(), line.x(), 0, 0); + font.draw(matrices, needsMoreXp ? line.text().shallowCopy().formatted(Formatting.OBFUSCATED, Formatting.BLACK) : line.text(), line.x(), 0, 0xFF000000); matrices.translate(0, font.fontHeight, 0); }); matrices.pop(); diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/ProfileTooltip.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/ProfileTooltip.java index 27d27f4a..bf4ee861 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/ProfileTooltip.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/ProfileTooltip.java @@ -5,16 +5,16 @@ import java.util.List; import com.minelittlepony.common.client.gui.Tooltip; import com.minelittlepony.unicopia.entity.player.Pony; -import net.minecraft.text.Text; +import net.minecraft.text.LiteralText; public class ProfileTooltip { public static Tooltip get(Pony pony) { return () -> { return List.of( - Text.literal(String.format("Level %d ", pony.getLevel().get() + 1)).append(pony.getSpecies().getDisplayName()).formatted(pony.getSpecies().getAffinity().getColor()), - Text.literal(String.format("Mana: %d%%", (int)(pony.getMagicalReserves().getMana().getPercentFill() * 100))), - Text.literal(String.format("Experience: %d", (int)(pony.getMagicalReserves().getXp().getPercentFill() * 100))), - Text.literal(String.format("Next level in: %d experience points", 100 - (int)(pony.getMagicalReserves().getXp().getPercentFill() * 100))) + new LiteralText(String.format("Level %d ", pony.getLevel().get() + 1)).append(pony.getSpecies().getDisplayName()).formatted(pony.getSpecies().getAffinity().getColor()), + new LiteralText(String.format("Mana: %d%%", (int)(pony.getMagicalReserves().getMana().getPercentFill() * 100))), + new LiteralText(String.format("Experience: %d", (int)(pony.getMagicalReserves().getXp().getPercentFill() * 100))), + new LiteralText(String.format("Next level in: %d experience points", 100 - (int)(pony.getMagicalReserves().getXp().getPercentFill() * 100))) ); }; } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookCraftingPageContent.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookCraftingPageContent.java index da5c2991..1e45d3e6 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookCraftingPageContent.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookCraftingPageContent.java @@ -11,11 +11,12 @@ import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; import net.minecraft.util.Identifier; public class SpellbookCraftingPageContent extends ScrollContainer implements SpellbookChapterList.Content, SpellbookScreen.RecipesChangedListener { - public static final Text INVENTORY_TITLE = Text.translatable("gui.unicopia.spellbook.page.inventory"); - public static final Text RECIPES_TITLE = Text.translatable("gui.unicopia.spellbook.page.recipes"); + public static final Text INVENTORY_TITLE = new TranslatableText("gui.unicopia.spellbook.page.inventory"); + public static final Text RECIPES_TITLE = new TranslatableText("gui.unicopia.spellbook.page.recipes"); public static final int TOTAL_PAGES = 2; private final SpellbookScreen screen; @@ -46,7 +47,7 @@ public class SpellbookCraftingPageContent extends ScrollContainer implements Spe DrawableUtil.drawScaledText(matrices, state.getOffset() == 0 ? INVENTORY_TITLE : RECIPES_TITLE, screen.getFrameBounds().left + screen.getFrameBounds().width / 2 + 20, SpellbookScreen.TITLE_Y, 1.3F, headerColor); - Text pageText = Text.translatable("%s/%s", state.getOffset() + 1, TOTAL_PAGES); + Text pageText = new TranslatableText("%s/%s", state.getOffset() + 1, TOTAL_PAGES); textRenderer.draw(matrices, pageText, 337 - textRenderer.getWidth(pageText) / 2F, 190, headerColor); } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookProfilePageContent.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookProfilePageContent.java index c56407a2..b461f706 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookProfilePageContent.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookProfilePageContent.java @@ -10,7 +10,7 @@ import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.resource.language.I18n; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.text.Text; +import net.minecraft.text.*; import net.minecraft.util.Hand; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; @@ -104,7 +104,7 @@ public class SpellbookProfilePageContent extends DrawableHelper implements Spell font.draw(matrices, "Mana", -font.getWidth("Mana") / 2, y, SpellbookScreen.TITLE_COLOR); font.draw(matrices, manaString, -font.getWidth(manaString) / 2, y += font.fontHeight, SpellbookScreen.TITLE_COLOR); - Text levelString = I18n.hasTranslation("enchantment.level." + (currentLevel + 1)) ? Text.translatable("enchantment.level." + (currentLevel + 1)) : Text.literal(currentLevel >= 999 ? ">999" : "" + (currentLevel + 1)); + Text levelString = I18n.hasTranslation("enchantment.level." + (currentLevel + 1)) ? new TranslatableText("enchantment.level." + (currentLevel + 1)) : new LiteralText(currentLevel >= 999 ? ">999" : "" + (currentLevel + 1)); matrices.translate(-font.getWidth(levelString), -35, 0); matrices.scale(2F, 2F, 1); diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookScreen.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookScreen.java index 222bb210..5f30f30e 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookScreen.java @@ -202,6 +202,10 @@ public class SpellbookScreen extends HandledScreen imple protected void drawForeground(MatrixStack matrices, int mouseX, int mouseY) { } + public void clearAndInit() { + init(client, width, height); + } + @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { return tabs.getAllTabs().anyMatch(tab -> { @@ -244,6 +248,7 @@ public class SpellbookScreen extends HandledScreen imple getStyle().setIcon(sprite); onClick(sender -> { pageAction.accept(increment); + screen.init(); screen.clearAndInit(); }); } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookTraitDexPageContent.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookTraitDexPageContent.java index 304cc471..f4b4f4ab 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookTraitDexPageContent.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookTraitDexPageContent.java @@ -20,7 +20,7 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.*; -import net.minecraft.text.Text; +import net.minecraft.text.*; import net.minecraft.util.Identifier; import net.minecraft.util.Util; import net.minecraft.util.collection.DefaultedList; @@ -104,9 +104,9 @@ public class SpellbookTraitDexPageContent extends DrawableHelper implements Spel addButton(new TraitButton(width / 2 - 8, 8, trait)); addButton(new Label(width / 2, 26).setCentered()) .getStyle() - .setText(known ? Text.translatable("gui.unicopia.trait.label", - Text.translatable("trait." + trait.getId().getNamespace() + "." + trait.getId().getPath() + ".name") - ) : Text.literal("???")); + .setText(known ? new TranslatableText("gui.unicopia.trait.label", + new TranslatableText("trait." + trait.getId().getNamespace() + "." + trait.getId().getPath() + ".name") + ) : new LiteralText("???")); IngredientTree tree = new IngredientTree(0, 50, width + 18).noLabels(); List knownItems = Pony.of(MinecraftClient.getInstance().player).getDiscoveries().getKnownItems(trait).toList(); diff --git a/src/main/java/com/minelittlepony/unicopia/client/particle/LightningBoltParticle.java b/src/main/java/com/minelittlepony/unicopia/client/particle/LightningBoltParticle.java index a2194589..55935a9c 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/particle/LightningBoltParticle.java +++ b/src/main/java/com/minelittlepony/unicopia/client/particle/LightningBoltParticle.java @@ -58,9 +58,9 @@ public class LightningBoltParticle extends AbstractGeometryBasedParticle { while (nodes.size() < intendedLength) { startPos = startPos.add( - world.random.nextTriangular(0.1, 3), - world.random.nextTriangular(0.1, 3), - world.random.nextTriangular(0.1, 3) + 0.1 + world.random.nextDouble(6) - 3, + 0.1 + world.random.nextDouble(6) - 3, + 0.1 + world.random.nextDouble(6) - 3 ); nodes.add(startPos); diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/IcarusWingsFeatureRenderer.java b/src/main/java/com/minelittlepony/unicopia/client/render/IcarusWingsFeatureRenderer.java index 94fc1355..4402ed43 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/IcarusWingsFeatureRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/IcarusWingsFeatureRenderer.java @@ -23,6 +23,6 @@ public class IcarusWingsFeatureRenderer extends WingsFea @Override protected Identifier getTexture(E entity) { - return entity.world.getDimension().ultrawarm() ? ICARUS_WINGS_CORRUPTED : ICARUS_WINGS; + return entity.world.getDimension().isUltrawarm() ? ICARUS_WINGS_CORRUPTED : ICARUS_WINGS; } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/sound/FadeOutSoundInstance.java b/src/main/java/com/minelittlepony/unicopia/client/sound/FadeOutSoundInstance.java index 4c77afcc..cef0864d 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/sound/FadeOutSoundInstance.java +++ b/src/main/java/com/minelittlepony/unicopia/client/sound/FadeOutSoundInstance.java @@ -1,11 +1,12 @@ package com.minelittlepony.unicopia.client.sound; +import java.util.Random; + import net.minecraft.client.MinecraftClient; import net.minecraft.client.sound.MovingSoundInstance; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvent; import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.random.Random; public abstract class FadeOutSoundInstance extends MovingSoundInstance { @@ -21,7 +22,7 @@ public abstract class FadeOutSoundInstance extends MovingSoundInstance { private boolean fadingOut; public FadeOutSoundInstance(SoundEvent sound, SoundCategory category, float volume, Random random) { - super(sound, category, random); + super(sound, category); this.relative = true; this.repeat = true; this.volume = volume; @@ -72,6 +73,6 @@ public abstract class FadeOutSoundInstance extends MovingSoundInstance { @Override public final float getVolume() { - return getLerpedVolume() * sound.getVolume().get(field_38800); + return getLerpedVolume() * sound.getVolume(); } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/sound/LoopedEntityTrackingSoundInstance.java b/src/main/java/com/minelittlepony/unicopia/client/sound/LoopedEntityTrackingSoundInstance.java index 54354909..fe045ee6 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/sound/LoopedEntityTrackingSoundInstance.java +++ b/src/main/java/com/minelittlepony/unicopia/client/sound/LoopedEntityTrackingSoundInstance.java @@ -6,7 +6,7 @@ import net.minecraft.sound.SoundEvent; public class LoopedEntityTrackingSoundInstance extends EntityTrackingSoundInstance { public LoopedEntityTrackingSoundInstance(SoundEvent soundEvent, float volume, float pitch, Entity entity, long seed) { - super(soundEvent, entity.getSoundCategory(), volume, pitch, entity, seed); + super(soundEvent, entity.getSoundCategory(), volume, pitch, entity); this.repeat = true; this.repeatDelay = 0; } diff --git a/src/main/java/com/minelittlepony/unicopia/client/sound/LoopingSoundInstance.java b/src/main/java/com/minelittlepony/unicopia/client/sound/LoopingSoundInstance.java index 111509c1..e5e20ab7 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/sound/LoopingSoundInstance.java +++ b/src/main/java/com/minelittlepony/unicopia/client/sound/LoopingSoundInstance.java @@ -1,11 +1,11 @@ package com.minelittlepony.unicopia.client.sound; +import java.util.Random; import java.util.function.Predicate; import net.minecraft.client.sound.SoundInstance; import net.minecraft.entity.Entity; import net.minecraft.sound.SoundEvent; -import net.minecraft.util.math.random.Random; public class LoopingSoundInstance extends FadeOutSoundInstance { diff --git a/src/main/java/com/minelittlepony/unicopia/client/sound/MagicAuraSoundInstance.java b/src/main/java/com/minelittlepony/unicopia/client/sound/MagicAuraSoundInstance.java index d01b9504..83e823d8 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/sound/MagicAuraSoundInstance.java +++ b/src/main/java/com/minelittlepony/unicopia/client/sound/MagicAuraSoundInstance.java @@ -1,6 +1,7 @@ package com.minelittlepony.unicopia.client.sound; import java.util.Optional; +import java.util.Random; import com.minelittlepony.unicopia.USounds; import com.minelittlepony.unicopia.entity.Living; @@ -9,7 +10,6 @@ import com.minelittlepony.unicopia.item.enchantment.UEnchantments; import net.minecraft.sound.SoundCategory; import net.minecraft.util.math.Vec3d; -import net.minecraft.util.math.random.Random; public class MagicAuraSoundInstance extends FadeOutSoundInstance { diff --git a/src/main/java/com/minelittlepony/unicopia/client/sound/MotionBasedSoundInstance.java b/src/main/java/com/minelittlepony/unicopia/client/sound/MotionBasedSoundInstance.java index 80823061..6f6e83bf 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/sound/MotionBasedSoundInstance.java +++ b/src/main/java/com/minelittlepony/unicopia/client/sound/MotionBasedSoundInstance.java @@ -1,11 +1,12 @@ package com.minelittlepony.unicopia.client.sound; +import java.util.Random; + import com.minelittlepony.unicopia.entity.player.Pony; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.sound.SoundEvent; import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.random.Random; public class MotionBasedSoundInstance extends FadeOutSoundInstance { diff --git a/src/main/java/com/minelittlepony/unicopia/command/Commands.java b/src/main/java/com/minelittlepony/unicopia/command/Commands.java index d1310f89..7b78a023 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/Commands.java +++ b/src/main/java/com/minelittlepony/unicopia/command/Commands.java @@ -1,22 +1,20 @@ package com.minelittlepony.unicopia.command; -import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; +import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback; -import com.minelittlepony.unicopia.Unicopia; - -import net.fabricmc.fabric.api.command.v2.ArgumentTypeRegistry; import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.command.argument.ArgumentTypes; import net.minecraft.server.MinecraftServer; public class Commands { @SuppressWarnings({ "deprecation", "unchecked", "rawtypes" }) public static void bootstrap() { - ArgumentTypeRegistry.registerArgumentType( - Unicopia.id("enumeration"), + ArgumentTypes.register( + "unicopia:enumeration", EnumArgumentType.class, new EnumArgumentType.Serializer() ); - CommandRegistrationCallback.EVENT.register((dispatcher, access, environment) -> { + CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> { SpeciesCommand.register(dispatcher); RacelistCommand.register(dispatcher); GravityCommand.register(dispatcher); diff --git a/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java b/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java index 56af4365..8b93e36c 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java @@ -26,12 +26,12 @@ import net.minecraft.nbt.NbtCompound; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; import net.minecraft.util.Identifier; import net.minecraft.world.GameRules; public class DisguiseCommand { - private static final SimpleCommandExceptionType FAILED_EXCEPTION = new SimpleCommandExceptionType(Text.translatable("commands.disguise.notfound")); + private static final SimpleCommandExceptionType FAILED_EXCEPTION = new SimpleCommandExceptionType(new TranslatableText("commands.disguise.notfound")); public static void register(CommandDispatcher dispatcher) { dispatcher.register(CommandManager @@ -87,13 +87,13 @@ public class DisguiseCommand { .setDisguise(entity); if (source.getEntity() == player) { - source.sendFeedback(Text.translatable("commands.disguise.success.self", entity.getName()), true); + source.sendFeedback(new TranslatableText("commands.disguise.success.self", entity.getName()), true); } else { if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) { - player.sendMessage(Text.translatable("commands.disguise.success", entity.getName())); + player.sendMessage(new TranslatableText("commands.disguise.success", entity.getName()), false); } - source.sendFeedback(Text.translatable("commands.disguise.success.other", player.getName(), entity.getName()), true); + source.sendFeedback(new TranslatableText("commands.disguise.success.other", player.getName(), entity.getName()), true); } return 0; @@ -114,13 +114,13 @@ public class DisguiseCommand { iplayer.getSpellSlot().removeIf(SpellPredicate.IS_DISGUISE, true); if (source.getEntity() == player) { - source.sendFeedback(Text.translatable("commands.disguise.removed.self"), true); + source.sendFeedback(new TranslatableText("commands.disguise.removed.self"), true); } else { if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) { - player.sendMessage(Text.translatable("commands.disguise.removed")); + player.sendMessage(new TranslatableText("commands.disguise.removed"), false); } - source.sendFeedback(Text.translatable("commands.disguise.removed.other", player.getName()), true); + source.sendFeedback(new TranslatableText("commands.disguise.removed.other", player.getName()), true); } return 0; diff --git a/src/main/java/com/minelittlepony/unicopia/command/EnumArgumentType.java b/src/main/java/com/minelittlepony/unicopia/command/EnumArgumentType.java index eeee14ea..349f036f 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/EnumArgumentType.java +++ b/src/main/java/com/minelittlepony/unicopia/command/EnumArgumentType.java @@ -20,9 +20,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder; import io.netty.buffer.ByteBufInputStream; import io.netty.buffer.ByteBufOutputStream; -import net.minecraft.command.CommandRegistryAccess; import net.minecraft.command.argument.serialize.ArgumentSerializer; -import net.minecraft.command.argument.serialize.ArgumentSerializer.ArgumentTypeProperties; import net.minecraft.network.PacketByteBuf; class EnumArgumentType> implements ArgumentType, Serializable { @@ -95,52 +93,28 @@ class EnumArgumentType> implements ArgumentType, Serializab return suggestions; } - public static class Serializer> implements ArgumentSerializer, Serializer.Properties> { + public static class Serializer> implements ArgumentSerializer> { @SuppressWarnings("unchecked") @Override - public Properties fromPacket(PacketByteBuf buf) { + public EnumArgumentType fromPacket(PacketByteBuf buf) { try (ObjectInputStream stream = new ObjectInputStream(new ByteBufInputStream(buf))) { - return getArgumentTypeProperties((EnumArgumentType)stream.readObject()); + return (EnumArgumentType)stream.readObject(); } catch (IOException | ClassNotFoundException e) { throw new RuntimeException(e); } } @Override - public void writePacket(Properties properties, PacketByteBuf buf) { + public void toPacket(EnumArgumentType type, PacketByteBuf buf) { try (ObjectOutputStream stream = new ObjectOutputStream(new ByteBufOutputStream(buf))) { - stream.writeObject(properties.type); + stream.writeObject(type); } catch (IOException e) { throw new RuntimeException(e); } } @Override - public void writeJson(Properties properties, JsonObject json) { - } - - @Override - public Properties getArgumentTypeProperties(EnumArgumentType type) { - return new Properties(type); - } - - public final class Properties implements ArgumentTypeProperties> { - - private final EnumArgumentType type; - - public Properties(EnumArgumentType type) { - this.type = type; - } - - @Override - public EnumArgumentType createType(CommandRegistryAccess var1) { - return type; - } - - @Override - public ArgumentSerializer, ?> getSerializer() { - return Serializer.this; - } + public void toJson(EnumArgumentType var1, JsonObject var2) { } } } \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/unicopia/command/GravityCommand.java b/src/main/java/com/minelittlepony/unicopia/command/GravityCommand.java index 88b9cfaf..eb063514 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/GravityCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/GravityCommand.java @@ -10,7 +10,7 @@ import net.minecraft.command.argument.EntityArgumentType; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; import net.minecraft.world.GameRules; class GravityCommand { @@ -43,9 +43,9 @@ class GravityCommand { float gravity = iplayer.getPhysics().getGravityModifier(); if (source.getPlayer() == player) { - player.sendMessage(Text.translatable(translationKey, gravity), false); + player.sendMessage(new TranslatableText(translationKey, gravity), false); } else { - source.sendFeedback(Text.translatable(translationKey + ".other", player.getName(), gravity), true); + source.sendFeedback(new TranslatableText(translationKey + ".other", player.getName(), gravity), true); } return 0; @@ -60,13 +60,13 @@ class GravityCommand { iplayer.setDirty(); if (source.getEntity() == player) { - source.sendFeedback(Text.translatable("commands.gamemode.success.self", gravity), true); + source.sendFeedback(new TranslatableText("commands.gamemode.success.self", gravity), true); } else { if (source.getWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) { - player.sendMessage(Text.translatable(translationKey, gravity)); + player.sendMessage(new TranslatableText(translationKey, gravity), false); } - source.sendFeedback(Text.translatable(translationKey + ".other", player.getName(), gravity), true); + source.sendFeedback(new TranslatableText(translationKey + ".other", player.getName(), gravity), true); } return 0; diff --git a/src/main/java/com/minelittlepony/unicopia/command/ManaCommand.java b/src/main/java/com/minelittlepony/unicopia/command/ManaCommand.java index 3bc9725f..3b50f2f0 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/ManaCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/ManaCommand.java @@ -8,7 +8,7 @@ import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.FloatArgumentType; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.text.Text; +import net.minecraft.text.LiteralText; public class ManaCommand { static void register(CommandDispatcher dispatcher) { @@ -19,7 +19,7 @@ public class ManaCommand { var pony = Pony.of(source.getSource().getPlayer()); var bar = type.getBar(pony.getMagicalReserves()); - source.getSource().getPlayer().sendMessage(Text.literal(type.name() + " is " + bar.get() + "/" + bar.getMax())); + source.getSource().getPlayer().sendMessage(new LiteralText(type.name() + " is " + bar.get() + "/" + bar.getMax()), false); return 0; }) .then(CommandManager.argument("value", FloatArgumentType.floatArg()).executes(source -> { @@ -28,7 +28,7 @@ public class ManaCommand { var bar = type.getBar(pony.getMagicalReserves()); bar.set(source.getArgument("value", Float.class)); - source.getSource().getPlayer().sendMessage(Text.literal("Set " + type.name() + " to " + bar.get() + "/" + bar.getMax())); + source.getSource().getPlayer().sendMessage(new LiteralText("Set " + type.name() + " to " + bar.get() + "/" + bar.getMax()), false); return 0; })) ) diff --git a/src/main/java/com/minelittlepony/unicopia/command/RacelistCommand.java b/src/main/java/com/minelittlepony/unicopia/command/RacelistCommand.java index 3560df6a..359a8b9f 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/RacelistCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/RacelistCommand.java @@ -12,6 +12,7 @@ import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; import net.minecraft.util.Formatting; class RacelistCommand { @@ -54,7 +55,7 @@ class RacelistCommand { Text formattedName = race.getDisplayName().copy().formatted(Formatting.GOLD); - source.sendFeedback(Text.translatable(translationKey, formattedName).formatted(Formatting.GREEN), false); + source.sendFeedback(new TranslatableText(translationKey, formattedName).formatted(Formatting.GREEN), false); return 0; } } diff --git a/src/main/java/com/minelittlepony/unicopia/command/SpeciesCommand.java b/src/main/java/com/minelittlepony/unicopia/command/SpeciesCommand.java index bc4e04aa..78c1041c 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/SpeciesCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/SpeciesCommand.java @@ -10,8 +10,7 @@ import net.minecraft.command.argument.RegistryKeyArgumentType; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.text.MutableText; -import net.minecraft.text.Text; +import net.minecraft.text.*; import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; import net.minecraft.world.GameRules; @@ -55,15 +54,15 @@ class SpeciesCommand { pony.setDirty(); if (!isSelf) { - source.sendFeedback(Text.translatable("commands.race.success.other", player.getName(), race.getDisplayName()), true); + source.sendFeedback(new TranslatableText("commands.race.success.other", player.getName(), race.getDisplayName()), true); } else { if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) { - player.sendMessage(Text.translatable("commands.race.success.self"), false); + player.sendMessage(new TranslatableText("commands.race.success.self"), false); } - source.sendFeedback(Text.translatable("commands.race.success.otherself", player.getName(), race.getDisplayName()), true); + source.sendFeedback(new TranslatableText("commands.race.success.otherself", player.getName(), race.getDisplayName()), true); } } else if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) { - player.sendMessage(Text.translatable("commands.race.permission"), false); + player.sendMessage(new TranslatableText("commands.race.permission"), false); } return 0; @@ -75,22 +74,22 @@ class SpeciesCommand { String name = "commands.race.tell."; name += isSelf ? "self" : "other"; - player.sendMessage(Text.translatable(name) - .append(Text.translatable(spec.getTranslationKey()) + player.sendMessage(new TranslatableText(name) + .append(new TranslatableText(spec.getTranslationKey()) .styled(s -> s.withColor(Formatting.GOLD))), false); return 0; } static int list(PlayerEntity player) { - player.sendMessage(Text.translatable("commands.race.list"), false); + player.sendMessage(new TranslatableText("commands.race.list"), false); - MutableText message = Text.literal(""); + MutableText message = new LiteralText(""); boolean first = true; for (Race i : Race.REGISTRY) { if (!i.isDefault() && i.isPermitted(player)) { - message.append(Text.literal((!first ? "\n" : "") + " - ")); + message.append(new LiteralText((!first ? "\n" : "") + " - ")); message.append(i.getDisplayName()); first = false; } @@ -104,9 +103,9 @@ class SpeciesCommand { static int describe(PlayerEntity player, Race species) { Identifier id = Race.REGISTRY.getId(species); - player.sendMessage(Text.translatable(String.format("commands.race.describe.%s.%s.1", id.getNamespace(), id.getPath())).styled(s -> s.withColor(Formatting.YELLOW)), false); - player.sendMessage(Text.translatable(String.format("commands.race.describe.%s.%s.2", id.getNamespace(), id.getPath())), false); - player.sendMessage(Text.translatable(String.format("commands.race.describe.%s.%s.3", id.getNamespace(), id.getPath())).styled(s -> s.withColor(Formatting.RED)), false); + player.sendMessage(new TranslatableText(String.format("commands.race.describe.%s.%s.1", id.getNamespace(), id.getPath())).styled(s -> s.withColor(Formatting.YELLOW)), false); + player.sendMessage(new TranslatableText(String.format("commands.race.describe.%s.%s.2", id.getNamespace(), id.getPath())), false); + player.sendMessage(new TranslatableText(String.format("commands.race.describe.%s.%s.3", id.getNamespace(), id.getPath())).styled(s -> s.withColor(Formatting.RED)), false); return 0; } diff --git a/src/main/java/com/minelittlepony/unicopia/command/TraitCommand.java b/src/main/java/com/minelittlepony/unicopia/command/TraitCommand.java index 828afe6e..d7c95920 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/TraitCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/TraitCommand.java @@ -43,13 +43,13 @@ class TraitCommand { static int add(ServerCommandSource source, PlayerEntity player, Trait trait, float amount) throws CommandSyntaxException { if (trait == null) { - source.sendError(Text.literal("Invalid trait")); + source.sendError(new LiteralText("Invalid trait")); return 0; } ItemStack stack = player.getMainHandStack(); if (stack.isEmpty()) { - source.sendError(Text.literal("That trait cannot be added to the current item")); + source.sendError(new LiteralText("That trait cannot be added to the current item")); return 0; } @@ -60,7 +60,7 @@ class TraitCommand { static int remove(ServerCommandSource source, PlayerEntity player, Trait trait) throws CommandSyntaxException { if (trait == null) { - source.sendError(Text.literal("Invalid trait")); + source.sendError(new LiteralText("Invalid trait")); return 0; } @@ -84,9 +84,9 @@ class TraitCommand { float gravity = iplayer.getPhysics().getGravityModifier(); if (source.getPlayer() == player) { - player.sendMessage(Text.translatable(translationKey, gravity), false); + player.sendMessage(new TranslatableText(translationKey, gravity), false); } else { - source.sendFeedback(Text.translatable(translationKey + ".other", player.getName(), gravity), true); + source.sendFeedback(new TranslatableText(translationKey + ".other", player.getName(), gravity), true); } return 0; diff --git a/src/main/java/com/minelittlepony/unicopia/container/SpellbookChapterLoader.java b/src/main/java/com/minelittlepony/unicopia/container/SpellbookChapterLoader.java index b6181928..4727a3d6 100644 --- a/src/main/java/com/minelittlepony/unicopia/container/SpellbookChapterLoader.java +++ b/src/main/java/com/minelittlepony/unicopia/container/SpellbookChapterLoader.java @@ -1,7 +1,6 @@ package com.minelittlepony.unicopia.container; import java.util.*; -import java.util.concurrent.*; import java.util.stream.Collectors; import java.util.stream.StreamSupport; @@ -29,7 +28,7 @@ import net.minecraft.util.profiler.Profiler; public class SpellbookChapterLoader extends JsonDataLoader implements IdentifiableResourceReloadListener { private static final Logger LOGGER = LogUtils.getLogger(); private static final Identifier ID = Unicopia.id("spellbook/chapters"); - private static final Executor EXECUTOR = CompletableFuture.delayedExecutor(5, TimeUnit.SECONDS); + //private static final Executor EXECUTOR = CompletableFuture.delayedExecutor(5, TimeUnit.SECONDS); public static boolean DEBUG = false; public static final SpellbookChapterLoader INSTANCE = new SpellbookChapterLoader(); @@ -73,7 +72,7 @@ public class SpellbookChapterLoader extends JsonDataLoader implements Identifiab LOGGER.error("Could not load spellbook chapters due to exception", e); } - if (DEBUG) { + /*if (DEBUG) { CompletableFuture.runAsync(() -> { try { Util.waitAndApply(executor -> reload(CompletableFuture::completedFuture, manager, profiler, profiler, Util.getMainWorkerExecutor(), executor)).get(); @@ -81,7 +80,7 @@ public class SpellbookChapterLoader extends JsonDataLoader implements Identifiab } dirty = true; }, EXECUTOR); - } + }*/ } public record Chapter ( diff --git a/src/main/java/com/minelittlepony/unicopia/container/UScreenHandlers.java b/src/main/java/com/minelittlepony/unicopia/container/UScreenHandlers.java index 07f99b2b..54f55ce5 100644 --- a/src/main/java/com/minelittlepony/unicopia/container/UScreenHandlers.java +++ b/src/main/java/com/minelittlepony/unicopia/container/UScreenHandlers.java @@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.container; import com.minelittlepony.unicopia.Unicopia; -import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerType; +import net.fabricmc.fabric.impl.screenhandler.ExtendedScreenHandlerType; import net.minecraft.screen.ScreenHandler; import net.minecraft.screen.ScreenHandlerType; import net.minecraft.util.registry.Registry; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ButterflyEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/ButterflyEntity.java index deb7f9ba..ae67b723 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ButterflyEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ButterflyEntity.java @@ -1,8 +1,6 @@ package com.minelittlepony.unicopia.entity; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; +import java.util.*; import org.jetbrains.annotations.Nullable; @@ -31,7 +29,6 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; -import net.minecraft.util.math.random.Random; import net.minecraft.world.World; import net.minecraft.world.WorldAccess; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/CastSpellEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/CastSpellEntity.java index b0c1f30a..dcb60ae3 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/CastSpellEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/CastSpellEntity.java @@ -20,6 +20,7 @@ import net.minecraft.entity.data.TrackedDataHandlerRegistry; import net.minecraft.nbt.NbtCompound; import net.minecraft.network.Packet; import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; import net.minecraft.world.World; public class CastSpellEntity extends LightEmittingEntity implements Caster, WeaklyOwned { @@ -53,7 +54,7 @@ public class CastSpellEntity extends LightEmittingEntity implements Caster, Owned { private static final TrackedData ITEM_RACE = DataTracker.registerData(ItemEntity.class, TrackedDataHandlerRegistry.STRING); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/Living.java b/src/main/java/com/minelittlepony/unicopia/entity/Living.java index fe2a3313..bb4512ab 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/Living.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/Living.java @@ -124,7 +124,7 @@ public abstract class Living implements Equine, Caste DragonBreathStore store = DragonBreathStore.get(entity.world); String name = entity.getDisplayName().getString(); store.popEntries(name).forEach(stack -> { - Vec3d randomPos = targetPos.add(VecHelper.supply(() -> entity.getRandom().nextTriangular(0.1, 0.5))); + Vec3d randomPos = targetPos.add(VecHelper.supply(() -> 0.1 + entity.getRandom().nextDouble(1) - 0.5)); if (!entity.getWorld().isAir(new BlockPos(randomPos))) { store.put(name, stack.payload()); @@ -132,7 +132,7 @@ public abstract class Living implements Equine, Caste for (int i = 0; i < 10; i++) { ParticleUtils.spawnParticle(entity.world, ParticleTypes.FLAME, randomPos.add( - VecHelper.supply(() -> entity.getRandom().nextTriangular(0.1, 0.5)) + VecHelper.supply(() -> 0.1 + entity.getRandom().nextDouble(1) - 0.5) ), Vec3d.ZERO); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/UTradeOffers.java b/src/main/java/com/minelittlepony/unicopia/entity/UTradeOffers.java index 8d4b6319..8b52020f 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/UTradeOffers.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/UTradeOffers.java @@ -1,5 +1,7 @@ package com.minelittlepony.unicopia.entity; +import java.util.Random; + import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.UTags; @@ -16,7 +18,6 @@ import net.minecraft.item.Items; import net.minecraft.tag.ItemTags; import net.minecraft.tag.TagKey; import net.minecraft.util.Util; -import net.minecraft.util.math.random.Random; import net.minecraft.village.TradeOffer; import net.minecraft.village.TradeOffers; import net.minecraft.village.VillagerProfession; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/Disguise.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/Disguise.java index d0f7e9ba..f6790006 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/Disguise.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/Disguise.java @@ -113,7 +113,7 @@ public interface Disguise extends FlightType.Provider, PlayerDimensions.Provider } static abstract class PlayerAccess extends PlayerEntity { - public PlayerAccess() { super(null, null, 0, null, null); } + public PlayerAccess() { super(null, null, 0, null); } static TrackedData getModelBitFlag() { return PLAYER_MODEL_PARTS; } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SheepBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SheepBehaviour.java index 5d67e1ef..8c3058c7 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SheepBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SheepBehaviour.java @@ -1,5 +1,7 @@ package com.minelittlepony.unicopia.entity.behaviour; +import java.util.Random; + import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.mixin.MixinSheepEntity; @@ -12,7 +14,6 @@ import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; import net.minecraft.sound.SoundEvents; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.random.Random; import net.minecraft.world.WorldEvents; public class SheepBehaviour extends EntityBehaviour { diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SteedBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SteedBehaviour.java index 43ed9904..9af70a44 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SteedBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SteedBehaviour.java @@ -4,7 +4,7 @@ import com.minelittlepony.unicopia.entity.player.Pony; import net.minecraft.entity.passive.*; -public class SteedBehaviour extends EntityBehaviour { +public class SteedBehaviour extends EntityBehaviour { @Override public void update(Pony player, T horse, Disguise spell) { diff --git a/src/main/java/com/minelittlepony/unicopia/entity/effect/RaceChangeStatusEffect.java b/src/main/java/com/minelittlepony/unicopia/entity/effect/RaceChangeStatusEffect.java index a760af55..d583c5dc 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/effect/RaceChangeStatusEffect.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/effect/RaceChangeStatusEffect.java @@ -15,6 +15,7 @@ import net.minecraft.entity.effect.*; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.particle.ParticleTypes; import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; @@ -150,7 +151,7 @@ public class RaceChangeStatusEffect extends StatusEffect { } public Text getMessage(Race race) { - return Text.translatable(getTranslationKey(), race.getDisplayName()); + return new TranslatableText(getTranslationKey(), race.getDisplayName()); } } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/effect/SunBlindnessStatusEffect.java b/src/main/java/com/minelittlepony/unicopia/entity/effect/SunBlindnessStatusEffect.java index 3b681d00..8263e5ce 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/effect/SunBlindnessStatusEffect.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/effect/SunBlindnessStatusEffect.java @@ -51,7 +51,7 @@ public class SunBlindnessStatusEffect extends StatusEffect { public static boolean hasSunExposure(LivingEntity entity) { - if (entity.hasPortalCooldown()) { + if (entity.hasNetherPortalCooldown()) { return false; } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerCharmTracker.java b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerCharmTracker.java index 3db6efc8..2b2598c6 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerCharmTracker.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerCharmTracker.java @@ -70,7 +70,7 @@ public class PlayerCharmTracker implements Tickable, NbtSerialisable { } public TypedActionResult> getSpellInHand(Hand hand) { - return Streams.stream(pony.getMaster().getHandItems()) + return Streams.stream(pony.getMaster().getItemsHand()) .filter(GemstoneItem::isEnchanted) .map(stack -> GemstoneItem.consumeSpell(stack, pony.getMaster(), null)) .findFirst() diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java index 25b3f0b5..c1a91a7f 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java @@ -192,7 +192,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab if (typeChanged) { pony.spawnParticles(ParticleTypes.CLOUD, 10); - entity.playSound(entity.world.getDimension().ultrawarm() ? USounds.ITEM_ICARUS_WINGS_CORRUPT : USounds.ITEM_ICARUS_WINGS_PURIFY, 0.1125F, 1.5F); + entity.playSound(entity.world.getDimension().isUltrawarm() ? USounds.ITEM_ICARUS_WINGS_CORRUPT : USounds.ITEM_ICARUS_WINGS_PURIFY, 0.1125F, 1.5F); } entity.getAbilities().allowFlying = type.canFlyCreative(entity); @@ -369,7 +369,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab if (entity.world.hasRain(entity.getBlockPos())) { energyConsumed *= 3; } - if (entity.world.getDimension().ultrawarm()) { + if (entity.world.getDimension().isUltrawarm()) { energyConsumed *= 4; damageInterval /= 2; minDamage *= 3; 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 73bc9d18..ca77396d 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java @@ -58,6 +58,7 @@ import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.SoundEvents; import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; import net.minecraft.util.Hand; import net.minecraft.util.math.*; @@ -369,7 +370,7 @@ public class Pony extends Living implements Transmittable, Copieab ticksHanging = 0; } - if (getSpecies() == Race.BAT && !entity.hasPortalCooldown()) { + if (getSpecies() == Race.BAT && !entity.hasNetherPortalCooldown()) { if (SunBlindnessStatusEffect.hasSunExposure(entity)) { if (ticksInSun < 200) { ticksInSun++; @@ -448,7 +449,6 @@ public class Pony extends Living implements Transmittable, Copieab return Optional.empty(); } - @SuppressWarnings("deprecation") @Override protected void handleFall(float distance, float damageMultiplier, DamageSource cause) { super.handleFall(distance, damageMultiplier, cause); @@ -529,13 +529,13 @@ public class Pony extends Living implements Transmittable, Copieab public Optional trySleep(BlockPos pos) { if (UItems.ALICORN_AMULET.isApplicable(entity)) { - return Optional.of(Text.translatable("block.unicopia.bed.not_tired")); + return Optional.of(new TranslatableText("block.unicopia.bed.not_tired")); } return findAllSpellsInRange(10) .filter(p -> p instanceof Pony && ((Pony)p).isEnemy(this)) .findFirst() - .map(p -> Text.translatable("block.unicopia.bed.not_safe")); + .map(p -> new TranslatableText("block.unicopia.bed.not_safe")); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/dummy/DummyClientPlayerEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/player/dummy/DummyClientPlayerEntity.java index 582bf617..af23246e 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/dummy/DummyClientPlayerEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/dummy/DummyClientPlayerEntity.java @@ -17,7 +17,7 @@ import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.network.packet.s2c.play.PlayerListS2CPacket; -import net.minecraft.text.Text; +import net.minecraft.text.LiteralText; import net.minecraft.world.GameMode; public class DummyClientPlayerEntity extends AbstractClientPlayerEntity implements Owned { @@ -27,7 +27,7 @@ public class DummyClientPlayerEntity extends AbstractClientPlayerEntity implemen private PlayerEntity owner; public DummyClientPlayerEntity(ClientWorld world, GameProfile profile) { - super(world, profile, null); + super(world, profile); } @Override @@ -49,7 +49,7 @@ public class DummyClientPlayerEntity extends AbstractClientPlayerEntity implemen playerInfo = connection.getPlayerListEntry(getGameProfile().getId()); if (playerInfo == null) { - playerInfo = new PlayerListEntry(new Packet().entry(), MinecraftClient.getInstance().getServicesSignatureVerifier(), false); + playerInfo = new PlayerListEntry(new Packet().entry()); } } @@ -57,7 +57,7 @@ public class DummyClientPlayerEntity extends AbstractClientPlayerEntity implemen } @Override - protected void playEquipSound(ItemStack stack) { + protected void onEquipStack(ItemStack stack) { /*noop*/ } @@ -87,7 +87,7 @@ public class DummyClientPlayerEntity extends AbstractClientPlayerEntity implemen getGameProfile(), 0, GameMode.DEFAULT, - Text.literal(getGameProfile().getName()), null); + new LiteralText(getGameProfile().getName())); } } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/dummy/DummyPlayerEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/player/dummy/DummyPlayerEntity.java index 07b8c1bb..a4caa6a4 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/dummy/DummyPlayerEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/dummy/DummyPlayerEntity.java @@ -16,11 +16,11 @@ public class DummyPlayerEntity extends PlayerEntity implements Owned 0) { - tooltip.add(Text.translatable(getTranslationKey() + ".lore", StringHelper.formatTicks(attachedTime))); + tooltip.add(new TranslatableText(getTranslationKey() + ".lore", StringHelper.formatTicks(attachedTime))); } } } diff --git a/src/main/java/com/minelittlepony/unicopia/item/AmuletItem.java b/src/main/java/com/minelittlepony/unicopia/item/AmuletItem.java index 122815b3..ec5b38e2 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/AmuletItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/AmuletItem.java @@ -23,10 +23,7 @@ import net.minecraft.item.ArmorMaterials; import net.minecraft.item.ItemStack; import net.minecraft.particle.ParticleTypes; import net.minecraft.sound.SoundEvent; -import net.minecraft.text.MutableText; -import net.minecraft.text.StringVisitable; -import net.minecraft.text.Style; -import net.minecraft.text.Text; +import net.minecraft.text.*; import net.minecraft.util.Formatting; import net.minecraft.world.World; @@ -53,7 +50,7 @@ public class AmuletItem extends WearableItem { && entity instanceof LivingEntity && ((LivingEntity) entity).getEquippedStack(EquipmentSlot.CHEST) == stack && isApplicable((LivingEntity)entity)) { - ParticleUtils.spawnParticles(entity.world.getDimension().ultrawarm() ? ParticleTypes.SOUL_FIRE_FLAME : ParticleTypes.COMPOSTER, entity, 1); + ParticleUtils.spawnParticles(entity.world.getDimension().isUltrawarm() ? ParticleTypes.SOUL_FIRE_FLAME : ParticleTypes.COMPOSTER, entity, 1); } } @@ -61,8 +58,8 @@ public class AmuletItem extends WearableItem { public void appendTooltip(ItemStack stack, @Nullable World world, List list, TooltipContext tooltipContext) { for (StringVisitable line : MinecraftClient.getInstance().textRenderer.getTextHandler().wrapLines( - Text.translatable(getTranslationKey(stack) + ".lore"), 150, Style.EMPTY)) { - MutableText compiled = Text.literal("").formatted(Formatting.ITALIC, Formatting.GRAY); + new TranslatableText(getTranslationKey(stack) + ".lore"), 150, Style.EMPTY)) { + MutableText compiled = new LiteralText("").formatted(Formatting.ITALIC, Formatting.GRAY); line.visit(s -> { compiled.append(s); return Optional.empty(); @@ -71,7 +68,7 @@ public class AmuletItem extends WearableItem { } if (isChargable()) { - list.add(Text.translatable("item.unicopia.amulet.energy", (int)Math.floor(getEnergy(stack)), maxEnergy)); + list.add(new TranslatableText("item.unicopia.amulet.energy", (int)Math.floor(getEnergy(stack)), maxEnergy)); } } diff --git a/src/main/java/com/minelittlepony/unicopia/item/FilledJarItem.java b/src/main/java/com/minelittlepony/unicopia/item/FilledJarItem.java index 82a442c2..5a99c001 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/FilledJarItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/FilledJarItem.java @@ -19,6 +19,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.particle.ParticleTypes; import net.minecraft.server.world.ServerWorld; import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; import net.minecraft.util.ActionResult; import net.minecraft.util.math.MathHelper; import net.minecraft.world.WorldEvents; @@ -31,7 +32,7 @@ public class FilledJarItem extends JarItem implements ChameleonItem { @Override public Text getName(ItemStack stack) { - return hasAppearance(stack) ? Text.translatable(getTranslationKey(stack), getAppearanceStack(stack).getName()) : UItems.EMPTY_JAR.getName(UItems.EMPTY_JAR.getDefaultStack()); + return hasAppearance(stack) ? new TranslatableText(getTranslationKey(stack), getAppearanceStack(stack).getName()) : UItems.EMPTY_JAR.getName(UItems.EMPTY_JAR.getDefaultStack()); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/item/FriendshipBraceletItem.java b/src/main/java/com/minelittlepony/unicopia/item/FriendshipBraceletItem.java index a40d3e85..117b4392 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/FriendshipBraceletItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/FriendshipBraceletItem.java @@ -25,6 +25,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.stat.Stats; import net.minecraft.text.Text; import net.minecraft.util.*; +import net.minecraft.text.TranslatableText; import net.minecraft.world.World; public class FriendshipBraceletItem extends WearableItem implements DyeableItem, GlowableItem { @@ -68,10 +69,10 @@ public class FriendshipBraceletItem extends WearableItem implements DyeableItem, @Environment(EnvType.CLIENT) public void appendTooltip(ItemStack stack, @Nullable World world, List list, TooltipContext tooltipContext) { if (isSigned(stack)) { - list.add(Text.translatable("item.unicopia.friendship_bracelet.issuer", getSignatorName(stack))); + list.add(new TranslatableText("item.unicopia.friendship_bracelet.issuer", getSignatorName(stack))); } if (isGlowing(stack)) { - list.add(Text.translatable("item.unicopia.friendship_bracelet.glowing").formatted(Formatting.ITALIC, Formatting.GRAY)); + list.add(new TranslatableText("item.unicopia.friendship_bracelet.glowing").formatted(Formatting.ITALIC, Formatting.GRAY)); } } diff --git a/src/main/java/com/minelittlepony/unicopia/item/GemstoneItem.java b/src/main/java/com/minelittlepony/unicopia/item/GemstoneItem.java index 3fef3ea8..3a8ee916 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/GemstoneItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/GemstoneItem.java @@ -20,8 +20,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; -import net.minecraft.text.MutableText; -import net.minecraft.text.Text; +import net.minecraft.text.*; import net.minecraft.util.Formatting; import net.minecraft.util.Hand; import net.minecraft.util.Identifier; @@ -79,7 +78,7 @@ public class GemstoneItem extends Item { if (isEnchanted(stack)) { SpellType key = getSpellKey(stack); - MutableText line = Text.translatable(key.getTranslationKey() + ".lore").formatted(key.getAffinity().getColor()); + MutableText line = new TranslatableText(key.getTranslationKey() + ".lore").formatted(key.getAffinity().getColor()); if (!Unicopia.SIDE.getPlayerSpecies().canCast()) { line = line.formatted(Formatting.OBFUSCATED); @@ -112,10 +111,10 @@ public class GemstoneItem extends Item { public Text getName(ItemStack stack) { if (isEnchanted(stack)) { if (!Unicopia.SIDE.getPlayerSpecies().canCast()) { - return Text.translatable(getTranslationKey(stack) + ".obfuscated"); + return new TranslatableText(getTranslationKey(stack) + ".obfuscated"); } - return Text.translatable(getTranslationKey(stack) + ".enchanted", getSpellKey(stack).getName()); + return new TranslatableText(getTranslationKey(stack) + ".enchanted", getSpellKey(stack).getName()); } return super.getName(); } diff --git a/src/main/java/com/minelittlepony/unicopia/item/UItems.java b/src/main/java/com/minelittlepony/unicopia/item/UItems.java index fbfdae8e..947cd6fe 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/UItems.java +++ b/src/main/java/com/minelittlepony/unicopia/item/UItems.java @@ -113,7 +113,7 @@ public interface UItems { return register(name, new MusicDiscItem(1, sound, new Settings() .maxCount(1) .group(ItemGroup.MISC) - .rarity(Rarity.RARE), seconds + .rarity(Rarity.RARE) ) {}); } diff --git a/src/main/java/com/minelittlepony/unicopia/item/URecipes.java b/src/main/java/com/minelittlepony/unicopia/item/URecipes.java index 7c1a72c1..2d6d3493 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/URecipes.java +++ b/src/main/java/com/minelittlepony/unicopia/item/URecipes.java @@ -1,11 +1,10 @@ package com.minelittlepony.unicopia.item; -import java.util.List; - import com.google.gson.JsonArray; import com.minelittlepony.unicopia.ability.magic.spell.crafting.*; -import net.fabricmc.fabric.api.loot.v2.LootTableEvents; +import net.fabricmc.fabric.api.loot.v1.FabricLootSupplier; +import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback; import net.minecraft.loot.LootTable; import net.minecraft.recipe.Ingredient; import net.minecraft.recipe.RecipeSerializer; @@ -39,7 +38,7 @@ public interface URecipes { } static void bootstrap() { - LootTableEvents.MODIFY.register((res, manager, id, supplier, setter) -> { + LootTableLoadingCallback.EVENT.register((res, manager, id, supplier, setter) -> { if (!"minecraft".contentEquals(id.getNamespace())) { return; } @@ -47,7 +46,7 @@ public interface URecipes { Identifier modId = new Identifier("unicopiamc", id.getPath()); LootTable table = manager.getTable(modId); if (table != LootTable.EMPTY) { - supplier.pools(List.of(table.pools)); + supplier.withPools(((FabricLootSupplier)table).getPools()); } }); } 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 7fc0cde5..78e229d7 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/enchantment/PoisonedJokeEnchantment.java +++ b/src/main/java/com/minelittlepony/unicopia/item/enchantment/PoisonedJokeEnchantment.java @@ -1,8 +1,8 @@ package com.minelittlepony.unicopia.item.enchantment; +import java.io.IOException; import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.List; +import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; import java.util.stream.Collectors; @@ -20,7 +20,6 @@ import net.minecraft.resource.ResourceManager; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvent; import net.minecraft.util.Identifier; -import net.minecraft.util.math.random.Random; import net.minecraft.util.profiler.Profiler; import net.minecraft.util.registry.Registry; @@ -72,11 +71,13 @@ public class PoisonedJokeEnchantment extends SimpleEnchantment implements Identi clientProfiler.startTick(); clientProfiler.push("Loading poisoned joke sound options"); - sounds = Resources.getResources(manager, FILE) - .flatMap(r -> Resources.loadFile(r, TYPE, "Failed to load sounds file at ")) - .distinct() - .flatMap(this::findSound) - .collect(Collectors.toList()); + try { + sounds = Resources.getResources(manager, FILE) + .flatMap(r -> Resources.loadFile(r, TYPE, "Failed to load sounds file at ")) + .distinct() + .flatMap(this::findSound) + .collect(Collectors.toList()); + } catch (IOException e) {} clientProfiler.pop(); clientProfiler.endTick(); diff --git a/src/main/java/com/minelittlepony/unicopia/item/toxin/Toxicity.java b/src/main/java/com/minelittlepony/unicopia/item/toxin/Toxicity.java index f901adac..af8dd7db 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/toxin/Toxicity.java +++ b/src/main/java/com/minelittlepony/unicopia/item/toxin/Toxicity.java @@ -6,6 +6,7 @@ import java.util.function.Function; import java.util.stream.Collectors; import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; import net.minecraft.util.Formatting; public enum Toxicity { @@ -28,7 +29,7 @@ public enum Toxicity { } public Text getTooltip() { - return Text.translatable(getTranslationKey()).formatted(color); + return new TranslatableText(getTranslationKey()).formatted(color); } public static Toxicity byName(String name) { diff --git a/src/main/java/com/minelittlepony/unicopia/item/toxin/Toxin.java b/src/main/java/com/minelittlepony/unicopia/item/toxin/Toxin.java index 0e9007ff..008e61ea 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/toxin/Toxin.java +++ b/src/main/java/com/minelittlepony/unicopia/item/toxin/Toxin.java @@ -10,8 +10,7 @@ import net.minecraft.entity.effect.StatusEffects; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.FoodComponent; import net.minecraft.item.ItemStack; -import net.minecraft.text.MutableText; -import net.minecraft.text.Text; +import net.minecraft.text.*; import net.minecraft.util.StringHelper; import net.minecraft.world.Difficulty; @@ -92,10 +91,10 @@ public interface Toxin extends Affliction { MutableText text = effect.getName().copy(); if (amplifier > 0) { - text = Text.translatable("potion.withAmplifier", text, Text.translatable("potion.potency." + amplifier)); + text = new TranslatableText("potion.withAmplifier", text, new TranslatableText("potion.potency." + amplifier)); } - text = Text.translatable("potion.withDuration", text, StringHelper.formatTicks(ticks)); + text = new TranslatableText("potion.withDuration", text, StringHelper.formatTicks(ticks)); return of(text, (player, stack) -> { StatusEffectInstance current = player.getStatusEffect(effect); diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinBoatEntity.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinBoatEntity.java index 627651b1..ef89de82 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinBoatEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinBoatEntity.java @@ -24,7 +24,7 @@ abstract class MixinBoatEntity extends Entity implements LavaAffine { @Redirect( method = { - "getWaterHeightBelow", + "method_7544", "checkBoatInWater", "getUnderWaterLocation", "fall", diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinDamageSource.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinDamageSource.java index caa1544b..570eb4c0 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinDamageSource.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinDamageSource.java @@ -11,6 +11,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; @Mixin(DamageSource.class) abstract class MixinDamageSource { @@ -22,11 +23,11 @@ abstract class MixinDamageSource { Entity prime = entity.getPrimeAdversary(); if (prime != null && !(attacker instanceof Owned && ((Owned)attacker).isOwnedBy(prime))) { - info.setReturnValue(Text.translatable("death.attack.generic.and_also", info.getReturnValue(), attacker.getDisplayName())); + info.setReturnValue(new TranslatableText("death.attack.generic.and_also", info.getReturnValue(), attacker.getDisplayName())); return; } - info.setReturnValue(Text.translatable("death.attack." + self.getName() + ".player", entity.getDisplayName(), attacker.getDisplayName())); + info.setReturnValue(new TranslatableText("death.attack." + self.getName() + ".player", entity.getDisplayName(), attacker.getDisplayName())); }); } } diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerPlayerEntity.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerPlayerEntity.java index 24ca0d46..2cf6e79f 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerPlayerEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerPlayerEntity.java @@ -16,7 +16,7 @@ import net.minecraft.server.network.ServerPlayerEntity; @Mixin(ServerPlayerEntity.class) abstract class MixinServerPlayerEntity extends PlayerEntity implements ScreenHandlerListener, PonyContainer, ServerPlayerEntityDuck { - MixinServerPlayerEntity() {super(null, null, 0, null, null);} + MixinServerPlayerEntity() {super(null, null, 0, null);} @Override @Accessor("inTeleportationState") diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerWorld.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerWorld.java index 49edc53c..ead6887e 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerWorld.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerWorld.java @@ -15,7 +15,7 @@ import net.minecraft.world.World; @Mixin(ServerWorld.class) abstract class MixinServerWorld extends World implements StructureWorldAccess { - MixinServerWorld() { super(null, null, null, null, false, false, 0, 0); } + MixinServerWorld() { super(null, null, null, null, false, false, 0); } @Inject(method = "onBlockChanged", at = @At("HEAD")) private void onOnBlockChanged(BlockPos pos, BlockState oldState, BlockState newState, CallbackInfo info) { diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinKeyboardInput.java b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinKeyboardInput.java index f67de81c..c9bdf628 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinKeyboardInput.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinKeyboardInput.java @@ -13,8 +13,8 @@ import net.minecraft.client.input.KeyboardInput; @Mixin(KeyboardInput.class) abstract class MixinKeyboardInput extends Input { - @Inject(method = "tick(ZF)V", at = @At("RETURN")) - private void onTick(boolean a, float b, CallbackInfo info) { + @Inject(method = "tick(Z)V", at = @At("RETURN")) + private void onTick(boolean a, CallbackInfo info) { Pony player = Pony.of(MinecraftClient.getInstance().player); if (player != null && player.getPhysics().isGravityNegative()) { diff --git a/src/main/java/com/minelittlepony/unicopia/network/MsgPlayerCapabilities.java b/src/main/java/com/minelittlepony/unicopia/network/MsgPlayerCapabilities.java index ed344378..7bd3e326 100644 --- a/src/main/java/com/minelittlepony/unicopia/network/MsgPlayerCapabilities.java +++ b/src/main/java/com/minelittlepony/unicopia/network/MsgPlayerCapabilities.java @@ -32,7 +32,7 @@ public class MsgPlayerCapabilities implements Packet { MsgPlayerCapabilities(PacketByteBuf buffer) { playerId = buffer.readUuid(); - newRace = buffer.readRegistryValue(Race.REGISTRY); + newRace = Race.REGISTRY.get(buffer.readIdentifier()); try (InputStream in = new ByteBufInputStream(buffer)) { compoundTag = NbtIo.readCompressed(in); } catch (IOException e) { @@ -49,7 +49,7 @@ public class MsgPlayerCapabilities implements Packet { @Override public void toBuffer(PacketByteBuf buffer) { buffer.writeUuid(playerId); - buffer.writeRegistryValue(Race.REGISTRY, newRace); + buffer.writeIdentifier(Race.REGISTRY.getId(newRace)); try (OutputStream out = new ByteBufOutputStream(buffer)) { NbtIo.writeCompressed(compoundTag, out); } catch (IOException e) { diff --git a/src/main/java/com/minelittlepony/unicopia/network/MsgRequestSpeciesChange.java b/src/main/java/com/minelittlepony/unicopia/network/MsgRequestSpeciesChange.java index db2da4a8..0f1b9e30 100644 --- a/src/main/java/com/minelittlepony/unicopia/network/MsgRequestSpeciesChange.java +++ b/src/main/java/com/minelittlepony/unicopia/network/MsgRequestSpeciesChange.java @@ -21,7 +21,7 @@ public class MsgRequestSpeciesChange implements Packet { MsgRequestSpeciesChange(PacketByteBuf buffer) { force = buffer.readBoolean(); - newRace = buffer.readRegistryValue(Race.REGISTRY); + newRace = Race.REGISTRY.get(buffer.readIdentifier()); } public MsgRequestSpeciesChange(Race newRace) { @@ -36,7 +36,7 @@ public class MsgRequestSpeciesChange implements Packet { @Override public void toBuffer(PacketByteBuf buffer) { buffer.writeBoolean(force); - buffer.writeRegistryValue(Race.REGISTRY, newRace); + buffer.writeIdentifier(Race.REGISTRY.getId(newRace)); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/network/MsgTribeSelect.java b/src/main/java/com/minelittlepony/unicopia/network/MsgTribeSelect.java index dc56d48f..f7603692 100644 --- a/src/main/java/com/minelittlepony/unicopia/network/MsgTribeSelect.java +++ b/src/main/java/com/minelittlepony/unicopia/network/MsgTribeSelect.java @@ -22,7 +22,7 @@ public class MsgTribeSelect implements Packet { int len = buffer.readInt(); availableRaces = new HashSet<>(); while (len-- > 0) { - availableRaces.add(buffer.readRegistryValue(Race.REGISTRY)); + availableRaces.add(Race.REGISTRY.get(buffer.readIdentifier())); } } @@ -33,7 +33,7 @@ public class MsgTribeSelect implements Packet { @Override public void toBuffer(PacketByteBuf buffer) { buffer.writeInt(availableRaces.size()); - availableRaces.forEach(race -> buffer.writeRegistryValue(Race.REGISTRY, race)); + availableRaces.forEach(race -> buffer.writeIdentifier(Race.REGISTRY.getId(race))); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/particle/MagicParticleEffect.java b/src/main/java/com/minelittlepony/unicopia/particle/MagicParticleEffect.java index d1161dd1..aac8668b 100644 --- a/src/main/java/com/minelittlepony/unicopia/particle/MagicParticleEffect.java +++ b/src/main/java/com/minelittlepony/unicopia/particle/MagicParticleEffect.java @@ -1,6 +1,7 @@ package com.minelittlepony.unicopia.particle; import java.util.Locale; +import java.util.Random; import com.minelittlepony.common.util.Color; import com.mojang.brigadier.StringReader; @@ -11,7 +12,6 @@ import net.minecraft.particle.ParticleEffect; import net.minecraft.particle.ParticleType; import net.minecraft.network.PacketByteBuf; import net.minecraft.util.math.Vec3f; -import net.minecraft.util.math.random.Random; import net.minecraft.util.registry.Registry; public class MagicParticleEffect implements ParticleEffect { diff --git a/src/main/java/com/minelittlepony/unicopia/util/MagicalDamageSource.java b/src/main/java/com/minelittlepony/unicopia/util/MagicalDamageSource.java index afb359b4..4dee85ae 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/MagicalDamageSource.java +++ b/src/main/java/com/minelittlepony/unicopia/util/MagicalDamageSource.java @@ -13,6 +13,7 @@ import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.damage.EntityDamageSource; import net.minecraft.item.ItemStack; import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; public class MagicalDamageSource extends EntityDamageSource { @@ -89,6 +90,6 @@ public class MagicalDamageSource extends EntityDamageSource { params.add(item.toHoverableText()); } - return Text.translatable(basic, params.toArray()); + return new TranslatableText(basic, params.toArray()); } } diff --git a/src/main/java/com/minelittlepony/unicopia/util/Resources.java b/src/main/java/com/minelittlepony/unicopia/util/Resources.java index ab78f637..53530195 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/Resources.java +++ b/src/main/java/com/minelittlepony/unicopia/util/Resources.java @@ -21,7 +21,7 @@ public interface Resources { .registerTypeAdapter(Identifier.class, new ToStringAdapter<>(Identifier::new)) .create(); - static Stream getResources(ResourceManager manager, Identifier id) { + static Stream getResources(ResourceManager manager, Identifier id) throws IOException { return manager.getAllResources(id).stream(); } diff --git a/src/main/java/com/minelittlepony/unicopia/util/shape/Cylinder.java b/src/main/java/com/minelittlepony/unicopia/util/shape/Cylinder.java index b68ed3df..74d703ff 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/shape/Cylinder.java +++ b/src/main/java/com/minelittlepony/unicopia/util/shape/Cylinder.java @@ -1,8 +1,9 @@ package com.minelittlepony.unicopia.util.shape; +import java.util.Random; + import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; -import net.minecraft.util.math.random.Random; public class Cylinder implements Shape { diff --git a/src/main/java/com/minelittlepony/unicopia/util/shape/Line.java b/src/main/java/com/minelittlepony/unicopia/util/shape/Line.java index 806198c3..a9b0e5f3 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/shape/Line.java +++ b/src/main/java/com/minelittlepony/unicopia/util/shape/Line.java @@ -1,8 +1,9 @@ package com.minelittlepony.unicopia.util.shape; +import java.util.Random; + import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; -import net.minecraft.util.math.random.Random; /** * A lonely Line. The simplest form of shape. diff --git a/src/main/java/com/minelittlepony/unicopia/util/shape/PointGenerator.java b/src/main/java/com/minelittlepony/unicopia/util/shape/PointGenerator.java index e133bc56..6e1c1d7b 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/shape/PointGenerator.java +++ b/src/main/java/com/minelittlepony/unicopia/util/shape/PointGenerator.java @@ -1,5 +1,6 @@ package com.minelittlepony.unicopia.util.shape; +import java.util.Random; import java.util.Spliterator; import java.util.Spliterators.AbstractSpliterator; import java.util.concurrent.atomic.AtomicInteger; @@ -10,7 +11,6 @@ import java.util.stream.StreamSupport; import com.google.common.collect.Streams; import net.minecraft.util.math.Vec3d; -import net.minecraft.util.math.random.Random; /** * diff --git a/src/main/java/com/minelittlepony/unicopia/util/shape/Sphere.java b/src/main/java/com/minelittlepony/unicopia/util/shape/Sphere.java index ecf666cd..7d77b5df 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/shape/Sphere.java +++ b/src/main/java/com/minelittlepony/unicopia/util/shape/Sphere.java @@ -1,8 +1,9 @@ package com.minelittlepony.unicopia.util.shape; +import java.util.Random; + import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; -import net.minecraft.util.math.random.Random; /** * A sphere, or 2d circle of you so desire.