From d3f5a5dd8a22288a16c35639bd1106d07492e960 Mon Sep 17 00:00:00 2001 From: Florens Pauwels Date: Fri, 17 Dec 2021 21:39:11 +0100 Subject: [PATCH] Mitigate server-side crash --- CHANGELOG.md | 8 ++++- gradle.properties | 2 +- .../EntityKillTrackerComponent.java | 29 +++++-------------- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5323576c..0fa434f40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [4.0.3] - 2021-12-17 +### Fixed +- Mitigate a server-side crash + ## [4.0.2] - 2021-10-04 ### Fixed - Rollback bundled version of expandability @@ -202,7 +206,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Initial release -[Unreleased]: https://github.com/florensie/artifacts-fabric/compare/v4.0.1...HEAD +[Unreleased]: https://github.com/florensie/artifacts-fabric/compare/v4.0.3...HEAD +[4.0.3]: https://github.com/florensie/artifacts-fabric/compare/v4.0.2...v4.0.3 +[4.0.2]: https://github.com/florensie/artifacts-fabric/compare/v4.0.1...v4.0.2 [4.0.1]: https://github.com/florensie/artifacts-fabric/compare/v4.0.0...v4.0.1 [4.0.0]: https://github.com/florensie/artifacts-fabric/compare/v3.2.1...v4.0.0 [3.2.1]: https://github.com/florensie/artifacts-fabric/compare/v3.2.0...v3.2.1 diff --git a/gradle.properties b/gradle.properties index 90c746461..621bbf1c2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ loader_version=0.11.7 parchment_version=2021.08.29 # Mod Properties -mod_version=4.0.2+fabric +mod_version=4.0.3+fabric maven_group=artifacts archives_base_name=artifacts diff --git a/src/main/java/artifacts/components/EntityKillTrackerComponent.java b/src/main/java/artifacts/components/EntityKillTrackerComponent.java index 0486ffdf1..58d755308 100644 --- a/src/main/java/artifacts/components/EntityKillTrackerComponent.java +++ b/src/main/java/artifacts/components/EntityKillTrackerComponent.java @@ -1,19 +1,13 @@ package artifacts.components; -import artifacts.mixin.extensions.DefaultedRegistryExtensions; import com.google.common.collect.EvictingQueue; import dev.onyxstudios.cca.api.v3.component.Component; import dev.onyxstudios.cca.api.v3.entity.PlayerComponent; -import java.util.Optional; -import java.util.Queue; -import java.util.stream.Collectors; -import net.minecraft.core.Registry; import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.nbt.StringTag; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.EntityType; +import java.util.Queue; + @SuppressWarnings("UnstableApiUsage") public class EntityKillTrackerComponent implements PlayerComponent { @@ -33,25 +27,16 @@ public double getKillRatio(EntityType type) { return this.getlastKilledEntityTypes().stream().filter(type::equals).count() / (double) MAX_SIZE; } + /* + * Read and write implementation removed because of https://github.com/florensie/artifacts-fabric/issues/50 + * Didn't remove entire functionality to make sure we're compatible with clients + */ + @Override public void readFromNbt(CompoundTag tag) { - if (tag.contains("lastKilledEntities")) { - this.lastKilledEntityTypes = tag.getList("lastKilledEntities", 8).stream() - .map(entityTypeId -> Registry.ENTITY_TYPE.getOptional(new ResourceLocation(entityTypeId.getAsString()))) - .filter(Optional::isPresent) - .map(Optional::get) - .collect(Collectors.toCollection(() -> EvictingQueue.create(MAX_SIZE))); - } } @Override public void writeToNbt(CompoundTag tag) { - //noinspection unchecked - tag.put("lastKilledEntities", this.lastKilledEntityTypes.stream() - .map(((DefaultedRegistryExtensions>) Registry.ENTITY_TYPE)::artifacts$getIdOrEmpty) - //.flatMap(Optional::stream) TODO: Java 9+ - .filter(Optional::isPresent) - .map(identifier -> StringTag.valueOf(identifier.get().toString())) - .collect(Collectors.toCollection(ListTag::new))); } }