diff --git a/gradle.properties b/gradle.properties index 2ca38e39..f4c2cb67 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,12 +1,12 @@ -project_version=1.5.0.rc4 +project_version=1.3.5 # FM Protocols protocols_version=b15c1841 protocols_use_local_build=false protocols_local_version=1.1.5 -mc_version=1.21.4 -minecraft_version=1.21.4-R0.1-SNAPSHOT +mc_version=1.21.1 +minecraft_version=1.21.1-R0.1-SNAPSHOT # Dependencies protocollib_version=5.3.0 diff --git a/src/main/java/xyz/nifeather/morph/FeatherMorphMain.java b/src/main/java/xyz/nifeather/morph/FeatherMorphMain.java index 451725f0..cbd1c72b 100644 --- a/src/main/java/xyz/nifeather/morph/FeatherMorphMain.java +++ b/src/main/java/xyz/nifeather/morph/FeatherMorphMain.java @@ -131,7 +131,7 @@ protected void enable() pluginManager = Bukkit.getPluginManager(); var bukkitVersion = Bukkit.getMinecraftVersion(); - String primaryVersion = "1.21.4"; + String primaryVersion = "1.21.1"; String[] compatVersions = new String[] { primaryVersion }; if (Arrays.stream(compatVersions).noneMatch(bukkitVersion::equals)) { diff --git a/src/main/java/xyz/nifeather/morph/abilities/impl/BossbarAbility.java b/src/main/java/xyz/nifeather/morph/abilities/impl/BossbarAbility.java index 2400c656..53433329 100644 --- a/src/main/java/xyz/nifeather/morph/abilities/impl/BossbarAbility.java +++ b/src/main/java/xyz/nifeather/morph/abilities/impl/BossbarAbility.java @@ -109,7 +109,7 @@ public boolean handle(Player player, DisguiseState state) if (playerGameMode == GameMode.SPECTATOR) playersToShow.removeIf(p -> p.getGameMode() != playerGameMode); - bossbar.progress((float) (player.getHealth() / player.getAttribute(Attribute.MAX_HEALTH).getValue())); + bossbar.progress((float) (player.getHealth() / player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue())); //bossbar.name(this.getBossbarName(state, option)); if (state.canDisplayBossbar()) diff --git a/src/main/java/xyz/nifeather/morph/backends/server/renderer/network/PacketFactory.java b/src/main/java/xyz/nifeather/morph/backends/server/renderer/network/PacketFactory.java index de1115e6..5e3f645b 100644 --- a/src/main/java/xyz/nifeather/morph/backends/server/renderer/network/PacketFactory.java +++ b/src/main/java/xyz/nifeather/morph/backends/server/renderer/network/PacketFactory.java @@ -166,7 +166,7 @@ public List> buildPlayerInfoPackets(SingleWatcher watcher) spawnUUID, watcher.readEntryOrThrow(CustomEntries.PROFILE), watcher.readEntryOrDefault(CustomEntries.PROFILE_LISTED, false), 114514, GameType.DEFAULT_MODE, - null, true, 0, null + null, null ) ); diff --git a/src/main/java/xyz/nifeather/morph/backends/server/renderer/network/datawatcher/watchers/types/CreakingWatcher.java b/src/main/java/xyz/nifeather/morph/backends/server/renderer/network/datawatcher/watchers/types/CreakingWatcher.java deleted file mode 100644 index a8fb0b1b..00000000 --- a/src/main/java/xyz/nifeather/morph/backends/server/renderer/network/datawatcher/watchers/types/CreakingWatcher.java +++ /dev/null @@ -1,54 +0,0 @@ -package xyz.nifeather.morph.backends.server.renderer.network.datawatcher.watchers.types; - -import org.bukkit.Sound; -import org.bukkit.SoundCategory; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import xyz.nifeather.morph.backends.server.renderer.network.registries.CustomEntries; -import xyz.nifeather.morph.backends.server.renderer.network.registries.CustomEntry; -import xyz.nifeather.morph.backends.server.renderer.network.registries.ValueIndex; -import xyz.nifeather.morph.misc.AnimationNames; - -public class CreakingWatcher extends LivingEntityWatcher -{ - public CreakingWatcher(Player bindingPlayer) - { - super(bindingPlayer, EntityType.CREAKING); - } - - @Override - protected void initRegistry() - { - super.initRegistry(); - - register(ValueIndex.CREAKING); - } - - @Override - protected void onEntryWrite(CustomEntry entry, X oldVal, X newVal) - { - super.onEntryWrite(entry, oldVal, newVal); - - if (entry.equals(CustomEntries.ANIMATION)) - { - var id = newVal.toString(); - var bindingPlayer = getBindingPlayer(); - var world = bindingPlayer.getWorld(); - - switch (id) - { - case AnimationNames.MAKE_ACTIVE -> - { - this.writePersistent(ValueIndex.CREAKING.IS_ACTIVE, true); - world.playSound(bindingPlayer.getLocation(), Sound.ENTITY_CREAKING_ACTIVATE, SoundCategory.HOSTILE, 1, 1); - } - - case AnimationNames.MAKE_INACTIVE -> - { - this.writePersistent(ValueIndex.CREAKING.IS_ACTIVE, false); - world.playSound(bindingPlayer.getLocation(), Sound.ENTITY_CREAKING_FREEZE, SoundCategory.HOSTILE, 1, 1); - } - } - } - } -} diff --git a/src/main/java/xyz/nifeather/morph/backends/server/renderer/network/listeners/PlayerLookPacketListener.java b/src/main/java/xyz/nifeather/morph/backends/server/renderer/network/listeners/PlayerLookPacketListener.java index c19d0578..633d4bd3 100644 --- a/src/main/java/xyz/nifeather/morph/backends/server/renderer/network/listeners/PlayerLookPacketListener.java +++ b/src/main/java/xyz/nifeather/morph/backends/server/renderer/network/listeners/PlayerLookPacketListener.java @@ -66,7 +66,7 @@ else if (packetType == PacketType.Play.Server.ENTITY_TELEPORT) private void onTeleport(ClientboundTeleportEntityPacket packet, PacketEvent event) { //获取此包的来源实体 - var sourceNmsEntity = getNmsPlayerFrom(packet.id()); + var sourceNmsEntity = getNmsPlayerFrom(packet.getId()); if (sourceNmsEntity == null) return; @@ -83,15 +83,21 @@ private void onTeleport(ClientboundTeleportEntityPacket packet, PacketEvent even if (!isDragon && !isPhantom) return; - float yaw = packet.change().yRot(); - float pitch = packet.change().xRot(); + var yaw = packet.getyRot(); + var pitch = packet.getxRot(); - yaw = isDragon ? (yaw + 180f) : yaw; - pitch = isPhantom ? -pitch : pitch; + var playerYaw = isDragon ? (sourcePlayer.getYaw() + 180f) : sourcePlayer.getYaw(); + var finalYaw = (playerYaw / 360f) * 256f; + yaw = (byte)finalYaw; + + var playerPitch = isPhantom ? -sourcePlayer.getPitch() : sourcePlayer.getPitch(); + + var finalPitch = (playerPitch / 360f) * 256f; + pitch = (byte)finalPitch; var container = event.getPacket(); - container.getBytes().write(0, Mth.packDegrees(yaw)); - container.getBytes().write(1, Mth.packDegrees(pitch)); + container.getBytes().write(0, yaw); + container.getBytes().write(1, pitch); } private void onHeadRotation(ClientboundRotateHeadPacket packet, PacketEvent event) @@ -107,9 +113,9 @@ private void onHeadRotation(ClientboundRotateHeadPacket packet, PacketEvent even if (watcher == null || watcher.getEntityType() != EntityType.ENDER_DRAGON) return; - var newHeadYaw = packet.getYHeadRot() + 180f; + var newHeadYaw = (byte)(((sourcePlayer.getYaw() + 180f) / 360f) * 256f); - var newPacket = new ClientboundRotateHeadPacket(sourceNmsEntity, Mth.packDegrees(newHeadYaw)); + var newPacket = new ClientboundRotateHeadPacket(sourceNmsEntity, newHeadYaw); var finalPacket = PacketContainer.fromPacket(newPacket); getFactory().markPacketOurs(finalPacket); @@ -136,11 +142,17 @@ private void onLookPacket(ClientboundMoveEntityPacket packet, PacketEvent event) if (!isDragon && !isPhantom) return; - float yaw = packet.getyRot(); - float pitch = packet.getxRot(); + var yaw = packet.getyRot(); + var pitch = packet.getxRot(); + + var playerYaw = isDragon ? (sourcePlayer.getYaw() + 180f) : sourcePlayer.getYaw(); + var finalYaw = (playerYaw / 360f) * 256f; + yaw = (byte)finalYaw; + + var playerPitch = isPhantom ? -sourcePlayer.getPitch() : sourcePlayer.getPitch(); - yaw = isDragon ? (yaw + 180f) : yaw; - pitch = isPhantom ? -pitch : pitch; + var finalPitch = (playerPitch / 360f) * 256f; + pitch = (byte)finalPitch; ClientboundMoveEntityPacket newPacket; @@ -150,7 +162,7 @@ private void onLookPacket(ClientboundMoveEntityPacket packet, PacketEvent event) { newPacket = new ClientboundMoveEntityPacket.Rot( sourcePlayer.getEntityId(), - Mth.packDegrees(yaw), Mth.packDegrees(pitch), + yaw, pitch, packet.isOnGround() ); } @@ -167,7 +179,7 @@ else if (packetType == PacketType.Play.Server.REL_ENTITY_MOVE_LOOK) newPacket = new ClientboundMoveEntityPacket.PosRot( sourcePlayer.getEntityId(), packet.getXa(), packet.getYa(), packet.getZa(), - Mth.packDegrees(yaw), Mth.packDegrees(pitch), + yaw, pitch, packet.isOnGround() ); } diff --git a/src/main/java/xyz/nifeather/morph/backends/server/renderer/network/listeners/SoundListener.java b/src/main/java/xyz/nifeather/morph/backends/server/renderer/network/listeners/SoundListener.java index e0b32e4c..4705c103 100644 --- a/src/main/java/xyz/nifeather/morph/backends/server/renderer/network/listeners/SoundListener.java +++ b/src/main/java/xyz/nifeather/morph/backends/server/renderer/network/listeners/SoundListener.java @@ -90,7 +90,7 @@ private ClientboundSoundPacket getClientboundSoundPacket(PacketEvent event, Pack // 获取正要播放的音效 AtomicReference resourceLocationRef = new AtomicReference<>(null); left.ifPresent(rK -> resourceLocationRef.set(rK.location())); - right.ifPresent(se -> resourceLocationRef.set(se.location())); + right.ifPresent(se -> resourceLocationRef.set(se.getLocation())); if (resourceLocationRef.get() == null) return null; SoundEvent sound = null; diff --git a/src/main/java/xyz/nifeather/morph/backends/server/renderer/network/registries/WatcherIndex.java b/src/main/java/xyz/nifeather/morph/backends/server/renderer/network/registries/WatcherIndex.java index 2fb99819..21537357 100644 --- a/src/main/java/xyz/nifeather/morph/backends/server/renderer/network/registries/WatcherIndex.java +++ b/src/main/java/xyz/nifeather/morph/backends/server/renderer/network/registries/WatcherIndex.java @@ -86,8 +86,6 @@ public WatcherIndex() setTypeWatcher(EntityType.ARMADILLO, ArmadilloWatcher::new); setTypeWatcher(EntityType.SHULKER, ShulkerWatcher::new); setTypeWatcher(EntityType.PUFFERFISH, PufferfishWatcher::new); - - setTypeWatcher(EntityType.CREAKING, CreakingWatcher::new); } private void setTypeWatcher(EntityType type, Function func) diff --git a/src/main/java/xyz/nifeather/morph/backends/server/renderer/utilties/HolderUtils.java b/src/main/java/xyz/nifeather/morph/backends/server/renderer/utilties/HolderUtils.java index 567f397a..a90aa18a 100644 --- a/src/main/java/xyz/nifeather/morph/backends/server/renderer/utilties/HolderUtils.java +++ b/src/main/java/xyz/nifeather/morph/backends/server/renderer/utilties/HolderUtils.java @@ -26,7 +26,7 @@ private static Registry lookupRegistryOrThrow(ResourceKey> re { setupLevel(); - return level.registryAccess().lookup(registryKey).orElseThrow(); + return level.registryAccess().registryOrThrow(registryKey); } public static Holder getHolderOrThrow(ResourceLocation location, ResourceKey> registryKey) @@ -35,7 +35,7 @@ public static Holder getHolderOrThrow(ResourceLocation location, Resource var registry = lookupRegistryOrThrow(registryKey); - var ref = registry.get(location).orElse(null); + var ref = registry.getHolder(location).orElse(null); if (ref == null) throw new NullPointerException("Reference for key '%s' does not found in the registry '%s'.".formatted(location, registry.key())); @@ -51,7 +51,7 @@ public static Holder getHolderOrThrow(ResourceKey key, ResourceKey true)); + nmsMob.goalSelector.addGoal(-1, new FeatherMorphNearestAttackableGoal(manager, nmsMob, Player.class, true, living -> true)); } private void addAvoidEntityGoal(GoalSelector goalSelector, PathfinderMob sourceMob) diff --git a/src/main/java/xyz/nifeather/morph/misc/mobs/ai/FeatherMorphNearestAttackableGoal.java b/src/main/java/xyz/nifeather/morph/misc/mobs/ai/FeatherMorphNearestAttackableGoal.java index e18a928f..810ac86c 100644 --- a/src/main/java/xyz/nifeather/morph/misc/mobs/ai/FeatherMorphNearestAttackableGoal.java +++ b/src/main/java/xyz/nifeather/morph/misc/mobs/ai/FeatherMorphNearestAttackableGoal.java @@ -1,6 +1,7 @@ package xyz.nifeather.morph.misc.mobs.ai; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.NeutralMob; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; @@ -11,6 +12,8 @@ import xyz.nifeather.morph.MorphManager; import xyz.nifeather.morph.utilities.EntityTypeUtils; +import java.util.function.Predicate; + /** * 此Goal将被添加到生物,作为附加的TargetGoal执行。 */ @@ -20,7 +23,7 @@ public class FeatherMorphNearestAttackableGoal extends NearestAttackableTargetGo public FeatherMorphNearestAttackableGoal(MorphManager morphManager, net.minecraft.world.entity.Mob mob, Class targetClass, - boolean checkVisibility, TargetingConditions.Selector targetPredicate) + boolean checkVisibility, Predicate targetPredicate) { super(mob, targetClass, checkVisibility, targetPredicate); diff --git a/src/main/java/xyz/nifeather/morph/misc/playerList/PlayerListHandler.java b/src/main/java/xyz/nifeather/morph/misc/playerList/PlayerListHandler.java index 2bbad8d2..a87a4ea6 100644 --- a/src/main/java/xyz/nifeather/morph/misc/playerList/PlayerListHandler.java +++ b/src/main/java/xyz/nifeather/morph/misc/playerList/PlayerListHandler.java @@ -116,7 +116,7 @@ public void showFakePlayer(UUID disguiseUUID, GameProfile profile) disguiseUUID, profile, true, 114514, GameType.DEFAULT_MODE, - null, true, 0, null + null, null ) ); @@ -166,7 +166,7 @@ public void handle(Player player) disguiseUUID, profile, true, 114514, GameType.DEFAULT_MODE, - null, true, 0, null + null, null ) ); diff --git a/src/main/java/xyz/nifeather/morph/providers/animation/provider/VanillaAnimationProvider.java b/src/main/java/xyz/nifeather/morph/providers/animation/provider/VanillaAnimationProvider.java index 533e6542..10c5964c 100644 --- a/src/main/java/xyz/nifeather/morph/providers/animation/provider/VanillaAnimationProvider.java +++ b/src/main/java/xyz/nifeather/morph/providers/animation/provider/VanillaAnimationProvider.java @@ -25,7 +25,6 @@ public VanillaAnimationProvider() this.registerAnimSet(EntityType.FROG, new FrogAnimationSet()); this.registerAnimSet(EntityType.WOLF, new WolfAnimationSet()); this.registerAnimSet(EntityType.PANDA, new PandaAnimationSet()); - this.registerAnimSet(EntityType.CREAKING, new CreakingAnimationSet()); } @Override diff --git a/src/main/java/xyz/nifeather/morph/providers/disguise/VanillaDisguiseProvider.java b/src/main/java/xyz/nifeather/morph/providers/disguise/VanillaDisguiseProvider.java index fbfc9a74..6cd4b5ec 100644 --- a/src/main/java/xyz/nifeather/morph/providers/disguise/VanillaDisguiseProvider.java +++ b/src/main/java/xyz/nifeather/morph/providers/disguise/VanillaDisguiseProvider.java @@ -252,13 +252,9 @@ private void tryAddModifier(DisguiseState state) } var craftLiving = (net.minecraft.world.entity.LivingEntity) ((CraftLivingEntity)living).getHandleRaw(); - var mobMaxHealth = craftLiving.craftAttributes.getAttribute(Attribute.MAX_HEALTH).getBaseValue(); + var mobMaxHealth = craftLiving.craftAttributes.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue(); - // patch: CREAKING only have half heart, and we don't want that. - if (state.getEntityType() == EntityType.CREAKING) - mobMaxHealth = 20; - - var playerAttribute = player.getAttribute(Attribute.MAX_HEALTH); + var playerAttribute = player.getAttribute(Attribute.GENERIC_MAX_HEALTH); if (mobMaxHealth <= 0d) { @@ -401,7 +397,7 @@ private void executeThenScaleHealth(Player player, AttributeInstance attributeIn private void removeAllHealthModifiers(Player player) { - var attribute = player.getAttribute(Attribute.MAX_HEALTH); + var attribute = player.getAttribute(Attribute.GENERIC_MAX_HEALTH); assert attribute != null; this.executeThenScaleHealth(player, attribute, () -> attribute.removeModifier(healthModifierKey)); diff --git a/src/main/java/xyz/nifeather/morph/skills/DefaultConfigGenerator.java b/src/main/java/xyz/nifeather/morph/skills/DefaultConfigGenerator.java index 024d4fcf..919ce853 100644 --- a/src/main/java/xyz/nifeather/morph/skills/DefaultConfigGenerator.java +++ b/src/main/java/xyz/nifeather/morph/skills/DefaultConfigGenerator.java @@ -195,18 +195,18 @@ public void generateAbilities() this.getConfiguration(EntityType.HORSE) .addAbilityIdentifier(AbilityType.ATTRIBUTE) .appendOption(AbilityType.ATTRIBUTE, AttributeModifyOption - .from(Attribute.MOVEMENT_SPEED, AttributeModifyOption.OperationType.multiply_base, 0.5d) - .with(Attribute.STEP_HEIGHT, AttributeModifyOption.OperationType.add, 0.4d)); + .from(Attribute.GENERIC_MOVEMENT_SPEED, AttributeModifyOption.OperationType.multiply_base, 0.5d) + .with(Attribute.GENERIC_STEP_HEIGHT, AttributeModifyOption.OperationType.add, 0.4d)); this.getConfiguration(EntityType.IRON_GOLEM) .addAbilityIdentifier(AbilityType.ATTRIBUTE) .appendOption( AbilityType.ATTRIBUTE, AttributeModifyOption - .from(Attribute.MOVEMENT_SPEED, AttributeModifyOption.OperationType.multiply_base, -0.6) - .with(Attribute.KNOCKBACK_RESISTANCE, AttributeModifyOption.OperationType.add, 1d) - .with(Attribute.ATTACK_DAMAGE, AttributeModifyOption.OperationType.add, 15) - .with(Attribute.ATTACK_SPEED, AttributeModifyOption.OperationType.multiply_base, -0.55d) + .from(Attribute.GENERIC_MOVEMENT_SPEED, AttributeModifyOption.OperationType.multiply_base, -0.6) + .with(Attribute.GENERIC_KNOCKBACK_RESISTANCE, AttributeModifyOption.OperationType.add, 1d) + .with(Attribute.GENERIC_ATTACK_DAMAGE, AttributeModifyOption.OperationType.add, 15) + .with(Attribute.GENERIC_ATTACK_SPEED, AttributeModifyOption.OperationType.multiply_base, -0.55d) ) .addAbilityIdentifier(AbilityType.EXTRA_KNOCKBACK) .appendOption( @@ -219,10 +219,10 @@ public void generateAbilities() .appendOption( AbilityType.ATTRIBUTE, AttributeModifyOption - .from(Attribute.MOVEMENT_SPEED, AttributeModifyOption.OperationType.multiply_base, -0.6) - .with(Attribute.KNOCKBACK_RESISTANCE, AttributeModifyOption.OperationType.add, 1d) - .with(Attribute.ATTACK_DAMAGE, AttributeModifyOption.OperationType.add, 30) - .with(Attribute.ATTACK_SPEED, AttributeModifyOption.OperationType.multiply_base, -0.6d) + .from(Attribute.GENERIC_MOVEMENT_SPEED, AttributeModifyOption.OperationType.multiply_base, -0.6) + .with(Attribute.GENERIC_KNOCKBACK_RESISTANCE, AttributeModifyOption.OperationType.add, 1d) + .with(Attribute.GENERIC_ATTACK_DAMAGE, AttributeModifyOption.OperationType.add, 30) + .with(Attribute.GENERIC_ATTACK_SPEED, AttributeModifyOption.OperationType.multiply_base, -0.6d) ) .addAbilityIdentifier(AbilityType.WARDEN); diff --git a/src/main/java/xyz/nifeather/morph/skills/impl/SplashPotionSkill.java b/src/main/java/xyz/nifeather/morph/skills/impl/SplashPotionSkill.java index d2d4a4c7..f5eeef56 100644 --- a/src/main/java/xyz/nifeather/morph/skills/impl/SplashPotionSkill.java +++ b/src/main/java/xyz/nifeather/morph/skills/impl/SplashPotionSkill.java @@ -57,7 +57,7 @@ public int executeSkill(Player player, DisguiseState state, SkillAbilityConfigur meta.addCustomEffect(potionEffect, true); Potion targetPotion = null; - var potionRef = BuiltInRegistries.POTION.get(ResourceLocation.parse(info.type.getKey().asString())) + var potionRef = BuiltInRegistries.POTION.getHolder(ResourceLocation.parse(info.type.getKey().asString())) .orElse(null); if (potionRef != null && potionRef.isBound()) diff --git a/src/main/java/xyz/nifeather/morph/storage/skill/SkillsConfigurationStoreNew.java b/src/main/java/xyz/nifeather/morph/storage/skill/SkillsConfigurationStoreNew.java index 62f51738..d4f99a9d 100644 --- a/src/main/java/xyz/nifeather/morph/storage/skill/SkillsConfigurationStoreNew.java +++ b/src/main/java/xyz/nifeather/morph/storage/skill/SkillsConfigurationStoreNew.java @@ -49,63 +49,10 @@ private void update(int currentVersion) else saveDefaultGeneratedConfigurations(); } - if (currentVersion < PackageVersions.ATTRIBUTE_NAME_CHANGED) - migrate_attribute(); - - if (currentVersion < PackageVersions.WITHER_SKELETON_CHANGES) - { - migrateWitherSkeleton(); - } setPackageVersion(TARGET_PACKAGE_VERSION); } - private void migrate_attribute() - { - logger.info("Starting migration of attribute names..."); - var files = directoryStorage.getFiles(".*\\.json$"); - - var abilityInstance = new AttributeModifyingAbility(); - - for (File file : files) - { - var config = this.loadFrom(file); - if (config == null) - { - logger.warn("Can't load SkillAbilityConfiguration from '%s', see errors above.".formatted(file.toString())); - continue; - } - - var targetOption = config.getAbilityOptions(abilityInstance); - - if (targetOption == null) continue; - - var key = getKeyFromFile(file); - config.legacy_MobID = key; - logger.info("Migrating " + key); - - for (AttributeModifyOption.AttributeInfo attributeInfo : targetOption.modifiers) - { - if (!attributeInfo.isValid()) - { - logger.warn("Invalid attribute info for '%s > %s'! Ignoring...".formatted( - config.legacy_MobID, - attributeInfo.attributeName == null ? "" : attributeInfo.attributeName)); - - continue; - } - - attributeInfo.attributeName = attributeInfo.attributeName.replace("generic.", ""); - } - - config.setOption(abilityInstance.getIdentifier().asString(), targetOption); - - this.save(config); - } - - logger.info("Done."); - } - private void migrateFromLegacyStorage() { try @@ -140,28 +87,6 @@ private void migrateFromLegacyStorage() } } - private void migrateWitherSkeleton() - { - logger.info("Migrating new Wither Skeleton configuration"); - - var configuration = this.get(EntityType.WITHER_SKELETON.key().asString()); - if (configuration == null) - { - logger.info("No configuration present for minecraft:wither_skeleton, skipping..."); - return; - } - - configuration.addAbilityIdentifier(AbilityType.HAS_FIRE_RESISTANCE) - .addAbilityIdentifier(AbilityType.REDUCES_WITHER_DAMAGE) - .appendOption(AbilityType.REDUCES_WITHER_DAMAGE, - new ReduceDamageOption(1, true)); - - configuration.legacy_MobID = EntityType.WITHER_SKELETON.key().asString(); - this.save(configuration); - - logger.info("Done Migrating new Wither Skeleton configuration"); - } - private void saveDefaultGeneratedConfigurations() { logger.info("Saving default generated skill configurations..."); @@ -249,7 +174,11 @@ public SkillAbilityConfigurationContainer getStoring() public static class PackageVersions { public static final int INITIAL = 1; + + @Deprecated // Not for 1.21.1 public static final int ATTRIBUTE_NAME_CHANGED = 2; + + @Deprecated // Not for 1.21.1 public static final int WITHER_SKELETON_CHANGES = 3; } } diff --git a/src/main/java/xyz/nifeather/morph/utilities/EntityTypeUtils.java b/src/main/java/xyz/nifeather/morph/utilities/EntityTypeUtils.java index fcf296a7..e0012ce1 100644 --- a/src/main/java/xyz/nifeather/morph/utilities/EntityTypeUtils.java +++ b/src/main/java/xyz/nifeather/morph/utilities/EntityTypeUtils.java @@ -8,8 +8,8 @@ import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntitySpawnReason; import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.MobSpawnType; import net.minecraft.world.entity.player.Player; import org.bukkit.Location; import org.bukkit.World; @@ -75,7 +75,7 @@ public static T createEntityThenDispose(net.minecraft.world.e var locationBlock = spawnLocation.toBlockLocation(); var spawnBlockLocation = new BlockPos(locationBlock.getBlockX(), locationBlock.getBlockY(), locationBlock.getBlockZ()); - return nmsType.create(serverWorld, EntityTypeUtils::scheduleEntityDiscard, spawnBlockLocation, EntitySpawnReason.COMMAND, false, false); + return nmsType.create(serverWorld, EntityTypeUtils::scheduleEntityDiscard, spawnBlockLocation, MobSpawnType.COMMAND, false, false); } @NotNull @@ -433,7 +433,6 @@ public static boolean panicsFrom(EntityType sourceType, EntityType targetType) case SPIDER -> targetType == EntityType.ARMADILLO; case SKELETON, WITHER_SKELETON -> targetType == EntityType.WOLF; case VILLAGER -> targetType == EntityType.ZOMBIE || targetType == EntityType.ZOMBIE_VILLAGER; - case PILLAGER, VINDICATOR, EVOKER, ILLUSIONER -> targetType == EntityType.CREAKING; default -> false; }; diff --git a/src/main/java/xyz/nifeather/morph/utilities/NmsUtils.java b/src/main/java/xyz/nifeather/morph/utilities/NmsUtils.java index b5409263..28fec022 100644 --- a/src/main/java/xyz/nifeather/morph/utilities/NmsUtils.java +++ b/src/main/java/xyz/nifeather/morph/utilities/NmsUtils.java @@ -6,7 +6,6 @@ import it.unimi.dsi.fastutil.objects.ObjectLists; import net.minecraft.core.Holder; import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.entity.EntitySpawnReason; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.*; import net.minecraft.world.phys.Vec3; @@ -37,7 +36,7 @@ public static Entity spawnEntity(EntityType bukkitType, World targetWorld, Locat throw new IllegalArgumentException("No NMS EntityType for bukkit type '%s'".formatted(bukkitType)); var nmsWorld = ((CraftWorld) targetWorld).getHandle(); - var nmsEntity = nmsType.create(nmsWorld, EntitySpawnReason.COMMAND); + var nmsEntity = nmsType.create(nmsWorld); if (nmsEntity == null) throw new IllegalArgumentException("Unable to spawn entity"); diff --git a/src/main/java/xyz/nifeather/morph/utilities/SoundUtils.java b/src/main/java/xyz/nifeather/morph/utilities/SoundUtils.java index 3447bdc1..fed7d514 100644 --- a/src/main/java/xyz/nifeather/morph/utilities/SoundUtils.java +++ b/src/main/java/xyz/nifeather/morph/utilities/SoundUtils.java @@ -12,7 +12,7 @@ public static Sound toBukkitSound(EntityTypeUtils.SoundInfo si, float pitch) if (si.sound() == null) return null; - var resLoc = si.sound().location(); + var resLoc = si.sound().getLocation(); return Sound.sound().source(toAdventureSource(si.source())).volume(si.volume()).pitch(pitch) .type(Key.key(resLoc.getNamespace(), resLoc.getPath())).build();