make it compile \o/

This commit is contained in:
granny
2025-03-27 16:27:08 -07:00
parent f1e732aa3a
commit 73e0e17b6d
29 changed files with 134 additions and 147 deletions

View File

@@ -3,9 +3,9 @@ package org.purpurmc.purpur.entity;
import io.papermc.paper.adventure.PaperAdventure;
import net.kyori.adventure.text.Component;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;
import net.minecraft.nbt.NbtOps;
import net.minecraft.network.chat.ComponentSerialization;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.item.component.CustomData;
import net.minecraft.world.level.block.entity.BeehiveBlockEntity;
import org.bukkit.block.EntityBlockStorage;
import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer;
@@ -32,12 +32,11 @@ public class PurpurStoredBee implements StoredEntity<Bee> {
this.blockStorage = blockStorage;
CompoundTag customData = handle.occupant.entityData().copyTag();
this.customName = customData.contains("CustomName")
? PaperAdventure.asAdventure(net.minecraft.network.chat.Component.Serializer.fromJson(customData.getString("CustomName"), MinecraftServer.getDefaultRegistryAccess()))
: null;
net.minecraft.network.chat.Component customNameMinecraft = customData.read("CustomName", ComponentSerialization.CODEC, MinecraftServer.getDefaultRegistryAccess().createSerializationContext(NbtOps.INSTANCE)).orElse(null);
this.customName = customNameMinecraft == null ? null : PaperAdventure.asAdventure(customNameMinecraft);
if(customData.contains("BukkitValues", Tag.TAG_COMPOUND)) {
this.persistentDataContainer.putAll(customData.getCompound("BukkitValues"));
if (customData.get("BukkitValues") instanceof CompoundTag compoundTag) {
this.persistentDataContainer.putAll(compoundTag);
}
}

View File

@@ -70,7 +70,7 @@ public class PhantomFlames extends LlamaSpit {
this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
} else if (this.level().getBlockStates(this.getBoundingBox()).noneMatch(BlockBehaviour.BlockStateBase::isAir)) {
this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
} else if (this.isInWaterOrBubble()) {
} else if (this.isInWater()) {
this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
} else {
this.setDeltaMovement(mot.scale(0.99D));

View File

@@ -1,5 +1,6 @@
package org.purpurmc.purpur.item;
import java.util.Optional;
import net.minecraft.core.BlockPos;
import net.minecraft.core.component.DataComponents;
import net.minecraft.nbt.CompoundTag;
@@ -27,11 +28,11 @@ public class SpawnerItem extends BlockItem {
BlockEntity blockEntity = level.getBlockEntity(pos);
if (blockEntity instanceof SpawnerBlockEntity spawner) {
CompoundTag customData = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY).copyTag();
if (customData.contains("Purpur.mob_type")) {
EntityType.byString(customData.getString("Purpur.mob_type")).ifPresent(type -> spawner.getSpawner().setEntityId(type, level, level.random, pos));
Optional<String> mobTypeStringOptional = customData.getString("Purpur.mob_type");
if (mobTypeStringOptional.isPresent()) {
EntityType.byString(mobTypeStringOptional.get()).ifPresent(type -> spawner.getSpawner().setEntityId(type, level, level.random, pos));
} else if (customData.contains("Purpur.SpawnData")) {
net.minecraft.world.level.SpawnData.CODEC.parse(net.minecraft.nbt.NbtOps.INSTANCE, customData.getCompound("Purpur.SpawnData")).result()
.ifPresent(spawnData -> spawner.getSpawner().nextSpawnData = spawnData);
customData.read("SpawnData", net.minecraft.world.level.SpawnData.CODEC).ifPresent(spawnData -> spawner.getSpawner().nextSpawnData = spawnData);
}
}
}