@@ -3,31 +3,32 @@ package org.bukkit.craftbukkit;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.ImmutableBiMap;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.IRegistry;
|
||||
import net.minecraft.resources.MinecraftKey;
|
||||
import net.minecraft.world.entity.decoration.Paintings;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.entity.decoration.PaintingVariant;
|
||||
import org.bukkit.Art;
|
||||
|
||||
public class CraftArt {
|
||||
private static final BiMap<Paintings, Art> artwork;
|
||||
private static final BiMap<Holder<PaintingVariant>, Art> artwork;
|
||||
|
||||
static {
|
||||
ImmutableBiMap.Builder<Paintings, Art> artworkBuilder = ImmutableBiMap.builder();
|
||||
for (MinecraftKey key : IRegistry.MOTIVE.keySet()) {
|
||||
artworkBuilder.put(IRegistry.MOTIVE.get(key), Art.getByName(key.getPath()));
|
||||
ImmutableBiMap.Builder<Holder<PaintingVariant>, Art> artworkBuilder = ImmutableBiMap.builder();
|
||||
for (ResourceKey<PaintingVariant> key : IRegistry.PAINTING_VARIANT.registryKeySet()) {
|
||||
artworkBuilder.put(IRegistry.PAINTING_VARIANT.getHolderOrThrow(key), Art.getByName(key.location().getPath()));
|
||||
}
|
||||
|
||||
artwork = artworkBuilder.build();
|
||||
}
|
||||
|
||||
public static Art NotchToBukkit(Paintings art) {
|
||||
public static Art NotchToBukkit(Holder<PaintingVariant> art) {
|
||||
Art bukkit = artwork.get(art);
|
||||
Preconditions.checkArgument(bukkit != null);
|
||||
return bukkit;
|
||||
}
|
||||
|
||||
public static Paintings BukkitToNotch(Art art) {
|
||||
Paintings nms = artwork.inverse().get(art);
|
||||
public static Holder<PaintingVariant> BukkitToNotch(Art art) {
|
||||
Holder<PaintingVariant> nms = artwork.inverse().get(art);
|
||||
Preconditions.checkArgument(nms != null);
|
||||
return nms;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user