Update to Minecraft 1.20.5

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2024-04-24 01:15:00 +10:00
parent 4deda9501f
commit 65bc2541a3
524 changed files with 7788 additions and 6181 deletions

View File

@@ -1,5 +1,8 @@
package org.bukkit.craftbukkit;
import com.google.common.base.Preconditions;
import net.minecraft.core.Holder;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.item.Instrument;
import org.bukkit.MusicInstrument;
@@ -14,10 +17,27 @@ public class CraftMusicInstrument extends MusicInstrument implements Handleable<
return CraftRegistry.minecraftToBukkit(minecraft, Registries.INSTRUMENT, Registry.INSTRUMENT);
}
public static MusicInstrument minecraftHolderToBukkit(Holder<Instrument> minecraft) {
return minecraftToBukkit(minecraft.value());
}
public static Instrument bukkitToMinecraft(MusicInstrument bukkit) {
return CraftRegistry.bukkitToMinecraft(bukkit);
}
public static Holder<Instrument> bukkitToMinecraftHolder(MusicInstrument bukkit) {
Preconditions.checkArgument(bukkit != null);
IRegistry<Instrument> registry = CraftRegistry.getMinecraftRegistry(Registries.INSTRUMENT);
if (registry.wrapAsHolder(bukkitToMinecraft(bukkit)) instanceof Holder.c<Instrument> holder) {
return holder;
}
throw new IllegalArgumentException("No Reference holder found for " + bukkit
+ ", this can happen if a plugin creates its own instrument without properly registering it.");
}
private final NamespacedKey key;
private final Instrument handle;