From ded553bd31e6ae5ef9fe5d4a0308dda723212078 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 25 Jun 2022 00:19:55 +0200 Subject: [PATCH] 1.18 -> 1.19 --- build.gradle | 8 +-- gradle.properties | 14 ++--- .../unicopia/InteractionManager.java | 2 +- .../com/minelittlepony/unicopia/Race.java | 5 +- .../unicopia/WorldTribeManager.java | 5 +- .../unicopia/ability/Ability.java | 3 +- .../unicopia/ability/BatEeeeAbility.java | 3 +- .../ability/EarthPonyStompAbility.java | 2 +- .../ability/PegasusCaptureStormAbility.java | 4 +- .../ability/UnicornCastingAbility.java | 3 +- .../ability/UnicornDispellAbility.java | 6 +-- .../magic/spell/effect/InfernoSpell.java | 2 +- .../ability/magic/spell/effect/SpellType.java | 3 +- .../ability/magic/spell/trait/Trait.java | 15 +++--- .../magic/spell/trait/TraitLoader.java | 3 +- .../unicopia/block/FrostedObsidianBlock.java | 2 +- .../unicopia/block/RockCropBlock.java | 3 +- .../client/ClientInteractionManager.java | 11 ++-- .../unicopia/client/DiscoveryToast.java | 5 +- .../unicopia/client/FlowingText.java | 8 ++- .../unicopia/client/KeyBindingsHandler.java | 3 +- .../client/ModifierTooltipRenderer.java | 23 ++++---- .../unicopia/client/URenderers.java | 4 +- .../unicopia/client/UnicopiaClient.java | 8 +-- .../client/gui/DismissSpellScreen.java | 23 ++++---- .../unicopia/client/gui/DrawableUtil.java | 9 ++-- .../client/gui/ItemTraitsTooltipRenderer.java | 30 ++++++++--- .../client/gui/LanSettingsScreen.java | 6 +-- .../unicopia/client/gui/SettingsScreen.java | 13 +++-- .../unicopia/client/gui/TribeButton.java | 4 +- .../client/gui/TribeConfirmationScreen.java | 19 ++++--- .../client/gui/TribeSelectionScreen.java | 12 ++--- .../unicopia/client/gui/UHud.java | 4 +- .../particle/LightningBoltParticle.java | 6 +-- .../unicopia/client/particle/SphereModel.java | 6 ++- .../render/IcarusWingsFeatureRenderer.java | 2 +- .../client/sound/FadeOutSoundInstance.java | 7 +-- .../LoopedEntityTrackingSoundInstance.java | 4 +- .../client/sound/LoopingSoundInstance.java | 5 +- .../client/sound/MagicAuraSoundInstance.java | 5 +- .../sound/MotionBasedSoundInstance.java | 5 +- .../unicopia/command/Commands.java | 9 ++-- .../unicopia/command/DisguiseCommand.java | 17 +++--- .../unicopia/command/EnumArgumentType.java | 53 ++++++++++++++----- .../unicopia/command/GravityCommand.java | 13 +++-- .../unicopia/command/RacelistCommand.java | 5 +- .../unicopia/command/SpeciesCommand.java | 28 +++++----- .../unicopia/command/TraitCommand.java | 13 +++-- .../unicopia/container/SpellbookPage.java | 3 +- .../unicopia/container/SpellbookScreen.java | 3 +- .../unicopia/container/UScreenHandlers.java | 7 ++- .../unicopia/entity/ButterflyEntity.java | 2 +- .../unicopia/entity/CastSpellEntity.java | 3 +- .../unicopia/entity/ItemImpl.java | 2 +- .../unicopia/entity/UEntities.java | 13 +++-- .../unicopia/entity/UTradeOffers.java | 3 +- .../entity/behaviour/BeeBehaviour.java | 2 +- .../unicopia/entity/behaviour/Disguise.java | 2 +- .../entity/behaviour/MinecartBehaviour.java | 2 +- .../entity/behaviour/SheepBehaviour.java | 3 +- .../entity/behaviour/SteedBehaviour.java | 11 ++-- .../entity/effect/RaceChangeStatusEffect.java | 3 +- .../unicopia/entity/player/PlayerPhysics.java | 8 +-- .../unicopia/entity/player/Pony.java | 9 ++-- .../player/dummy/DummyClientPlayerEntity.java | 10 ++-- .../player/dummy/DummyPlayerEntity.java | 4 +- .../player/dummy/DummyServerPlayerEntity.java | 4 +- .../unicopia/item/AlicornAmuletItem.java | 3 +- .../unicopia/item/AmuletItem.java | 10 ++-- .../unicopia/item/FilledJarItem.java | 3 +- .../unicopia/item/FriendshipBraceletItem.java | 7 ++- .../unicopia/item/GemstoneItem.java | 7 ++- .../unicopia/item/URecipes.java | 9 ++-- .../enchantment/GemFindingEnchantment.java | 2 +- .../enchantment/PoisonedJokeEnchantment.java | 2 +- .../unicopia/item/toxin/Toxicity.java | 3 +- .../unicopia/item/toxin/Toxin.java | 11 ++-- .../unicopia/mixin/MixinDamageSource.java | 5 +- .../mixin/MixinServerPlayerEntity.java | 2 +- .../unicopia/mixin/MixinServerWorld.java | 2 +- .../mixin/client/MixinKeyboardInput.java | 4 +- .../handler/ClientNetworkHandlerImpl.java | 2 +- .../particle/MagicParticleEffect.java | 2 +- .../unicopia/util/MagicalDamageSource.java | 3 +- .../unicopia/util/Resources.java | 9 ++-- .../unicopia/util/shape/Cylinder.java | 3 +- .../unicopia/util/shape/Line.java | 3 +- .../unicopia/util/shape/PointGenerator.java | 2 +- .../unicopia/util/shape/Sphere.java | 3 +- src/main/resources/fabric.mod.json | 5 +- 90 files changed, 320 insertions(+), 319 deletions(-) diff --git a/build.gradle b/build.gradle index 7d7b12fa..a038c47e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id 'java-library' - id 'fabric-loom' version '0.10-SNAPSHOT' + id 'fabric-loom' version '0.12-SNAPSHOT' id 'org.ajoberstar.reckon' version '0.13.0' } @@ -8,6 +8,7 @@ java { toolchain { languageVersion = JavaLanguageVersion.of(17) } + withSourcesJar() } group = project.group @@ -65,8 +66,3 @@ processResources { tasks.withType(JavaCompile) { options.encoding = "UTF-8" } - -task sourcesJar(type: Jar, dependsOn: classes) { - classifier = "sources" - from sourceSets.main.allSource -} diff --git a/gradle.properties b/gradle.properties index 545a2f36..881eed74 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,10 +3,10 @@ org.gradle.daemon=false # Fabric Properties # check these on https://fabricmc.net/develop - minecraft_version=1.18.2 - yarn_mappings=1.18.2+build.1 - loader_version=0.13.3 - fabric_version=0.47.8+1.18.2 + minecraft_version=1.19 + yarn_mappings=1.19+build.1 + loader_version=0.14.7 + fabric_version=0.55.3+1.19 # Mod Properties group=com.minelittlepony @@ -15,6 +15,6 @@ org.gradle.daemon=false description=Magical Abilities for Mine Little Pony! # Dependencies - modmenu_version=3.1.0 - minelp_version=4.4.4 - kirin_version=1.10.0 + modmenu_version=4.0.0 + minelp_version=4.5.1 + kirin_version=1.11.0 diff --git a/src/main/java/com/minelittlepony/unicopia/InteractionManager.java b/src/main/java/com/minelittlepony/unicopia/InteractionManager.java index aa1bb97d..0a8bb759 100644 --- a/src/main/java/com/minelittlepony/unicopia/InteractionManager.java +++ b/src/main/java/com/minelittlepony/unicopia/InteractionManager.java @@ -48,7 +48,7 @@ public class InteractionManager { /** * Plays a custom sound instance */ - public void playLoopingSound(Entity source, int type) { + public void playLoopingSound(Entity source, int type, long seed) { } diff --git a/src/main/java/com/minelittlepony/unicopia/Race.java b/src/main/java/com/minelittlepony/unicopia/Race.java index 8fb0d326..e1efa88e 100644 --- a/src/main/java/com/minelittlepony/unicopia/Race.java +++ b/src/main/java/com/minelittlepony/unicopia/Race.java @@ -16,7 +16,6 @@ import com.minelittlepony.unicopia.ability.magic.Affine; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; import net.minecraft.util.Identifier; public enum Race implements Affine { @@ -86,11 +85,11 @@ public enum Race implements Affine { } public Text getDisplayName() { - return new TranslatableText(getTranslationKey()); + return Text.translatable(getTranslationKey()); } public Text getAltDisplayName() { - return new TranslatableText(getTranslationKey() + ".alt"); + return Text.translatable(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 ba1cdb10..658af33b 100644 --- a/src/main/java/com/minelittlepony/unicopia/WorldTribeManager.java +++ b/src/main/java/com/minelittlepony/unicopia/WorldTribeManager.java @@ -5,6 +5,7 @@ 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 { @@ -31,13 +32,13 @@ public class WorldTribeManager extends PersistentState { } public static String nameFor(RegistryEntry dimension) { - if (dimension.matchesKey(DimensionType.THE_END_REGISTRY_KEY)) { + if (dimension.matchesKey(DimensionTypes.THE_END)) { return "unicopia:tribes_end"; } return "unicopia:tribes"; } public static WorldTribeManager forWorld(ServerWorld world) { - return world.getPersistentStateManager().getOrCreate(WorldTribeManager::new, WorldTribeManager::new, nameFor(world.method_40134())); + return world.getPersistentStateManager().getOrCreate(WorldTribeManager::new, WorldTribeManager::new, nameFor(world.getDimensionEntry())); } } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/Ability.java b/src/main/java/com/minelittlepony/unicopia/ability/Ability.java index 4c9a0d74..b604379d 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/Ability.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/Ability.java @@ -7,7 +7,6 @@ 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; @@ -79,7 +78,7 @@ public interface Ability { */ default Text getName() { Identifier id = Abilities.REGISTRY.getId(this); - return new TranslatableText("ability." + id.getNamespace() + "." + id.getPath().replace('/', '.')); + return Text.translatable("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 3f1f2fbe..b2d2947e 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/BatEeeeAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/BatEeeeAbility.java @@ -1,7 +1,5 @@ package com.minelittlepony.unicopia.ability; -import java.util.Random; - import com.minelittlepony.unicopia.AwaitTickQueue; import com.minelittlepony.unicopia.EquinePredicates; import com.minelittlepony.unicopia.Race; @@ -15,6 +13,7 @@ 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/EarthPonyStompAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java index 86c43419..3d21a0bc 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java @@ -182,7 +182,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); + state.onStacksDropped((ServerWorld)w, pos, stack, true); } } } else { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/PegasusCaptureStormAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/PegasusCaptureStormAbility.java index 022e58df..1fb893eb 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.TranslatableText; +import net.minecraft.text.Text; 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(new TranslatableText(translation), true); + player.getMaster().sendMessage(Text.translatable(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 5c2a9112..63c35ab6 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java @@ -1,7 +1,5 @@ package com.minelittlepony.unicopia.ability; -import java.util.Random; - import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.Race; @@ -25,6 +23,7 @@ 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 ac52988d..f49dc43c 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.TranslatableText; +import net.minecraft.text.Text; /** * 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(new TranslatableText("gui.unicopia.action.spells_cleared"), true); + player.getMaster().sendMessage(Text.translatable("gui.unicopia.action.spells_cleared"), true); } else { - player.getMaster().sendMessage(new TranslatableText("gui.unicopia.action.no_spells_cleared"), true); + player.getMaster().sendMessage(Text.translatable("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 9402dccd..23bee836 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 @@ -39,7 +39,7 @@ public class InfernoSpell extends FireSpell { Vec3d origin = source.getOriginVector(); - BlockStateConverter converter = w.getDimension().isUltrawarm() ? StateMaps.HELLFIRE_AFFECTED.getInverse() : StateMaps.HELLFIRE_AFFECTED; + BlockStateConverter converter = w.getDimension().ultrawarm() ? 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/SpellType.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SpellType.java index 296ed4ed..a5480606 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 @@ -26,7 +26,6 @@ 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; @@ -124,7 +123,7 @@ public final class SpellType implements Affine, SpellPredicate< } public Text getName() { - return new TranslatableText(getTranslationKey()); + return Text.translatable(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 6d6b25d1..eaaa6b27 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 @@ -13,8 +13,7 @@ import com.minelittlepony.common.client.gui.Tooltip; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NbtElement; import net.minecraft.nbt.NbtList; -import net.minecraft.text.LiteralText; -import net.minecraft.text.TranslatableText; +import net.minecraft.text.*; import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; @@ -91,14 +90,14 @@ public enum Trait { : Formatting.WHITE; return Tooltip.of( - new TranslatableText("gui.unicopia.trait.label", - new TranslatableText("trait." + getId().getNamespace() + "." + getId().getPath() + ".name") + Text.translatable("gui.unicopia.trait.label", + Text.translatable("trait." + getId().getNamespace() + "." + getId().getPath() + ".name") ).formatted(Formatting.YELLOW) - .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(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("\n") - .append(new TranslatableText("gui.unicopia.trait.corruption", ItemStack.MODIFIER_FORMAT.format(getGroup().getCorruption())).formatted(Formatting.ITALIC, corruptionColor))), 200); + .append(Text.translatable("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 dcedae05..84fb3d8e 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 @@ -4,7 +4,6 @@ import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.util.HashMap; -import java.util.HashSet; import java.util.Map; import java.util.Map.Entry; import java.util.Set; @@ -53,7 +52,7 @@ public class TraitLoader extends SinglePreparationResourceReloader prepared = HashMultimap.create(); - for (Identifier path : new HashSet<>(manager.findResources("traits", p -> p.endsWith(".json")))) { + for (var path : manager.findResources("traits", p -> p.getPath().endsWith(".json")).keySet()) { 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 b57c84b3..4cc23ee9 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().isUltrawarm()) { + if (world.getDimension().ultrawarm()) { 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 8d9c2901..3b1860c4 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/RockCropBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/RockCropBlock.java @@ -1,7 +1,5 @@ package com.minelittlepony.unicopia.block; -import java.util.Random; - import com.minelittlepony.unicopia.EquinePredicates; import com.minelittlepony.unicopia.item.UItems; @@ -11,6 +9,7 @@ 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/client/ClientInteractionManager.java b/src/main/java/com/minelittlepony/unicopia/client/ClientInteractionManager.java index d77a892a..3a64e5f6 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/ClientInteractionManager.java +++ b/src/main/java/com/minelittlepony/unicopia/client/ClientInteractionManager.java @@ -31,6 +31,7 @@ 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 { @@ -50,12 +51,12 @@ public class ClientInteractionManager extends InteractionManager { } @Override - public void playLoopingSound(Entity source, int type) { + public void playLoopingSound(Entity source, int type, long seed) { client.execute(() -> { SoundManager soundManager = client.getSoundManager(); if (type == SOUND_EARS_RINGING && source instanceof LivingEntity) { - soundManager.play(new LoopingSoundInstance<>((LivingEntity)source, e -> e.hasStatusEffect(UEffects.SUN_BLINDNESS), USounds.ENTITY_PLAYER_EARS_RINGING, 1, 1)); + soundManager.play(new LoopingSoundInstance<>((LivingEntity)source, e -> e.hasStatusEffect(UEffects.SUN_BLINDNESS), USounds.ENTITY_PLAYER_EARS_RINGING, 1, 1, Random.create(seed))); } else if (type == SOUND_BEE && source instanceof BeeEntity) { soundManager.playNextTick( ((BeeEntity)source).hasAngerTime() @@ -68,11 +69,11 @@ 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)); + }, USounds.ENTITY_PLAYER_CHANGELING_BUZZ, 1F, 1F, Random.create(seed))); } else if (type == SOUND_GLIDING && source instanceof PlayerEntity) { - soundManager.play(new MotionBasedSoundInstance(SoundEvents.ITEM_ELYTRA_FLYING, (PlayerEntity)source)); + soundManager.play(new MotionBasedSoundInstance(SoundEvents.ITEM_ELYTRA_FLYING, (PlayerEntity)source, Random.create(seed))); } else if (type == SOUND_MAGIC_BEAM) { - soundManager.play(new LoopedEntityTrackingSoundInstance(USounds.SPELL_CAST_SHOOT, 0.3F, 1F, source)); + 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 2aa9b0d9..b66fd55a 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/DiscoveryToast.java +++ b/src/main/java/com/minelittlepony/unicopia/client/DiscoveryToast.java @@ -13,13 +13,12 @@ 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 = new TranslatableText("unicopia.toast.discoveries.title"); - private static final Text DESCRIPTION = new TranslatableText("unicopia.toast.discoveries.description"); + private static final Text TITLE = Text.translatable("unicopia.toast.discoveries.title"); + private static final Text DESCRIPTION = Text.translatable("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 25461b80..1d820649 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/FlowingText.java +++ b/src/main/java/com/minelittlepony/unicopia/client/FlowingText.java @@ -4,16 +4,14 @@ import java.util.Optional; import java.util.stream.Stream; import net.minecraft.client.MinecraftClient; -import net.minecraft.text.LiteralText; -import net.minecraft.text.Style; -import net.minecraft.text.Text; +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 -> { - LiteralText compiled = new LiteralText(""); + MutableText compiled = Text.literal(""); line.visit((s, t) -> { - compiled.append(new LiteralText(t).setStyle(s)); + compiled.append(Text.literal(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 3744f599..ea7c7ac6 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/KeyBindingsHandler.java +++ b/src/main/java/com/minelittlepony/unicopia/client/KeyBindingsHandler.java @@ -20,7 +20,6 @@ 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.TranslatableText; import net.minecraft.util.math.MathHelper; public class KeyBindingsHandler { @@ -106,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(new TranslatableText("gui.unicopia.page_num", page + 1, max + 1)); + UHud.INSTANCE.setMessage(Text.translatable("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 21dad364..3feb674a 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/ModifierTooltipRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/client/ModifierTooltipRenderer.java @@ -26,9 +26,8 @@ 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.text.LiteralText; +import net.minecraft.screen.ScreenTexts; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; import net.minecraft.util.Pair; @@ -60,10 +59,10 @@ public class ModifierTooltipRenderer implements ItemTooltipCallback { .forEach(entry -> describeModifiers(entry.getKey(), entry.getValue(), null, newLines)); if (!newLines.isEmpty()) { - Text find = new TranslatableText("item.modifiers." + slot.getName()).formatted(Formatting.GRAY); + Text find = Text.translatable("item.modifiers." + slot.getName()).formatted(Formatting.GRAY); int insertPosition = getInsertPosition(stack, find, flags, lines, context.isAdvanced()); if (insertPosition == -1) { - lines.add(LiteralText.EMPTY); + lines.add(ScreenTexts.EMPTY); lines.add(find); lines.addAll(newLines); } else { @@ -87,23 +86,23 @@ public class ModifierTooltipRenderer implements ItemTooltipCallback { if (insertPosition == -1 && stack.hasNbt()) { if (isShowing(flags, ItemStack.TooltipSection.MODIFIERS) && stack.getNbt().getBoolean("Unbreakable")) { - insertPosition = checkFor(lines, new TranslatableText("item.unbreakable").formatted(Formatting.BLUE)); + insertPosition = checkFor(lines, Text.translatable("item.unbreakable").formatted(Formatting.BLUE)); } if (insertPosition == -1 && isShowing(flags, ItemStack.TooltipSection.CAN_DESTROY) && stack.getNbt().contains("CanDestroy", 9)) { - insertPosition = checkFor(lines, new TranslatableText("item.canBreak").formatted(Formatting.GRAY)); + insertPosition = checkFor(lines, Text.translatable("item.canBreak").formatted(Formatting.GRAY)); } if (insertPosition == -1 && isShowing(flags, ItemStack.TooltipSection.CAN_PLACE) && stack.getNbt().contains("CanPlaceOn", 9)) { - insertPosition = checkFor(lines, new TranslatableText("item.canPlace").formatted(Formatting.GRAY)); + insertPosition = checkFor(lines, Text.translatable("item.canPlace").formatted(Formatting.GRAY)); } } if (insertPosition == -1 && advanced) { if (stack.isDamaged()) { - insertPosition = checkFor(lines, new TranslatableText("item.durability", stack.getMaxDamage() - stack.getDamage(), stack.getMaxDamage())); + insertPosition = checkFor(lines, Text.translatable("item.durability", stack.getMaxDamage() - stack.getDamage(), stack.getMaxDamage())); } else { - insertPosition = checkFor(lines, new LiteralText(Registry.ITEM.getId(stack.getItem()).toString()).formatted(Formatting.DARK_GRAY)); + insertPosition = checkFor(lines, Text.literal(Registry.ITEM.getId(stack.getItem()).toString()).formatted(Formatting.DARK_GRAY)); } } @@ -132,7 +131,7 @@ public class ModifierTooltipRenderer implements ItemTooltipCallback { } if (baseAdjusted) { - lines.add(new LiteralText(" ").append(getModifierLineBase("equals", displayValue, op, attribute, Formatting.DARK_GREEN))); + lines.add(Text.literal(" ").append(getModifierLineBase("equals", displayValue, op, attribute, Formatting.DARK_GREEN))); } else if (value > 0) { lines.add(getModifierLineBase("plus", displayValue, op, attribute, attribute == PlayerAttributes.ENTITY_GRAVTY_MODIFIER ? Formatting.RED : Formatting.BLUE)); } else if (value < 0) { @@ -141,9 +140,9 @@ public class ModifierTooltipRenderer implements ItemTooltipCallback { } private Text getModifierLineBase(String root, double displayValue, Operation op, EntityAttribute attribute, Formatting color) { - return new TranslatableText("attribute.modifier." + root + "." + op.getId(), + return Text.translatable("attribute.modifier." + root + "." + op.getId(), ItemStack.MODIFIER_FORMAT.format(displayValue), - new TranslatableText(attribute.getTranslationKey()) + Text.translatable(attribute.getTranslationKey()) ).formatted(color); } diff --git a/src/main/java/com/minelittlepony/unicopia/client/URenderers.java b/src/main/java/com/minelittlepony/unicopia/client/URenderers.java index 5f23d4b6..6eebed20 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/URenderers.java +++ b/src/main/java/com/minelittlepony/unicopia/client/URenderers.java @@ -34,8 +34,8 @@ import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry.Pendin import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry; import net.fabricmc.fabric.api.client.rendering.v1.BuiltinItemRendererRegistry; import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; -import net.fabricmc.fabric.api.object.builder.v1.client.model.FabricModelPredicateProviderRegistry; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.item.ModelPredicateProviderRegistry; import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.SpriteProvider; import net.minecraft.client.render.DiffuseLighting; @@ -111,7 +111,7 @@ public interface URenderers { matrices.push(); }); - FabricModelPredicateProviderRegistry.register(UItems.GEMSTONE, new Identifier("affinity"), (stack, world, entity, seed) -> { + ModelPredicateProviderRegistry.register(UItems.GEMSTONE, new Identifier("affinity"), (stack, world, entity, seed) -> { return GemstoneItem.isEnchanted(stack) ? 1 + GemstoneItem.getSpellKey(stack).getAffinity().ordinal() : 0; }); ColorProviderRegistry.ITEM.register((stack, i) -> { diff --git a/src/main/java/com/minelittlepony/unicopia/client/UnicopiaClient.java b/src/main/java/com/minelittlepony/unicopia/client/UnicopiaClient.java index 81332d7f..dac89058 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/UnicopiaClient.java +++ b/src/main/java/com/minelittlepony/unicopia/client/UnicopiaClient.java @@ -18,13 +18,13 @@ import com.minelittlepony.unicopia.entity.player.Pony; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback; -import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.OpenToLanScreen; 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.TranslatableText; +import net.minecraft.text.Text; public class UnicopiaClient implements ClientModInitializer { @@ -62,7 +62,7 @@ public class UnicopiaClient implements ClientModInitializer { KeyBindingsHandler.bootstrap(); URenderers.bootstrap(); - ScreenRegistry.register(UScreenHandlers.SPELL_BOOK, SpellbookScreen::new); + HandledScreens.register(UScreenHandlers.SPELL_BOOK, SpellbookScreen::new); ClientTickEvents.END_CLIENT_TICK.register(this::onTick); ScreenInitCallback.EVENT.register(this::onScreenInit); @@ -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(new TranslatableText("unicopia.options.title")); + .getStyle().setText(Text.translatable("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 dd175312..62b18829 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/DismissSpellScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/DismissSpellScreen.java @@ -19,11 +19,10 @@ import net.minecraft.client.gui.Selectable; 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.LiteralText; import net.minecraft.text.MutableText; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; import net.minecraft.util.math.Vector4f; public class DismissSpellScreen extends GameGui { @@ -33,7 +32,7 @@ public class DismissSpellScreen extends GameGui { private int relativeMouseY; public DismissSpellScreen() { - super(new TranslatableText("gui.unicopia.dismiss_spell")); + super(Text.translatable("gui.unicopia.dismiss_spell")); } @Override @@ -72,7 +71,7 @@ public class DismissSpellScreen extends GameGui { matrices.push(); matrices.translate(0, 0, 300); - Text cancel = new LiteralText("Press ESC to cancel"); + Text cancel = Text.literal("Press ESC to cancel"); getFont().drawWithShadow(matrices, cancel, (width - getFont().getWidth(cancel)) / 2, height - 30, 0xFFFFFFFF); matrices.pop(); } @@ -105,18 +104,18 @@ public class DismissSpellScreen extends GameGui { SphereModel.convertToCartesianCoord(this, radius, azimuth, azimuth); add(0, -(float)radius / 2F, 0, 0); - MutableText name = actualSpell.getType().getName().shallowCopy(); + MutableText name = actualSpell.getType().getName().copy(); int color = actualSpell.getType().getColor(); name.setStyle(name.getStyle().withColor(color == 0 ? 0xFFAAAAAA : color)); - tooltip.add(new TranslatableText("Spell Type: %s", name)); + tooltip.add(Text.translatable("Spell Type: %s", name)); actualSpell.getType().getTraits().appendTooltip(tooltip); - 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()); - tooltip.add(LiteralText.EMPTY); - tooltip.add(new TranslatableText("[Click to Discard]")); + 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(ScreenTexts.EMPTY); + tooltip.add(Text.translatable("[Click to Discard]")); } private Spell getActualSpell() { 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 6cbe1085..637b6970 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/DrawableUtil.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/DrawableUtil.java @@ -56,8 +56,7 @@ public class 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(); - bufferBuilder.end(); - BufferRenderer.draw(bufferBuilder); + BufferRenderer.drawWithoutShader(bufferBuilder.end()); RenderSystem.enableTexture(); RenderSystem.disableBlend(); } @@ -105,8 +104,7 @@ public class DrawableUtil { cylendricalVertex(bufferBuilder, model, innerRadius, angle + INCREMENT, r, g, b, k); } - bufferBuilder.end(); - BufferRenderer.draw(bufferBuilder); + BufferRenderer.drawWithShader(bufferBuilder.end()); RenderSystem.enableTexture(); } @@ -172,8 +170,7 @@ public class DrawableUtil { } } - bufferBuilder.end(); - BufferRenderer.draw(bufferBuilder); + BufferRenderer.drawWithShader(bufferBuilder.end()); 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 2db80d65..756e4758 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/ItemTraitsTooltipRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/ItemTraitsTooltipRenderer.java @@ -1,5 +1,7 @@ package com.minelittlepony.unicopia.client.gui; +import java.util.List; + import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits; import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait; import com.mojang.blaze3d.systems.RenderSystem; @@ -12,11 +14,9 @@ import net.minecraft.client.render.Tessellator; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.item.ItemRenderer; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.text.BaseText; -import net.minecraft.text.CharacterVisitor; -import net.minecraft.text.OrderedText; +import net.minecraft.text.*; -public class ItemTraitsTooltipRenderer extends BaseText implements OrderedText, TooltipComponent { +public class ItemTraitsTooltipRenderer implements Text, OrderedText, TooltipComponent { private final SpellTraits traits; @@ -67,8 +67,8 @@ public class ItemTraitsTooltipRenderer extends BaseText implements OrderedText, } @Override - public BaseText copy() { - return new ItemTraitsTooltipRenderer(traits); + public MutableText copy() { + return Text.empty(); } public static void renderTraitIcon(Trait trait, float value, MatrixStack matrices, int xx, int yy) { @@ -88,4 +88,22 @@ public class ItemTraitsTooltipRenderer extends BaseText implements OrderedText, immediate.draw(); matrices.pop(); } + + @Override + public Style getStyle() { + // TODO Auto-generated method stub + return null; + } + + @Override + public TextContent getContent() { + // TODO Auto-generated method stub + return null; + } + + @Override + public List getSiblings() { + // TODO Auto-generated method stub + return null; + } } 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 b4605b03..da4e43c8 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/LanSettingsScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/LanSettingsScreen.java @@ -18,7 +18,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.TranslatableText; +import net.minecraft.text.Text; import net.minecraft.util.Formatting; import net.minecraft.util.math.MathHelper; @@ -38,7 +38,7 @@ public class LanSettingsScreen extends GameGui { private boolean forceHideWhitelist; public LanSettingsScreen(Screen parent) { - super(new TranslatableText("unicopia.options.title"), parent); + super(Text.translatable("unicopia.options.title"), parent); content.margin.setVertical(30); content.getContentPadding().setHorizontal(10); @@ -101,7 +101,7 @@ public class LanSettingsScreen extends GameGui { if (whitelistEnabled) { - content.addButton(new Label(LEFT, row += 20)).getStyle().setText(new TranslatableText("unicopia.options.whitelist.details").formatted(Formatting.DARK_GREEN)); + content.addButton(new Label(LEFT, row += 20)).getStyle().setText(Text.translatable("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/SettingsScreen.java b/src/main/java/com/minelittlepony/unicopia/client/gui/SettingsScreen.java index 098e27be..5fbe0d50 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/SettingsScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/SettingsScreen.java @@ -21,7 +21,6 @@ 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 { @@ -33,7 +32,7 @@ public class SettingsScreen extends GameGui { private Style mineLpStatus; public SettingsScreen(Screen parent) { - super(new TranslatableText("unicopia.options.title"), parent); + super(Text.translatable("unicopia.options.title"), parent); content.margin.setVertical(30); content.getContentPadding().setHorizontal(10); @@ -76,7 +75,7 @@ public class SettingsScreen extends GameGui { content.addButton(new EnumSlider<>(LEFT, row += 25, config.preferredRace.get())) .onChange(config.preferredRace::set) - .setTextFormat(v -> new TranslatableText("unicopia.options.preferred_race", v.getValue().getDisplayName())); + .setTextFormat(v -> Text.translatable("unicopia.options.preferred_race", v.getValue().getDisplayName())); IntegratedServer server = client.getServer(); if (server != null) { @@ -87,7 +86,7 @@ public class SettingsScreen extends GameGui { content.addButton(new EnumSlider<>(LEFT, row += 20, tribes.getDefaultRace())) .onChange(tribes::setDefaultRace) - .setTextFormat(v -> new TranslatableText("unicopia.options.world.default_race", v.getValue().getDisplayName())) + .setTextFormat(v -> Text.translatable("unicopia.options.world.default_race", v.getValue().getDisplayName())) .setEnabled(client.isInSingleplayer()); } } @@ -97,13 +96,13 @@ public class SettingsScreen extends GameGui { if (hasMineLP) { if (config.ignoreMineLP.get()) { - return new TranslatableText("unicopia.options.ignore_mine_lp.undetected").formatted(Formatting.DARK_GREEN); + return Text.translatable("unicopia.options.ignore_mine_lp.undetected").formatted(Formatting.DARK_GREEN); } - return new TranslatableText("unicopia.options.ignore_mine_lp.detected", MineLPConnector.getPlayerPonyRace().getDisplayName()).formatted(Formatting.GREEN); + return Text.translatable("unicopia.options.ignore_mine_lp.detected", MineLPConnector.getPlayerPonyRace().getDisplayName()).formatted(Formatting.GREEN); } - return new TranslatableText("unicopia.options.ignore_mine_lp.missing").formatted(Formatting.RED); + return Text.translatable("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 8e98ba8b..505d38fb 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/TribeButton.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/TribeButton.java @@ -9,7 +9,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.TranslatableText; +import net.minecraft.text.Text; import net.minecraft.util.math.MathHelper; public class TribeButton extends Button { @@ -54,7 +54,7 @@ public class TribeButton extends Button { drawTexture(matrices, x - 4, y - 14, 76, 0, 78, 71); if (hovered && screenWidth > 0) { - drawCenteredText(matrices, getFont(), new TranslatableText("gui.unicopia.tribe_selection.describe." + race.name().toLowerCase()), screenWidth / 2, y + height, 0xFFFFFFFF); + drawCenteredText(matrices, getFont(), Text.translatable("gui.unicopia.tribe_selection.describe." + race.name().toLowerCase()), 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 8eec229b..7bf774ed 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/TribeConfirmationScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/TribeConfirmationScreen.java @@ -11,7 +11,6 @@ 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.Formatting; import net.minecraft.util.Language; @@ -21,7 +20,7 @@ public class TribeConfirmationScreen extends GameGui implements HidesHud { private final BooleanConsumer callback; public TribeConfirmationScreen(BooleanConsumer callback, Race selection) { - super(new TranslatableText("gui.unicopia.tribe_selection")); + super(Text.translatable("gui.unicopia.tribe_selection")); this.callback = callback; this.selection = selection; } @@ -35,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, 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))); + 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))); - addDrawable(new Label(width / 2, top - 30).setCentered()).getStyle().setText(new TranslatableText("gui.unicopia.tribe_selection.confirm", selection.getDisplayName().shallowCopy().formatted(Formatting.YELLOW))); + 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 TribeButton((width - 70) / 2, top, 0, selection)); @@ -46,9 +45,9 @@ public class TribeConfirmationScreen extends GameGui implements HidesHud { int left = (width - columnWidth) / 2 + padding; - Text race = selection.getAltDisplayName().shallowCopy().formatted(Formatting.YELLOW); + Text race = selection.getAltDisplayName().copy().formatted(Formatting.YELLOW); - addDrawable(new Label(left - 3, top += 10)).getStyle().setText(new TranslatableText("gui.unicopia.tribe_selection.confirm.goods", race).formatted(Formatting.YELLOW)); + addDrawable(new Label(left - 3, top += 10)).getStyle().setText(Text.translatable("gui.unicopia.tribe_selection.confirm.goods", race).formatted(Formatting.YELLOW)); top += 15; @@ -58,12 +57,12 @@ public class TribeConfirmationScreen extends GameGui implements HidesHud { String key = String.format("gui.unicopia.tribe_selection.confirm.goods.%d.%s", i, selection.name().toLowerCase()); if (Language.getInstance().hasTranslation(key)) { TextBlock block = addDrawable(new TextBlock(left, top, maxWidth)); - block.getStyle().setText(new TranslatableText(key)); + block.getStyle().setText(Text.translatable(key)); top += block.getBounds().height; } } - addDrawable(new Label(left - 3, top += 5)).getStyle().setText(new TranslatableText("gui.unicopia.tribe_selection.confirm.bads", race).formatted(Formatting.YELLOW)); + addDrawable(new Label(left - 3, top += 5)).getStyle().setText(Text.translatable("gui.unicopia.tribe_selection.confirm.bads", race).formatted(Formatting.YELLOW)); top += 15; @@ -71,7 +70,7 @@ public class TribeConfirmationScreen extends GameGui implements HidesHud { String key = String.format("gui.unicopia.tribe_selection.confirm.bads.%d.%s", i, selection.name().toLowerCase()); if (Language.getInstance().hasTranslation(key)) { TextBlock block = addDrawable(new TextBlock(left, top, maxWidth)); - block.getStyle().setText(new TranslatableText(key)); + block.getStyle().setText(Text.translatable(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 b0c66c8d..a4436d9d 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/TribeSelectionScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/TribeSelectionScreen.java @@ -11,7 +11,7 @@ import com.minelittlepony.unicopia.network.Channel; import com.minelittlepony.unicopia.network.MsgRequestSpeciesChange; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.text.TranslatableText; +import net.minecraft.text.Text; 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(new TranslatableText("gui.unicopia.tribe_selection")); + super(Text.translatable("gui.unicopia.tribe_selection")); this.allowedRaces = allowedRaces; } @@ -35,16 +35,16 @@ public class TribeSelectionScreen extends GameGui implements HidesHud { int top = 0; - addDrawable(new Label(width / 2, top += 20).setCentered()).getStyle().setText(getTitle().shallowCopy().formatted(Formatting.YELLOW)); + addDrawable(new Label(width / 2, top += 20).setCentered()).getStyle().setText(getTitle().copy().formatted(Formatting.YELLOW)); top += height / 8; TextBlock block = addDrawable(new TextBlock(left, top += 10, pageWidth)); - block.getStyle().setText(new TranslatableText("gui.unicopia.tribe_selection.welcome.journey")); + block.getStyle().setText(Text.translatable("gui.unicopia.tribe_selection.welcome.journey")); top += block.getBounds().height; block = addDrawable(new TextBlock(left, top += 7, pageWidth)); - block.getStyle().setText(new TranslatableText("gui.unicopia.tribe_selection.welcome.choice")); + block.getStyle().setText(Text.translatable("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(new TranslatableText("gui.unicopia.tribe_selection.preference", preference.getDisplayName().shallowCopy().formatted(Formatting.YELLOW))); + addDrawable(new Label(width / 2, top).setCentered()).getStyle().setText(Text.translatable("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 672ee94f..de8ae64a 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java @@ -1,7 +1,6 @@ package com.minelittlepony.unicopia.client.gui; import java.util.List; -import java.util.Random; import org.jetbrains.annotations.Nullable; @@ -35,6 +34,7 @@ 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 { @@ -227,7 +227,7 @@ public class UHud extends DrawableHelper { client.getSoundManager().play( heartbeatSound = new LoopingSoundInstance<>(client.player, player -> { return Pony.of(player).getMagicalReserves().getExhaustion().getPercentFill() > 0.5F; - }, USounds.ENTITY_PLAYER_HEARTBEAT, 1, 1) + }, USounds.ENTITY_PLAYER_HEARTBEAT, 1, 1, client.world.random) ); } 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 55935a9c..a2194589 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( - 0.1 + world.random.nextDouble(6) - 3, - 0.1 + world.random.nextDouble(6) - 3, - 0.1 + world.random.nextDouble(6) - 3 + world.random.nextTriangular(0.1, 3), + world.random.nextTriangular(0.1, 3), + world.random.nextTriangular(0.1, 3) ); nodes.add(startPos); diff --git a/src/main/java/com/minelittlepony/unicopia/client/particle/SphereModel.java b/src/main/java/com/minelittlepony/unicopia/client/particle/SphereModel.java index 95241871..80c1ff67 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/particle/SphereModel.java +++ b/src/main/java/com/minelittlepony/unicopia/client/particle/SphereModel.java @@ -15,6 +15,8 @@ import net.minecraft.util.math.Vector4f; public class SphereModel { public static final SphereModel SPHERE = new SphereModel(40, 40, DrawableUtil.TAU); public static final SphereModel DISK = new SphereModel(40, 2, DrawableUtil.PI); + public static final SphereModel HEXAGON = new SphereModel(3, 2, DrawableUtil.TAU); + public static final SphereModel PRISM = new SphereModel(6, 6, DrawableUtil.TAU); private final List vertices = new ArrayList<>(); private final Vector4f drawVert = new Vector4f(); @@ -40,8 +42,8 @@ public class SphereModel { } private static void compileVertices(double azimuthRange, double zenithIncrement, double azimuthIncrement, Consumer collector) { - for (double zenith = -DrawableUtil.PI; zenith < DrawableUtil.PI; zenith += zenithIncrement) { - for (double azimuth = -azimuthRange; azimuth < azimuthRange; azimuth += azimuthIncrement) { + for (double zenith = 0; zenith < DrawableUtil.PI; zenith += zenithIncrement) { + for (double azimuth = 0; azimuth < azimuthRange; azimuth += azimuthIncrement) { collector.accept(convertToCartesianCoord(new Vector4f(), 1, zenith, azimuth)); collector.accept(convertToCartesianCoord(new Vector4f(), 1, zenith + zenithIncrement, azimuth)); collector.accept(convertToCartesianCoord(new Vector4f(), 1, zenith + zenithIncrement, azimuth + azimuthIncrement)); 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 9f827eab..0633d51e 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/IcarusWingsFeatureRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/IcarusWingsFeatureRenderer.java @@ -22,6 +22,6 @@ public class IcarusWingsFeatureRenderer extends WingsFea @Override protected Identifier getTexture(E entity) { - return entity.world.getDimension().isUltrawarm() ? ICARUS_WINGS_CORRUPTED : ICARUS_WINGS; + return entity.world.getDimension().ultrawarm() ? 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 4ba59a06..4c77afcc 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/sound/FadeOutSoundInstance.java +++ b/src/main/java/com/minelittlepony/unicopia/client/sound/FadeOutSoundInstance.java @@ -5,6 +5,7 @@ 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 { @@ -19,8 +20,8 @@ public abstract class FadeOutSoundInstance extends MovingSoundInstance { private boolean fadingOut; - public FadeOutSoundInstance(SoundEvent sound, SoundCategory category, float volume) { - super(sound, category); + public FadeOutSoundInstance(SoundEvent sound, SoundCategory category, float volume, Random random) { + super(sound, category, random); this.relative = true; this.repeat = true; this.volume = volume; @@ -71,6 +72,6 @@ public abstract class FadeOutSoundInstance extends MovingSoundInstance { @Override public final float getVolume() { - return getLerpedVolume() * sound.getVolume(); + return getLerpedVolume() * sound.getVolume().get(field_38800); } } 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 16aacdff..54354909 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/sound/LoopedEntityTrackingSoundInstance.java +++ b/src/main/java/com/minelittlepony/unicopia/client/sound/LoopedEntityTrackingSoundInstance.java @@ -5,8 +5,8 @@ import net.minecraft.entity.Entity; import net.minecraft.sound.SoundEvent; public class LoopedEntityTrackingSoundInstance extends EntityTrackingSoundInstance { - public LoopedEntityTrackingSoundInstance(SoundEvent soundEvent, float volume, float pitch, Entity entity) { - super(soundEvent, entity.getSoundCategory(), volume, pitch, entity); + public LoopedEntityTrackingSoundInstance(SoundEvent soundEvent, float volume, float pitch, Entity entity, long seed) { + super(soundEvent, entity.getSoundCategory(), volume, pitch, entity, seed); 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 603ef019..9d1ab245 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/sound/LoopingSoundInstance.java +++ b/src/main/java/com/minelittlepony/unicopia/client/sound/LoopingSoundInstance.java @@ -5,6 +5,7 @@ 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 { @@ -12,8 +13,8 @@ public class LoopingSoundInstance extends FadeOutSoundInstance private final Predicate shouldPlay; - public LoopingSoundInstance(T source, Predicate shouldPlay, SoundEvent soundEvent, float volume, float pitch) { - super(soundEvent, source.getSoundCategory(), volume); + public LoopingSoundInstance(T source, Predicate shouldPlay, SoundEvent soundEvent, float volume, float pitch, Random random) { + super(soundEvent, source.getSoundCategory(), volume, random); this.source = source; this.shouldPlay = shouldPlay; this.pitch = pitch; 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 0b95c5c7..d01b9504 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/sound/MagicAuraSoundInstance.java +++ b/src/main/java/com/minelittlepony/unicopia/client/sound/MagicAuraSoundInstance.java @@ -9,13 +9,14 @@ 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 { private final Living living; - public MagicAuraSoundInstance(SoundCategory category, Living living) { - super(USounds.ITEM_MAGIC_AURA, category, 1); + public MagicAuraSoundInstance(SoundCategory category, Living living, Random random) { + super(USounds.ITEM_MAGIC_AURA, category, 1, random); this.living = living; } 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 fce925cb..489b1bd8 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/sound/MotionBasedSoundInstance.java +++ b/src/main/java/com/minelittlepony/unicopia/client/sound/MotionBasedSoundInstance.java @@ -5,6 +5,7 @@ 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 { @@ -12,8 +13,8 @@ public class MotionBasedSoundInstance extends FadeOutSoundInstance { private int tickCount; - public MotionBasedSoundInstance(SoundEvent sound, PlayerEntity player) { - super(sound, player.getSoundCategory(), 0.1F); + public MotionBasedSoundInstance(SoundEvent sound, PlayerEntity player, Random random) { + super(sound, player.getSoundCategory(), 0.1F, random); this.player = player; } diff --git a/src/main/java/com/minelittlepony/unicopia/command/Commands.java b/src/main/java/com/minelittlepony/unicopia/command/Commands.java index 2844e16f..5417802d 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/Commands.java +++ b/src/main/java/com/minelittlepony/unicopia/command/Commands.java @@ -1,15 +1,16 @@ package com.minelittlepony.unicopia.command; -import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback; +import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; +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; +import net.minecraft.util.Identifier; public class Commands { @SuppressWarnings({ "deprecation", "unchecked", "rawtypes" }) public static void bootstrap() { - ArgumentTypes.register("unicopia:enumeration", EnumArgumentType.class, new EnumArgumentType.Serializer()); - CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> { + ArgumentTypeRegistry.registerArgumentType(new Identifier("unicopia", "enumeration"), EnumArgumentType.class, new EnumArgumentType.Serializer()); + CommandRegistrationCallback.EVENT.register((dispatcher, access, environment) -> { 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 a75f2a38..56af4365 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java @@ -26,13 +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.TranslatableText; +import net.minecraft.text.Text; import net.minecraft.util.Identifier; -import net.minecraft.util.Util; import net.minecraft.world.GameRules; public class DisguiseCommand { - private static final SimpleCommandExceptionType FAILED_EXCEPTION = new SimpleCommandExceptionType(new TranslatableText("commands.disguise.notfound")); + private static final SimpleCommandExceptionType FAILED_EXCEPTION = new SimpleCommandExceptionType(Text.translatable("commands.disguise.notfound")); public static void register(CommandDispatcher dispatcher) { dispatcher.register(CommandManager @@ -88,13 +87,13 @@ public class DisguiseCommand { .setDisguise(entity); if (source.getEntity() == player) { - source.sendFeedback(new TranslatableText("commands.disguise.success.self", entity.getName()), true); + source.sendFeedback(Text.translatable("commands.disguise.success.self", entity.getName()), true); } else { if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) { - player.sendSystemMessage(new TranslatableText("commands.disguise.success", entity.getName()), Util.NIL_UUID); + player.sendMessage(Text.translatable("commands.disguise.success", entity.getName())); } - source.sendFeedback(new TranslatableText("commands.disguise.success.other", player.getName(), entity.getName()), true); + source.sendFeedback(Text.translatable("commands.disguise.success.other", player.getName(), entity.getName()), true); } return 0; @@ -115,13 +114,13 @@ public class DisguiseCommand { iplayer.getSpellSlot().removeIf(SpellPredicate.IS_DISGUISE, true); if (source.getEntity() == player) { - source.sendFeedback(new TranslatableText("commands.disguise.removed.self"), true); + source.sendFeedback(Text.translatable("commands.disguise.removed.self"), true); } else { if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) { - player.sendSystemMessage(new TranslatableText("commands.disguise.removed"), Util.NIL_UUID); + player.sendMessage(Text.translatable("commands.disguise.removed")); } - source.sendFeedback(new TranslatableText("commands.disguise.removed.other", player.getName()), true); + source.sendFeedback(Text.translatable("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 2230ef9c..d3b104d4 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/EnumArgumentType.java +++ b/src/main/java/com/minelittlepony/unicopia/command/EnumArgumentType.java @@ -21,7 +21,9 @@ 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 { @@ -100,27 +102,52 @@ class EnumArgumentType> implements ArgumentType, Serializab return suggestions; } - public static class Serializer> implements ArgumentSerializer> { - @Override - public void toPacket(EnumArgumentType type, PacketByteBuf buf) { - try (ObjectOutputStream stream = new ObjectOutputStream(new ByteBufOutputStream(buf))) { - stream.writeObject(type); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - + public static class Serializer> implements ArgumentSerializer, Serializer.Properties> { @SuppressWarnings("unchecked") @Override - public EnumArgumentType fromPacket(PacketByteBuf buf) { + public Properties fromPacket(PacketByteBuf buf) { try (ObjectInputStream stream = new ObjectInputStream(new ByteBufInputStream(buf))) { - return (EnumArgumentType)stream.readObject(); + return getArgumentTypeProperties((EnumArgumentType)stream.readObject()); } catch (IOException | ClassNotFoundException e) { throw new RuntimeException(e); } } @Override - public void toJson(EnumArgumentType type, JsonObject json) { } + public void writePacket(Properties properties, PacketByteBuf buf) { + try (ObjectOutputStream stream = new ObjectOutputStream(new ByteBufOutputStream(buf))) { + stream.writeObject(properties.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; + } + } } } \ 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 13e98c52..88b9cfaf 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/GravityCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/GravityCommand.java @@ -10,8 +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.TranslatableText; -import net.minecraft.util.Util; +import net.minecraft.text.Text; import net.minecraft.world.GameRules; class GravityCommand { @@ -44,9 +43,9 @@ class GravityCommand { float gravity = iplayer.getPhysics().getGravityModifier(); if (source.getPlayer() == player) { - player.sendMessage(new TranslatableText(translationKey, gravity), false); + player.sendMessage(Text.translatable(translationKey, gravity), false); } else { - source.sendFeedback(new TranslatableText(translationKey + ".other", player.getName(), gravity), true); + source.sendFeedback(Text.translatable(translationKey + ".other", player.getName(), gravity), true); } return 0; @@ -61,13 +60,13 @@ class GravityCommand { iplayer.setDirty(); if (source.getEntity() == player) { - source.sendFeedback(new TranslatableText("commands.gamemode.success.self", gravity), true); + source.sendFeedback(Text.translatable("commands.gamemode.success.self", gravity), true); } else { if (source.getWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) { - player.sendSystemMessage(new TranslatableText(translationKey, gravity), Util.NIL_UUID); + player.sendMessage(Text.translatable(translationKey, gravity)); } - source.sendFeedback(new TranslatableText(translationKey + ".other", player.getName(), gravity), true); + source.sendFeedback(Text.translatable(translationKey + ".other", player.getName(), gravity), true); } 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 9c68614d..9307432c 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/RacelistCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/RacelistCommand.java @@ -11,7 +11,6 @@ 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 { @@ -52,9 +51,9 @@ class RacelistCommand { translationKey += ".failed"; } - Text formattedName = new TranslatableText(race.name().toLowerCase()).formatted(Formatting.GOLD); + Text formattedName = Text.translatable(race.name().toLowerCase()).formatted(Formatting.GOLD); - source.sendFeedback(new TranslatableText(translationKey, formattedName).formatted(Formatting.GREEN), false); + source.sendFeedback(Text.translatable(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 7abb242f..937112dd 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/SpeciesCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/SpeciesCommand.java @@ -9,10 +9,8 @@ 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.LiteralText; import net.minecraft.text.MutableText; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; import net.minecraft.util.Formatting; import net.minecraft.world.GameRules; @@ -54,18 +52,18 @@ class SpeciesCommand { pony.setSpecies(race); pony.setDirty(); - Text formattedName = new TranslatableText(race.name().toLowerCase()); + Text formattedName = Text.translatable(race.name().toLowerCase()); if (!isSelf) { - source.sendFeedback(new TranslatableText("commands.race.success.other", player.getName(), formattedName), true); + source.sendFeedback(Text.translatable("commands.race.success.other", player.getName(), formattedName), true); } else { if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) { - player.sendMessage(new TranslatableText("commands.race.success.self"), false); + player.sendMessage(Text.translatable("commands.race.success.self"), false); } - source.sendFeedback(new TranslatableText("commands.race.success.otherself", player.getName(), formattedName), true); + source.sendFeedback(Text.translatable("commands.race.success.otherself", player.getName(), formattedName), true); } } else if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) { - player.sendMessage(new TranslatableText("commands.race.permission"), false); + player.sendMessage(Text.translatable("commands.race.permission"), false); } return 0; @@ -77,22 +75,22 @@ class SpeciesCommand { String name = "commands.race.tell."; name += isSelf ? "self" : "other"; - player.sendMessage(new TranslatableText(name) - .append(new TranslatableText(spec.getTranslationKey()) + player.sendMessage(Text.translatable(name) + .append(Text.translatable(spec.getTranslationKey()) .styled(s -> s.withColor(Formatting.GOLD))), false); return 0; } static int list(PlayerEntity player) { - player.sendMessage(new TranslatableText("commands.race.list"), false); + player.sendMessage(Text.translatable("commands.race.list"), false); - MutableText message = new LiteralText(""); + MutableText message = Text.literal(""); boolean first = true; for (Race i : Race.values()) { if (!i.isDefault() && i.isPermitted(player)) { - message.append(new TranslatableText((!first ? "\n" : "") + " - " + i.name().toLowerCase())); + message.append(Text.translatable((!first ? "\n" : "") + " - " + i.name().toLowerCase())); first = false; } } @@ -105,9 +103,9 @@ class SpeciesCommand { static int describe(PlayerEntity player, Race species) { String name = species.name().toLowerCase(); - player.sendMessage(new TranslatableText(String.format("commands.race.describe.%s.1", name)).styled(s -> s.withColor(Formatting.YELLOW)), false); - player.sendMessage(new TranslatableText(String.format("commands.race.describe.%s.2", name)), false); - player.sendMessage(new TranslatableText(String.format("commands.race.describe.%s.3", name)).styled(s -> s.withColor(Formatting.RED)), false); + player.sendMessage(Text.translatable(String.format("commands.race.describe.%s.1", name)).styled(s -> s.withColor(Formatting.YELLOW)), false); + player.sendMessage(Text.translatable(String.format("commands.race.describe.%s.2", name)), false); + player.sendMessage(Text.translatable(String.format("commands.race.describe.%s.3", name)).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 1bc81dcb..828afe6e 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/TraitCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/TraitCommand.java @@ -12,8 +12,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.text.LiteralText; -import net.minecraft.text.TranslatableText; +import net.minecraft.text.*; import net.minecraft.util.Hand; class TraitCommand { @@ -44,13 +43,13 @@ class TraitCommand { static int add(ServerCommandSource source, PlayerEntity player, Trait trait, float amount) throws CommandSyntaxException { if (trait == null) { - source.sendError(new LiteralText("Invalid trait")); + source.sendError(Text.literal("Invalid trait")); return 0; } ItemStack stack = player.getMainHandStack(); if (stack.isEmpty()) { - source.sendError(new LiteralText("That trait cannot be added to the current item")); + source.sendError(Text.literal("That trait cannot be added to the current item")); return 0; } @@ -61,7 +60,7 @@ class TraitCommand { static int remove(ServerCommandSource source, PlayerEntity player, Trait trait) throws CommandSyntaxException { if (trait == null) { - source.sendError(new LiteralText("Invalid trait")); + source.sendError(Text.literal("Invalid trait")); return 0; } @@ -85,9 +84,9 @@ class TraitCommand { float gravity = iplayer.getPhysics().getGravityModifier(); if (source.getPlayer() == player) { - player.sendMessage(new TranslatableText(translationKey, gravity), false); + player.sendMessage(Text.translatable(translationKey, gravity), false); } else { - source.sendFeedback(new TranslatableText(translationKey + ".other", player.getName(), gravity), true); + source.sendFeedback(Text.translatable(translationKey + ".other", player.getName(), gravity), true); } return 0; diff --git a/src/main/java/com/minelittlepony/unicopia/container/SpellbookPage.java b/src/main/java/com/minelittlepony/unicopia/container/SpellbookPage.java index b9543543..e8e104d5 100644 --- a/src/main/java/com/minelittlepony/unicopia/container/SpellbookPage.java +++ b/src/main/java/com/minelittlepony/unicopia/container/SpellbookPage.java @@ -1,7 +1,6 @@ package com.minelittlepony.unicopia.container; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; import net.minecraft.util.math.MathHelper; public enum SpellbookPage { @@ -12,7 +11,7 @@ public enum SpellbookPage { public static final SpellbookPage[] VALUES = values(); private static int current; - private final Text label = new TranslatableText("gui.unicopia.spellbook.page." + name().toLowerCase()); + private final Text label = Text.translatable("gui.unicopia.spellbook.page." + name().toLowerCase()); public Text getLabel() { return label; diff --git a/src/main/java/com/minelittlepony/unicopia/container/SpellbookScreen.java b/src/main/java/com/minelittlepony/unicopia/container/SpellbookScreen.java index fbcf7204..7bbdeb64 100644 --- a/src/main/java/com/minelittlepony/unicopia/container/SpellbookScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/container/SpellbookScreen.java @@ -23,7 +23,6 @@ import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.screen.slot.Slot; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; import net.minecraft.util.Identifier; public class SpellbookScreen extends HandledScreen implements RecipeBookProvider { @@ -156,7 +155,7 @@ public class SpellbookScreen extends HandledScreen imple textRenderer.draw(matrices, title, titleX, titleY, 4210752); textRenderer.draw(matrices, SpellbookPage.getCurrent().getLabel(), 220, this.titleY, 4210752); - Text pageText = new TranslatableText("%s/%s", SpellbookPage.getCurrent().ordinal() + 1, SpellbookPage.VALUES.length); + Text pageText = Text.translatable("%s/%s", SpellbookPage.getCurrent().ordinal() + 1, SpellbookPage.VALUES.length); textRenderer.draw(matrices, pageText, x + 325 - textRenderer.getWidth(pageText) / 2F, y + 188 - textRenderer.fontHeight, 4210752); } diff --git a/src/main/java/com/minelittlepony/unicopia/container/UScreenHandlers.java b/src/main/java/com/minelittlepony/unicopia/container/UScreenHandlers.java index 719f7548..4a6f1c05 100644 --- a/src/main/java/com/minelittlepony/unicopia/container/UScreenHandlers.java +++ b/src/main/java/com/minelittlepony/unicopia/container/UScreenHandlers.java @@ -1,16 +1,15 @@ package com.minelittlepony.unicopia.container; -import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry; -import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry.SimpleClientHandlerFactory; import net.minecraft.screen.ScreenHandler; import net.minecraft.screen.ScreenHandlerType; import net.minecraft.util.Identifier; +import net.minecraft.util.registry.Registry; public interface UScreenHandlers { ScreenHandlerType SPELL_BOOK = register("spell_book", SpellbookScreenHandler::new); - static ScreenHandlerType register(String name, SimpleClientHandlerFactory factory) { - return ScreenHandlerRegistry.registerSimple(new Identifier("unicopia", name), factory); + static ScreenHandlerType register(String name, ScreenHandlerType.Factory factory) { + return Registry.register(Registry.SCREEN_HANDLER, new Identifier("unicopia", name), new ScreenHandlerType<>(factory)); } static void bootstrap() { } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ButterflyEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/ButterflyEntity.java index 3de20c98..8521df6b 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ButterflyEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ButterflyEntity.java @@ -3,7 +3,6 @@ package com.minelittlepony.unicopia.entity; import java.util.HashMap; import java.util.Map; import java.util.Optional; -import java.util.Random; import org.jetbrains.annotations.Nullable; @@ -31,6 +30,7 @@ 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 0bae579e..ef93ff15 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/CastSpellEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/CastSpellEntity.java @@ -21,7 +21,6 @@ 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 { @@ -54,7 +53,7 @@ public class CastSpellEntity extends LightEmittingEntity implements Caster, Owned { private static final TrackedData ITEM_RACE = DataTracker.registerData(ItemEntity.class, TrackedDataHandlerRegistry.INTEGER); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/UEntities.java b/src/main/java/com/minelittlepony/unicopia/entity/UEntities.java index a537fa87..3d37c8a0 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/UEntities.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/UEntities.java @@ -13,10 +13,10 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityDimensions; import net.minecraft.entity.EntityType; import net.minecraft.entity.SpawnGroup; +import net.minecraft.tag.BiomeTags; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; import net.minecraft.world.biome.Biome; -import net.minecraft.world.biome.Biome.Category; public interface UEntities { EntityType BUTTERFLY = register("butterfly", FabricEntityTypeBuilder.create(SpawnGroup.AMBIENT, ButterflyEntity::new) @@ -59,8 +59,15 @@ public interface UEntities { final Predicate butterflySpawnable = BiomeSelectors.foundInOverworld() .and(ctx -> ctx.getBiome().getPrecipitation() == Biome.Precipitation.RAIN); - BiomeModifications.addSpawn(butterflySpawnable.and(BiomeSelectors.categories(Category.RIVER, Category.FOREST, Category.EXTREME_HILLS)), SpawnGroup.AMBIENT, BUTTERFLY, 3, 3, 12); - BiomeModifications.addSpawn(butterflySpawnable.and(BiomeSelectors.categories(Category.PLAINS, Category.JUNGLE)), SpawnGroup.AMBIENT, BUTTERFLY, 7, 5, 19); + BiomeModifications.addSpawn(butterflySpawnable.and( + BiomeSelectors.tag(BiomeTags.IS_RIVER) + .or(BiomeSelectors.tag(BiomeTags.IS_FOREST)) + .or(BiomeSelectors.tag(BiomeTags.IS_HILL)) + ), SpawnGroup.AMBIENT, BUTTERFLY, 3, 3, 12); + BiomeModifications.addSpawn(butterflySpawnable.and( + BiomeSelectors.tag(BiomeTags.IS_JUNGLE) + .or(BiomeSelectors.tag(BiomeTags.IS_MOUNTAIN)) + ), SpawnGroup.AMBIENT, BUTTERFLY, 7, 5, 19); UTradeOffers.bootstrap(); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/UTradeOffers.java b/src/main/java/com/minelittlepony/unicopia/entity/UTradeOffers.java index 8b52020f..8d4b6319 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/UTradeOffers.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/UTradeOffers.java @@ -1,7 +1,5 @@ package com.minelittlepony.unicopia.entity; -import java.util.Random; - import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.UTags; @@ -18,6 +16,7 @@ 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/BeeBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/BeeBehaviour.java index 7d054758..77ba854f 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/BeeBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/BeeBehaviour.java @@ -10,7 +10,7 @@ public class BeeBehaviour extends EntityBehaviour { public BeeEntity onCreate(BeeEntity entity, EntityAppearance context, boolean replaceOld) { super.onCreate(entity, context, replaceOld); if (replaceOld && entity.world.isClient) { - InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_BEE); + InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_BEE, entity.getId()); } return entity; } 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 f6790006..d0f7e9ba 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); } + public PlayerAccess() { super(null, null, 0, null, null); } static TrackedData getModelBitFlag() { return PLAYER_MODEL_PARTS; } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MinecartBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MinecartBehaviour.java index 48e1fead..0f563e07 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MinecartBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MinecartBehaviour.java @@ -12,7 +12,7 @@ public class MinecartBehaviour extends EntityBehaviour { public AbstractMinecartEntity onCreate(AbstractMinecartEntity entity, EntityAppearance context, boolean replaceOld) { super.onCreate(entity, context, replaceOld); if (replaceOld && entity.world.isClient) { - InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_MINECART); + InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_MINECART, entity.getId()); } return entity; } 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 8c3058c7..5d67e1ef 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SheepBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SheepBehaviour.java @@ -1,7 +1,5 @@ package com.minelittlepony.unicopia.entity.behaviour; -import java.util.Random; - import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.mixin.MixinSheepEntity; @@ -14,6 +12,7 @@ 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 7b6f90cb..43ed9904 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SteedBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SteedBehaviour.java @@ -2,17 +2,12 @@ package com.minelittlepony.unicopia.entity.behaviour; import com.minelittlepony.unicopia.entity.player.Pony; -import net.minecraft.entity.JumpingMount; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.passive.HorseBaseEntity; +import net.minecraft.entity.passive.*; -public class SteedBehaviour extends EntityBehaviour { +public class SteedBehaviour extends EntityBehaviour { @Override - public void update(Pony player, T entity, Disguise spell) { - - HorseBaseEntity horse = ((HorseBaseEntity)entity); - + public void update(Pony player, T horse, Disguise spell) { boolean angry = !player.getEntity().isOnGround() && player.getMaster().isSprinting(); boolean sneaking = isSneakingOnGround(player); 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 a0961cfe..f61cc294 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/effect/RaceChangeStatusEffect.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/effect/RaceChangeStatusEffect.java @@ -18,7 +18,6 @@ import net.minecraft.entity.effect.StatusEffectCategory; 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; @@ -142,7 +141,7 @@ public class RaceChangeStatusEffect extends StatusEffect { } public Text getMessage(Race race) { - return new TranslatableText(getTranslationKey(), race.getDisplayName()); + return Text.translatable(getTranslationKey(), race.getDisplayName()); } } } 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 67bb87c1..6d949c3b 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java @@ -194,7 +194,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab if (typeChanged) { pony.spawnParticles(ParticleTypes.CLOUD, 10); - entity.playSound(entity.world.getDimension().isUltrawarm() ? USounds.ITEM_ICARUS_WINGS_CORRUPT : USounds.ITEM_ICARUS_WINGS_PURIFY, 0.1125F, 1.5F); + entity.playSound(entity.world.getDimension().ultrawarm() ? USounds.ITEM_ICARUS_WINGS_CORRUPT : USounds.ITEM_ICARUS_WINGS_PURIFY, 0.1125F, 1.5F); } entity.getAbilities().allowFlying = type.canFlyCreative(entity); @@ -345,7 +345,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab if (!SpellPredicate.IS_DISGUISE.isOn(pony)) { if (ticksInAir % GLIDING_SOUND_INTERVAL == 1 && pony.isClient()) { - InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_GLIDING); + InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_GLIDING, entity.getId()); } } @@ -355,7 +355,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab } else if (type == FlightType.INSECTOID && !SpellPredicate.IS_DISGUISE.isOn(pony)) { if (entity.world.isClient && !soundPlaying) { soundPlaying = true; - InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_CHANGELING_BUZZ); + InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_CHANGELING_BUZZ, entity.getId()); } } } @@ -371,7 +371,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab if (entity.world.hasRain(entity.getBlockPos())) { energyConsumed *= 3; } - if (entity.world.getDimension().isUltrawarm()) { + if (entity.world.getDimension().ultrawarm()) { 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 452bbe17..5ef59449 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java @@ -63,7 +63,6 @@ import net.minecraft.network.packet.s2c.play.EntityPassengersSetS2CPacket; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; @@ -356,7 +355,6 @@ public class Pony extends Living implements Transmittable, Copieab if (getSpecies() == Race.BAT) { if (SunBlindnessStatusEffect.hasSunExposure(entity)) { - System.out.println("Sun exposure " + entity); if (ticksInSun < 200) { ticksInSun++; } @@ -366,7 +364,7 @@ public class Pony extends Living implements Transmittable, Copieab entity.addStatusEffect(new StatusEffectInstance(UEffects.SUN_BLINDNESS, SunBlindnessStatusEffect.MAX_DURATION * 10, 1, true, false)); UCriteria.LOOK_INTO_SUN.trigger(entity); } else if (isClientPlayer()) { - InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_EARS_RINGING); + InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_EARS_RINGING, getEntity().getId()); } } } else if (ticksInSun > 0) { @@ -434,6 +432,7 @@ 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); @@ -500,13 +499,13 @@ public class Pony extends Living implements Transmittable, Copieab public Optional trySleep(BlockPos pos) { if (UItems.ALICORN_AMULET.isApplicable(entity)) { - return Optional.of(new TranslatableText("block.unicopia.bed.not_tired")); + return Optional.of(Text.translatable("block.unicopia.bed.not_tired")); } return findAllSpellsInRange(10) .filter(p -> p instanceof Pony && ((Pony)p).isEnemy(this)) .findFirst() - .map(p -> new TranslatableText("block.unicopia.bed.not_safe")); + .map(p -> Text.translatable("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 af23246e..0c1eb9f8 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.LiteralText; +import net.minecraft.text.Text; 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); + super(world, profile, null); } @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()); + playerInfo = new PlayerListEntry(new Packet().entry(), MinecraftClient.getInstance().getServicesSignatureVerifier()); } } @@ -57,7 +57,7 @@ public class DummyClientPlayerEntity extends AbstractClientPlayerEntity implemen } @Override - protected void onEquipStack(ItemStack stack) { + protected void playEquipSound(ItemStack stack) { /*noop*/ } @@ -87,7 +87,7 @@ public class DummyClientPlayerEntity extends AbstractClientPlayerEntity implemen getGameProfile(), 0, GameMode.DEFAULT, - new LiteralText(getGameProfile().getName())); + Text.literal(getGameProfile().getName()), null); } } } 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 a4caa6a4..07b8c1bb 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(new TranslatableText(getTranslationKey() + ".lore", StringHelper.formatTicks(attachedTime))); + tooltip.add(Text.translatable(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 d0365fb4..da51b994 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/AmuletItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/AmuletItem.java @@ -22,12 +22,10 @@ import net.minecraft.item.ArmorMaterials; import net.minecraft.item.ItemStack; import net.minecraft.particle.ParticleTypes; import net.minecraft.sound.SoundEvent; -import net.minecraft.text.LiteralText; import net.minecraft.text.MutableText; import net.minecraft.text.StringVisitable; import net.minecraft.text.Style; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; import net.minecraft.util.Formatting; import net.minecraft.world.World; @@ -54,7 +52,7 @@ public class AmuletItem extends WearableItem { && entity instanceof LivingEntity && ((LivingEntity) entity).getEquippedStack(EquipmentSlot.CHEST) == stack && isApplicable((LivingEntity)entity)) { - ParticleUtils.spawnParticles(entity.world.getDimension().isUltrawarm() ? ParticleTypes.SOUL_FIRE_FLAME : ParticleTypes.COMPOSTER, entity, 1); + ParticleUtils.spawnParticles(entity.world.getDimension().ultrawarm() ? ParticleTypes.SOUL_FIRE_FLAME : ParticleTypes.COMPOSTER, entity, 1); } } @@ -62,8 +60,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( - new TranslatableText(getTranslationKey(stack) + ".lore"), 150, Style.EMPTY)) { - MutableText compiled = new LiteralText("").formatted(Formatting.ITALIC, Formatting.GRAY); + Text.translatable(getTranslationKey(stack) + ".lore"), 150, Style.EMPTY)) { + MutableText compiled = Text.literal("").formatted(Formatting.ITALIC, Formatting.GRAY); line.visit(s -> { compiled.append(s); return Optional.empty(); @@ -72,7 +70,7 @@ public class AmuletItem extends WearableItem { } if (isChargable()) { - list.add(new TranslatableText("item.unicopia.amulet.energy", (int)Math.floor(getEnergy(stack)), maxEnergy)); + list.add(Text.translatable("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 60338d85..870ce1ef 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/FilledJarItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/FilledJarItem.java @@ -19,7 +19,6 @@ 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; @@ -32,7 +31,7 @@ public class FilledJarItem extends JarItem implements ChameleonItem { @Override public Text getName(ItemStack stack) { - return hasAppearance(stack) ? new TranslatableText(getTranslationKey(stack), getAppearanceStack(stack).getName()) : UItems.EMPTY_JAR.getName(UItems.EMPTY_JAR.getDefaultStack()); + return hasAppearance(stack) ? Text.translatable(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 42bfa4ce..6b18df71 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/FriendshipBraceletItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/FriendshipBraceletItem.java @@ -20,7 +20,6 @@ import net.minecraft.item.DyeableItem; import net.minecraft.item.ItemStack; import net.minecraft.stat.Stats; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; import net.minecraft.util.Formatting; import net.minecraft.util.Hand; import net.minecraft.util.TypedActionResult; @@ -41,7 +40,7 @@ public class FriendshipBraceletItem extends WearableItem implements DyeableItem, ItemStack result = stack.copy(); result.setCount(1); - result.getOrCreateNbt().putString("issuer", player.getName().asString()); + result.getOrCreateNbt().putString("issuer", player.getName().getString()); result.getOrCreateNbt().putUuid("issuer_id", player.getUuid()); if (!player.getAbilities().creativeMode) { @@ -67,10 +66,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(new TranslatableText("item.unicopia.friendship_bracelet.issuer", getSignatorName(stack))); + list.add(Text.translatable("item.unicopia.friendship_bracelet.issuer", getSignatorName(stack))); } if (isGlowing(stack)) { - list.add(new TranslatableText("item.unicopia.friendship_bracelet.glowing").formatted(Formatting.ITALIC, Formatting.GRAY)); + list.add(Text.translatable("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 538be17f..9380cba5 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/GemstoneItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/GemstoneItem.java @@ -22,7 +22,6 @@ import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.text.MutableText; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; import net.minecraft.util.Formatting; import net.minecraft.util.Hand; import net.minecraft.util.Identifier; @@ -61,7 +60,7 @@ public class GemstoneItem extends Item { if (isEnchanted(stack)) { SpellType key = getSpellKey(stack); - MutableText line = new TranslatableText(key.getTranslationKey() + ".lore").formatted(key.getAffinity().getColor()); + MutableText line = Text.translatable(key.getTranslationKey() + ".lore").formatted(key.getAffinity().getColor()); if (!Unicopia.SIDE.getPlayerSpecies().canCast()) { line = line.formatted(Formatting.OBFUSCATED); @@ -94,10 +93,10 @@ public class GemstoneItem extends Item { public Text getName(ItemStack stack) { if (isEnchanted(stack)) { if (!Unicopia.SIDE.getPlayerSpecies().canCast()) { - return new TranslatableText(getTranslationKey(stack) + ".obfuscated"); + return Text.translatable(getTranslationKey(stack) + ".obfuscated"); } - return new TranslatableText(getTranslationKey(stack) + ".enchanted", getSpellKey(stack).getName()); + return Text.translatable(getTranslationKey(stack) + ".enchanted", getSpellKey(stack).getName()); } return super.getName(); } diff --git a/src/main/java/com/minelittlepony/unicopia/item/URecipes.java b/src/main/java/com/minelittlepony/unicopia/item/URecipes.java index 48ccf9a9..60f79f19 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/URecipes.java +++ b/src/main/java/com/minelittlepony/unicopia/item/URecipes.java @@ -1,11 +1,12 @@ package com.minelittlepony.unicopia.item; +import java.util.List; + import com.google.gson.JsonArray; import com.minelittlepony.unicopia.ability.magic.spell.crafting.SpellbookRecipe; import com.minelittlepony.unicopia.ability.magic.spell.crafting.TraitRequirementRecipe; -import net.fabricmc.fabric.api.loot.v1.FabricLootSupplier; -import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback; +import net.fabricmc.fabric.api.loot.v2.LootTableEvents; import net.minecraft.loot.LootTable; import net.minecraft.recipe.Ingredient; import net.minecraft.recipe.RecipeSerializer; @@ -37,7 +38,7 @@ public interface URecipes { } static void bootstrap() { - LootTableLoadingCallback.EVENT.register((res, manager, id, supplier, setter) -> { + LootTableEvents.MODIFY.register((res, manager, id, supplier, setter) -> { if (!"minecraft".contentEquals(id.getNamespace())) { return; } @@ -45,7 +46,7 @@ public interface URecipes { Identifier modId = new Identifier("unicopiamc", id.getPath()); LootTable table = manager.getTable(modId); if (table != LootTable.EMPTY) { - supplier.withPools(((FabricLootSupplier)table).getPools()); + supplier.pools(List.of(table.pools)); } }); } diff --git a/src/main/java/com/minelittlepony/unicopia/item/enchantment/GemFindingEnchantment.java b/src/main/java/com/minelittlepony/unicopia/item/enchantment/GemFindingEnchantment.java index 5b1ec818..6adf346e 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/enchantment/GemFindingEnchantment.java +++ b/src/main/java/com/minelittlepony/unicopia/item/enchantment/GemFindingEnchantment.java @@ -37,7 +37,7 @@ public class GemFindingEnchantment extends SimpleEnchantment { @Override public void onEquipped(Living user) { if (user.isClient()) { - MinecraftClient.getInstance().getSoundManager().play(new MagicAuraSoundInstance(user.getEntity().getSoundCategory(), user)); + MinecraftClient.getInstance().getSoundManager().play(new MagicAuraSoundInstance(user.getEntity().getSoundCategory(), user, user.getReferenceWorld().getRandom())); } } 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 408dd750..eecee10c 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/enchantment/PoisonedJokeEnchantment.java +++ b/src/main/java/com/minelittlepony/unicopia/item/enchantment/PoisonedJokeEnchantment.java @@ -3,7 +3,6 @@ package com.minelittlepony.unicopia.item.enchantment; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; -import java.util.Random; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; import java.util.stream.Collectors; @@ -21,6 +20,7 @@ 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; 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 af8dd7db..f901adac 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/toxin/Toxicity.java +++ b/src/main/java/com/minelittlepony/unicopia/item/toxin/Toxicity.java @@ -6,7 +6,6 @@ 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 { @@ -29,7 +28,7 @@ public enum Toxicity { } public Text getTooltip() { - return new TranslatableText(getTranslationKey()).formatted(color); + return Text.translatable(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 22989f4d..1ce0f337 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/toxin/Toxin.java +++ b/src/main/java/com/minelittlepony/unicopia/item/toxin/Toxin.java @@ -12,7 +12,6 @@ import net.minecraft.item.FoodComponent; import net.minecraft.item.ItemStack; import net.minecraft.text.MutableText; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; import net.minecraft.util.StringHelper; import net.minecraft.world.Difficulty; @@ -68,7 +67,7 @@ public interface Toxin extends Affliction { @Override public Text getName() { - return self.getName().shallowCopy().append(" + ").append(other.getName()); + return self.getName().copy().append(" + ").append(other.getName()); } }; } @@ -90,13 +89,13 @@ public interface Toxin extends Affliction { static Toxin of(StatusEffect effect, int seconds, int amplifier) { int ticks = seconds * 20; - MutableText text = effect.getName().shallowCopy(); + MutableText text = effect.getName().copy(); if (amplifier > 0) { - text = new TranslatableText("potion.withAmplifier", text, new TranslatableText("potion.potency." + amplifier)); + text = Text.translatable("potion.withAmplifier", text, Text.translatable("potion.potency." + amplifier)); } - text = new TranslatableText("potion.withDuration", text, StringHelper.formatTicks(ticks)); + text = Text.translatable("potion.withDuration", text, StringHelper.formatTicks(ticks)); return of(text, (player, stack) -> { StatusEffectInstance current = player.getStatusEffect(effect); @@ -138,7 +137,7 @@ public interface Toxin extends Affliction { @Override public Text getName() { - return Predicate.this.getName().shallowCopy().append(toxin.getName()); + return Predicate.this.getName().copy().append(toxin.getName()); } }; } diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinDamageSource.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinDamageSource.java index 570eb4c0..caa1544b 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinDamageSource.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinDamageSource.java @@ -11,7 +11,6 @@ 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 { @@ -23,11 +22,11 @@ abstract class MixinDamageSource { Entity prime = entity.getPrimeAdversary(); if (prime != null && !(attacker instanceof Owned && ((Owned)attacker).isOwnedBy(prime))) { - info.setReturnValue(new TranslatableText("death.attack.generic.and_also", info.getReturnValue(), attacker.getDisplayName())); + info.setReturnValue(Text.translatable("death.attack.generic.and_also", info.getReturnValue(), attacker.getDisplayName())); return; } - info.setReturnValue(new TranslatableText("death.attack." + self.getName() + ".player", entity.getDisplayName(), attacker.getDisplayName())); + info.setReturnValue(Text.translatable("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 873ddd72..6c6d60c2 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, MotionChecker { - MixinServerPlayerEntity() {super(null, null, 0, null);} + MixinServerPlayerEntity() {super(null, null, 0, null, 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 d6d12835..67d8a6e2 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 { - private MixinServerWorld() {super(null, null, null, null, false, false, 0);} + MixinServerWorld() { super(null, null, null, null, false, false, 0, 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 a79b899c..f67de81c 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(Z)V", at = @At("RETURN")) - private void onTick(boolean strafe, CallbackInfo info) { + @Inject(method = "tick(ZF)V", at = @At("RETURN")) + private void onTick(boolean a, float b, 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/handler/ClientNetworkHandlerImpl.java b/src/main/java/com/minelittlepony/unicopia/network/handler/ClientNetworkHandlerImpl.java index abc8c777..92115dfa 100644 --- a/src/main/java/com/minelittlepony/unicopia/network/handler/ClientNetworkHandlerImpl.java +++ b/src/main/java/com/minelittlepony/unicopia/network/handler/ClientNetworkHandlerImpl.java @@ -47,7 +47,7 @@ public class ClientNetworkHandlerImpl implements ClientNetworkHandler { } if (entity.getType() == UEntities.MAGIC_BEAM) { - InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_MAGIC_BEAM); + InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_MAGIC_BEAM, entity.getId()); } world.addEntity(packet.getId(), entity); diff --git a/src/main/java/com/minelittlepony/unicopia/particle/MagicParticleEffect.java b/src/main/java/com/minelittlepony/unicopia/particle/MagicParticleEffect.java index aac8668b..d1161dd1 100644 --- a/src/main/java/com/minelittlepony/unicopia/particle/MagicParticleEffect.java +++ b/src/main/java/com/minelittlepony/unicopia/particle/MagicParticleEffect.java @@ -1,7 +1,6 @@ package com.minelittlepony.unicopia.particle; import java.util.Locale; -import java.util.Random; import com.minelittlepony.common.util.Color; import com.mojang.brigadier.StringReader; @@ -12,6 +11,7 @@ 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 35e4cc59..376906a7 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/MagicalDamageSource.java +++ b/src/main/java/com/minelittlepony/unicopia/util/MagicalDamageSource.java @@ -13,7 +13,6 @@ 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 +88,6 @@ public class MagicalDamageSource extends EntityDamageSource { params.add(item.toHoverableText()); } - return new TranslatableText(basic, params.toArray()); + return Text.translatable(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 5e84d25d..ab78f637 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/Resources.java +++ b/src/main/java/com/minelittlepony/unicopia/util/Resources.java @@ -22,15 +22,12 @@ public interface Resources { .create(); static Stream getResources(ResourceManager manager, Identifier id) { - try { - return manager.getAllResources(id).stream(); - } catch (IOException ignored) { } - return Stream.empty(); + return manager.getAllResources(id).stream(); } static Stream loadFile(Resource res, Type type, String msg) throws JsonParseException { - try (Resource resource = res) { - return (GSON.>fromJson(new InputStreamReader(resource.getInputStream()), type)).stream(); + try (InputStreamReader reader = new InputStreamReader(res.getInputStream())) { + return (GSON.>fromJson(reader, type)).stream(); } catch (JsonParseException e) { Unicopia.LOGGER.warn(msg + res.getResourcePackName(), e); } catch (IOException ignored) {} 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 74d703ff..b68ed3df 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/shape/Cylinder.java +++ b/src/main/java/com/minelittlepony/unicopia/util/shape/Cylinder.java @@ -1,9 +1,8 @@ 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 a9b0e5f3..806198c3 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/shape/Line.java +++ b/src/main/java/com/minelittlepony/unicopia/util/shape/Line.java @@ -1,9 +1,8 @@ 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 6e1c1d7b..e133bc56 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/shape/PointGenerator.java +++ b/src/main/java/com/minelittlepony/unicopia/util/shape/PointGenerator.java @@ -1,6 +1,5 @@ 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; @@ -11,6 +10,7 @@ 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 047db6e7..ecf666cd 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/shape/Sphere.java +++ b/src/main/java/com/minelittlepony/unicopia/util/shape/Sphere.java @@ -2,8 +2,7 @@ package com.minelittlepony.unicopia.util.shape; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; - -import java.util.Random; +import net.minecraft.util.math.random.Random; /** * A sphere, or 2d circle of you so desire. diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index e369155f..c723fd95 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -34,13 +34,10 @@ "fabricloader": ">=0.12.0", "java": ">=17", "fabric-api-base": ">=0.1.0", - "fabric-events-lifecycle-v0": ">=0.1.0", "kirin": "*" }, "suggests": { "minelp": "*", - "modmenu": "*", - "fabric-keybindings-v0": ">=0.1.0", - "fabric-rendering-v1": ">=0.1.0" + "modmenu": "*" } }