From 55e990882e6b8c1012c9d54716ecca612474eb37 Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 4 Aug 2021 15:38:03 +0200 Subject: [PATCH] 1.16.5 -> 1.17 --- build.gradle | 71 +++++++++--------- gradle.properties | 16 ++-- .../unicopia/EquinePredicates.java | 6 +- .../unicopia/InteractionManager.java | 6 +- .../com/minelittlepony/unicopia/Race.java | 4 +- .../unicopia/WorldTribeManager.java | 17 ++--- .../unicopia/ability/Ability.java | 2 +- .../unicopia/ability/AbilityDispatcher.java | 18 ++--- .../ability/ChangelingDisguiseAbility.java | 2 +- .../ability/ChangelingFeedAbility.java | 2 +- .../ability/EarthPonyKickAbility.java | 2 +- .../ability/EarthPonyStompAbility.java | 4 +- .../ability/PegasusCaptureStormAbility.java | 4 +- .../ability/PegasusRainboomAbility.java | 2 +- .../ability/UnicornCastingAbility.java | 2 +- .../ability/UnicornProjectileAbility.java | 2 +- .../unicopia/ability/magic/Caster.java | 2 +- .../ability/magic/SpellContainer.java | 2 +- .../unicopia/ability/magic/Thrown.java | 4 +- .../magic/spell/AbstractPlacedSpell.java | 8 +- .../ability/magic/spell/AbstractSpell.java | 6 +- .../ability/magic/spell/AttractiveSpell.java | 8 +- .../ability/magic/spell/DisguiseSpell.java | 8 +- .../ability/magic/spell/IceSpell.java | 3 +- .../ability/magic/spell/JoustingSpell.java | 8 +- .../ability/magic/spell/NecromancySpell.java | 14 ++-- .../ability/magic/spell/ScorchSpell.java | 2 +- .../ability/magic/spell/ShieldSpell.java | 3 +- .../ability/magic/spell/SiphoningSpell.java | 8 +- .../ability/magic/spell/SpellType.java | 10 +-- .../block/state/BlockStateConverter.java | 8 +- .../unicopia/block/state/BlockStateMap.java | 8 +- .../unicopia/block/state/StateMapping.java | 10 +-- .../client/ClientInteractionManager.java | 6 +- .../unicopia/client/KeyBindingsHandler.java | 2 +- .../client/ModifierTooltipRenderer.java | 6 +- .../unicopia/client/URenderers.java | 8 +- .../unicopia/client/UnicopiaClient.java | 2 +- .../unicopia/client/gui/ManaRingSlot.java | 3 +- .../unicopia/client/gui/SettingsScreen.java | 14 ++-- .../unicopia/client/gui/Slot.java | 1 - .../unicopia/client/gui/UHud.java | 23 +++--- .../unicopia/client/minelittlepony/Main.java | 8 +- .../particle/AbstractBillboardParticle.java | 12 ++- .../client/particle/MagicParticle.java | 4 +- .../particle/OrientedBillboardParticle.java | 18 ++--- .../client/particle/RainbowTrailParticle.java | 22 +++--- .../client/particle/RunesParticle.java | 20 ++--- .../unicopia/client/particle/SphereModel.java | 10 +-- .../client/render/AmuletFeatureRenderer.java | 31 ++++++-- .../render/BraceletFeatureRenderer.java | 37 +++++++--- .../render/CastSpellEntityRenderer.java | 7 +- .../FloatingArtefactEntityRenderer.java | 15 ++-- .../unicopia/client/render/RenderLayers.java | 29 +++----- .../client/render/WingsFeatureRenderer.java | 74 +++++++++++-------- .../client/render/WorldRenderDelegate.java | 22 +++--- .../client/sound/MagicAuraSoundInstance.java | 2 +- .../unicopia/command/DisguiseCommand.java | 12 +-- .../unicopia/entity/CastSpellEntity.java | 18 ++--- .../unicopia/entity/Creature.java | 8 +- .../unicopia/entity/Enchantments.java | 18 ++--- .../unicopia/entity/EntityPhysics.java | 13 ++-- .../unicopia/entity/EntityReference.java | 12 +-- .../unicopia/entity/Equine.java | 4 +- .../entity/FloatingArtefactEntity.java | 12 +-- .../unicopia/entity/ItemImpl.java | 10 +-- .../unicopia/entity/ItemPhysics.java | 3 +- .../unicopia/entity/Living.java | 16 ++-- .../unicopia/entity/PonyContainer.java | 2 +- .../unicopia/entity/ai/BreakHeartGoal.java | 2 +- .../unicopia/entity/ai/DynamicTargetGoal.java | 2 +- .../unicopia/entity/ai/WantItTakeItGoal.java | 11 +-- .../entity/behaviour/ChickenBehaviour.java | 6 +- .../unicopia/entity/behaviour/Disguise.java | 47 ++++++------ .../entity/behaviour/EntityBehaviour.java | 21 +++--- .../behaviour/FallingBlockBehaviour.java | 16 ++-- .../entity/behaviour/GhastBehaviour.java | 9 ++- .../entity/behaviour/HoppingBehaviour.java | 3 +- .../entity/behaviour/MinecartBehaviour.java | 4 +- .../entity/behaviour/SheepBehaviour.java | 5 +- .../entity/behaviour/ShulkerBehaviour.java | 11 +-- .../SpellcastingIllagerBehaviour.java | 8 ++ .../entity/effect/RaceChangeStatusEffect.java | 2 +- .../unicopia/entity/player/ManaContainer.java | 3 +- .../entity/player/PlayerAttributes.java | 2 +- .../entity/player/PlayerDimensions.java | 2 +- .../unicopia/entity/player/PlayerPhysics.java | 56 +++++++------- .../unicopia/entity/player/Pony.java | 27 +++---- .../player/dummy/DummyClientPlayerEntity.java | 9 ++- .../player/dummy/DummyServerPlayerEntity.java | 3 +- .../unicopia/item/AmuletItem.java | 2 +- .../unicopia/item/AppleItem.java | 9 ++- .../unicopia/item/CrystalHeartItem.java | 2 +- .../unicopia/item/DrinkableItem.java | 2 +- .../unicopia/item/FriendshipBraceletItem.java | 4 +- .../unicopia/item/GemstoneItem.java | 2 +- .../unicopia/item/GlowableItem.java | 4 +- .../minelittlepony/unicopia/item/JarItem.java | 13 ++-- .../unicopia/item/ZapAppleItem.java | 2 +- .../enchantment/GemFindingEnchantment.java | 11 +-- .../unicopia/mixin/MixinBlockEntity.java | 6 +- .../unicopia/mixin/MixinEntity.java | 12 +++ .../unicopia/mixin/MixinItem.java | 2 +- .../unicopia/mixin/MixinItemEntity.java | 12 +-- .../unicopia/mixin/MixinLivingEntity.java | 14 ++-- .../unicopia/mixin/MixinPlayerEntity.java | 16 ++-- .../unicopia/mixin/MixinShulkerEntity.java | 10 +++ .../unicopia/mixin/MixinTargetPredicate.java | 2 +- .../unicopia/mixin/MixinWorld.java | 2 +- .../unicopia/mixin/MixinWorldChunk.java | 1 - .../mixin/client/MixinGameRenderer.java | 8 +- .../unicopia/mixin/client/MixinItem.java | 2 +- .../mixin/client/MixinKeyboardInput.java | 2 +- .../mixin/client/MixinWorldRenderer.java | 4 +- .../unicopia/modmenu/UMenuFactory.java | 4 +- .../unicopia/network/EffectSync.java | 14 ++-- .../network/MsgPlayerCapabilities.java | 6 +- .../unicopia/network/MsgSpawnProjectile.java | 25 ++----- .../particle/FollowingParticleEffect.java | 4 +- .../unicopia/particle/ParticleHandle.java | 2 +- .../projectile/MagicProjectileEntity.java | 24 +++--- .../unicopia/projectile/ProjectileUtil.java | 2 +- .../unicopia/util/CustomStatusEffect.java | 12 +-- .../unicopia/util/MagicalDamageSource.java | 2 +- .../unicopia/util/NbtSerialisable.java | 26 +++---- .../unicopia/util/PosHelper.java | 2 +- .../unicopia/util/RayTraceHelper.java | 2 +- .../unicopia/util/Tickable.java | 5 ++ .../unicopia/util/VecHelper.java | 5 +- .../unicopia/util/Weighted.java | 6 +- src/main/resources/fabric.mod.json | 1 + src/main/resources/unicopia.aw | 3 + src/main/resources/unicopia.mixin.json | 3 +- 133 files changed, 688 insertions(+), 629 deletions(-) create mode 100644 src/main/java/com/minelittlepony/unicopia/mixin/MixinEntity.java create mode 100644 src/main/java/com/minelittlepony/unicopia/util/Tickable.java create mode 100644 src/main/resources/unicopia.aw diff --git a/build.gradle b/build.gradle index ace30d5e..78c61c3a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,32 +1,43 @@ plugins { id 'java-library' id 'fabric-loom' version '0.8-SNAPSHOT' + id 'org.ajoberstar.reckon' version '0.13.0' } -apply plugin: 'fabric-loom' - -targetCompatibility = JavaVersion.VERSION_1_8 -sourceCompatibility = JavaVersion.VERSION_1_8 - -version = "${project.minecraft_version}-${project.version}" - -if (project.release != 'RELEASE') { - version += "-${project.release}" +java { + toolchain { + languageVersion = JavaLanguageVersion.of(16) + } } group = project.group description = project.displayname archivesBaseName = project.name -// check for updates every build when on CI -if (System.env.CI) { - configurations.all { - resolutionStrategy.cacheChangingModulesFor 0, 'seconds' - } -} - minecraft { refmapName = 'unicopia.mixin.refmap.json' + accessWidener 'src/main/resources/unicopia.aw' +} + +reckon { + scopeFromProp() + stageFromProp('beta', 'rc', 'final') +} + +repositories { + mavenLocal() + maven { + name = 'modmenu' + url = 'https://maven.terraformersmc.com/releases' + } + maven { + name = 'minelp' + url = 'https://repo.minelittlepony-mod.com/maven/snapshot' + } + maven { + name = 'minelp-release' + url = 'https://repo.minelittlepony-mod.com/maven/release' + } } dependencies { @@ -34,23 +45,20 @@ dependencies { mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" modApi "net.fabricmc:fabric-loader:${project.loader_version}" modApi "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - compileOnly "com.google.code.findbugs:jsr305:3.0.2" - modApi "com.minelittlepony:MineLittlePony:${project.minelp_version}" + modApi "com.minelittlepony:minelittlepony:${project.minelp_version}" - modApi "com.minelittlepony:Kirin:${project.kirin_version}" - include "com.minelittlepony:Kirin:${project.kirin_version}" + modApi "com.minelittlepony:kirin:${project.kirin_version}" + include "com.minelittlepony:kirin:${project.kirin_version}" - modCompileOnly("io.github.prospector:modmenu:${project.modmenu_version}") { - transitive = false - } + modCompileOnly("com.terraformersmc:modmenu:${project.modmenu_version}") } processResources { - inputs.property "version", project.version + inputs.property "version", project.version.toString() filesMatching("fabric.mod.json") { - expand "version": project.version + expand "version": project.version.toString() } } @@ -62,16 +70,3 @@ task sourcesJar(type: Jar, dependsOn: classes) { classifier = "sources" from sourceSets.main.allSource } - -repositories { - maven { - name = 'minelp' - url = 'https://repo.minelittlepony-mod.com/maven/snapshot' - } - maven { - name = 'minelp-release' - url = 'https://repo.minelittlepony-mod.com/maven/release' - } -} - - diff --git a/gradle.properties b/gradle.properties index 4cea621f..82ae3bd3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,20 +3,18 @@ org.gradle.daemon=false # Fabric Properties # check these on https://modmuss50.me/fabric.html - minecraft_version=1.16.5 - yarn_mappings=1.16.5+build.4 - loader_version=0.11.1 - fabric_version=0.30.3+1.16 + minecraft_version=1.17 + yarn_mappings=1.17+build.5 + loader_version=0.11.3 + fabric_version=0.34.9+1.17 # Mod Properties group=com.minelittlepony displayname=Unicopia authors=Sollace description=Magical Abilities for Mine Little Pony! - version=9 - release=BETA # Dependencies - modmenu_version=1.14.+ - minelp_version=4.2.2-1.16.5-1.16-SNAPSHOT - kirin_version=1.7.1-1.16.2-SNAPSHOT + modmenu_version=2.0.0-beta.7 + minelp_version=4.3.4 + kirin_version=1.9.1 diff --git a/src/main/java/com/minelittlepony/unicopia/EquinePredicates.java b/src/main/java/com/minelittlepony/unicopia/EquinePredicates.java index 7c044357..c1dee993 100644 --- a/src/main/java/com/minelittlepony/unicopia/EquinePredicates.java +++ b/src/main/java/com/minelittlepony/unicopia/EquinePredicates.java @@ -2,7 +2,7 @@ package com.minelittlepony.unicopia; import java.util.function.Predicate; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.spell.SpellType; @@ -24,9 +24,9 @@ public interface EquinePredicates { Predicate PLAYER_BAT = IS_PLAYER.and(ofRace(Race.BAT)); Predicate PLAYER_UNICORN = IS_PLAYER.and(raceMatches(Race::canCast)); Predicate PLAYER_CHANGELING = IS_PLAYER.and(ofRace(Race.CHANGELING)); - Predicate PLAYER_PEGASUS = IS_PLAYER.and(e -> ((PlayerEntity)e).abilities.creativeMode || RACE_INTERACT_WITH_CLOUDS.test(e)); + Predicate PLAYER_PEGASUS = IS_PLAYER.and(e -> ((PlayerEntity)e).getAbilities().creativeMode || RACE_INTERACT_WITH_CLOUDS.test(e)); - Predicate IS_CASTER = e -> !e.removed && (e instanceof Caster || PLAYER_UNICORN.test(e)); + Predicate IS_CASTER = e -> !e.isRemoved() && (e instanceof Caster || PLAYER_UNICORN.test(e)); Predicate HAS_WANT_IT_NEED_IT = e -> EnchantmentHelper.getEquipmentLevel(UEnchantments.WANT_IT_NEED_IT, e) > 0; diff --git a/src/main/java/com/minelittlepony/unicopia/InteractionManager.java b/src/main/java/com/minelittlepony/unicopia/InteractionManager.java index 680000cd..627af1ed 100644 --- a/src/main/java/com/minelittlepony/unicopia/InteractionManager.java +++ b/src/main/java/com/minelittlepony/unicopia/InteractionManager.java @@ -1,7 +1,7 @@ package com.minelittlepony.unicopia; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.entity.player.dummy.DummyPlayerEntity; import com.minelittlepony.unicopia.entity.player.dummy.DummyServerPlayerEntity; @@ -38,7 +38,7 @@ public class InteractionManager { * * Returns an implementation of PlayerEntity appropriate to the side being called on. */ - @Nonnull + @NotNull public PlayerEntity createPlayer(Entity observer, GameProfile profile) { if (observer.world instanceof ServerWorld) { return new DummyServerPlayerEntity((ServerWorld)observer.world, profile); diff --git a/src/main/java/com/minelittlepony/unicopia/Race.java b/src/main/java/com/minelittlepony/unicopia/Race.java index a2fd6e63..fb86e9bc 100644 --- a/src/main/java/com/minelittlepony/unicopia/Race.java +++ b/src/main/java/com/minelittlepony/unicopia/Race.java @@ -6,7 +6,7 @@ import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.google.common.base.Strings; import com.minelittlepony.common.client.gui.sprite.TextureSprite; @@ -107,7 +107,7 @@ public enum Race implements Affine { } public boolean isPermitted(@Nullable PlayerEntity sender) { - if (isOp() && (sender == null || !sender.abilities.creativeMode)) { + if (isOp() && (sender == null || !sender.getAbilities().creativeMode)) { return false; } diff --git a/src/main/java/com/minelittlepony/unicopia/WorldTribeManager.java b/src/main/java/com/minelittlepony/unicopia/WorldTribeManager.java index e3ab5384..42f17da4 100644 --- a/src/main/java/com/minelittlepony/unicopia/WorldTribeManager.java +++ b/src/main/java/com/minelittlepony/unicopia/WorldTribeManager.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.server.world.ServerWorld; import net.minecraft.world.PersistentState; import net.minecraft.world.dimension.DimensionType; @@ -9,8 +9,10 @@ public class WorldTribeManager extends PersistentState { private Race defaultRace = Unicopia.getConfig().preferredRace.get(); - public WorldTribeManager(ServerWorld world) { - super(nameFor(world.getDimension())); + public WorldTribeManager() {} + + public WorldTribeManager(NbtCompound nbt) { + defaultRace = Race.fromName(nbt.getString("defaultRace")); } public Race getDefaultRace() { @@ -22,12 +24,7 @@ public class WorldTribeManager extends PersistentState { } @Override - public void fromTag(CompoundTag tag) { - defaultRace = Race.fromName(tag.getString("defaultRace")); - } - - @Override - public CompoundTag toTag(CompoundTag tag) { + public NbtCompound writeNbt(NbtCompound tag) { tag.putString("defaultRace", defaultRace.name()); return tag; } @@ -37,6 +34,6 @@ public class WorldTribeManager extends PersistentState { } public static WorldTribeManager forWorld(ServerWorld world) { - return world.getPersistentStateManager().getOrCreate(() -> new WorldTribeManager(world), nameFor(world.getDimension())); + return world.getPersistentStateManager().getOrCreate(WorldTribeManager::new, WorldTribeManager::new, nameFor(world.getDimension())); } } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/Ability.java b/src/main/java/com/minelittlepony/unicopia/ability/Ability.java index 338053a2..53daac5f 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/Ability.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/Ability.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.ability; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.data.Hit; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/AbilityDispatcher.java b/src/main/java/com/minelittlepony/unicopia/ability/AbilityDispatcher.java index 65a243b5..fba1c708 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/AbilityDispatcher.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/AbilityDispatcher.java @@ -8,7 +8,7 @@ import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.data.Hit; @@ -16,11 +16,11 @@ import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.network.MsgPlayerAbility; import com.minelittlepony.unicopia.network.Channel; import com.minelittlepony.unicopia.util.NbtSerialisable; +import com.minelittlepony.unicopia.util.Tickable; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.sound.SoundEvents; import net.minecraft.util.Identifier; -import net.minecraft.util.Tickable; public class AbilityDispatcher implements Tickable, NbtSerialisable { @@ -78,10 +78,10 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable { } @Override - public void toNBT(CompoundTag compound) { + public void toNBT(NbtCompound compound) { if (compound.contains("stats")) { stats.clear(); - CompoundTag li = compound.getCompound("stats"); + NbtCompound li = compound.getCompound("stats"); li.getKeys().forEach(key -> { getStat(AbilitySlot.valueOf(key)).fromNBT(li.getCompound(key)); }); @@ -89,8 +89,8 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable { } @Override - public void fromNBT(CompoundTag compound) { - CompoundTag li = new CompoundTag(); + public void fromNBT(NbtCompound compound) { + NbtCompound li = new NbtCompound(); stats.forEach((key, value) -> li.put(key.name(), value.toNBT())); compound.put("stats", li); } @@ -251,7 +251,7 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable { } @Override - public void toNBT(CompoundTag compound) { + public void toNBT(NbtCompound compound) { compound.putInt("warmup", warmup); compound.putInt("cooldown", cooldown); compound.putInt("maxWarmup", maxWarmup); @@ -263,7 +263,7 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable { } @Override - public void fromNBT(CompoundTag compound) { + public void fromNBT(NbtCompound compound) { warmup = compound.getInt("warmup"); cooldown = compound.getInt("cooldown"); maxWarmup = compound.getInt("maxWarmup"); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/ChangelingDisguiseAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/ChangelingDisguiseAbility.java index 92aa1cfb..7d296a7d 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/ChangelingDisguiseAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/ChangelingDisguiseAbility.java @@ -1,7 +1,7 @@ package com.minelittlepony.unicopia.ability; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.ability.data.Hit; import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java index 2bdbbdbe..31ad0cf6 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java @@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.ability; import java.util.List; import java.util.stream.Collectors; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.data.Hit; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java index 6f9f011e..83b59fd3 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java @@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.ability; import java.util.List; import java.util.Optional; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.google.common.collect.Lists; import com.minelittlepony.unicopia.BlockDestructionManager; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java index b664b3e7..63ea1231 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.ability; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.BlockDestructionManager; import com.minelittlepony.unicopia.Race; @@ -58,7 +58,7 @@ public class EarthPonyStompAbility implements Ability { @Nullable @Override public Hit tryActivate(Pony player) { - if (!player.getMaster().isOnGround() && player.getMaster().getVelocity().y * player.getPhysics().getGravitySignum() < 0 && !player.getMaster().abilities.flying) { + if (!player.getMaster().isOnGround() && player.getMaster().getVelocity().y * player.getPhysics().getGravitySignum() < 0 && !player.getMaster().getAbilities().flying) { thrustDownwards(player); return Hit.INSTANCE; } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/PegasusCaptureStormAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/PegasusCaptureStormAbility.java index d265fcc3..ac5e42a7 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/PegasusCaptureStormAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/PegasusCaptureStormAbility.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.ability; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.data.Hit; @@ -73,7 +73,7 @@ public class PegasusCaptureStormAbility implements Ability { } else if (player.getOrigin().getY() < 120) { tell(player, "ability.unicopia.too_low"); } else { - if (!player.getMaster().abilities.creativeMode) { + if (!player.getMaster().getAbilities().creativeMode) { stack.decrement(1); } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/PegasusRainboomAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/PegasusRainboomAbility.java index b800d1c6..96fb43b8 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/PegasusRainboomAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/PegasusRainboomAbility.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.ability; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.data.Hit; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java index fb12d723..621b2c37 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java @@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.ability; import java.util.Random; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.google.common.collect.Streams; import com.minelittlepony.unicopia.Race; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/UnicornProjectileAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/UnicornProjectileAbility.java index b1a1887b..fcbc8702 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/UnicornProjectileAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/UnicornProjectileAbility.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.ability; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.google.common.collect.Streams; import com.minelittlepony.unicopia.Race; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/Caster.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/Caster.java index ffb6b00d..66358cd6 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/Caster.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/Caster.java @@ -4,7 +4,7 @@ import java.util.Optional; import java.util.function.Predicate; import java.util.stream.Stream; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.EquinePredicates; import com.minelittlepony.unicopia.Owned; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/SpellContainer.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/SpellContainer.java index 942e68b1..71584c73 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/SpellContainer.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/SpellContainer.java @@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.ability.magic; import java.util.Optional; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.ability.magic.spell.SpellPredicate; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/Thrown.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/Thrown.java index b7c9f5ae..521494a2 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/Thrown.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/Thrown.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.ability.magic; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.item.GemstoneItem; import com.minelittlepony.unicopia.item.UItems; @@ -83,7 +83,7 @@ public interface Thrown extends Spell, ProjectileDelegate { projectile.setThrowDamage(getThrowDamage(caster)); projectile.setSpell(this); projectile.setHydrophobic(); - projectile.setProperties(entity, entity.pitch, entity.yaw, 0, 1.5F, 1); + projectile.setProperties(entity, entity.getPitch(), entity.getYaw(), 0, 1.5F, 1); world.spawnEntity(projectile); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/AbstractPlacedSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/AbstractPlacedSpell.java index 993891e8..c304c4fd 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/AbstractPlacedSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/AbstractPlacedSpell.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.ability.magic.spell; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.UEntities; import com.minelittlepony.unicopia.ability.magic.Attached; @@ -11,7 +11,7 @@ import com.minelittlepony.unicopia.particle.OrientedBillboardParticleEffect; import com.minelittlepony.unicopia.particle.ParticleHandle; import com.minelittlepony.unicopia.particle.UParticles; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.util.Identifier; import net.minecraft.util.math.Vec3d; @@ -74,7 +74,7 @@ public abstract class AbstractPlacedSpell extends AbstractSpell implements Attac } @Override - public void toNBT(CompoundTag compound) { + public void toNBT(NbtCompound compound) { super.toNBT(compound); if (dimension != null) { @@ -84,7 +84,7 @@ public abstract class AbstractPlacedSpell extends AbstractSpell implements Attac } @Override - public void fromNBT(CompoundTag compound) { + public void fromNBT(NbtCompound compound) { super.fromNBT(compound); if (compound.contains("dimension")) { dimension = new Identifier(compound.getString("dimension")); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/AbstractSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/AbstractSpell.java index a053a3fd..8d027613 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/AbstractSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/AbstractSpell.java @@ -6,7 +6,7 @@ import com.minelittlepony.unicopia.Affinity; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.Spell; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; public abstract class AbstractSpell implements Spell { @@ -69,13 +69,13 @@ public abstract class AbstractSpell implements Spell { } @Override - public void toNBT(CompoundTag compound) { + public void toNBT(NbtCompound compound) { compound.putBoolean("dead", isDead); compound.putUuid("uuid", uuid); } @Override - public void fromNBT(CompoundTag compound) { + public void fromNBT(NbtCompound compound) { isDirty = false; if (compound.contains("uuid")) { uuid = compound.getUuid("uuid"); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/AttractiveSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/AttractiveSpell.java index 5d314813..5d2f70e8 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/AttractiveSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/AttractiveSpell.java @@ -1,7 +1,7 @@ package com.minelittlepony.unicopia.ability.magic.spell; import java.util.List; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.Thrown; @@ -14,7 +14,7 @@ import com.minelittlepony.unicopia.util.shape.Sphere; import net.minecraft.entity.Entity; import net.minecraft.entity.ItemEntity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtHelper; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; @@ -88,7 +88,7 @@ public class AttractiveSpell extends ShieldSpell implements Thrown { } @Override - public void toNBT(CompoundTag compound) { + public void toNBT(NbtCompound compound) { super.toNBT(compound); if (homingPos != null) { compound.put("homingPos", NbtHelper.fromBlockPos(homingPos)); @@ -96,7 +96,7 @@ public class AttractiveSpell extends ShieldSpell implements Thrown { } @Override - public void fromNBT(CompoundTag compound) { + public void fromNBT(NbtCompound compound) { super.fromNBT(compound); if (compound.contains("homingPos")) { homingPos = NbtHelper.toBlockPos(compound.getCompound("homingPos")); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/DisguiseSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/DisguiseSpell.java index 10f525ab..11da8f91 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/DisguiseSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/DisguiseSpell.java @@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.ability.magic.spell; import java.util.Optional; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.FlightType; import com.minelittlepony.unicopia.Owned; @@ -25,7 +25,7 @@ import net.minecraft.entity.data.TrackedData; import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.projectile.ProjectileEntity; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; public class DisguiseSpell extends AbstractSpell implements Attached, Suppressable, FlightType.Provider, PlayerDimensions.Provider, ProjectileImpactListener { @@ -178,7 +178,7 @@ public class DisguiseSpell extends AbstractSpell implements Attached, Suppressab } @Override - public void toNBT(CompoundTag compound) { + public void toNBT(NbtCompound compound) { super.toNBT(compound); compound.putInt("suppressionCounter", suppressionCounter); @@ -186,7 +186,7 @@ public class DisguiseSpell extends AbstractSpell implements Attached, Suppressab } @Override - public void fromNBT(CompoundTag compound) { + public void fromNBT(NbtCompound compound) { super.fromNBT(compound); suppressionCounter = compound.getInt("suppressionCounter"); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/IceSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/IceSpell.java index bdd5c99c..ba665d10 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/IceSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/IceSpell.java @@ -20,6 +20,7 @@ import net.minecraft.block.PlantBlock; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.TntEntity; +import net.minecraft.entity.Entity.RemovalReason; import net.minecraft.particle.ParticleTypes; import net.minecraft.tag.BlockTags; import net.minecraft.util.math.BlockPos; @@ -63,7 +64,7 @@ public class IceSpell extends AbstractSpell implements Thrown, Attached { protected boolean applyEntitySingle(LivingEntity owner, Entity e) { if (e instanceof TntEntity) { - e.remove(); + e.remove(RemovalReason.DISCARDED); e.getEntityWorld().setBlockState(e.getBlockPos(), Blocks.TNT.getDefaultState()); } else if (e.isOnFire()) { e.extinguish(); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/JoustingSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/JoustingSpell.java index 0ba94b2c..d25d1084 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/JoustingSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/JoustingSpell.java @@ -15,7 +15,7 @@ import com.minelittlepony.unicopia.util.shape.Sphere; import net.minecraft.block.BlockState; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.GameRules; @@ -72,7 +72,7 @@ public class JoustingSpell extends AbstractSpell implements Attached { ((Pony)source).getMagicalReserves().getEnergy().multiply(0.2F); } - return !source.getEntity().removed && age++ < 90 + 7 * (source.getLevel().get() + 1); + return !source.getEntity().isRemoved() && age++ < 90 + 7 * (source.getLevel().get() + 1); } private boolean canBreak(BlockPos pos, LivingEntity entity) { @@ -85,13 +85,13 @@ public class JoustingSpell extends AbstractSpell implements Attached { } @Override - public void toNBT(CompoundTag compound) { + public void toNBT(NbtCompound compound) { super.toNBT(compound); compound.putInt("age", age); } @Override - public void fromNBT(CompoundTag compound) { + public void fromNBT(NbtCompound compound) { super.fromNBT(compound); age = compound.getInt("age"); } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/NecromancySpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/NecromancySpell.java index 07d6d695..8348ca34 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/NecromancySpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/NecromancySpell.java @@ -13,8 +13,8 @@ import com.minelittlepony.unicopia.util.shape.Sphere; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.mob.ZombieEntity; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtList; import net.minecraft.particle.ParticleTypes; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; @@ -89,7 +89,7 @@ public class NecromancySpell extends AbstractPlacedSpell { summonedEntities.forEach(ref -> { ref.ifPresent(caster.getWorld(), e -> { if (master != null) { - master.dealDamage(master, e); + master.applyDamageEffects(master, e); } if (caster.getWorld().random.nextInt(2000) != 0) { e.setHealth(0); @@ -117,23 +117,23 @@ public class NecromancySpell extends AbstractPlacedSpell { } @Override - public void toNBT(CompoundTag compound) { + public void toNBT(NbtCompound compound) { super.toNBT(compound); if (summonedEntities.size() > 0) { - ListTag list = new ListTag(); + NbtList list = new NbtList(); summonedEntities.forEach(ref -> list.add(ref.toNBT())); compound.put("summonedEntities", list); } } @Override - public void fromNBT(CompoundTag compound) { + public void fromNBT(NbtCompound compound) { super.fromNBT(compound); summonedEntities.clear(); if (compound.contains("summonedEntities")) { compound.getList("summonedEntities", 10).forEach(tag -> { EntityReference ref = new EntityReference<>(); - ref.fromNBT((CompoundTag)tag); + ref.fromNBT((NbtCompound)tag); summonedEntities.add(ref); }); } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ScorchSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ScorchSpell.java index c77af967..facf318e 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ScorchSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ScorchSpell.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.ability.magic.spell; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.block.state.StateMaps; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ShieldSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ShieldSpell.java index 816a6c3f..54631731 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ShieldSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/ShieldSpell.java @@ -27,6 +27,7 @@ import net.minecraft.entity.EyeOfEnderEntity; import net.minecraft.entity.FallingBlockEntity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.TntEntity; +import net.minecraft.entity.Entity.RemovalReason; import net.minecraft.entity.decoration.ArmorStandEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.vehicle.AbstractMinecartEntity; @@ -157,7 +158,7 @@ public class ShieldSpell extends AbstractSpell implements Attached, Thrown { if (!ProjectileUtil.isProjectileThrownBy(target, source.getMaster())) { if (distance < 1) { target.playSound(SoundEvents.ENTITY_ZOMBIE_VILLAGER_CURE, 0.1F, 1); - target.remove(); + target.remove(RemovalReason.DISCARDED); } else { ProjectileUtil.ricochet(target, pos, 0.9F); } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/SiphoningSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/SiphoningSpell.java index 80741d66..acb41241 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/SiphoningSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/SiphoningSpell.java @@ -17,7 +17,7 @@ import com.minelittlepony.unicopia.util.shape.Sphere; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.particle.ParticleTypes; import net.minecraft.predicate.entity.EntityPredicates; import net.minecraft.util.math.BlockPos; @@ -71,7 +71,7 @@ public class SiphoningSpell extends AbstractPlacedSpell { } private Stream getTargets(Caster source) { - return VecHelper.findInRange(null, source.getWorld(), source.getOriginVector(), 4 + source.getLevel().get(), EntityPredicates.EXCEPT_CREATIVE_SPECTATOR_OR_PEACEFUL.and(e -> e instanceof LivingEntity)) + return VecHelper.findInRange(null, source.getWorld(), source.getOriginVector(), 4 + source.getLevel().get(), EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR.and(e -> e instanceof LivingEntity)) .stream() .map(e -> (LivingEntity)e); } @@ -147,13 +147,13 @@ public class SiphoningSpell extends AbstractPlacedSpell { @Override - public void toNBT(CompoundTag compound) { + public void toNBT(NbtCompound compound) { super.toNBT(compound); compound.putInt("upset", ticksUpset); } @Override - public void fromNBT(CompoundTag compound) { + public void fromNBT(NbtCompound compound) { super.fromNBT(compound); ticksUpset = compound.getInt("upset"); } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/SpellType.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/SpellType.java index d794de7f..02f16374 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/SpellType.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/SpellType.java @@ -6,14 +6,14 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.Affinity; import com.minelittlepony.unicopia.ability.magic.Affine; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.Spell; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.text.Text; import net.minecraft.text.TranslatableText; import net.minecraft.util.Identifier; @@ -168,7 +168,7 @@ public final class SpellType implements Affine, SpellPredicate< } @Nullable - public static Spell fromNBT(@Nullable CompoundTag compound) { + public static Spell fromNBT(@Nullable NbtCompound compound) { if (compound != null && compound.contains("effect_id")) { Spell effect = getKey(new Identifier(compound.getString("effect_id"))).create(); @@ -182,8 +182,8 @@ public final class SpellType implements Affine, SpellPredicate< return null; } - public static CompoundTag toNBT(Spell effect) { - CompoundTag compound = effect.toNBT(); + public static NbtCompound toNBT(Spell effect) { + NbtCompound compound = effect.toNBT(); compound.putString("effect_id", effect.getType().getId().toString()); diff --git a/src/main/java/com/minelittlepony/unicopia/block/state/BlockStateConverter.java b/src/main/java/com/minelittlepony/unicopia/block/state/BlockStateConverter.java index 841450c8..e0991d87 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/state/BlockStateConverter.java +++ b/src/main/java/com/minelittlepony/unicopia/block/state/BlockStateConverter.java @@ -1,7 +1,7 @@ package com.minelittlepony.unicopia.block.state; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import net.minecraft.block.BlockState; import net.minecraft.block.enums.DoubleBlockHalf; @@ -27,8 +27,8 @@ public interface BlockStateConverter { * * @return The converted state if there is one, otherwise the original state is returned */ - @Nonnull - BlockState getConverted(World world, @Nonnull BlockState state); + @NotNull + BlockState getConverted(World world, @NotNull BlockState state); /** * Attempts to convert a block state at a position. diff --git a/src/main/java/com/minelittlepony/unicopia/block/state/BlockStateMap.java b/src/main/java/com/minelittlepony/unicopia/block/state/BlockStateMap.java index edc08a56..a6ac3334 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/state/BlockStateMap.java +++ b/src/main/java/com/minelittlepony/unicopia/block/state/BlockStateMap.java @@ -4,8 +4,8 @@ import java.util.ArrayList; import java.util.List; import java.util.function.Predicate; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -31,8 +31,8 @@ class BlockStateMap implements BlockStateConverter { } @Override - @Nonnull - public BlockState getConverted(World world, @Nonnull BlockState state) { + @NotNull + public BlockState getConverted(World world, @NotNull BlockState state) { for (StateMapping i : mappings) { if (i.test(state)) { return i.apply(world, state); diff --git a/src/main/java/com/minelittlepony/unicopia/block/state/StateMapping.java b/src/main/java/com/minelittlepony/unicopia/block/state/StateMapping.java index b22ee469..f31cb80e 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/state/StateMapping.java +++ b/src/main/java/com/minelittlepony/unicopia/block/state/StateMapping.java @@ -4,7 +4,7 @@ import java.util.function.BiFunction; import java.util.function.Function; import java.util.function.Predicate; -import javax.annotation.Nonnull; +import org.jetbrains.annotations.NotNull; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -124,7 +124,7 @@ interface StateMapping extends Predicate, BiFunction, BiFunction (CompoundTag)t) + .map(t -> (NbtCompound)t) .map(tag -> Registry.ENCHANTMENT.getOrEmpty(Identifier.tryParse(tag.getString("id"))) .map(ench -> new Pair<>(tag.getInt("lvl"), ench))) .filter(Optional::isPresent) diff --git a/src/main/java/com/minelittlepony/unicopia/client/URenderers.java b/src/main/java/com/minelittlepony/unicopia/client/URenderers.java index f3983f50..8b80c4d3 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/URenderers.java +++ b/src/main/java/com/minelittlepony/unicopia/client/URenderers.java @@ -60,7 +60,7 @@ public interface URenderers { AccessoryFeatureRenderer.register(AmuletFeatureRenderer::new); AccessoryFeatureRenderer.register(WingsFeatureRenderer::new); - EntityRendererRegistry.INSTANCE.register(UEntities.THROWN_ITEM, (manager, context) -> new FlyingItemEntityRenderer<>(manager, context.getItemRenderer())); + EntityRendererRegistry.INSTANCE.register(UEntities.THROWN_ITEM, FlyingItemEntityRenderer::new); EntityRendererRegistry.INSTANCE.register(UEntities.FLOATING_ARTEFACT, FloatingArtefactEntityRenderer::new); EntityRendererRegistry.INSTANCE.register(UEntities.CAST_SPELL, CastSpellEntityRenderer::new); @@ -84,10 +84,10 @@ public interface URenderers { matrices.push(); matrices.scale(0.5F, 0.5F, 0.5F); matrices.translate(0.0125, 0.1, 0); - renderer.renderItem(item.getAppearanceStack(stack), mode, light, overlay, matrices, immediate); + renderer.renderItem(item.getAppearanceStack(stack), mode, light, overlay, matrices, immediate, 0); matrices.pop(); } - renderer.renderItem(item.createAppearanceStack(stack, UItems.EMPTY_JAR), mode, light, OverlayTexture.DEFAULT_UV, matrices, immediate); + renderer.renderItem(item.createAppearanceStack(stack, UItems.EMPTY_JAR), mode, light, OverlayTexture.DEFAULT_UV, matrices, immediate, 0); immediate.draw(); if (mode == ModelTransformation.Mode.GUI) { @@ -96,7 +96,7 @@ public interface URenderers { matrices.push(); }); - FabricModelPredicateProviderRegistry.register(UItems.GEMSTONE, new Identifier("affinity"), (stack, world, entity) -> { + FabricModelPredicateProviderRegistry.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 0e139746..6e4879c6 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/UnicopiaClient.java +++ b/src/main/java/com/minelittlepony/unicopia/client/UnicopiaClient.java @@ -69,7 +69,7 @@ public class UnicopiaClient implements ClientModInitializer { private void onScreenInit(Screen screen, ButtonList buttons) { if (screen instanceof CreateWorldScreen) { - buttons.add(SettingsScreen.createRaceSelector(screen)); + buttons.addButton(SettingsScreen.createRaceSelector(screen)); } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/ManaRingSlot.java b/src/main/java/com/minelittlepony/unicopia/client/gui/ManaRingSlot.java index 671f72b1..803dae83 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/ManaRingSlot.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/ManaRingSlot.java @@ -11,6 +11,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.render.BufferBuilder; import net.minecraft.client.render.BufferRenderer; import net.minecraft.client.render.Tessellator; +import net.minecraft.client.render.VertexFormat; import net.minecraft.client.render.VertexFormats; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.math.MathHelper; @@ -110,7 +111,7 @@ class ManaRingSlot extends Slot { RenderSystem.disableTexture(); RenderSystem.defaultBlendFunc(); - bufferBuilder.begin(7, VertexFormats.POSITION_COLOR); + bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); Matrix4f model = matrices.peek().getModel(); 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 7c8ed4dd..9f9ae9c7 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/SettingsScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/SettingsScreen.java @@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.client.gui; import java.util.Set; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.common.client.gui.GameGui; import com.minelittlepony.common.client.gui.ScrollContainer; @@ -54,9 +54,9 @@ public class SettingsScreen extends GameGui { super(new TranslatableText("unicopia.options.title"), parent); content.margin.setVertical(30); - content.padding.setHorizontal(10); - content.padding.top = 10; - content.padding.bottom = 20; + content.getContentPadding().setHorizontal(10); + content.getContentPadding().top = 10; + content.getContentPadding().bottom = 20; } @Override @@ -89,7 +89,7 @@ public class SettingsScreen extends GameGui { RIGHT = LEFT; } - children().add(content); + getChildElements().add(content); int row = 0; @@ -115,7 +115,7 @@ public class SettingsScreen extends GameGui { content.addButton(new EnumSlider<>(LEFT, row += 25, config.preferredRace.get())) .onChange(config.preferredRace::set) - .setFormatter(v -> new TranslatableText("unicopia.options.preferred_race", v.getDisplayName()).getString()); + .setTextFormat(v -> new TranslatableText("unicopia.options.preferred_race", v.getValue().getDisplayName())); if (server != null) { row += 20; @@ -125,7 +125,7 @@ public class SettingsScreen extends GameGui { content.addButton(new EnumSlider<>(LEFT, row += 20, tribes.getDefaultRace())) .onChange(tribes::setDefaultRace) - .setFormatter(v -> new TranslatableText("unicopia.options.world.default_race", v.getDisplayName()).getString()) + .setTextFormat(v -> new TranslatableText("unicopia.options.world.default_race", v.getValue().getDisplayName())) .setEnabled(client.isInSingleplayer()); } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/Slot.java b/src/main/java/com/minelittlepony/unicopia/client/gui/Slot.java index 00707b8d..ff3c2080 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/Slot.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/Slot.java @@ -97,7 +97,6 @@ class Slot { // progress UHud.fill(matrices, slotPadding, progressTop, size - slotPadding, progressBottom, 0xCFFFFFFF); - RenderSystem.enableAlphaTest(); RenderSystem.enableBlend(); } 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 5e6cb7a8..ae528db3 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java @@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.client.gui; import java.util.ArrayList; import java.util.List; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.AbilityDispatcher; @@ -25,6 +25,7 @@ import net.minecraft.text.Text; import net.minecraft.util.Arm; import net.minecraft.util.Identifier; import net.minecraft.util.Util; +import net.minecraft.util.math.Quaternion; public class UHud extends DrawableHelper { @@ -73,10 +74,9 @@ public class UHud extends DrawableHelper { renderMessage(matrices, tickDelta); } - RenderSystem.enableAlphaTest(); RenderSystem.enableBlend(); - client.getTextureManager().bindTexture(HUD_TEXTURE); + RenderSystem.setShaderTexture(0, HUD_TEXTURE); boolean swap = client.options.keySneak.isPressed(); @@ -84,7 +84,6 @@ public class UHud extends DrawableHelper { slots.forEach(slot -> slot.renderLabel(matrices, abilities, tickDelta)); RenderSystem.disableBlend(); - RenderSystem.disableAlphaTest(); matrices.pop(); @@ -100,13 +99,17 @@ public class UHud extends DrawableHelper { int x = scaledWidth / 2 + 67; int y = scaledHeight - 25; - RenderSystem.pushMatrix(); - RenderSystem.translatef(x, y, 0); - RenderSystem.rotatef(45, -0.2F, 1, 0); + MatrixStack view = RenderSystem.getModelViewStack(); + + view.push(); + view.translate(x, y, 0); + view.multiply(new Quaternion(-9, 45, 0, true)); InventoryScreen.drawEntity(0, 0, scale, 0, -20, client.player); - RenderSystem.popMatrix(); + view.pop(); }); } + + } private void renderMessage(MatrixStack matrices, float tickDelta) { @@ -139,9 +142,9 @@ public class UHud extends DrawableHelper { void renderAbilityIcon(MatrixStack matrices, AbilityDispatcher.Stat stat, int x, int y, int u, int v, int frameWidth, int frameHeight) { stat.getAbility(KeyBindingsHandler.INSTANCE.page).ifPresent(ability -> { - client.getTextureManager().bindTexture(ability.getIcon(Pony.of(client.player), client.options.keySneak.isPressed())); + RenderSystem.setShaderTexture(0, ability.getIcon(Pony.of(client.player), client.options.keySneak.isPressed())); drawTexture(matrices, x, y, 0, 0, frameWidth, frameHeight, u, v); - client.getTextureManager().bindTexture(HUD_TEXTURE); + RenderSystem.setShaderTexture(0, HUD_TEXTURE); }); } diff --git a/src/main/java/com/minelittlepony/unicopia/client/minelittlepony/Main.java b/src/main/java/com/minelittlepony/unicopia/client/minelittlepony/Main.java index c7555e91..23a1707e 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/minelittlepony/Main.java +++ b/src/main/java/com/minelittlepony/unicopia/client/minelittlepony/Main.java @@ -1,8 +1,8 @@ package com.minelittlepony.unicopia.client.minelittlepony; -import com.minelittlepony.client.render.EquineRenderManager; -import com.minelittlepony.model.IModel; -import com.minelittlepony.model.capabilities.fabric.PonyModelPrepareCallback; +import com.minelittlepony.api.model.IModel; +import com.minelittlepony.api.model.ModelAttributes; +import com.minelittlepony.api.model.fabric.PonyModelPrepareCallback; import com.minelittlepony.unicopia.Unicopia; import com.minelittlepony.unicopia.entity.player.Pony; @@ -20,7 +20,7 @@ public class Main implements ClientModInitializer { PonyModelPrepareCallback.EVENT.register(this::onPonyModelPrepared); } - private void onPonyModelPrepared(Entity entity, IModel model, EquineRenderManager.Mode mode) { + private void onPonyModelPrepared(Entity entity, IModel model, ModelAttributes.Mode mode) { if (hookErroring) return; try { if (entity instanceof PlayerEntity) { diff --git a/src/main/java/com/minelittlepony/unicopia/client/particle/AbstractBillboardParticle.java b/src/main/java/com/minelittlepony/unicopia/client/particle/AbstractBillboardParticle.java index ffee02b8..507431e7 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/particle/AbstractBillboardParticle.java +++ b/src/main/java/com/minelittlepony/unicopia/client/particle/AbstractBillboardParticle.java @@ -10,8 +10,9 @@ import net.minecraft.client.render.BufferBuilder; import net.minecraft.client.render.Camera; import net.minecraft.client.render.Tessellator; import net.minecraft.client.render.VertexConsumer; +import net.minecraft.client.render.VertexFormat; import net.minecraft.client.render.VertexFormats; -import net.minecraft.client.util.math.Vector3f; +import net.minecraft.util.math.Vec3f; import net.minecraft.client.world.ClientWorld; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; @@ -43,8 +44,6 @@ public abstract class AbstractBillboardParticle extends Particle { GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA ); - RenderSystem.alphaFunc(516, 0.003921569F); - Vec3d cam = camera.getPos(); @@ -55,7 +54,6 @@ public abstract class AbstractBillboardParticle extends Particle { renderQuads(te, buffer, renderX, renderY, renderZ, tickDelta); RenderSystem.enableCull(); - RenderSystem.defaultAlphaFunc(); RenderSystem.defaultBlendFunc(); } @@ -65,10 +63,10 @@ public abstract class AbstractBillboardParticle extends Particle { MinecraftClient.getInstance().getTextureManager().bindTexture(texture); } - protected void renderQuad(Tessellator te, BufferBuilder buffer, Vector3f[] corners, float alpha, float tickDelta) { - int light = getColorMultiplier(tickDelta); + protected void renderQuad(Tessellator te, BufferBuilder buffer, Vec3f[] corners, float alpha, float tickDelta) { + int light = getBrightness(tickDelta); - buffer.begin(7, VertexFormats.POSITION_TEXTURE_COLOR_LIGHT); + buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR_LIGHT); buffer.vertex(corners[0].getX(), corners[0].getY(), corners[0].getZ()).texture(0, 0).color(colorRed, colorGreen, colorBlue, alpha).light(light).next(); buffer.vertex(corners[1].getX(), corners[1].getY(), corners[1].getZ()).texture(1, 0).color(colorRed, colorGreen, colorBlue, alpha).light(light).next(); buffer.vertex(corners[2].getX(), corners[2].getY(), corners[2].getZ()).texture(1, 1).color(colorRed, colorGreen, colorBlue, alpha).light(light).next(); diff --git a/src/main/java/com/minelittlepony/unicopia/client/particle/MagicParticle.java b/src/main/java/com/minelittlepony/unicopia/client/particle/MagicParticle.java index 16ec7b38..f1c21922 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/particle/MagicParticle.java +++ b/src/main/java/com/minelittlepony/unicopia/client/particle/MagicParticle.java @@ -64,8 +64,8 @@ public class MagicParticle extends SpriteBillboardParticle { } @Override - public int getColorMultiplier(float tint) { - int light = super.getColorMultiplier(tint); + public int getBrightness(float tint) { + int light = super.getBrightness(tint); float timer = (float)age / (float)maxAge; int v = light >> 16 & 255; diff --git a/src/main/java/com/minelittlepony/unicopia/client/particle/OrientedBillboardParticle.java b/src/main/java/com/minelittlepony/unicopia/client/particle/OrientedBillboardParticle.java index 1759b974..8d708bf6 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/particle/OrientedBillboardParticle.java +++ b/src/main/java/com/minelittlepony/unicopia/client/particle/OrientedBillboardParticle.java @@ -6,7 +6,7 @@ import net.minecraft.client.render.BufferBuilder; import net.minecraft.client.render.Camera; import net.minecraft.client.render.Tessellator; import net.minecraft.client.render.VertexConsumer; -import net.minecraft.client.util.math.Vector3f; +import net.minecraft.util.math.Vec3f; import net.minecraft.client.world.ClientWorld; import net.minecraft.util.math.Quaternion; @@ -20,8 +20,8 @@ public abstract class OrientedBillboardParticle extends AbstractBillboardParticl fixed = effect.isAngleFixed(); if (fixed) { - rotation.hamiltonProduct(Vector3f.POSITIVE_X.getDegreesQuaternion(180 - effect.getYaw())); - rotation.hamiltonProduct(Vector3f.POSITIVE_Y.getDegreesQuaternion(effect.getPitch())); + rotation.hamiltonProduct(Vec3f.POSITIVE_X.getDegreesQuaternion(180 - effect.getYaw())); + rotation.hamiltonProduct(Vec3f.POSITIVE_Y.getDegreesQuaternion(effect.getPitch())); } } @@ -35,16 +35,16 @@ public abstract class OrientedBillboardParticle extends AbstractBillboardParticl @Override protected void renderQuads(Tessellator te, BufferBuilder buffer, float x, float y, float z, float tickDelta) { - Vector3f[] corners = new Vector3f[]{ - new Vector3f(-1, -1, 0), - new Vector3f(-1, 1, 0), - new Vector3f( 1, 1, 0), - new Vector3f( 1, -1, 0) + Vec3f[] corners = new Vec3f[]{ + new Vec3f(-1, -1, 0), + new Vec3f(-1, 1, 0), + new Vec3f( 1, 1, 0), + new Vec3f( 1, -1, 0) }; float scale = getScale(tickDelta); for(int k = 0; k < 4; ++k) { - Vector3f corner = corners[k]; + Vec3f corner = corners[k]; corner.rotate(rotation); corner.scale(scale); corner.add(x, y, z); diff --git a/src/main/java/com/minelittlepony/unicopia/client/particle/RainbowTrailParticle.java b/src/main/java/com/minelittlepony/unicopia/client/particle/RainbowTrailParticle.java index ebdfa218..939e8eab 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/particle/RainbowTrailParticle.java +++ b/src/main/java/com/minelittlepony/unicopia/client/particle/RainbowTrailParticle.java @@ -11,7 +11,7 @@ import com.minelittlepony.unicopia.particle.ParticleHandle.Link; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.BufferBuilder; import net.minecraft.client.render.Tessellator; -import net.minecraft.client.util.math.Vector3f; +import net.minecraft.util.math.Vec3f; import net.minecraft.client.world.ClientWorld; import net.minecraft.particle.DefaultParticleType; import net.minecraft.util.Identifier; @@ -60,11 +60,11 @@ public class RainbowTrailParticle extends AbstractBillboardParticle implements A float alpha = 1 - (float)age / maxAge; for (int i = 0; i < segments.size() - 1; i++) { - Vector3f[] corners = segments.get(i).getPlane(segments.get(i + 1)); + Vec3f[] corners = segments.get(i).getPlane(segments.get(i + 1)); float scale = getScale(tickDelta); for (int k = 0; k < 4; ++k) { - Vector3f corner = corners[k]; + Vec3f corner = corners[k]; corner.scale(scale); corner.add(x, y, z); } @@ -107,14 +107,14 @@ public class RainbowTrailParticle extends AbstractBillboardParticle implements A private final class Segment { Vec3d position; - Vector3f offset; + Vec3f offset; int age; int maxAge; Segment(Vec3d position) { this.position = position; - this.offset = new Vector3f((float)(position.getX() - x), (float)(position.getY() - y), (float)(position.getZ() - z)); + this.offset = new Vec3f((float)(position.getX() - x), (float)(position.getY() - y), (float)(position.getZ() - z)); this.maxAge = 90; } @@ -126,7 +126,7 @@ public class RainbowTrailParticle extends AbstractBillboardParticle implements A return segments.indexOf(this) < segments.size() - 1 && age++ >= maxAge; } - Vector3f[] getPlane(Segment to) { + Vec3f[] getPlane(Segment to) { float fromX = offset.getX(); float toX = to.offset.getX(); @@ -139,11 +139,11 @@ public class RainbowTrailParticle extends AbstractBillboardParticle implements A float toTopY = to.offset.getY() + 1; float toBottomY = to.offset.getY(); - return new Vector3f[]{ - new Vector3f(fromX, fromBottomY, fromZ), // bottom left - new Vector3f(fromX, fromTopY, fromZ), // top left - new Vector3f(toX, toTopY, toZ), // top right - new Vector3f(toX, toBottomY, toZ) // bottom right + return new Vec3f[]{ + new Vec3f(fromX, fromBottomY, fromZ), // bottom left + new Vec3f(fromX, fromTopY, fromZ), // top left + new Vec3f(toX, toTopY, toZ), // top right + new Vec3f(toX, toBottomY, toZ) // bottom right }; } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/particle/RunesParticle.java b/src/main/java/com/minelittlepony/unicopia/client/particle/RunesParticle.java index 211c4f1e..6d16cd9c 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/particle/RunesParticle.java +++ b/src/main/java/com/minelittlepony/unicopia/client/particle/RunesParticle.java @@ -9,7 +9,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.render.BufferBuilder; import net.minecraft.client.render.Tessellator; -import net.minecraft.client.util.math.Vector3f; +import net.minecraft.util.math.Vec3f; import net.minecraft.client.world.ClientWorld; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; @@ -91,7 +91,7 @@ public class RunesParticle extends OrientedBillboardParticle implements Attachme } @Override - protected int getColorMultiplier(float tint) { + protected int getBrightness(float tint) { return 0xF000F0; } @@ -105,22 +105,22 @@ public class RunesParticle extends OrientedBillboardParticle implements Attachme for (int i = 0; i < TEXTURES.length; i++) { bindTexture(TEXTURES[i]); - RenderSystem.color3f(colorRed, colorGreen, colorBlue); + RenderSystem.setShaderColor(colorRed, colorGreen, colorBlue, alpha); - Vector3f[] corners = new Vector3f[]{ - new Vector3f(-1, -1, 0), - new Vector3f(-1, 1, 0), - new Vector3f( 1, 1, 0), - new Vector3f( 1, -1, 0) + Vec3f[] corners = new Vec3f[]{ + new Vec3f(-1, -1, 0), + new Vec3f(-1, 1, 0), + new Vec3f( 1, 1, 0), + new Vec3f( 1, -1, 0) }; float scale = getScale(tickDelta); float ringSpeed = (i % 2 == 0 ? i : -1) * i; - Quaternion ringAngle = Vector3f.POSITIVE_Z.getDegreesQuaternion(angle * ringSpeed); + Quaternion ringAngle = Vec3f.POSITIVE_Z.getDegreesQuaternion(angle * ringSpeed); for(int k = 0; k < 4; ++k) { - Vector3f corner = corners[k]; + Vec3f corner = corners[k]; corner.rotate(ringAngle); corner.rotate(rotation); corner.scale(scale); 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 70113521..ed3d3d07 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/particle/SphereModel.java +++ b/src/main/java/com/minelittlepony/unicopia/client/particle/SphereModel.java @@ -3,8 +3,8 @@ package com.minelittlepony.unicopia.client.particle; import net.minecraft.client.render.VertexConsumer; import net.minecraft.util.math.Matrix4f; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.client.util.math.Vector3f; -import net.minecraft.client.util.math.Vector4f; +import net.minecraft.util.math.Vec3f; +import net.minecraft.util.math.Vector4f; import net.minecraft.util.math.Quaternion; import net.minecraft.util.math.Vec3d; @@ -21,9 +21,9 @@ public class SphereModel { } public void setRotation(float x, float y, float z) { - rotX = Vector3f.POSITIVE_X.getDegreesQuaternion(x); - rotY = Vector3f.POSITIVE_Y.getDegreesQuaternion(y); - rotZ = Vector3f.POSITIVE_Z.getDegreesQuaternion(z); + rotX = Vec3f.POSITIVE_X.getDegreesQuaternion(x); + rotY = Vec3f.POSITIVE_Y.getDegreesQuaternion(y); + rotZ = Vec3f.POSITIVE_Z.getDegreesQuaternion(z); } public void render(MatrixStack matrices, float scale, VertexConsumer vertexWriter, int light, int overlay, float r, float g, float b, float a) { diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/AmuletFeatureRenderer.java b/src/main/java/com/minelittlepony/unicopia/client/render/AmuletFeatureRenderer.java index 1d058bee..f29d7c66 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/AmuletFeatureRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/AmuletFeatureRenderer.java @@ -4,8 +4,15 @@ import java.util.HashMap; import java.util.Map; import com.minelittlepony.unicopia.item.AmuletItem; + +import net.minecraft.client.model.Dilation; import net.minecraft.client.model.Model; +import net.minecraft.client.model.ModelData; import net.minecraft.client.model.ModelPart; +import net.minecraft.client.model.ModelPartBuilder; +import net.minecraft.client.model.ModelPartData; +import net.minecraft.client.model.ModelTransform; +import net.minecraft.client.model.TexturedModelData; import net.minecraft.client.render.OverlayTexture; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.VertexConsumer; @@ -22,7 +29,7 @@ import net.minecraft.util.registry.Registry; public class AmuletFeatureRenderer implements AccessoryFeatureRenderer.Feature { - private final AmuletModel model = new AmuletModel(0.3F); + private final AmuletModel model; private final Map textures = new HashMap<>(); @@ -30,6 +37,7 @@ public class AmuletFeatureRenderer implements AccessoryF public AmuletFeatureRenderer(FeatureRendererContext> context) { this.context = context; + this.model = new AmuletModel(AmuletModel.getData(new Dilation(0.3F)).createModel()); } @Override @@ -49,22 +57,29 @@ public class AmuletFeatureRenderer implements AccessoryF static class AmuletModel extends Model { - private final ModelPart torso; + private final ModelPart amulet; - public AmuletModel(float dilate) { + public AmuletModel(ModelPart tree) { super(RenderLayer::getEntityTranslucent); - torso = new ModelPart(this, 0, 0); - torso.addCuboid(-4, 0, -2, 8, 12, 4, dilate); - torso.setPivot(0, 0, 0); + amulet = tree.getChild("amulet"); + } + + public static TexturedModelData getData(Dilation dilation) { + ModelData data = new ModelData(); + ModelPartData root = data.getRoot(); + + root.addChild("amulet", ModelPartBuilder.create().cuboid(-4, 0, -2, 8, 12, 4, dilation), ModelTransform.NONE); + + return TexturedModelData.of(data, 64, 64); } public void setAngles(LivingEntity entity, BipedEntityModel biped) { - torso.copyPositionAndRotation(biped.torso); + amulet.copyTransform(biped.body); } @Override public void render(MatrixStack matrices, VertexConsumer vertexConsumer, int i, int j, float f, float g, float h, float k) { - torso.render(matrices, vertexConsumer, i, j, f, g, h, k); + amulet.render(matrices, vertexConsumer, i, j, f, g, h, k); } } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/BraceletFeatureRenderer.java b/src/main/java/com/minelittlepony/unicopia/client/render/BraceletFeatureRenderer.java index da7e6f42..77b4c35d 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/BraceletFeatureRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/BraceletFeatureRenderer.java @@ -4,8 +4,14 @@ import com.minelittlepony.common.util.Color; import com.minelittlepony.unicopia.item.FriendshipBraceletItem; import com.minelittlepony.unicopia.item.GlowableItem; +import net.minecraft.client.model.Dilation; import net.minecraft.client.model.Model; +import net.minecraft.client.model.ModelData; import net.minecraft.client.model.ModelPart; +import net.minecraft.client.model.ModelPartBuilder; +import net.minecraft.client.model.ModelPartData; +import net.minecraft.client.model.ModelTransform; +import net.minecraft.client.model.TexturedModelData; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.render.OverlayTexture; import net.minecraft.client.render.RenderLayer; @@ -13,6 +19,7 @@ import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.feature.FeatureRendererContext; import net.minecraft.client.render.entity.model.BipedEntityModel; +import net.minecraft.client.render.entity.model.EntityModelPartNames; import net.minecraft.client.render.item.ItemRenderer; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.EquipmentSlot; @@ -27,13 +34,16 @@ public class BraceletFeatureRenderer implements Accessor private static final Identifier TEXTURE = new Identifier("unicopia", "textures/models/armor/bracelet.png"); - private final BraceletModel steveModel = new BraceletModel(0.3F, false); - private final BraceletModel alexModel = new BraceletModel(0.3F, true); + private final BraceletModel steveModel; + private final BraceletModel alexModel; private final FeatureRendererContext> context; public BraceletFeatureRenderer(FeatureRendererContext> context) { this.context = context; + Dilation dilation = new Dilation(0.3F); + steveModel = new BraceletModel(BraceletModel.getData(dilation, false).createModel(), false); + alexModel = new BraceletModel(BraceletModel.getData(dilation, true).createModel(), true); } @Override @@ -74,19 +84,26 @@ public class BraceletFeatureRenderer implements Accessor private final boolean alex; - public BraceletModel(float dilate, boolean alex) { + public BraceletModel(ModelPart tree, boolean alex) { super(RenderLayer::getEntityTranslucent); this.alex = alex; - rightArm = new ModelPart(this, 0, alex ? 6 : 0); - rightArm.addCuboid(-3, 7, -2, alex ? 3 : 4, 2, 4, dilate); - leftArm = new ModelPart(this, 0, alex ? 6 : 0); - leftArm.mirror = true; - leftArm.addCuboid(-1, 7, -2, alex ? 3 : 4, 2, 4, dilate); + this.leftArm = tree.getChild(EntityModelPartNames.LEFT_ARM); + this.rightArm = tree.getChild(EntityModelPartNames.RIGHT_ARM); + } + + public static TexturedModelData getData(Dilation dilation, boolean alex) { + ModelData data = new ModelData(); + ModelPartData root = data.getRoot(); + + root.addChild(EntityModelPartNames.RIGHT_ARM, ModelPartBuilder.create().uv(0, alex ? 6 : 0).cuboid(-3, 7, -2, alex ? 3 : 4, 2, 4, dilation), ModelTransform.NONE); + root.addChild(EntityModelPartNames.LEFT_ARM, ModelPartBuilder.create().mirrored().uv(0, alex ? 6 : 0).cuboid(-1, 7, -2, alex ? 3 : 4, 2, 4, dilation), ModelTransform.NONE); + + return TexturedModelData.of(data, 64, 64); } public void setAngles(BipedEntityModel biped) { - leftArm.copyPositionAndRotation(biped.leftArm); - rightArm.copyPositionAndRotation(biped.rightArm); + leftArm.copyTransform(biped.leftArm); + rightArm.copyTransform(biped.rightArm); if (alex) { rightArm.pivotX++; } diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/CastSpellEntityRenderer.java b/src/main/java/com/minelittlepony/unicopia/client/render/CastSpellEntityRenderer.java index d170622c..0e7e0a3d 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/CastSpellEntityRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/CastSpellEntityRenderer.java @@ -2,16 +2,15 @@ package com.minelittlepony.unicopia.client.render; import com.minelittlepony.unicopia.entity.CastSpellEntity; -import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry; -import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.entity.EntityRenderer; +import net.minecraft.client.render.entity.EntityRendererFactory; import net.minecraft.client.texture.SpriteAtlasTexture; import net.minecraft.util.Identifier; public class CastSpellEntityRenderer extends EntityRenderer { - public CastSpellEntityRenderer(EntityRenderDispatcher dispatcher, EntityRendererRegistry.Context context) { - super(dispatcher); + public CastSpellEntityRenderer(EntityRendererFactory.Context ctx) { + super(ctx); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/FloatingArtefactEntityRenderer.java b/src/main/java/com/minelittlepony/unicopia/client/render/FloatingArtefactEntityRenderer.java index e8c4b419..d122ae57 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/FloatingArtefactEntityRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/FloatingArtefactEntityRenderer.java @@ -3,27 +3,26 @@ package com.minelittlepony.unicopia.client.render; import com.minelittlepony.unicopia.entity.FloatingArtefactEntity; import com.minelittlepony.unicopia.item.UItems; -import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry; import net.minecraft.client.render.OverlayTexture; import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.entity.EntityRenderer; +import net.minecraft.client.render.entity.EntityRendererFactory; import net.minecraft.client.render.item.ItemRenderer; import net.minecraft.client.render.model.BakedModel; import net.minecraft.client.render.model.json.ModelTransformation; import net.minecraft.client.texture.SpriteAtlasTexture; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.client.util.math.Vector3f; import net.minecraft.item.ItemStack; import net.minecraft.util.Identifier; +import net.minecraft.util.math.Vec3f; public class FloatingArtefactEntityRenderer extends EntityRenderer { private final ItemRenderer itemRenderer; - public FloatingArtefactEntityRenderer(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) { - super(manager); - itemRenderer = context.getItemRenderer(); + public FloatingArtefactEntityRenderer(EntityRendererFactory.Context ctx) { + super(ctx); + itemRenderer = ctx.getItemRenderer(); } @Override @@ -35,7 +34,7 @@ public class FloatingArtefactEntityRenderer extends EntityRenderer RenderSystem.setShaderColor(red, green, blue, alpha), + () -> RenderSystem.setShaderColor(1, 1, 1, 1) + ); this.red = red; this.green = green; this.blue = blue; this.alpha = alpha; } - @Override - public void startDrawing() { - RenderSystem.blendColor(red, green, blue, alpha); - super.startDrawing(); - } - - @Override - public void endDrawing() { - super.endDrawing(); - RenderSystem.blendColor(1, 1, 1, 1); - } - @Override public boolean equals(Object other) { return super.equals(other) diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/WingsFeatureRenderer.java b/src/main/java/com/minelittlepony/unicopia/client/render/WingsFeatureRenderer.java index cbca4bcf..f02d327e 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/WingsFeatureRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/WingsFeatureRenderer.java @@ -3,8 +3,14 @@ package com.minelittlepony.unicopia.client.render; import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.item.UItems; +import net.minecraft.client.model.Dilation; import net.minecraft.client.model.Model; +import net.minecraft.client.model.ModelData; import net.minecraft.client.model.ModelPart; +import net.minecraft.client.model.ModelPartBuilder; +import net.minecraft.client.model.ModelPartData; +import net.minecraft.client.model.ModelTransform; +import net.minecraft.client.model.TexturedModelData; import net.minecraft.client.render.OverlayTexture; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.VertexConsumer; @@ -23,12 +29,13 @@ public class WingsFeatureRenderer implements AccessoryFe private static final Identifier ICARUS_WINGS_CORRUPTED = new Identifier("unicopia", "textures/models/wings/icarus_corrupted.png"); private static final Identifier PEGASUS_WINGS = new Identifier("unicopia", "textures/models/wings/pegasus.png"); - private final WingsModel model = new WingsModel(); + private final WingsModel model; private final FeatureRendererContext> context; public WingsFeatureRenderer(FeatureRendererContext> context) { this.context = context; + this.model = new WingsModel(WingsModel.getData(Dilation.NONE).createModel()); } @Override @@ -51,19 +58,24 @@ public class WingsFeatureRenderer implements AccessoryFe private final ModelPart root; private final Wing[] wings; - public WingsModel() { + public WingsModel(ModelPart tree) { super(RenderLayer::getEntityTranslucent); - this.textureHeight = 23; - this.textureWidth = 24; - root = new ModelPart(this, 0, 0); + root = tree; wings = new Wing[] { - new Wing(this, root, -1), - new Wing(this, root, 1) + new Wing(tree.getChild("left_wing"), -1), + new Wing(tree.getChild("right_wing"), 1) }; } + static TexturedModelData getData(Dilation dilation) { + ModelData data = new ModelData(); + Wing.getData("left_wing", data.getRoot(), dilation, -1); + Wing.getData("right_wing", data.getRoot(), dilation, 1); + return TexturedModelData.of(data, 24, 23); + } + public void setAngles(LivingEntity entity, BipedEntityModel biped) { - root.copyPositionAndRotation(biped.torso); + root.copyTransform(biped.body); for (Wing wing : wings) { wing.setAngles(entity); } @@ -75,36 +87,36 @@ public class WingsFeatureRenderer implements AccessoryFe } static class Wing { - ModelPart base; + final ModelPart base; - ModelPart[] feathers; + final ModelPart[] feathers = new ModelPart[8]; - int k; + final int k; - Wing(Model model, ModelPart torso, int k) { + Wing(ModelPart tree, int k) { this.k = k; - base = new ModelPart(model, 0, 0); - - base.setPivot(k * 2, 2, 2 + k * 0.5F); - base.addCuboid(0, 0, 0, 2, 10, 2); - - feathers = new ModelPart[8]; - + base = tree; for (int i = 0; i < feathers.length; i++) { - int texX = (i % 2) * 8; - - ModelPart feather = new ModelPart(model, 8 + texX, 0); - feather.setPivot(0, 9, 0); - - int featherLength = 21 - i * 2; - - feather.addCuboid(-k * (i % 2) / 90F, 0, 0, 2, featherLength, 2); - - base.addChild(feather); - feathers[i] = feather; + feathers[i] = base.getChild("feather_" + i); } + } - torso.addChild(base); + static void getData(String name, ModelPartData parent, Dilation dilation, int k) { + ModelPartData base = parent.addChild(name, + ModelPartBuilder.create().cuboid(0, 0, 0, 2, 10, 2, dilation), + ModelTransform.pivot(k * 2, 2, 2 + k * 0.5F)); + + int featherCount = 8; + + for (int i = 0; i < featherCount; i++) { + int texX = (i % 2) * 8; + int featherLength = 21 - i * 2; + base.addChild("feather_" + i, + ModelPartBuilder.create() + .uv(8 + texX, 0) + .cuboid(-k * (i % 2) / 90F, 0, 0, 2, featherLength, 2, dilation), + ModelTransform.pivot(0, 9, 0)); + } } void setAngles(LivingEntity entity) { diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/WorldRenderDelegate.java b/src/main/java/com/minelittlepony/unicopia/client/render/WorldRenderDelegate.java index 931c747c..db577b0a 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/WorldRenderDelegate.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/WorldRenderDelegate.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.client.render; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.spell.SpellType; @@ -9,6 +9,7 @@ import com.minelittlepony.unicopia.entity.ItemImpl; import com.minelittlepony.unicopia.entity.Living; import com.minelittlepony.unicopia.entity.behaviour.Disguise; import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.mixin.MixinBlockEntity; import net.minecraft.block.BlockState; import net.minecraft.block.entity.BlockEntity; @@ -16,14 +17,13 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.model.Model; import net.minecraft.client.render.OverlayTexture; import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher; import net.minecraft.client.render.block.entity.BlockEntityRenderer; import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.entity.EntityRenderer; import net.minecraft.client.render.entity.LivingEntityRenderer; import net.minecraft.client.render.entity.model.BipedEntityModel; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.client.util.math.Vector3f; +import net.minecraft.util.math.Vec3f; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; @@ -71,8 +71,8 @@ public class WorldRenderDelegate { roll = pony instanceof Pony ? ((Pony)pony).getInterpolator().interpolate("g_roll", roll, 15) : roll; matrices.translate(x, y + owner.getHeight() / 2, z); - matrices.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(roll)); - matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(roll)); + matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(roll)); + matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(roll)); matrices.translate(-x, -y - owner.getHeight() / 2, -z); if (negative) { @@ -132,9 +132,9 @@ public class WorldRenderDelegate { BlockEntity blockEntity = ve.getBlockEntity(); if (blockEntity != null) { - BlockEntityRenderer r = BlockEntityRenderDispatcher.INSTANCE.get(blockEntity); + BlockEntityRenderer r = MinecraftClient.getInstance().getBlockEntityRenderDispatcher().get(blockEntity); if (r != null) { - blockEntity.setPos(e.getBlockPos()); + ((MixinBlockEntity)blockEntity).setPos(e.getBlockPos()); matrices.push(); BlockState state = blockEntity.getCachedState(); @@ -143,7 +143,7 @@ public class WorldRenderDelegate { matrices.translate(x, y, z); matrices.multiply(direction.getRotationQuaternion()); - matrices.multiply(Vector3f.NEGATIVE_X.getDegreesQuaternion(90)); + matrices.multiply(Vec3f.NEGATIVE_X.getDegreesQuaternion(90)); matrices.translate(-0.5, 0, -0.5); @@ -161,7 +161,7 @@ public class WorldRenderDelegate { } e.setFireTicks(fireTicks); - dispatcher.render(e, x, y, z, e.yaw, tickDelta, matrices, vertexConsumers, light); + dispatcher.render(e, x, y, z, e.getYaw(), tickDelta, matrices, vertexConsumers, light); e.setFireTicks(0); if (model != null) { @@ -184,10 +184,10 @@ public class WorldRenderDelegate { private void flipAngles(Entity entity) { if (entity instanceof PlayerEntity) { entity.prevYaw *= -1; - entity.yaw *= -1; + entity.setYaw(entity.getYaw() * -1); entity.prevPitch *= -1; - entity.pitch *= -1; + entity.setPitch(entity.getPitch() * -1); } if (entity instanceof LivingEntity) { 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 09658567..313badbf 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/sound/MagicAuraSoundInstance.java +++ b/src/main/java/com/minelittlepony/unicopia/client/sound/MagicAuraSoundInstance.java @@ -45,7 +45,7 @@ public class MagicAuraSoundInstance extends MovingSoundInstance { y = pos.y; z = pos.z; - if (!living.getEntity().removed && data.isPresent()) { + if (!living.getEntity().isRemoved() && data.isPresent()) { float level = data.get().level; if (level != targetVolume) { setTargetVolume(level); diff --git a/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java b/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java index bfcc4c62..6690c29f 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java @@ -11,12 +11,12 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; import net.minecraft.command.argument.EntitySummonArgumentType; -import net.minecraft.command.argument.NbtCompoundTagArgumentType; +import net.minecraft.command.argument.NbtCompoundArgumentType; import net.minecraft.command.suggestion.SuggestionProviders; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.text.TranslatableText; @@ -38,18 +38,18 @@ public class DisguiseCommand { .executes(context -> disguise(context.getSource(), context.getSource().getPlayer(), EntitySummonArgumentType.getEntitySummon(context, "entity"), - new CompoundTag(), true)) - .then(CommandManager.argument("nbt", NbtCompoundTagArgumentType.nbtCompound()) + new NbtCompound(), true)) + .then(CommandManager.argument("nbt", NbtCompoundArgumentType.nbtCompound()) .executes(context -> disguise(context.getSource(), context.getSource().getPlayer(), EntitySummonArgumentType.getEntitySummon(context, "entity"), - NbtCompoundTagArgumentType.getCompoundTag(context, "nbt"), false)) + NbtCompoundArgumentType.getNbtCompound(context, "nbt"), false)) )); dispatcher.register(builder); } - static int disguise(ServerCommandSource source, PlayerEntity player, Identifier id, CompoundTag nbt, boolean isSelf) throws CommandSyntaxException { + static int disguise(ServerCommandSource source, PlayerEntity player, Identifier id, NbtCompound nbt, boolean isSelf) throws CommandSyntaxException { nbt = nbt.copy(); nbt.putString("id", id.toString()); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/CastSpellEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/CastSpellEntity.java index 1e13de21..e141a2b8 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/CastSpellEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/CastSpellEntity.java @@ -19,7 +19,7 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.entity.data.DataTracker; import net.minecraft.entity.data.TrackedData; import net.minecraft.entity.data.TrackedDataHandlerRegistry; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.network.Packet; import net.minecraft.text.Text; import net.minecraft.text.TranslatableText; @@ -66,7 +66,7 @@ public class CastSpellEntity extends Entity implements Caster { public void tick() { super.tick(); - if (removed) { + if (isRemoved()) { return; } @@ -83,11 +83,11 @@ public class CastSpellEntity extends Entity implements Caster { } LivingEntity master = getMaster(); - if (master == null || master.removed) { + if (master == null || master.isRemoved()) { if (orphanedTicks-- > 0) { return; } - remove(); + remove(RemovalReason.DISCARDED); return; } @@ -104,13 +104,13 @@ public class CastSpellEntity extends Entity implements Caster { return true; }).isPresent()) { - remove(); + remove(RemovalReason.DISCARDED); } } @Override - public void remove() { - super.remove(); + public void remove(RemovalReason reason) { + super.remove(reason); if (world.isClient) { world.getLightingProvider().checkBlock(getBlockPos()); } @@ -162,7 +162,7 @@ public class CastSpellEntity extends Entity implements Caster { } @Override - protected void writeCustomDataToTag(CompoundTag tag) { + protected void writeCustomDataToNbt(NbtCompound tag) { tag.put("owner", owner.toNBT()); dataTracker.get(SPELL).ifPresent(spellId -> { tag.putUuid("spellId", spellId); @@ -171,7 +171,7 @@ public class CastSpellEntity extends Entity implements Caster { } @Override - protected void readCustomDataFromTag(CompoundTag tag) { + protected void readCustomDataFromNbt(NbtCompound tag) { if (tag.contains("owner")) { owner.fromNBT(tag.getCompound("owner")); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/Creature.java b/src/main/java/com/minelittlepony/unicopia/entity/Creature.java index c664cb33..7995e5f1 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/Creature.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/Creature.java @@ -20,11 +20,11 @@ import net.minecraft.entity.data.DataTracker; import net.minecraft.entity.data.TrackedData; import net.minecraft.entity.data.TrackedDataHandlerRegistry; import net.minecraft.entity.mob.MobEntity; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; public class Creature extends Living { - private static final TrackedData EFFECT = DataTracker.registerData(LivingEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND); + private static final TrackedData EFFECT = DataTracker.registerData(LivingEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND); public static final TrackedData GRAVITY = DataTracker.registerData(LivingEntity.class, TrackedDataHandlerRegistry.FLOAT); private static final LevelStore LEVELS = Levelled.fixed(0); @@ -94,7 +94,7 @@ public class Creature extends Living { } @Override - public void toNBT(CompoundTag compound) { + public void toNBT(NbtCompound compound) { super.toNBT(compound); getSpellSlot().get(true).ifPresent(effect -> { compound.put("effect", SpellType.toNBT(effect)); @@ -103,7 +103,7 @@ public class Creature extends Living { } @Override - public void fromNBT(CompoundTag compound) { + public void fromNBT(NbtCompound compound) { super.fromNBT(compound); if (compound.contains("effect")) { setSpell(SpellType.fromNBT(compound.getCompound("effect"))); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/Enchantments.java b/src/main/java/com/minelittlepony/unicopia/entity/Enchantments.java index a43d1514..d0457df4 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/Enchantments.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/Enchantments.java @@ -7,19 +7,19 @@ import java.util.Optional; import java.util.Set; import java.util.function.Supplier; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.item.enchantment.SimpleEnchantment; import com.minelittlepony.unicopia.item.enchantment.UEnchantments; import com.minelittlepony.unicopia.util.NbtSerialisable; +import com.minelittlepony.unicopia.util.Tickable; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.nbt.StringTag; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtList; +import net.minecraft.nbt.NbtString; import net.minecraft.util.Identifier; -import net.minecraft.util.Tickable; import net.minecraft.util.registry.Registry; public class Enchantments implements NbtSerialisable, Tickable { @@ -74,19 +74,19 @@ public class Enchantments implements NbtSerialisable, Tickable { } @Override - public void toNBT(CompoundTag compound) { - ListTag list = new ListTag(); + public void toNBT(NbtCompound compound) { + NbtList list = new NbtList(); equippedEnchantments.forEach(enchant -> { Identifier id = Registry.ENCHANTMENT.getId(enchant); if (id != null) { - list.add(StringTag.of(id.toString())); + list.add(NbtString.of(id.toString())); } }); compound.put("enchants", list); } @Override - public void fromNBT(CompoundTag compound) { + public void fromNBT(NbtCompound compound) { equippedEnchantments.clear(); if (compound.contains("enchants")) { compound.getList("enchants", 8).forEach(tag -> { diff --git a/src/main/java/com/minelittlepony/unicopia/entity/EntityPhysics.java b/src/main/java/com/minelittlepony/unicopia/entity/EntityPhysics.java index bdaf2e38..8e7257ca 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/EntityPhysics.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/EntityPhysics.java @@ -2,8 +2,8 @@ package com.minelittlepony.unicopia.entity; import com.minelittlepony.unicopia.entity.player.PlayerAttributes; import com.minelittlepony.unicopia.util.Copieable; +import com.minelittlepony.unicopia.util.Tickable; -import net.minecraft.block.Block; import net.minecraft.block.BlockRenderType; import net.minecraft.block.BlockState; import net.minecraft.block.FenceGateBlock; @@ -12,11 +12,10 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.data.TrackedData; import net.minecraft.entity.mob.MobEntity; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.particle.BlockStateParticleEffect; import net.minecraft.particle.ParticleTypes; import net.minecraft.tag.BlockTags; -import net.minecraft.util.Tickable; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; @@ -97,8 +96,8 @@ public class EntityPhysics implements Physics, Copieable implements Physics, Copieable implements NbtSerialisable { public void set(@Nullable T entity) { if (entity != null) { uuid = entity.getUuid(); - clientId = entity.getEntityId(); + clientId = entity.getId(); pos = Optional.of(entity.getPos()); } } @@ -35,7 +35,7 @@ public class EntityReference implements NbtSerialisable { public boolean isPresent(World world) { T entity = get(world); - return entity != null && !entity.removed; + return entity != null && !entity.isRemoved(); } public void ifPresent(World world, Consumer consumer) { @@ -59,7 +59,7 @@ public class EntityReference implements NbtSerialisable { } @Override - public void toNBT(CompoundTag tag) { + public void toNBT(NbtCompound tag) { if (uuid != null) { tag.putUuid("uuid", uuid); } @@ -70,7 +70,7 @@ public class EntityReference implements NbtSerialisable { } @Override - public void fromNBT(CompoundTag tag) { + public void fromNBT(NbtCompound tag) { uuid = tag.containsUuid("uuid") ? tag.getUuid("uuid") : null; pos = tag.contains("pos") ? Optional.ofNullable(NbtSerialisable.readVector(tag.getList("pos", 6))) : Optional.empty(); clientId = tag.getInt("clientId"); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/Equine.java b/src/main/java/com/minelittlepony/unicopia/entity/Equine.java index 95e5a1d9..e7deea55 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/Equine.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/Equine.java @@ -2,16 +2,16 @@ package com.minelittlepony.unicopia.entity; import java.util.Optional; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.projectile.ProjectileImpactListener; import com.minelittlepony.unicopia.util.NbtSerialisable; +import com.minelittlepony.unicopia.util.Tickable; import net.minecraft.entity.Entity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.projectile.ProjectileEntity; -import net.minecraft.util.Tickable; public interface Equine extends NbtSerialisable, Tickable, ProjectileImpactListener { Race getSpecies(); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/FloatingArtefactEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/FloatingArtefactEntity.java index 390fb800..000efc47 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/FloatingArtefactEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/FloatingArtefactEntity.java @@ -11,7 +11,7 @@ import net.minecraft.entity.data.DataTracker; import net.minecraft.entity.data.TrackedData; import net.minecraft.entity.data.TrackedDataHandlerRegistry; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.network.Packet; import net.minecraft.sound.SoundEvents; import net.minecraft.util.ActionResult; @@ -142,17 +142,17 @@ public class FloatingArtefactEntity extends Entity { } @Override - protected void readCustomDataFromTag(CompoundTag compound) { - ItemStack itemStack = ItemStack.fromTag(compound.getCompound("Item")); + protected void readCustomDataFromNbt(NbtCompound compound) { + ItemStack itemStack = ItemStack.fromNbt(compound.getCompound("Item")); setStack(itemStack); setState(State.valueOf(compound.getInt("State"))); } @Override - protected void writeCustomDataToTag(CompoundTag compound) { + protected void writeCustomDataToNbt(NbtCompound compound) { ItemStack stack = getStack(); if (!stack.isEmpty()) { - compound.put("Item", stack.toTag(new CompoundTag())); + compound.put("Item", stack.writeNbt(new NbtCompound())); } compound.putInt("State", getState().ordinal()); } @@ -167,7 +167,7 @@ public class FloatingArtefactEntity extends Entity { health -= amount; if (health <= 0) { - remove(); + remove(RemovalReason.KILLED); ItemStack stack = getStack(); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ItemImpl.java b/src/main/java/com/minelittlepony/unicopia/entity/ItemImpl.java index 894f6fee..aff9e5b6 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ItemImpl.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ItemImpl.java @@ -18,7 +18,7 @@ import net.minecraft.entity.data.TrackedDataHandlerRegistry; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.particle.ParticleEffect; import net.minecraft.particle.ParticleTypes; import net.minecraft.util.ActionResult; @@ -91,14 +91,14 @@ public class ItemImpl implements Equine, Owned { }); } - if (stack.getItem().isIn(UTags.FALLS_SLOWLY)) { + if (stack.isIn(UTags.FALLS_SLOWLY)) { if (!owner.isOnGround() && Math.signum(owner.getVelocity().y) != getPhysics().getGravitySignum()) { double ticks = ((Entity)owner).age; double shift = Math.sin(ticks / 9D) / 9D; double rise = -Math.cos(ticks / 9D) * getPhysics().getGravitySignum(); owner.prevYaw = owner.prevYaw; - owner.yaw += 0.3F; + owner.setYaw(owner.getYaw() + 0.3F); owner.setVelocity( owner.getVelocity() @@ -139,13 +139,13 @@ public class ItemImpl implements Equine, Owned { } @Override - public void toNBT(CompoundTag compound) { + public void toNBT(NbtCompound compound) { compound.putString("owner_species", getSpecies().name()); physics.toNBT(compound); } @Override - public void fromNBT(CompoundTag compound) { + public void fromNBT(NbtCompound compound) { setSpecies(Race.fromName(compound.getString("owner_species"))); physics.fromNBT(compound); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ItemPhysics.java b/src/main/java/com/minelittlepony/unicopia/entity/ItemPhysics.java index bbecf364..5464dea5 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ItemPhysics.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ItemPhysics.java @@ -1,6 +1,5 @@ package com.minelittlepony.unicopia.entity; -import net.minecraft.entity.Entity; import net.minecraft.entity.ItemEntity; class ItemPhysics extends EntityPhysics { @@ -22,7 +21,7 @@ class ItemPhysics extends EntityPhysics { ); if (!entity.isOnGround() - || Entity.squaredHorizontalLength(entity.getVelocity()) > 9.999999747378752E-6D) { + || entity.getVelocity().horizontalLengthSquared() > 9.999999747378752E-6D) { float above = 0.98f; if (entity.verticalCollision) { diff --git a/src/main/java/com/minelittlepony/unicopia/entity/Living.java b/src/main/java/com/minelittlepony/unicopia/entity/Living.java index 37382f28..ed1ec8d3 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/Living.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/Living.java @@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.entity; import java.util.Optional; import java.util.stream.Stream; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.SpellContainer; @@ -20,7 +20,7 @@ import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.data.TrackedData; import net.minecraft.entity.projectile.ProjectileEntity; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.util.Hand; public abstract class Living implements Equine, Caster { @@ -42,11 +42,11 @@ public abstract class Living implements Equine, Caste private final Enchantments enchants = new Enchantments(this); - protected Living(T entity, TrackedData effect) { + protected Living(T entity, TrackedData effect) { this.entity = entity; this.effectDelegate = new EffectSync(this, effect); - entity.getDataTracker().startTracking(effect, new CompoundTag()); + entity.getDataTracker().startTracking(effect, new NbtCompound()); } public void waitForFall(Runnable action) { @@ -164,19 +164,19 @@ public abstract class Living implements Equine, Caste .isPresent(); } - protected void handleFall(float distance, float damageMultiplier) { + protected void handleFall(float distance, float damageMultiplier, DamageSource cause) { getSpellSlot().get(SpellType.DISGUISE, false).ifPresent(spell -> { - spell.getDisguise().onImpact(this, distance, damageMultiplier); + spell.getDisguise().onImpact(this, distance, damageMultiplier, cause); }); } @Override - public void toNBT(CompoundTag compound) { + public void toNBT(NbtCompound compound) { enchants.toNBT(compound); } @Override - public void fromNBT(CompoundTag compound) { + public void fromNBT(NbtCompound compound) { enchants.fromNBT(compound); } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/PonyContainer.java b/src/main/java/com/minelittlepony/unicopia/entity/PonyContainer.java index b0d14671..fea09dde 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/PonyContainer.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/PonyContainer.java @@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.entity; import java.util.Optional; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import net.minecraft.entity.Entity; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ai/BreakHeartGoal.java b/src/main/java/com/minelittlepony/unicopia/entity/ai/BreakHeartGoal.java index eed025fa..fcd6be3d 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ai/BreakHeartGoal.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ai/BreakHeartGoal.java @@ -28,7 +28,7 @@ public class BreakHeartGoal extends Goal { } protected boolean canTarget(Entity e) { - return !e.removed + return !e.isRemoved() && e instanceof FloatingArtefactEntity && ((FloatingArtefactEntity)e).getStack().getItem() == UItems.CRYSTAL_HEART && mob.getVisibilityCache().canSee(e); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ai/DynamicTargetGoal.java b/src/main/java/com/minelittlepony/unicopia/entity/ai/DynamicTargetGoal.java index 388c6a06..edc1d3a7 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ai/DynamicTargetGoal.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ai/DynamicTargetGoal.java @@ -5,7 +5,7 @@ import java.util.Optional; import java.util.function.Predicate; import java.util.function.Supplier; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.util.VecHelper; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ai/WantItTakeItGoal.java b/src/main/java/com/minelittlepony/unicopia/entity/ai/WantItTakeItGoal.java index 08920d1b..89f2543f 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ai/WantItTakeItGoal.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ai/WantItTakeItGoal.java @@ -8,6 +8,7 @@ import com.minelittlepony.unicopia.particle.ParticleUtils; import com.minelittlepony.unicopia.particle.UParticles; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; +import net.minecraft.entity.Entity.RemovalReason; import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.ItemEntity; import net.minecraft.entity.LivingEntity; @@ -18,7 +19,7 @@ import net.minecraft.util.Hand; public class WantItTakeItGoal extends BreakHeartGoal { - private final TargetPredicate predicate = new TargetPredicate() + private final TargetPredicate predicate = TargetPredicate.createAttackable() .setBaseMaxDistance(64) .setPredicate(EquinePredicates.HAS_WANT_IT_NEED_IT); @@ -30,7 +31,7 @@ public class WantItTakeItGoal extends BreakHeartGoal { @Override protected boolean canTarget(Entity e) { - return (!e.removed && e instanceof ItemEntity && EnchantmentHelper.getLevel(UEnchantments.WANT_IT_NEED_IT, ((ItemEntity)e).getStack()) > 0) + return (!e.isRemoved() && e instanceof ItemEntity && EnchantmentHelper.getLevel(UEnchantments.WANT_IT_NEED_IT, ((ItemEntity)e).getStack()) > 0) || (e instanceof LivingEntity && predicate.test(mob, (LivingEntity)e)); } @@ -78,11 +79,11 @@ public class WantItTakeItGoal extends BreakHeartGoal { ItemEntity item = (ItemEntity)target; ItemStack stack = item.getStack(); - if (!item.removed) { + if (!item.isRemoved()) { mob.tryEquip(stack); - mob.method_29499(item); + mob.triggerItemPickedUpByEntityCriteria(item); mob.sendPickup(item, stack.getCount()); - item.remove(); + item.remove(RemovalReason.DISCARDED); } }, 0); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/ChickenBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/ChickenBehaviour.java index 8764d05d..7db0a67b 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/ChickenBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/ChickenBehaviour.java @@ -35,9 +35,9 @@ public class ChickenBehaviour extends EntityBehaviour { if (egg.isEmpty()) { egg = new ItemStack(Items.EGG); - int slot = player.getMaster().inventory.method_7371(egg); + int slot = player.getMaster().getInventory().indexOf(egg); if (slot > -1) { - player.getMaster().inventory.removeStack(slot, 1); + player.getMaster().getInventory().removeStack(slot, 1); entity.playSound(SoundEvents.ENTITY_CHICKEN_EGG, 1, (entity.world.random.nextFloat() - entity.world.random.nextFloat()) * 0.2F + 4 @@ -54,7 +54,7 @@ public class ChickenBehaviour extends EntityBehaviour { Entity src = source.getEntity(); - if (src.isOnGround() || src instanceof PlayerEntity && ((PlayerEntity)src).abilities.flying) { + if (src.isOnGround() || src instanceof PlayerEntity && ((PlayerEntity)src).getAbilities().flying) { return; } 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 b2c82ef0..39a45dde 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/Disguise.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/Disguise.java @@ -7,8 +7,8 @@ import java.util.UUID; import java.util.function.Consumer; import java.util.function.Predicate; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.FlightType; import com.minelittlepony.unicopia.InteractionManager; @@ -31,6 +31,7 @@ import net.minecraft.entity.FallingBlockEntity; import net.minecraft.entity.Flutterer; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.boss.dragon.EnderDragonEntity; +import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.decoration.AbstractDecorationEntity; import net.minecraft.entity.mob.AmbientEntity; import net.minecraft.entity.mob.FlyingEntity; @@ -39,7 +40,7 @@ import net.minecraft.entity.mob.SpiderEntity; import net.minecraft.entity.mob.VexEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.projectile.ShulkerBulletEntity; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.util.function.BooleanBiFunction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Box; @@ -49,7 +50,7 @@ import net.minecraft.world.WorldAccess; public class Disguise implements NbtSerialisable { - @Nonnull + @NotNull private String entityId = ""; @Nullable @@ -63,7 +64,7 @@ public class Disguise implements NbtSerialisable { private Optional dimensions = Optional.empty(); @Nullable - private CompoundTag entityNbt; + private NbtCompound entityNbt; @Nullable public Entity getAppearance() { @@ -110,12 +111,12 @@ public class Disguise implements NbtSerialisable { } } - private synchronized void createPlayer(CompoundTag nbt, GameProfile profile, Caster source) { + private synchronized void createPlayer(NbtCompound nbt, GameProfile profile, Caster source) { remove(); entity = InteractionManager.instance().createPlayer(source.getEntity(), profile); entity.setCustomName(source.getMaster().getName()); - ((PlayerEntity)entity).fromTag(nbt.getCompound("playerNbt")); + ((PlayerEntity)entity).readNbt(nbt.getCompound("playerNbt")); entity.setUuid(UUID.randomUUID()); entity.extinguish(); @@ -124,7 +125,7 @@ public class Disguise implements NbtSerialisable { public Entity getOrCreate(Caster source) { if (entity == null && entityNbt != null) { - CompoundTag nbt = entityNbt; + NbtCompound nbt = entityNbt; entityNbt = null; attachments.clear(); @@ -133,16 +134,14 @@ public class Disguise implements NbtSerialisable { nbt.getUuid("playerId"), nbt.getString("playerName") ), source); - new Thread(() -> createPlayer(nbt, SkullBlockEntity.loadProperties(new GameProfile( - null, - nbt.getString("playerName") - )), source)).start(); + + SkullBlockEntity.loadProperties(new GameProfile(null, nbt.getString("playerName")), profile ->{ }); } else { if (source.isClient()) { - entity = EntityType.fromTag(nbt).map(type -> type.create(source.getWorld())).orElse(null); + entity = EntityType.fromNbt(nbt).map(type -> type.create(source.getWorld())).orElse(null); if (entity != null) { try { - entity.fromTag(nbt); + entity.readNbt(nbt); } catch (Exception ignored) { // Mojang pls } @@ -161,8 +160,8 @@ public class Disguise implements NbtSerialisable { return entity; } - public void onImpact(Caster pony, float distance, float damageMultiplier) { - EntityBehaviour.forEntity(entity).onImpact(pony, entity, distance, damageMultiplier); + public void onImpact(Caster pony, float distance, float damageMultiplier, DamageSource cause) { + EntityBehaviour.forEntity(entity).onImpact(pony, entity, distance, damageMultiplier, cause); } private void onEntityLoaded(Caster source) { @@ -251,7 +250,7 @@ public class Disguise implements NbtSerialisable { } @Override - public void toNBT(CompoundTag compound) { + public void toNBT(NbtCompound compound) { compound.putString("entityId", entityId); if (entityNbt != null) { @@ -262,7 +261,7 @@ public class Disguise implements NbtSerialisable { } @Override - public void fromNBT(CompoundTag compound) { + public void fromNBT(NbtCompound compound) { String newId = compound.getString("entityId"); if (!newId.contentEquals(entityId)) { @@ -279,7 +278,7 @@ public class Disguise implements NbtSerialisable { if (entity != null) { try { - entity.fromTag(entityNbt); + entity.readNbt(entityNbt); } catch (Exception ignored) { // Mojang pls } @@ -296,8 +295,8 @@ public class Disguise implements NbtSerialisable { || entity instanceof FallingBlockEntity; } - private static CompoundTag encodeEntityToNBT(Entity entity) { - CompoundTag entityNbt = new CompoundTag(); + private static NbtCompound encodeEntityToNBT(Entity entity) { + NbtCompound entityNbt = new NbtCompound(); if (entity instanceof PlayerEntity) { GameProfile profile = ((PlayerEntity)entity).getGameProfile(); @@ -306,13 +305,13 @@ public class Disguise implements NbtSerialisable { entityNbt.putUuid("playerId", profile.getId()); entityNbt.putString("playerName", profile.getName()); - CompoundTag tag = new CompoundTag(); + NbtCompound tag = new NbtCompound(); - entity.saveToTag(tag); + entity.writeNbt(tag); entityNbt.put("playerNbt", tag); } else { - entity.saveToTag(entityNbt); + entity.writeNbt(entityNbt); } return entityNbt; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java index ffa4754a..a234344b 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java @@ -3,21 +3,24 @@ package com.minelittlepony.unicopia.entity.behaviour; import java.util.Optional; import java.util.function.Supplier; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell; import com.minelittlepony.unicopia.entity.ItemWielder; import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.mixin.MixinEntity; import com.minelittlepony.unicopia.util.Registries; import net.minecraft.entity.Entity; +import net.minecraft.entity.Entity.RemovalReason; import net.minecraft.entity.EntityDimensions; import net.minecraft.entity.EntityType; import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.FallingBlockEntity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.MovementType; +import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.mob.AbstractSkeletonEntity; import net.minecraft.entity.passive.LlamaEntity; import net.minecraft.entity.passive.SnowGolemEntity; @@ -47,7 +50,7 @@ public class EntityBehaviour { } - public void onImpact(Caster source, T entity, float distance, float damageMultiplier) { + public void onImpact(Caster source, T entity, float distance, float damageMultiplier, DamageSource cause) { } @@ -59,7 +62,7 @@ public class EntityBehaviour { public void onDestroy(T entity) { entity.setInvulnerable(false); entity.setNoGravity(false); - entity.remove(); + entity.remove(RemovalReason.KILLED); } public Optional getCameraDistance(Entity entity, Pony player) { @@ -97,7 +100,7 @@ public class EntityBehaviour { public void copyBaseAttributes(LivingEntity from, Entity to, Vec3d positionOffset) { // Set first because position calculations rely on it to.age = from.age; - to.removed = from.removed; + ((MixinEntity)to).setRemovalReason(from.getRemovalReason()); to.setOnGround(from.isOnGround()); if (!from.world.isClient) { @@ -143,10 +146,6 @@ public class EntityBehaviour { to.prevY = positionOffset.y + from.prevY; to.prevZ = positionOffset.z + from.prevZ; - to.chunkX = from.chunkX; - to.chunkY = from.chunkY; - to.chunkZ = from.chunkZ; - to.lastRenderX = positionOffset.x + from.lastRenderX; to.lastRenderY = positionOffset.y + from.lastRenderY; to.lastRenderZ = positionOffset.z + from.lastRenderZ; @@ -162,9 +161,9 @@ public class EntityBehaviour { to.setVelocity(from.getVelocity()); - to.pitch = from.pitch; + to.setPitch(from.getPitch()); to.prevPitch = from.prevPitch; - to.yaw = from.yaw; + to.setYaw(from.getYaw()); to.prevYaw = from.prevYaw; to.horizontalSpeed = from.horizontalSpeed; to.prevHorizontalSpeed = from.prevHorizontalSpeed; @@ -245,7 +244,7 @@ public class EntityBehaviour { protected boolean isSneakingOnGround(Caster source) { Entity e = source.getEntity(); - return e.isSneaking() && (e.isOnGround() || !(e instanceof PlayerEntity && ((PlayerEntity)e).abilities.flying)); + return e.isSneaking() && (e.isOnGround() || !(e instanceof PlayerEntity && ((PlayerEntity)e).getAbilities().flying)); } public static void register(Supplier> behaviour, EntityType... types) { diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/FallingBlockBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/FallingBlockBehaviour.java index eb35aad8..9c8a1e7b 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/FallingBlockBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/FallingBlockBehaviour.java @@ -8,6 +8,7 @@ import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell; import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.mixin.MixinBlockEntity; import com.minelittlepony.unicopia.mixin.MixinFallingBlock; +import com.minelittlepony.unicopia.util.Tickable; import net.minecraft.block.Block; import net.minecraft.block.BlockEntityProvider; @@ -21,9 +22,9 @@ import net.minecraft.block.enums.DoubleBlockHalf; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityDimensions; import net.minecraft.entity.FallingBlockEntity; +import net.minecraft.entity.damage.DamageSource; import net.minecraft.state.property.Properties; import net.minecraft.tag.BlockTags; -import net.minecraft.util.Tickable; import net.minecraft.util.math.Direction; import net.minecraft.util.math.Vec3d; @@ -39,10 +40,10 @@ public class FallingBlockBehaviour extends EntityBehaviour { } @Override - public void onImpact(Caster source, FallingBlockEntity entity, float distance, float damageMultiplier) { + public void onImpact(Caster source, FallingBlockEntity entity, float distance, float damageMultiplier, DamageSource cause) { if (source.getEntity().fallDistance > 3) { entity.fallDistance = source.getEntity().fallDistance; - entity.handleFallDamage(distance, damageMultiplier); + entity.handleFallDamage(distance, damageMultiplier, cause); BlockState state = entity.getBlockState(); if (state.getBlock() instanceof FallingBlock) { @@ -77,9 +78,7 @@ public class FallingBlockBehaviour extends EntityBehaviour { } if (block instanceof BlockEntityProvider) { - BlockEntity b = ((BlockEntityProvider)block).createBlockEntity(entity.world); - ((MixinBlockEntity)b).setCachedState(state); - context.addBlockEntity(b); + context.addBlockEntity(((BlockEntityProvider)block).createBlockEntity(entity.getBlockPos(), state)); } return configure(entity, block); @@ -115,9 +114,10 @@ public class FallingBlockBehaviour extends EntityBehaviour { be.onSyncedBlockEvent(1, isSneakingOnGround(source) ? 1 : 0); } - be.setLocation(entity.world, entity.getBlockPos()); + be.setWorld(entity.world); + ((MixinBlockEntity)be).setPos(entity.getBlockPos()); ceb.tick(); - be.setLocation(null, entity.getBlockPos()); + be.setWorld(null); } } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/GhastBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/GhastBehaviour.java index 30dbb6e8..f0f1b2d2 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/GhastBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/GhastBehaviour.java @@ -28,9 +28,12 @@ public class GhastBehaviour extends MobBehaviour { Vec3d rot = player.getEntity().getRotationVec(1); - FireballEntity proj = new FireballEntity(entity.world, entity, rot.getX(), rot.getY(), rot.getZ()); - proj.explosionPower = entity.getFireballStrength() * (player.getLevel().get() + 1); - proj.setOwner(player.getMaster()); + FireballEntity proj = new FireballEntity(entity.world, player.getMaster(), + rot.getX(), + rot.getY(), + rot.getZ(), + entity.getFireballStrength() * (player.getLevel().get() + 1) + ); proj.updatePosition( entity.getX() + rot.x * 4, entity.getBodyY(0.5D) + 0.5, diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/HoppingBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/HoppingBehaviour.java index b63e84db..550ceddd 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/HoppingBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/HoppingBehaviour.java @@ -3,7 +3,6 @@ package com.minelittlepony.unicopia.entity.behaviour; import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell; import com.minelittlepony.unicopia.entity.player.Pony; -import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.passive.RabbitEntity; @@ -12,7 +11,7 @@ public class HoppingBehaviour extends EntityBehaviour { public void update(Pony player, LivingEntity entity, DisguiseSpell spell) { if (player.getEntity().isOnGround()) { - if (Entity.squaredHorizontalLength(player.getEntity().getVelocity()) > 0.01) { + if (player.getEntity().getVelocity().horizontalLengthSquared() > 0.01) { player.getMaster().jump(); if (entity instanceof RabbitEntity) { ((RabbitEntity)entity).startJump(); 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 64b5fadd..af95ebe5 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MinecartBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MinecartBehaviour.java @@ -21,10 +21,10 @@ public class MinecartBehaviour extends EntityBehaviour { @Override public void update(Caster source, AbstractMinecartEntity entity, DisguiseSpell spell) { - entity.yaw -= 90; + entity.setYaw(entity.getYaw() - 90); entity.prevYaw -= 90; - entity.pitch = 0; + entity.setPitch(0); entity.prevPitch = 0; if (source.getEntity() instanceof LivingEntity) { 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 0bc6729e..e985b805 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SheepBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SheepBehaviour.java @@ -44,13 +44,14 @@ public class SheepBehaviour extends EntityBehaviour { entity.setSheared(true); Random rng = entity.world.random; - PlayerInventory inv = player.getMaster().inventory; + PlayerInventory inv = player.getMaster().getInventory(); int dropAmount = rng.nextInt(3); int slot; do { - slot = inv.method_7371(dropType); + slot = inv.indexOf(dropType); + if (slot < 0) { break; } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/ShulkerBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/ShulkerBehaviour.java index 2464ff37..0ec861db 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/ShulkerBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/ShulkerBehaviour.java @@ -5,7 +5,6 @@ import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell; import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.mixin.MixinShulkerEntity; -import net.minecraft.entity.Entity; import net.minecraft.entity.mob.ShulkerEntity; import net.minecraft.sound.SoundEvents; import net.minecraft.util.math.BlockPos; @@ -17,12 +16,10 @@ import net.minecraft.util.math.Vec3d; public class ShulkerBehaviour extends EntityBehaviour { @Override public void update(Caster source, ShulkerEntity shulker, DisguiseSpell spell) { - shulker.yaw = 0; + shulker.setYaw(0); shulker.prevBodyYaw = 0; shulker.bodyYaw = 0; - shulker.setAttachedBlock(null); - super.update(source, shulker, spell); Direction attachmentFace = shulker.getAttachedFace(); @@ -45,7 +42,7 @@ public class ShulkerBehaviour extends EntityBehaviour { float peekAmount = 30; double speed = !player.getEntity().isSneaking() ? 0.29 : 0; - speed += Math.sqrt(Entity.squaredHorizontalLength(player.getEntity().getVelocity())) * 2; + speed += Math.sqrt(player.getEntity().getVelocity().horizontalLengthSquared()) * 2; peekAmount = (float)MathHelper.clamp(speed, 0, 1); peekAmount = player.getInterpolator().interpolate("peek", peekAmount, 5); @@ -56,8 +53,8 @@ public class ShulkerBehaviour extends EntityBehaviour { mx.setOpenProgress(peekAmount); if (player.sneakingChanged()) { - shulker.setPeekAmount((int)(peekAmount / 0.01F)); - } else if (peekAmount > 0.2 && shulker.getPeekAmount() == 0) { + mx.callSetPeekAmount((int)(peekAmount / 0.01F)); + } else if (peekAmount > 0.2 && mx.callGetPeekAmount() == 0) { if (shulker.isAlive() && shulker.world.random.nextInt(1000) < shulker.ambientSoundChance++) { shulker.ambientSoundChance = -shulker.getMinAmbientSoundDelay(); shulker.playSound(SoundEvents.ENTITY_SHULKER_AMBIENT, 1, 1); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SpellcastingIllagerBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SpellcastingIllagerBehaviour.java index 41109c15..ec4c71d5 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SpellcastingIllagerBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SpellcastingIllagerBehaviour.java @@ -9,6 +9,14 @@ public class SpellcastingIllagerBehaviour extends EntityBehaviour implements Tickab entity.setPose(EntityPose.STANDING); } - boolean creative = entity.abilities.creativeMode || entity.isSpectator(); + boolean creative = entity.getAbilities().creativeMode || entity.isSpectator(); FlightType type = getFlightType(); @@ -131,12 +131,12 @@ public class PlayerPhysics extends EntityPhysics implements Tickab entity.world.playSound(entity.getX(), entity.getY(), entity.getZ(), entity.world.getDimension().isUltrawarm() ? SoundEvents.BLOCK_BELL_USE : SoundEvents.BLOCK_BELL_RESONATE, SoundCategory.PLAYERS, 0.1125F, 1.5F, true); } - entity.abilities.allowFlying = type.canFlyCreative(entity); + entity.getAbilities().allowFlying = type.canFlyCreative(entity); if (!creative) { - entity.abilities.flying |= (type.canFly() || entity.abilities.allowFlying) && isFlyingEither; + entity.getAbilities().flying |= (type.canFly() || entity.getAbilities().allowFlying) && isFlyingEither; if (!type.canFly() && (type != lastFlightType)) { - entity.abilities.flying = false; + entity.getAbilities().flying = false; } if ((entity.isOnGround() && entity.isSneaking()) @@ -144,28 +144,28 @@ public class PlayerPhysics extends EntityPhysics implements Tickab || entity.horizontalCollision || (entity.verticalCollision && (pony.getSpecies() != Race.BAT || velocity.y < 0))) { - if (entity.abilities.flying && entity.horizontalCollision) { + if (entity.getAbilities().flying && entity.horizontalCollision) { handleWallCollission(entity, velocity); entity.setVelocity(velocity.toImmutable()); - entity.abilities.flying = false; + entity.getAbilities().flying = false; return; } - entity.abilities.flying = false; - isFlyingSurvival = entity.abilities.flying && !creative; - isFlyingEither = isFlyingSurvival || (creative && entity.abilities.flying); + entity.getAbilities().flying = false; + isFlyingSurvival = entity.getAbilities().flying && !creative; + isFlyingEither = isFlyingSurvival || (creative && entity.getAbilities().flying); } } lastFlightType = type; - isFlyingSurvival = entity.abilities.flying && !creative; - isFlyingEither = isFlyingSurvival || (creative && entity.abilities.flying); + isFlyingSurvival = entity.getAbilities().flying && !creative; + isFlyingEither = isFlyingSurvival || (creative && entity.getAbilities().flying); if (isGravityNegative()) { if (entity.isOnGround() || (!creative && entity.horizontalCollision)) { - entity.abilities.flying = false; + entity.getAbilities().flying = false; isFlyingEither = false; isFlyingSurvival = false; } @@ -219,7 +219,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab if (!getFlightType().canFly()) { entity.world.playSoundFromEntity(null, entity, SoundEvents.ITEM_SHIELD_BREAK, SoundCategory.PLAYERS, 1, 2); - entity.abilities.flying = false; + entity.getAbilities().flying = false; isFlyingEither = false; isFlyingSurvival = false; } @@ -288,7 +288,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab boolean fallingTakeOffCondition = !entity.isOnGround() && velocity.y < -1.6 * getGravitySignum(); if (takeOffCondition || fallingTakeOffCondition) { - entity.abilities.flying = true; + entity.getAbilities().flying = true; isFlyingEither = true; isFlyingSurvival = true; @@ -364,9 +364,9 @@ public class PlayerPhysics extends EntityPhysics implements Tickab // vertical drop due to gravity forward += 0.005F; - velocity.x += - forward * MathHelper.sin(player.yaw * 0.017453292F); + velocity.x += - forward * MathHelper.sin(player.getYaw() * 0.017453292F); velocity.y -= (0.01F / Math.max(motion * 100, 1)) * getGravityModifier(); - velocity.z += forward * MathHelper.cos(player.yaw * 0.017453292F); + velocity.z += forward * MathHelper.cos(player.getYaw() * 0.017453292F); } protected void applyThrust(PlayerEntity player, MutableVector velocity) { @@ -426,8 +426,8 @@ public class PlayerPhysics extends EntityPhysics implements Tickab forward = Math.min(forward, 7); forward /= 1 + (EnchantmentHelper.getEquipmentLevel(UEnchantments.HEAVY, player) * 0.8F); - velocity.x += - forward * MathHelper.sin((player.yaw + glance) * 0.017453292F); - velocity.z += forward * MathHelper.cos((player.yaw + glance) * 0.017453292F); + velocity.x += - forward * MathHelper.sin((player.getYaw() + glance) * 0.017453292F); + velocity.z += forward * MathHelper.cos((player.getYaw() + glance) * 0.017453292F); if (!player.world.isClient && player.world.isThundering() && player.world.random.nextInt(9000) == 0) { LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(player.world); @@ -438,7 +438,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab } protected double getHorizontalMotion(Entity e) { - return Entity.squaredHorizontalLength(e.getPos().subtract(lastPos)); + return e.getPos().subtract(lastPos).horizontalLengthSquared(); } private FlightType getFlightType() { @@ -456,19 +456,19 @@ public class PlayerPhysics extends EntityPhysics implements Tickab public void updateFlightStat(boolean flying) { FlightType type = getFlightType(); - entity.abilities.allowFlying = type.canFlyCreative(entity); + entity.getAbilities().allowFlying = type.canFlyCreative(entity); - if (type.canFly() || entity.abilities.allowFlying) { - entity.abilities.flying |= flying; - isFlyingSurvival = entity.abilities.flying; + if (type.canFly() || entity.getAbilities().allowFlying) { + entity.getAbilities().flying |= flying; + isFlyingSurvival = entity.getAbilities().flying; } else { - entity.abilities.flying = false; + entity.getAbilities().flying = false; isFlyingSurvival = false; } } @Override - public void toNBT(CompoundTag compound) { + public void toNBT(NbtCompound compound) { super.toNBT(compound); compound.putBoolean("isFlying", isFlyingSurvival); compound.putBoolean("isFlyingEither", isFlyingEither); @@ -476,7 +476,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab } @Override - public void fromNBT(CompoundTag compound) { + public void fromNBT(NbtCompound compound) { super.fromNBT(compound); isFlyingSurvival = compound.getBoolean("isFlying"); isFlyingEither = compound.getBoolean("isFlyingEither"); 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 03805341..4567738b 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java @@ -5,7 +5,7 @@ import java.util.Objects; import java.util.Optional; import java.util.stream.Stream; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.Affinity; import com.minelittlepony.unicopia.client.UnicopiaClient; @@ -28,6 +28,7 @@ import com.minelittlepony.unicopia.network.MsgRequestCapabilities; import com.minelittlepony.unicopia.network.Transmittable; import com.minelittlepony.unicopia.util.Copieable; import com.minelittlepony.unicopia.util.MagicalDamageSource; +import com.minelittlepony.unicopia.util.Tickable; import com.minelittlepony.common.util.animation.LinearInterpolator; import com.google.common.collect.Lists; import com.google.common.collect.Streams; @@ -37,18 +38,18 @@ import com.mojang.authlib.GameProfile; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.attribute.DefaultAttributeContainer; +import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.data.DataTracker; import net.minecraft.entity.data.TrackedData; import net.minecraft.entity.data.TrackedDataHandlerRegistry; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; 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.Tickable; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; @@ -61,7 +62,7 @@ public class Pony extends Living implements Transmittable, Copieab static final TrackedData MANA = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.FLOAT); static final TrackedData XP = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.FLOAT); - private static final TrackedData EFFECT = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND); + private static final TrackedData EFFECT = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND); private final AbilityDispatcher powers = new AbilityDispatcher(this); private final PlayerPhysics gravity = new PlayerPhysics(this); @@ -118,7 +119,7 @@ public class Pony extends Living implements Transmittable, Copieab entity.getDataTracker().set(RACE, race.ordinal()); - gravity.updateFlightStat(entity.abilities.flying); + gravity.updateFlightStat(entity.getAbilities().flying); entity.sendAbilitiesUpdate(); } @@ -262,7 +263,7 @@ public class Pony extends Living implements Transmittable, Copieab if (isHanging()) { if (ticksHanging++ > 40) { - if (Entity.squaredHorizontalLength(entity.getVelocity()) > 0.01 + if (entity.getVelocity().horizontalLengthSquared() > 0.01 || entity.isSneaking() || !canHangAt(getHangingPos())) { @@ -284,7 +285,7 @@ public class Pony extends Living implements Transmittable, Copieab } } - public Optional onImpact(float distance, float damageMultiplier) { + public Optional onImpact(float distance, float damageMultiplier, DamageSource cause) { float g = gravity.getGravityModifier(); @@ -301,11 +302,11 @@ public class Pony extends Living implements Transmittable, Copieab distance = Math.max(0, (distance * g) - 5); - handleFall(distance, damageMultiplier); + handleFall(distance, damageMultiplier, cause); return Optional.of(distance); } - handleFall(distance, damageMultiplier); + handleFall(distance, damageMultiplier, cause); return Optional.empty(); } @@ -349,7 +350,7 @@ public class Pony extends Living implements Transmittable, Copieab protected Stream getInventoryStacks() { return Streams.concat( super.getInventoryStacks(), - entity.inventory.main.stream() + entity.getInventory().main.stream() ); } @@ -374,7 +375,7 @@ public class Pony extends Living implements Transmittable, Copieab } @Override - public void toNBT(CompoundTag compound) { + public void toNBT(NbtCompound compound) { super.toNBT(compound); compound.putString("playerSpecies", getSpecies().name()); @@ -389,7 +390,7 @@ public class Pony extends Living implements Transmittable, Copieab } @Override - public void fromNBT(CompoundTag compound) { + public void fromNBT(NbtCompound compound) { super.fromNBT(compound); speciesPersisted = true; setSpecies(Race.fromName(compound.getString("playerSpecies"))); @@ -407,7 +408,7 @@ public class Pony extends Living implements Transmittable, Copieab @Override public void copyFrom(Pony oldPlayer) { speciesPersisted = oldPlayer.speciesPersisted; - if (!oldPlayer.getEntity().removed) { + if (!oldPlayer.getEntity().isRemoved()) { setSpell(oldPlayer.getSpellSlot().get(true).orElse(null)); } oldPlayer.setSpell(null); 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 b8d90f76..cc963228 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 @@ -1,11 +1,12 @@ package com.minelittlepony.unicopia.entity.player.dummy; -import javax.annotation.Nonnull; +import org.jetbrains.annotations.NotNull; import com.minelittlepony.unicopia.InteractionManager; import com.minelittlepony.unicopia.Owned; import com.mojang.authlib.GameProfile; +import net.fabricmc.fabric.api.networking.v1.PacketByteBufs; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.network.ClientPlayNetworkHandler; @@ -38,7 +39,7 @@ public class DummyClientPlayerEntity extends AbstractClientPlayerEntity implemen } @Override - @Nonnull + @NotNull protected PlayerListEntry getPlayerListEntry() { if (playerInfo == null) { ClientPlayNetworkHandler connection = MinecraftClient.getInstance().getNetworkHandler(); @@ -74,11 +75,13 @@ public class DummyClientPlayerEntity extends AbstractClientPlayerEntity implemen } private final class Packet extends PlayerListS2CPacket { + public Packet() { super(PacketByteBufs.empty()); } + PlayerListS2CPacket.Entry entry() { return new PlayerListS2CPacket.Entry( getGameProfile(), 0, - GameMode.NOT_SET, + GameMode.DEFAULT, new LiteralText(getGameProfile().getName())); } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/dummy/DummyServerPlayerEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/player/dummy/DummyServerPlayerEntity.java index 5dac743e..a6b82c88 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/dummy/DummyServerPlayerEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/dummy/DummyServerPlayerEntity.java @@ -7,7 +7,6 @@ import com.mojang.authlib.GameProfile; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.network.ServerPlayerInteractionManager; import net.minecraft.server.world.ServerWorld; public class DummyServerPlayerEntity extends ServerPlayerEntity implements Owned { @@ -15,7 +14,7 @@ public class DummyServerPlayerEntity extends ServerPlayerEntity implements Owned private PlayerEntity owner; public DummyServerPlayerEntity(ServerWorld world, GameProfile profile) { - super(world.getServer(), world, profile, new ServerPlayerInteractionManager(world)); + super(world.getServer(), world, profile); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/item/AmuletItem.java b/src/main/java/com/minelittlepony/unicopia/item/AmuletItem.java index cbdecc1b..4a08b607 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/AmuletItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/AmuletItem.java @@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.item; import java.util.List; import java.util.Optional; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.Multimap; diff --git a/src/main/java/com/minelittlepony/unicopia/item/AppleItem.java b/src/main/java/com/minelittlepony/unicopia/item/AppleItem.java index 96381cd9..a73912cb 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/AppleItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/AppleItem.java @@ -1,13 +1,14 @@ package com.minelittlepony.unicopia.item; import java.util.List; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.entity.IItemEntity; import com.minelittlepony.unicopia.entity.ItemImpl; import com.minelittlepony.unicopia.item.toxin.Toxicity; import net.minecraft.client.item.TooltipContext; +import net.minecraft.entity.Entity.RemovalReason; import net.minecraft.entity.EntityType; import net.minecraft.entity.ItemEntity; import net.minecraft.item.Item; @@ -29,10 +30,10 @@ public class AppleItem extends Item implements ItemImpl.TickableItem { public ActionResult onGroundTick(IItemEntity item) { ItemEntity entity = item.get().getMaster(); - if (!entity.removed && item.getPickupDelay() == 0 && item.getAge() > 2030 && entity.world.random.nextInt(150) < 10) { + if (!entity.isRemoved() && item.getPickupDelay() == 0 && item.getAge() > 2030 && entity.world.random.nextInt(150) < 10) { if (!entity.world.isClient) { - entity.remove(); + entity.remove(RemovalReason.KILLED); ItemEntity neu = EntityType.ITEM.create(entity.world); neu.copyPositionAndRotation(entity); @@ -48,7 +49,7 @@ public class AppleItem extends Item implements ItemImpl.TickableItem { entity.world.spawnEntity(copy); } - float bob = MathHelper.sin(((float)item.getAge() + 1) / 10F + entity.hoverHeight) * 0.1F + 0.1F; + float bob = MathHelper.sin(((float)item.getAge() + 1) / 10F + entity.uniqueOffset) * 0.1F + 0.1F; for (int i = 0; i < 3; i++) { entity.world.addParticle(ParticleTypes.AMBIENT_ENTITY_EFFECT, entity.getX(), entity.getY() + bob, entity.getZ(), diff --git a/src/main/java/com/minelittlepony/unicopia/item/CrystalHeartItem.java b/src/main/java/com/minelittlepony/unicopia/item/CrystalHeartItem.java index 038b4d8d..964f5b6c 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/CrystalHeartItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/CrystalHeartItem.java @@ -101,7 +101,7 @@ public class CrystalHeartItem extends Item implements FloatingArtefactEntity.Art List inputs = new ArrayList<>(); List outputs = new ArrayList<>(); - VecHelper.findInRange(entity, entity.world, entity.getPos(), 20, EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR.and(e -> !e.removed && (e instanceof PlayerEntity || e instanceof MobEntity))).forEach(e -> { + VecHelper.findInRange(entity, entity.world, entity.getPos(), 20, EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR.and(e -> !e.isRemoved() && (e instanceof PlayerEntity || e instanceof MobEntity))).forEach(e -> { LivingEntity living = (LivingEntity)e; if (e instanceof PlayerEntity diff --git a/src/main/java/com/minelittlepony/unicopia/item/DrinkableItem.java b/src/main/java/com/minelittlepony/unicopia/item/DrinkableItem.java index aeb43692..09bbc584 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/DrinkableItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/DrinkableItem.java @@ -23,7 +23,7 @@ public class DrinkableItem extends Item { serverPlayerEntity.incrementStat(Stats.USED.getOrCreateStat(this)); } - if (user instanceof PlayerEntity && !((PlayerEntity)user).abilities.creativeMode) { + if (user instanceof PlayerEntity && !((PlayerEntity)user).getAbilities().creativeMode) { stack.decrement(1); } diff --git a/src/main/java/com/minelittlepony/unicopia/item/FriendshipBraceletItem.java b/src/main/java/com/minelittlepony/unicopia/item/FriendshipBraceletItem.java index 80c2cb43..ef2accf9 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/FriendshipBraceletItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/FriendshipBraceletItem.java @@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.item; import java.util.List; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.EquinePredicates; import com.minelittlepony.unicopia.ability.magic.Caster; @@ -42,7 +42,7 @@ public class FriendshipBraceletItem extends WearableItem implements DyeableItem, result.setCount(1); result.getOrCreateTag().putString("issuer", player.getName().asString()); - if (!player.abilities.creativeMode) { + if (!player.getAbilities().creativeMode) { stack.decrement(1); } diff --git a/src/main/java/com/minelittlepony/unicopia/item/GemstoneItem.java b/src/main/java/com/minelittlepony/unicopia/item/GemstoneItem.java index 71eb4ba4..d6860dc4 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/GemstoneItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/GemstoneItem.java @@ -4,7 +4,7 @@ import java.util.List; import java.util.Objects; import java.util.function.Predicate; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.Affinity; import com.minelittlepony.unicopia.Unicopia; diff --git a/src/main/java/com/minelittlepony/unicopia/item/GlowableItem.java b/src/main/java/com/minelittlepony/unicopia/item/GlowableItem.java index 0c3931c4..f50d9155 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/GlowableItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/GlowableItem.java @@ -1,11 +1,11 @@ package com.minelittlepony.unicopia.item; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; public interface GlowableItem { default boolean isGlowing(ItemStack stack) { - CompoundTag tag = stack.getSubTag("display"); + NbtCompound tag = stack.getSubTag("display"); return tag != null && tag.getBoolean("glowing"); } diff --git a/src/main/java/com/minelittlepony/unicopia/item/JarItem.java b/src/main/java/com/minelittlepony/unicopia/item/JarItem.java index 62071788..60133a53 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/JarItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/JarItem.java @@ -13,6 +13,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.ItemEntity; import net.minecraft.entity.LightningEntity; +import net.minecraft.entity.Entity.RemovalReason; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -47,20 +48,20 @@ public class JarItem extends Item implements ProjectileDelegate, ItemImpl.Tickab world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, - 0.4F / (RANDOM.nextFloat() * 0.4F + 0.8F)); + 0.4F / (world.random.nextFloat() * 0.4F + 0.8F)); if (!world.isClient) { MagicProjectileEntity projectile = new MagicProjectileEntity(world, player); projectile.setItem(stack); projectile.setThrowDamage(getProjectileDamage(stack)); - projectile.setProperties(player, player.pitch, player.yaw, 0, 1.5F, 1); + projectile.setProperties(player, player.getPitch(), player.getYaw(), 0, 1.5F, 1); world.spawnEntity(projectile); } player.incrementStat(Stats.USED.getOrCreateStat(this)); - if (!player.abilities.creativeMode) { + if (!player.getAbilities().creativeMode) { stack.decrement(1); } @@ -79,15 +80,15 @@ public class JarItem extends Item implements ProjectileDelegate, ItemImpl.Tickab if (!lightning && !entity.world.isClient - && !entity.removed - && entity.getAge() > 100 + && !entity.isRemoved() + && entity.getItemAge() > 100 && entity.world.isThundering() && entity.world.isSkyVisible(entity.getBlockPos()) && entity.world.random.nextInt(130) == 0) { LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(entity.world); lightning.refreshPositionAfterTeleport(entity.getX(), entity.getY(), entity.getZ()); - entity.remove(); + entity.remove(RemovalReason.DISCARDED); entity.world.spawnEntity(lightning); ItemEntity neu = EntityType.ITEM.create(entity.world); diff --git a/src/main/java/com/minelittlepony/unicopia/item/ZapAppleItem.java b/src/main/java/com/minelittlepony/unicopia/item/ZapAppleItem.java index 5b95fbd4..45637102 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/ZapAppleItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/ZapAppleItem.java @@ -78,7 +78,7 @@ public class ZapAppleItem extends AppleItem implements ChameleonItem { e.onStruckByLightning((ServerWorld)e.world, lightning); } - if (!player.abilities.creativeMode) { + if (!player.getAbilities().creativeMode) { stack.decrement(1); } 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 ba586f35..38c5d282 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/enchantment/GemFindingEnchantment.java +++ b/src/main/java/com/minelittlepony/unicopia/item/enchantment/GemFindingEnchantment.java @@ -10,7 +10,6 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.enchantment.EnchantmentTarget; import net.minecraft.entity.EquipmentSlot; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; public class GemFindingEnchantment extends SimpleEnchantment { @@ -24,14 +23,16 @@ public class GemFindingEnchantment extends SimpleEnchantment { BlockPos origin = user.getOrigin(); - float volume = BlockPos.findClosest(origin, radius, radius, pos -> user.getWorld().getBlockState(pos).isIn(UTags.INTERESTING)) + + + double volume = BlockPos.findClosest(origin, radius, radius, pos -> user.getWorld().getBlockState(pos).isIn(UTags.INTERESTING)) .map(p -> user.getOriginVector().squaredDistanceTo(p.getX(), p.getY(), p.getZ())) - .map(find -> (1 - (MathHelper.sqrt(find) / radius))) - .orElse(-1F); + .map(find -> (1 - (Math.sqrt(find) / radius))) + .orElse(-1D); volume = Math.max(volume, 0.04F); - user.getEnchants().computeIfAbsent(this, Data::new).level = volume * (1.3F + level * 0.3F); + user.getEnchants().computeIfAbsent(this, Data::new).level = (float)volume * (1.3F + level * 0.3F); } @Environment(EnvType.CLIENT) diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinBlockEntity.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinBlockEntity.java index 726a1c07..26b30410 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinBlockEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinBlockEntity.java @@ -3,11 +3,11 @@ package com.minelittlepony.unicopia.mixin; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import net.minecraft.block.BlockState; import net.minecraft.block.entity.BlockEntity; +import net.minecraft.util.math.BlockPos; @Mixin(BlockEntity.class) public interface MixinBlockEntity { - @Accessor("cachedState") - void setCachedState(BlockState state); + @Accessor("pos") + void setPos(BlockPos pos); } diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinEntity.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinEntity.java new file mode 100644 index 00000000..1b96b85a --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinEntity.java @@ -0,0 +1,12 @@ +package com.minelittlepony.unicopia.mixin; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; +import net.minecraft.entity.Entity; +import net.minecraft.entity.Entity.RemovalReason; + +@Mixin(Entity.class) +public interface MixinEntity { + @Accessor + void setRemovalReason(RemovalReason reason); +} diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinItem.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinItem.java index b39a064d..5aff2d31 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinItem.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinItem.java @@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.mixin; import java.util.Optional; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinItemEntity.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinItemEntity.java index 3ffc0a25..ea20b93e 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinItemEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinItemEntity.java @@ -11,7 +11,7 @@ import com.minelittlepony.unicopia.entity.ItemImpl; import net.minecraft.entity.Entity; import net.minecraft.entity.ItemEntity; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; @Mixin(ItemEntity.class) abstract class MixinItemEntity extends Entity implements IItemEntity { @@ -45,19 +45,19 @@ abstract class MixinItemEntity extends Entity implements IItemEntity { get().tick(); } - @Inject(method = "writeCustomDataToTag(Lnet/minecraft/nbt/CompoundTag;)V", at = @At("HEAD")) - private void onWriteCustomDataToTag(CompoundTag tag, CallbackInfo info) { + @Inject(method = "writeCustomDataToNbt(Lnet/minecraft/nbt/NbtCompound;)V", at = @At("HEAD")) + private void onWriteCustomDataToTag(NbtCompound tag, CallbackInfo info) { tag.put("unicopia_caster", get().toNBT()); } - @Inject(method = "readCustomDataFromTag(Lnet/minecraft/nbt/CompoundTag;)V", at = @At("HEAD")) - private void onReadCustomDataFromTag(CompoundTag tag, CallbackInfo info) { + @Inject(method = "readCustomDataFromNbt(Lnet/minecraft/nbt/NbtCompound;)V", at = @At("HEAD")) + private void onReadCustomDataFromTag(NbtCompound tag, CallbackInfo info) { if (tag.contains("unicopia_caster")) { get().fromNBT(tag.getCompound("unicopia_caster")); } } - @Accessor("age") + @Accessor("itemAge") @Override public abstract int getAge(); diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinLivingEntity.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinLivingEntity.java index b07758bd..dad579bd 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinLivingEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinLivingEntity.java @@ -29,7 +29,7 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.entity.attribute.DefaultAttributeContainer; import net.minecraft.entity.damage.DamageSource; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; @@ -139,13 +139,13 @@ abstract class MixinLivingEntity extends Entity implements PonyContainer info) { - get().onImpact(fallDistance, damageMultiplier).ifPresent(newDistance -> { + @Inject(method = "handleFallDamage(FFLnet/minecraft/entity/damage/DamageSource;)Z", at = @At("HEAD"), cancellable = true) + private void onHandleFallDamage(float distance, float damageMultiplier, DamageSource cause, CallbackInfoReturnable info) { + get().onImpact(fallDistance, damageMultiplier, cause).ifPresent(newDistance -> { PlayerEntity self = (PlayerEntity)(Object)this; if (newDistance >= 2) { self.increaseStat(Stats.FALL_ONE_CM, Math.round(newDistance * 100)); } - info.setReturnValue(super.handleFallDamage(newDistance, damageMultiplier)); + info.setReturnValue(super.handleFallDamage(newDistance, damageMultiplier, cause)); }); } @@ -82,12 +81,17 @@ abstract class MixinPlayerEntity extends LivingEntity implements PonyContainer

matrices.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(c.calculateRoll()))); + UnicopiaClient.getCamera().ifPresent(c -> matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(c.calculateRoll()))); } @Inject(method = "getNightVisionStrength(Lnet/minecraft/entity/LivingEntity;F)F", diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinItem.java b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinItem.java index 5b8b8180..a43b6671 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinItem.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinItem.java @@ -1,7 +1,7 @@ package com.minelittlepony.unicopia.mixin.client; import java.util.List; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; 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 84196fe7..a79b899c 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinKeyboardInput.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinKeyboardInput.java @@ -25,7 +25,7 @@ abstract class MixinKeyboardInput extends Input { movementSideways = -movementSideways; - if (player.getMaster().abilities.flying && !player.getPhysics().isFlying()) { + if (player.getMaster().getAbilities().flying && !player.getPhysics().isFlying()) { tmp = jumping; jumping = sneaking; sneaking = tmp; diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinWorldRenderer.java b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinWorldRenderer.java index 4e79f7eb..b9dc9479 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinWorldRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinWorldRenderer.java @@ -16,10 +16,10 @@ import com.minelittlepony.unicopia.client.ClientBlockDestructionManager; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import net.minecraft.client.render.BlockBreakingInfo; import net.minecraft.client.render.WorldRenderer; -import net.minecraft.resource.SynchronousResourceReloadListener; +import net.minecraft.resource.SynchronousResourceReloader; @Mixin(WorldRenderer.class) -abstract class MixinWorldRenderer implements SynchronousResourceReloadListener, AutoCloseable, ClientBlockDestructionManager.Source { +abstract class MixinWorldRenderer implements SynchronousResourceReloader, AutoCloseable, ClientBlockDestructionManager.Source { private final ClientBlockDestructionManager destructions = new ClientBlockDestructionManager(); diff --git a/src/main/java/com/minelittlepony/unicopia/modmenu/UMenuFactory.java b/src/main/java/com/minelittlepony/unicopia/modmenu/UMenuFactory.java index 392854b3..2633779b 100644 --- a/src/main/java/com/minelittlepony/unicopia/modmenu/UMenuFactory.java +++ b/src/main/java/com/minelittlepony/unicopia/modmenu/UMenuFactory.java @@ -2,8 +2,8 @@ package com.minelittlepony.unicopia.modmenu; import com.minelittlepony.unicopia.client.gui.SettingsScreen; -import io.github.prospector.modmenu.api.ConfigScreenFactory; -import io.github.prospector.modmenu.api.ModMenuApi; +import com.terraformersmc.modmenu.api.ConfigScreenFactory; +import com.terraformersmc.modmenu.api.ModMenuApi; public class UMenuFactory implements ModMenuApi { @Override diff --git a/src/main/java/com/minelittlepony/unicopia/network/EffectSync.java b/src/main/java/com/minelittlepony/unicopia/network/EffectSync.java index 393f3733..3a377a87 100644 --- a/src/main/java/com/minelittlepony/unicopia/network/EffectSync.java +++ b/src/main/java/com/minelittlepony/unicopia/network/EffectSync.java @@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.network; import java.util.Objects; import java.util.Optional; -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.Spell; @@ -12,7 +12,7 @@ import com.minelittlepony.unicopia.ability.magic.spell.SpellPredicate; import com.minelittlepony.unicopia.ability.magic.spell.SpellType; import net.minecraft.entity.data.TrackedData; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; /** * Synchronisation class for spells. @@ -27,12 +27,12 @@ public class EffectSync implements SpellContainer { private final Caster owner; - private final TrackedData param; + private final TrackedData param; @Nullable - private CompoundTag lastValue; + private NbtCompound lastValue; - public EffectSync(Caster owner, TrackedData param) { + public EffectSync(Caster owner, TrackedData param) { this.owner = owner; this.param = param; } @@ -63,7 +63,7 @@ public class EffectSync implements SpellContainer { private void sync(boolean force) { @Nullable - CompoundTag comp = owner.getEntity().getDataTracker().get(param); + NbtCompound comp = owner.getEntity().getDataTracker().get(param); @Nullable Spell effect = spell.orElse(null); @@ -88,7 +88,7 @@ public class EffectSync implements SpellContainer { public void put(@Nullable Spell effect) { effect = effect == null || effect.isDead() ? null : effect; updateReference(effect); - owner.getEntity().getDataTracker().set(param, effect == null ? new CompoundTag() : SpellType.toNBT(effect)); + owner.getEntity().getDataTracker().set(param, effect == null ? new NbtCompound() : SpellType.toNBT(effect)); } private void updateReference(@Nullable Spell effect) { diff --git a/src/main/java/com/minelittlepony/unicopia/network/MsgPlayerCapabilities.java b/src/main/java/com/minelittlepony/unicopia/network/MsgPlayerCapabilities.java index 6c092b68..c599e564 100644 --- a/src/main/java/com/minelittlepony/unicopia/network/MsgPlayerCapabilities.java +++ b/src/main/java/com/minelittlepony/unicopia/network/MsgPlayerCapabilities.java @@ -14,7 +14,7 @@ import io.netty.buffer.ByteBufInputStream; import io.netty.buffer.ByteBufOutputStream; import net.minecraft.network.PacketByteBuf; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtIo; public class MsgPlayerCapabilities implements Packet { @@ -23,7 +23,7 @@ public class MsgPlayerCapabilities implements Packet { private final Race newRace; - private final CompoundTag compoundTag; + private final NbtCompound compoundTag; MsgPlayerCapabilities(PacketByteBuf buffer) { playerId = buffer.readUuid(); @@ -38,7 +38,7 @@ public class MsgPlayerCapabilities implements Packet { public MsgPlayerCapabilities(boolean full, Pony player) { playerId = player.getMaster().getUuid(); newRace = player.getSpecies(); - compoundTag = full ? player.toNBT() : new CompoundTag(); + compoundTag = full ? player.toNBT() : new NbtCompound(); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/network/MsgSpawnProjectile.java b/src/main/java/com/minelittlepony/unicopia/network/MsgSpawnProjectile.java index d18e17e0..903200b3 100644 --- a/src/main/java/com/minelittlepony/unicopia/network/MsgSpawnProjectile.java +++ b/src/main/java/com/minelittlepony/unicopia/network/MsgSpawnProjectile.java @@ -1,8 +1,6 @@ package com.minelittlepony.unicopia.network; -import java.io.IOException; import java.util.Optional; - import com.minelittlepony.unicopia.Owned; import com.minelittlepony.unicopia.util.network.Packet; @@ -18,22 +16,17 @@ import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket; public class MsgSpawnProjectile extends EntitySpawnS2CPacket implements Packet { MsgSpawnProjectile(PacketByteBuf buffer) { - try { - read(buffer); - } catch (IOException e) { } + super(buffer); } @SuppressWarnings("unchecked") public MsgSpawnProjectile(Entity e) { - super(e, Optional.ofNullable(e instanceof Owned ? ((Owned)e).getMaster() : null).map(Entity::getEntityId).orElse(0)); + super(e, Optional.ofNullable(e instanceof Owned ? ((Owned)e).getMaster() : null).map(Entity::getId).orElse(0)); } @Override public void toBuffer(PacketByteBuf buffer) { - try { - write(buffer); - } catch (IOException e) { - } + write(buffer); } @@ -53,9 +46,9 @@ public class MsgSpawnProjectile extends EntitySpawnS2CPacket implements Packet

FACTORY = new ParticleEffect.Factory() { + public static final ParticleEffect.Factory FACTORY = new ParticleEffect.Factory<>() { @Override public FollowingParticleEffect read(ParticleType type, StringReader reader) throws CommandSyntaxException { reader.expect(' '); @@ -49,7 +49,7 @@ public class FollowingParticleEffect implements ParticleEffect { } public FollowingParticleEffect(ParticleType type, Entity target, float followSpeed) { - this(type, target.getEntityId(), target.getCameraPosVec(1), followSpeed); + this(type, target.getId(), target.getCameraPosVec(1), followSpeed); } private FollowingParticleEffect(ParticleType type, int movingTarget, Vec3d fixedTarget, float followSpeed) { diff --git a/src/main/java/com/minelittlepony/unicopia/particle/ParticleHandle.java b/src/main/java/com/minelittlepony/unicopia/particle/ParticleHandle.java index 2390d08f..151ee4c2 100644 --- a/src/main/java/com/minelittlepony/unicopia/particle/ParticleHandle.java +++ b/src/main/java/com/minelittlepony/unicopia/particle/ParticleHandle.java @@ -86,7 +86,7 @@ public class ParticleHandle { .filter(s -> s.getUuid().equals(effect)) .isPresent() && e != null - && c.getWorld().getEntityById(e.getEntityId()) != null; + && c.getWorld().getEntityById(e.getId()) != null; }); if (!caster.isPresent()) { action.run(); diff --git a/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java b/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java index 7713d997..fcd715a1 100644 --- a/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java @@ -28,7 +28,7 @@ import net.minecraft.entity.projectile.thrown.ThrownItemEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; -import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtCompound; import net.minecraft.network.Packet; import net.minecraft.particle.ItemStackParticleEffect; import net.minecraft.particle.ParticleEffect; @@ -50,7 +50,7 @@ public class MagicProjectileEntity extends ThrownItemEntity implements Caster

  • DAMAGE = DataTracker.registerData(MagicProjectileEntity.class, TrackedDataHandlerRegistry.FLOAT); private static final TrackedData GRAVITY = DataTracker.registerData(MagicProjectileEntity.class, TrackedDataHandlerRegistry.FLOAT); private static final TrackedData HYDROPHOBIC = DataTracker.registerData(MagicProjectileEntity.class, TrackedDataHandlerRegistry.BOOLEAN); - private static final TrackedData EFFECT = DataTracker.registerData(MagicProjectileEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND); + private static final TrackedData EFFECT = DataTracker.registerData(MagicProjectileEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND); private static final LevelStore LEVELS = Levelled.fixed(1); private final EffectSync effectDelegate = new EffectSync(this, EFFECT); @@ -72,7 +72,7 @@ public class MagicProjectileEntity extends ThrownItemEntity implements Caster
  • spell.onThrownTick(this)).isPresent()) { - remove(); + remove(RemovalReason.DISCARDED); } } @@ -209,8 +209,8 @@ public class MagicProjectileEntity extends ThrownItemEntity implements Caster
  • { compound.put("effect", SpellType.toNBT(effect)); @@ -228,13 +228,13 @@ public class MagicProjectileEntity extends ThrownItemEntity implements Caster
  • findInRange(@Nullable Entity origin, World w, Vec3d pos, double radius, @Nullable Predicate predicate) { - return w.getOtherEntities(origin, Box.method_29968(pos).expand(radius), predicate == null ? inRange(pos, radius) : inRange(pos, radius).and(predicate)); + double diameter = radius * 2; + return w.getOtherEntities(origin, Box.of(pos, diameter, diameter, diameter), predicate == null ? inRange(pos, radius) : inRange(pos, radius).and(predicate)); } } diff --git a/src/main/java/com/minelittlepony/unicopia/util/Weighted.java b/src/main/java/com/minelittlepony/unicopia/util/Weighted.java index 0f47ef89..0ca6718f 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/Weighted.java +++ b/src/main/java/com/minelittlepony/unicopia/util/Weighted.java @@ -5,8 +5,7 @@ import java.util.Optional; import java.util.Random; import java.util.function.Consumer; -import javax.annotation.Nonnull; -import javax.annotation.concurrent.Immutable; +import org.jetbrains.annotations.NotNull; import com.google.common.collect.Lists; @@ -26,7 +25,7 @@ public class Weighted { return result; } - public Weighted put(int weight, @Nonnull T value) { + public Weighted put(int weight, @NotNull T value) { entries.add(new Entry(weight, value)); totalWeight += weight; @@ -60,7 +59,6 @@ public class Weighted { .findFirst(); } - @Immutable class Entry { final float weight; diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index a065f0bc..f6791ccd 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -14,6 +14,7 @@ ], "license": "MIT", "icon": "icon.png", + "accessWidener": "unicopia.aw", "environment": "*", "entrypoints": { "main": [ diff --git a/src/main/resources/unicopia.aw b/src/main/resources/unicopia.aw new file mode 100644 index 00000000..30c717ac --- /dev/null +++ b/src/main/resources/unicopia.aw @@ -0,0 +1,3 @@ +accessWidener v1 named +accessible class net/minecraft/client/render/RenderLayer$MultiPhaseParameters +accessible method net/minecraft/client/render/RenderLayer of (Ljava/lang/String;Lnet/minecraft/client/render/VertexFormat;Lnet/minecraft/client/render/VertexFormat$DrawMode;IZZLnet/minecraft/client/render/RenderLayer$MultiPhaseParameters;)Lnet/minecraft/client/render/RenderLayer$MultiPhase; diff --git a/src/main/resources/unicopia.mixin.json b/src/main/resources/unicopia.mixin.json index c088db71..d367f811 100644 --- a/src/main/resources/unicopia.mixin.json +++ b/src/main/resources/unicopia.mixin.json @@ -3,12 +3,13 @@ "minVersion": "0.7", "package": "com.minelittlepony.unicopia.mixin", "refmap": "unicopia.mixin.refmap.json", - "compatibilityLevel": "JAVA_8", + "compatibilityLevel": "JAVA_16", "mixins": [ "MixinBlockEntity", "MixinBlockItem", "MixinBrain", "MixinDamageSource", + "MixinEntity", "MixinFallingBlock", "MixinItem", "MixinItemEntity",