Search in sources :

Example 1 with PaintingType

use of net.minecraft.entity.item.PaintingType in project LoliServer by Loli-Server.

the class CraftPainting method setArt.

@Override
public boolean setArt(Art art, boolean force) {
    PaintingEntity painting = this.getHandle();
    PaintingType oldArt = painting.motive;
    painting.motive = CraftArt.BukkitToNotch(art);
    painting.setDirection(painting.getDirection());
    if (!force && !painting.survives()) {
        // Revert painting since it doesn't fit
        painting.motive = oldArt;
        painting.setDirection(painting.getDirection());
        return false;
    }
    this.update();
    return true;
}
Also used : PaintingEntity(net.minecraft.entity.item.PaintingEntity) PaintingType(net.minecraft.entity.item.PaintingType)

Example 2 with PaintingType

use of net.minecraft.entity.item.PaintingType in project LoliServer by Loli-Server.

the class CraftArt method BukkitToNotch.

public static PaintingType BukkitToNotch(Art art) {
    PaintingType nms = artwork.inverse().get(art);
    Preconditions.checkArgument(nms != null);
    return nms;
}
Also used : PaintingType(net.minecraft.entity.item.PaintingType)

Example 3 with PaintingType

use of net.minecraft.entity.item.PaintingType in project Magma-1.16.x by magmafoundation.

the class CraftArt method BukkitToNotch.

public static PaintingType BukkitToNotch(Art art) {
    PaintingType nms = artwork.inverse().get(art);
    Preconditions.checkArgument(nms != null);
    return nms;
}
Also used : PaintingType(net.minecraft.entity.item.PaintingType)

Example 4 with PaintingType

use of net.minecraft.entity.item.PaintingType in project LoliServer by Loli-Server.

the class BukkitInjector method addEnumArt.

public static void addEnumArt() {
    int i = Art.values().length;
    HashMap<String, Art> BY_NAME = ObfuscationReflectionHelper.getPrivateValue(Art.class, null, "BY_NAME");
    HashMap<Integer, Art> BY_ID = ObfuscationReflectionHelper.getPrivateValue(Art.class, null, "BY_ID");
    for (PaintingType entry : ForgeRegistries.PAINTING_TYPES) {
        int width = entry.getWidth();
        int height = entry.getHeight();
        ResourceLocation resourceLocation = entry.getRegistryName();
        if (!resourceLocation.getNamespace().equals(NamespacedKey.MINECRAFT)) {
            String name = normalizeName(resourceLocation.toString());
            int id = i - 1;
            Art art = EnumHelper.addEnum(Art.class, name, new Class[] { Integer.TYPE, Integer.TYPE, Integer.TYPE }, new Object[] { id, width, height });
            artMap.put(entry, art);
            BY_NAME.put(name, art);
            BY_ID.put(id, art);
            LoliServer.LOGGER.debug("Registered forge PaintingType as Art {}", art);
            i++;
        }
    }
}
Also used : Art(org.bukkit.Art) ResourceLocation(net.minecraft.util.ResourceLocation) PaintingType(net.minecraft.entity.item.PaintingType)

Example 5 with PaintingType

use of net.minecraft.entity.item.PaintingType in project Magma-1.16.x by magmafoundation.

the class CraftPainting method setArt.

@Override
public boolean setArt(Art art, boolean force) {
    PaintingEntity painting = this.getHandle();
    PaintingType oldArt = painting.motive;
    painting.motive = CraftArt.BukkitToNotch(art);
    painting.setDirection(painting.getDirection());
    if (!force && !painting.survives()) {
        // Revert painting since it doesn't fit
        painting.motive = oldArt;
        painting.setDirection(painting.getDirection());
        return false;
    }
    this.update();
    return true;
}
Also used : PaintingEntity(net.minecraft.entity.item.PaintingEntity) PaintingType(net.minecraft.entity.item.PaintingType)

Aggregations

PaintingType (net.minecraft.entity.item.PaintingType)5 PaintingEntity (net.minecraft.entity.item.PaintingEntity)2 ResourceLocation (net.minecraft.util.ResourceLocation)1 Art (org.bukkit.Art)1