mirror of
https://github.com/PaperMC/Paper.git
synced 2025-07-26 09:42:06 -07:00
some fixes
This commit is contained in:
@@ -35,7 +35,6 @@ public net.minecraft.network.protocol.game.ServerboundMovePlayerPacket yRot
|
||||
public net.minecraft.network.protocol.game.ServerboundMovePlayerPacket z
|
||||
public net.minecraft.network.syncher.SynchedEntityData getItem(Lnet/minecraft/network/syncher/EntityDataAccessor;)Lnet/minecraft/network/syncher/SynchedEntityData$DataItem;
|
||||
public net.minecraft.resources.RegistryOps lookupProvider
|
||||
public net.minecraft.resources.RegistryOps$HolderLookupAdapter
|
||||
public net.minecraft.server.Main forceUpgrade(Lnet/minecraft/world/level/storage/LevelStorageSource$LevelStorageAccess;Lnet/minecraft/world/level/storage/WorldData;Lcom/mojang/datafixers/DataFixer;ZLjava/util/function/BooleanSupplier;Lnet/minecraft/core/RegistryAccess;Z)V
|
||||
public net.minecraft.server.MinecraftServer LOGGER
|
||||
public net.minecraft.server.MinecraftServer doRunTask(Lnet/minecraft/server/TickTask;)V
|
||||
|
@@ -62,24 +62,21 @@ public interface BlocksAttacks {
|
||||
*
|
||||
* @return a damage type tag key, or null if there is no such tag key
|
||||
*/
|
||||
@Nullable
|
||||
TagKey<DamageType> bypassedBy();
|
||||
@Nullable TagKey<DamageType> bypassedBy();
|
||||
|
||||
/**
|
||||
* Gets the key sound to play when an attack is successfully blocked.
|
||||
*
|
||||
* @return a key of the sound
|
||||
*/
|
||||
@Nullable
|
||||
Key blockSound();
|
||||
@Nullable Key blockSound();
|
||||
|
||||
/**
|
||||
* Gets the key sound to play when the item goes on its disabled cooldown due to an attack.
|
||||
*
|
||||
* @return a key of the sound
|
||||
*/
|
||||
@Nullable
|
||||
Key disableSound();
|
||||
@Nullable Key disableSound();
|
||||
|
||||
/**
|
||||
* Builder for {@link BlocksAttacks}.
|
||||
|
@@ -30,16 +30,14 @@ public interface DamageReduction {
|
||||
*
|
||||
* @return the set of damage type
|
||||
*/
|
||||
@Nullable
|
||||
RegistryKeySet<DamageType> type();
|
||||
@Nullable RegistryKeySet<DamageType> type();
|
||||
|
||||
/**
|
||||
* Get the maximum angle between the users facing direction and the direction of the incoming attack to be blocked.
|
||||
*
|
||||
* @return the angle
|
||||
*/
|
||||
@Positive
|
||||
float horizontalBlockingAngle();
|
||||
@Positive float horizontalBlockingAngle();
|
||||
|
||||
/**
|
||||
* Get the constant amount of damage to be blocked.
|
||||
|
@@ -881,6 +881,11 @@ public interface Tag<T extends Keyed> extends Keyed {
|
||||
*/
|
||||
@Deprecated(since = "1.21.5", forRemoval = true)
|
||||
Tag<Material> DEAD_BUSH_MAY_PLACE_ON = DRY_VEGETATION_MAY_PLACE_ON;
|
||||
/**
|
||||
* @deprecated replaced by {@link #TRIGGERS_AMBIENT_DESERT_DRY_VEGETATION_BLOCK_SOUNDS}
|
||||
*/
|
||||
@Deprecated(since = "1.21.6", forRemoval = true)
|
||||
Tag<Material> PLAYS_AMBIENT_DESERT_BLOCK_SOUNDS = TRIGGERS_AMBIENT_DESERT_DRY_VEGETATION_BLOCK_SOUNDS;
|
||||
/**
|
||||
* Vanilla block tag representing all blocks that are replaceable by
|
||||
* dripstone.
|
||||
|
@@ -328,7 +328,7 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
|
||||
boolean isVisualFire();
|
||||
|
||||
/**
|
||||
* Retrieves the visual fire state of the object.
|
||||
* Retrieves the visual fire state of the entity.
|
||||
*
|
||||
* @return A TriState indicating the current visual fire state.
|
||||
*/
|
||||
|
@@ -168,42 +168,38 @@ public class PaperLootableInventoryData {
|
||||
private static final String NUM_REFILLS = "numRefills";
|
||||
private static final String LOOTED_PLAYERS = "lootedPlayers";
|
||||
|
||||
public void loadNbt(final ValueInput base) {
|
||||
final Optional<ValueInput> compOpt = base.child(ROOT);
|
||||
if (compOpt.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
final ValueInput comp = compOpt.get();
|
||||
this.lastFill = comp.getLongOr(LAST_FILL, -1);
|
||||
this.nextRefill = comp.getLongOr(NEXT_REFILL, -1);
|
||||
this.numRefills = comp.getIntOr(NUM_REFILLS, 0);
|
||||
final ValueInput.TypedInputList<SerializedLootedPlayerEntry> list = comp.listOrEmpty(LOOTED_PLAYERS, SerializedLootedPlayerEntry.CODEC);
|
||||
public void loadNbt(final ValueInput input) {
|
||||
final ValueInput data = input.childOrEmpty(ROOT);
|
||||
this.lastFill = data.getLongOr(LAST_FILL, -1);
|
||||
this.nextRefill = data.getLongOr(NEXT_REFILL, -1);
|
||||
this.numRefills = data.getIntOr(NUM_REFILLS, 0);
|
||||
final ValueInput.TypedInputList<SerializedLootedPlayerEntry> list = data.listOrEmpty(LOOTED_PLAYERS, SerializedLootedPlayerEntry.CODEC);
|
||||
if (!list.isEmpty()) {
|
||||
this.lootedPlayers = new HashMap<>();
|
||||
list.forEach(serializedLootedPlayerEntry -> lootedPlayers.put(serializedLootedPlayerEntry.uuid, serializedLootedPlayerEntry.time));
|
||||
}
|
||||
}
|
||||
|
||||
public void saveNbt(final ValueOutput base) {
|
||||
final ValueOutput comp = base.child(ROOT);
|
||||
public void saveNbt(final ValueOutput output) {
|
||||
final ValueOutput data = output.child(ROOT);
|
||||
if (this.nextRefill != -1) {
|
||||
comp.putLong(NEXT_REFILL, this.nextRefill);
|
||||
data.putLong(NEXT_REFILL, this.nextRefill);
|
||||
}
|
||||
if (this.lastFill != -1) {
|
||||
comp.putLong(LAST_FILL, this.lastFill);
|
||||
data.putLong(LAST_FILL, this.lastFill);
|
||||
}
|
||||
if (this.numRefills != 0) {
|
||||
comp.putInt(NUM_REFILLS, this.numRefills);
|
||||
data.putInt(NUM_REFILLS, this.numRefills);
|
||||
}
|
||||
if (this.lootedPlayers != null && !this.lootedPlayers.isEmpty()) {
|
||||
final ValueOutput.TypedOutputList<SerializedLootedPlayerEntry> list = comp.list(LOOTED_PLAYERS, SerializedLootedPlayerEntry.CODEC);
|
||||
final ValueOutput.TypedOutputList<SerializedLootedPlayerEntry> list = data.list(LOOTED_PLAYERS, SerializedLootedPlayerEntry.CODEC);
|
||||
for (final Map.Entry<UUID, Long> entry : this.lootedPlayers.entrySet()) {
|
||||
list.add(new SerializedLootedPlayerEntry(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
if (comp.isEmpty()) {
|
||||
base.discard(ROOT);
|
||||
if (data.isEmpty()) {
|
||||
output.discard(ROOT);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -8,9 +8,9 @@ import io.papermc.paper.datacomponent.item.blocksattacks.PaperDamageReduction;
|
||||
import io.papermc.paper.datacomponent.item.blocksattacks.PaperItemDamageFunction;
|
||||
import io.papermc.paper.registry.PaperRegistries;
|
||||
import io.papermc.paper.registry.tag.TagKey;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.craftbukkit.util.Handleable;
|
||||
import org.bukkit.damage.DamageType;
|
||||
@@ -65,7 +65,7 @@ public record PaperBlocksAttacks(
|
||||
|
||||
private float blockDelaySeconds;
|
||||
private float disableCooldownScale = 1.0F;
|
||||
private List<DamageReduction> damageReductions = new ArrayList<>();
|
||||
private List<DamageReduction> damageReductions = new ObjectArrayList<>();
|
||||
private ItemDamageFunction itemDamage = new PaperItemDamageFunction(net.minecraft.world.item.component.BlocksAttacks.ItemDamageFunction.DEFAULT);
|
||||
private @Nullable TagKey<DamageType> bypassedBy;
|
||||
private @Nullable Key blockSound;
|
||||
@@ -87,11 +87,16 @@ public record PaperBlocksAttacks(
|
||||
|
||||
@Override
|
||||
public Builder addDamageReduction(final DamageReduction reduction) {
|
||||
Preconditions.checkArgument(reduction.horizontalBlockingAngle() >= 0, "horizontalBlockingAngle must be non-negative, was %s", reduction.horizontalBlockingAngle());
|
||||
this.damageReductions.add(reduction);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder damageReductions(final List<DamageReduction> reductions) {
|
||||
this.damageReductions = new ObjectArrayList<>(reductions);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder itemDamage(final ItemDamageFunction function) {
|
||||
this.itemDamage = function;
|
||||
@@ -105,30 +110,24 @@ public record PaperBlocksAttacks(
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder blockSound(@Nullable final Key sound) {
|
||||
public Builder blockSound(final @Nullable Key sound) {
|
||||
this.blockSound = sound;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder disableSound(@Nullable final Key sound) {
|
||||
public Builder disableSound(final @Nullable Key sound) {
|
||||
this.disableSound = sound;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder damageReductions(final List<DamageReduction> reductions) {
|
||||
this.damageReductions = new ArrayList<>(reductions);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlocksAttacks build() {
|
||||
return new PaperBlocksAttacks(new net.minecraft.world.item.component.BlocksAttacks(
|
||||
this.blockDelaySeconds,
|
||||
this.disableCooldownScale,
|
||||
this.damageReductions.stream().map(damageReduction -> ((PaperDamageReduction) damageReduction).getHandle()).toList(),
|
||||
((PaperItemDamageFunction) itemDamage).getHandle(),
|
||||
((PaperItemDamageFunction) this.itemDamage).getHandle(),
|
||||
Optional.ofNullable(this.bypassedBy).map(PaperRegistries::toNms),
|
||||
Optional.ofNullable(this.blockSound).map(PaperAdventure::resolveSound),
|
||||
Optional.ofNullable(this.disableSound).map(PaperAdventure::resolveSound)
|
||||
|
@@ -26,6 +26,7 @@ public record PaperItemArmorTrim(
|
||||
BuilderImpl(final ArmorTrim armorTrim) {
|
||||
this.armorTrim = armorTrim;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemArmorTrim.Builder armorTrim(final ArmorTrim armorTrim) {
|
||||
this.armorTrim = armorTrim;
|
||||
|
@@ -2,6 +2,7 @@ package io.papermc.paper.datacomponent.item.blocksattacks;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.data.util.Conversions;
|
||||
import io.papermc.paper.registry.set.PaperRegistrySets;
|
||||
import io.papermc.paper.registry.set.RegistryKeySet;
|
||||
import net.minecraft.core.HolderSet;
|
||||
@@ -9,7 +10,7 @@ import net.minecraft.core.registries.Registries;
|
||||
import org.bukkit.craftbukkit.util.Handleable;
|
||||
import org.bukkit.damage.DamageType;
|
||||
import org.checkerframework.checker.index.qual.Positive;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import java.util.Optional;
|
||||
|
||||
public record PaperDamageReduction(
|
||||
@@ -44,19 +45,19 @@ public record PaperDamageReduction(
|
||||
static final class BuilderImpl implements Builder {
|
||||
|
||||
private Optional<HolderSet<net.minecraft.world.damagesource.DamageType>> type = Optional.empty();
|
||||
private float horizontalBlockingAngle = 90f;
|
||||
private float base = 0;
|
||||
private float factor = 0;
|
||||
private float horizontalBlockingAngle = 90.0F;
|
||||
private float base = 0.0F;
|
||||
private float factor = 1.0F;
|
||||
|
||||
@Override
|
||||
public Builder type(final @Nullable RegistryKeySet<DamageType> type) {
|
||||
this.type = Optional.ofNullable(type)
|
||||
.map((set) -> PaperRegistrySets.convertToNms(Registries.DAMAGE_TYPE, net.minecraft.server.MinecraftServer.getServer().registryAccess().createSerializationContext(net.minecraft.nbt.NbtOps.INSTANCE).lookupProvider, set));
|
||||
.map((set) -> PaperRegistrySets.convertToNms(Registries.DAMAGE_TYPE, Conversions.global().lookup(), set));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder horizontalBlockingAngle(@Positive final float horizontalBlockingAngle) {
|
||||
public Builder horizontalBlockingAngle(final @Positive float horizontalBlockingAngle) {
|
||||
Preconditions.checkArgument(horizontalBlockingAngle > 0, "horizontalBlockingAngle must be positive and not zero, was %s", horizontalBlockingAngle);
|
||||
this.horizontalBlockingAngle = horizontalBlockingAngle;
|
||||
return this;
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package io.papermc.paper.datacomponent.item.blocksattacks;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.world.item.component.BlocksAttacks;
|
||||
import org.bukkit.craftbukkit.util.Handleable;
|
||||
import org.checkerframework.checker.index.qual.NonNegative;
|
||||
|
||||
@@ -35,12 +36,12 @@ public record PaperItemDamageFunction(
|
||||
|
||||
static final class BuilderImpl implements Builder {
|
||||
|
||||
private float threshold;
|
||||
private float base;
|
||||
private float factor;
|
||||
private float threshold = BlocksAttacks.ItemDamageFunction.DEFAULT.threshold();
|
||||
private float base = BlocksAttacks.ItemDamageFunction.DEFAULT.base();
|
||||
private float factor = BlocksAttacks.ItemDamageFunction.DEFAULT.factor();
|
||||
|
||||
@Override
|
||||
public Builder threshold(@NonNegative final float threshold) {
|
||||
public Builder threshold(final @NonNegative float threshold) {
|
||||
Preconditions.checkArgument(threshold >= 0, "threshold must be non-negative, was %s", threshold);
|
||||
this.threshold = threshold;
|
||||
return this;
|
||||
|
@@ -7,7 +7,6 @@ import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.craftbukkit.CraftRegistry;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import java.util.Objects;
|
||||
@@ -61,17 +60,17 @@ public class CraftBiome extends OldEnumHolderable<Biome, net.minecraft.world.lev
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull NamespacedKey getKey() {
|
||||
public NamespacedKey getKey() {
|
||||
return LEGACY_CUSTOM_KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@NotNull final Biome other) {
|
||||
public int compareTo(final Biome other) {
|
||||
return this.ordinal - other.ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String name() {
|
||||
public String name() {
|
||||
return "CUSTOM";
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.Optionull;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityReference;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
@@ -78,12 +79,7 @@ public abstract class AbstractProjectile extends CraftEntity implements Projecti
|
||||
|
||||
@Override
|
||||
public java.util.UUID getOwnerUniqueId() {
|
||||
EntityReference<Entity> reference = this.getHandle().owner;
|
||||
if (reference == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return reference.getUUID();
|
||||
return Optionull.map(this.getHandle().owner, EntityReference::getUUID);
|
||||
}
|
||||
// Paper end - More projectile API
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.util.UUID;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.Optionull;
|
||||
import net.minecraft.world.entity.EntityReference;
|
||||
import net.minecraft.world.entity.animal.Animal;
|
||||
import org.bukkit.Material;
|
||||
@@ -24,17 +24,12 @@ public class CraftAnimals extends CraftAgeable implements Animals {
|
||||
|
||||
@Override
|
||||
public UUID getBreedCause() {
|
||||
EntityReference<ServerPlayer> reference = this.getHandle().loveCause;
|
||||
if (reference == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return reference.getUUID();
|
||||
return Optionull.map(this.getHandle().loveCause, EntityReference::getUUID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBreedCause(UUID uuid) {
|
||||
this.getHandle().loveCause = new EntityReference<>(uuid);
|
||||
this.getHandle().loveCause = uuid == null ? null : new EntityReference<>(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -233,7 +233,7 @@ public class CraftAreaEffectCloud extends CraftEntity implements AreaEffectCloud
|
||||
|
||||
@Override
|
||||
public void setOwnerUniqueId(final java.util.UUID ownerUuid) {
|
||||
this.getHandle().owner = new EntityReference<>(ownerUuid);
|
||||
this.getHandle().owner = ownerUuid == null ? null : new EntityReference<>(ownerUuid);
|
||||
}
|
||||
// Paper end
|
||||
}
|
||||
|
@@ -1021,14 +1021,14 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
return net.minecraft.world.entity.EntityType.loadEntityRecursive(output.buildResult(), level, EntitySpawnReason.LOAD, java.util.function.Function.identity());
|
||||
}
|
||||
|
||||
public void storeBukkitValues(ValueOutput c) {
|
||||
public void storeBukkitValues(ValueOutput output) {
|
||||
if (!this.persistentDataContainer.isEmpty()) {
|
||||
c.store("BukkitValues", CompoundTag.CODEC, this.persistentDataContainer.toTagCompound());
|
||||
output.store("BukkitValues", CompoundTag.CODEC, this.persistentDataContainer.toTagCompound());
|
||||
}
|
||||
}
|
||||
|
||||
public void readBukkitValues(ValueInput c) {
|
||||
c.read("BukkitValues", CompoundTag.CODEC).ifPresent(this.persistentDataContainer::putAll);
|
||||
public void readBukkitValues(ValueInput input) {
|
||||
input.read("BukkitValues", CompoundTag.CODEC).ifPresent(this.persistentDataContainer::putAll);
|
||||
}
|
||||
|
||||
protected CompoundTag save() {
|
||||
|
@@ -138,7 +138,7 @@ public class CraftItem extends CraftEntity implements Item {
|
||||
|
||||
@Override
|
||||
public void setThrower(UUID uuid) {
|
||||
this.getHandle().thrower = new EntityReference<>(uuid);
|
||||
this.getHandle().thrower = uuid == null ? null : new EntityReference<>(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -2354,9 +2354,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
}
|
||||
// Paper end - getLastPlayed replacement API
|
||||
|
||||
public void readExtraData(ValueInput tag) {
|
||||
public void readExtraData(ValueInput input) {
|
||||
this.hasPlayedBefore = true;
|
||||
tag.child("bukkit").ifPresent(data -> {
|
||||
input.child("bukkit").ifPresent(data -> {
|
||||
this.firstPlayed = data.getLongOr("firstPlayed", 0);
|
||||
this.lastPlayed = data.getLongOr("lastPlayed", 0);
|
||||
|
||||
@@ -2369,10 +2369,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
});
|
||||
}
|
||||
|
||||
public void setExtraData(ValueOutput tag) {
|
||||
public void setExtraData(ValueOutput output) {
|
||||
this.lastSaveTime = System.currentTimeMillis(); // Paper
|
||||
|
||||
ValueOutput data = tag.child("bukkit");
|
||||
ValueOutput data = output.child("bukkit");
|
||||
ServerPlayer handle = this.getHandle();
|
||||
data.putInt("newExp", handle.newExp);
|
||||
data.putInt("newTotalExp", handle.newTotalExp);
|
||||
@@ -2384,7 +2384,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
data.putString("lastKnownName", handle.getScoreboardName());
|
||||
|
||||
// Paper start - persist for use in offline save data
|
||||
ValueOutput paper = tag.child("Paper");
|
||||
ValueOutput paper = output.child("Paper");
|
||||
paper.putLong("LastLogin", handle.loginTime);
|
||||
paper.putLong("LastSeen", System.currentTimeMillis());
|
||||
// Paper end
|
||||
|
@@ -4,6 +4,7 @@ import com.google.common.base.Preconditions;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import java.util.Optional;
|
||||
import io.papermc.paper.registry.data.util.Conversions;
|
||||
import net.minecraft.commands.arguments.item.ItemParser;
|
||||
import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
@@ -332,7 +333,7 @@ public final class CraftItemFactory implements ItemFactory {
|
||||
Optional.of(
|
||||
io.papermc.paper.registry.set.PaperRegistrySets.convertToNms(
|
||||
Registries.ENCHANTMENT,
|
||||
net.minecraft.server.MinecraftServer.getServer().registryAccess().createSerializationContext(net.minecraft.nbt.NbtOps.INSTANCE).lookupProvider,
|
||||
Conversions.global().lookup(),
|
||||
keySet
|
||||
)
|
||||
),
|
||||
|
@@ -323,11 +323,11 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta {
|
||||
@Override
|
||||
@NotNull
|
||||
public Color computeEffectiveColor() {
|
||||
if (hasColor()) return getColor();
|
||||
if (this.hasColor()) return this.getColor();
|
||||
|
||||
return Color.fromRGB(
|
||||
PotionContents.getColorOptional(Collections2.transform(getAllEffects(), CraftPotionUtil::fromBukkit))
|
||||
.orElse(PotionContents.BASE_POTION_COLOR) & 0xFFFFFF
|
||||
.orElse(PotionContents.BASE_POTION_COLOR) & 0x00FFFFFF
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -493,8 +493,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
@Override
|
||||
public byte[] serializeItem(ItemStack item) {
|
||||
Preconditions.checkNotNull(item, "null cannot be serialized");
|
||||
Preconditions.checkArgument(item.getType() != Material.AIR, "air cannot be serialized");
|
||||
Preconditions.checkArgument(!item.isEmpty(), "Empty itemstack cannot be serialised");
|
||||
Preconditions.checkArgument(!item.isEmpty(), "Empty itemstack cannot be serialized");
|
||||
|
||||
return serializeNbtToBytes(
|
||||
(CompoundTag) net.minecraft.world.item.ItemStack.CODEC.encodeStart(
|
||||
|
@@ -6,7 +6,6 @@ import io.papermc.paper.registry.entry.RegistryEntryMeta;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import org.bukkit.Keyed;
|
||||
import org.bukkit.support.RegistryHelper;
|
||||
@@ -32,7 +31,7 @@ class RegistryBuilderTest {
|
||||
<M, T extends Keyed> void testEquality(final RegistryEntryMeta.Buildable<M, T, ?> registryEntry) { // TODO remove Keyed
|
||||
final Registry<M> registry = RegistryHelper.getRegistry().lookupOrThrow(registryEntry.mcKey());
|
||||
for (final Map.Entry<ResourceKey<M>, M> entry : registry.entrySet()) {
|
||||
final M built = registryEntry.builderFiller().fill(new Conversions(new RegistryOps.HolderLookupAdapter(RegistryHelper.getRegistry())), entry.getValue()).build();
|
||||
final M built = registryEntry.builderFiller().fill(Conversions.global(), entry.getValue()).build();
|
||||
assertEquals(entry.getValue(), built);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user