Skip to content

Commit

Permalink
Merge pull request #5084 from SiverDX/fix/null_frozen_data
Browse files Browse the repository at this point in the history
fix #5080
  • Loading branch information
TheBv committed Jan 15, 2024
2 parents aea377a + 053896e commit ecc0414
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.core.particles.BlockParticleOption;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.entity.LivingEntity;

Expand All @@ -21,17 +22,16 @@ public class FrozenProperties {
private static final Random rand = new Random();

// FIXME: All of these hashmap optimizations are temporary to resolve performance issues, ideally we create a different system
private static HashMap<CompoundTag, Boolean> containsFrozenData = new HashMap<>();
private static final HashMap<CompoundTag, Boolean> containsFrozenData = new HashMap<>();

private static CompoundTag getOrCreateFrozenData(LivingEntity entity) {
return getOrCreateFrozenData(CitadelEntityData.getCitadelTag(entity));
}

private static CompoundTag getOrCreateFrozenData(CompoundTag entityData) {

if (containsFrozenData.containsKey(entityData) && containsFrozenData.get(entityData) && entityData.contains(FROZEN_DATA, 10)) {
if (containsFrozenData.containsKey(entityData) && containsFrozenData.getOrDefault(entityData, false) && entityData.contains(FROZEN_DATA, ListTag.TAG_COMPOUND)) {
return (CompoundTag) entityData.get(FROZEN_DATA);
} else if (entityData.contains(FROZEN_DATA, 10)) {
} else if (entityData.contains(FROZEN_DATA, ListTag.TAG_COMPOUND)) {
containsFrozenData.put(entityData, true);
return (CompoundTag) entityData.get(FROZEN_DATA);
} else {
Expand All @@ -45,7 +45,7 @@ private static CompoundTag createDefaultData() {
return clearFrozenStatus(nbt);
}

private static CompoundTag clearFrozenStatus(CompoundTag nbt, LivingEntity entity, boolean breakIce) {
private static void clearFrozenStatus(CompoundTag nbt, LivingEntity entity, boolean breakIce) {
if (breakIce) {
for (int i = 0; i < 15; i++) {
entity.level.addParticle(
Expand All @@ -58,7 +58,8 @@ private static CompoundTag clearFrozenStatus(CompoundTag nbt, LivingEntity entit
}
entity.playSound(SoundEvents.GLASS_BREAK, 3, 1);
}
return clearFrozenStatus(nbt);

clearFrozenStatus(nbt);
}

private static CompoundTag clearFrozenStatus(CompoundTag nbt) {
Expand Down

0 comments on commit ecc0414

Please sign in to comment.