下面列出了怎么用org.bukkit.Art的API类实例代码及写法,或者点击链接到github查看源代码。
public boolean setArt(Art art, boolean force) {
EntityPainting painting = this.getHandle();
EnumArt oldArt = painting.art;
painting.art = CraftArt.BukkitToNotch(art);
painting.updateFacingWithBoundingBox(painting.facingDirection);
if (!force && !painting.onValidSurface()) {
// Revert painting since it doesn't fit
painting.art = oldArt;
painting.updateFacingWithBoundingBox(painting.facingDirection);
return false;
}
this.update();
return true;
}
public boolean setArt(Art art, boolean force) {
net.minecraft.entity.item.EntityPainting painting = this.getHandle();
net.minecraft.entity.item.EntityPainting.EnumArt oldArt = painting.art;
painting.art = CraftArt.BukkitToNotch(art);
painting.setDirection(painting.hangingDirection);
if (!force && !painting.onValidSurface()) {
// Revert painting since it doesn't fit
painting.art = oldArt;
painting.setDirection(painting.hangingDirection);
return false;
}
this.update();
return true;
}
public static Art NotchToBukkit(net.minecraft.entity.item.EntityPainting.EnumArt art) {
switch (art) {
case Kebab: return Art.KEBAB;
case Aztec: return Art.AZTEC;
case Alban: return Art.ALBAN;
case Aztec2: return Art.AZTEC2;
case Bomb: return Art.BOMB;
case Plant: return Art.PLANT;
case Wasteland: return Art.WASTELAND;
case Pool: return Art.POOL;
case Courbet: return Art.COURBET;
case Sea: return Art.SEA;
case Sunset: return Art.SUNSET;
case Creebet: return Art.CREEBET;
case Wanderer: return Art.WANDERER;
case Graham: return Art.GRAHAM;
case Match: return Art.MATCH;
case Bust: return Art.BUST;
case Stage: return Art.STAGE;
case Void: return Art.VOID;
case SkullAndRoses: return Art.SKULL_AND_ROSES;
case Fighters: return Art.FIGHTERS;
case Pointer: return Art.POINTER;
case Pigscene: return Art.PIGSCENE;
case BurningSkull: return Art.BURNINGSKULL;
case Skeleton: return Art.SKELETON;
case DonkeyKong: return Art.DONKEYKONG;
case Wither: return Art.WITHER;
default:
throw new AssertionError(art);
}
}
public static net.minecraft.entity.item.EntityPainting.EnumArt BukkitToNotch(Art art) {
switch (art) {
case KEBAB: return net.minecraft.entity.item.EntityPainting.EnumArt.Kebab;
case AZTEC: return net.minecraft.entity.item.EntityPainting.EnumArt.Aztec;
case ALBAN: return net.minecraft.entity.item.EntityPainting.EnumArt.Alban;
case AZTEC2: return net.minecraft.entity.item.EntityPainting.EnumArt.Aztec2;
case BOMB: return net.minecraft.entity.item.EntityPainting.EnumArt.Bomb;
case PLANT: return net.minecraft.entity.item.EntityPainting.EnumArt.Plant;
case WASTELAND: return net.minecraft.entity.item.EntityPainting.EnumArt.Wasteland;
case POOL: return net.minecraft.entity.item.EntityPainting.EnumArt.Pool;
case COURBET: return net.minecraft.entity.item.EntityPainting.EnumArt.Courbet;
case SEA: return net.minecraft.entity.item.EntityPainting.EnumArt.Sea;
case SUNSET: return net.minecraft.entity.item.EntityPainting.EnumArt.Sunset;
case CREEBET: return net.minecraft.entity.item.EntityPainting.EnumArt.Creebet;
case WANDERER: return net.minecraft.entity.item.EntityPainting.EnumArt.Wanderer;
case GRAHAM: return net.minecraft.entity.item.EntityPainting.EnumArt.Graham;
case MATCH: return net.minecraft.entity.item.EntityPainting.EnumArt.Match;
case BUST: return net.minecraft.entity.item.EntityPainting.EnumArt.Bust;
case STAGE: return net.minecraft.entity.item.EntityPainting.EnumArt.Stage;
case VOID: return net.minecraft.entity.item.EntityPainting.EnumArt.Void;
case SKULL_AND_ROSES: return net.minecraft.entity.item.EntityPainting.EnumArt.SkullAndRoses;
case FIGHTERS: return net.minecraft.entity.item.EntityPainting.EnumArt.Fighters;
case POINTER: return net.minecraft.entity.item.EntityPainting.EnumArt.Pointer;
case PIGSCENE: return net.minecraft.entity.item.EntityPainting.EnumArt.Pigscene;
case BURNINGSKULL: return net.minecraft.entity.item.EntityPainting.EnumArt.BurningSkull;
case SKELETON: return net.minecraft.entity.item.EntityPainting.EnumArt.Skeleton;
case DONKEYKONG: return net.minecraft.entity.item.EntityPainting.EnumArt.DonkeyKong;
case WITHER: return net.minecraft.entity.item.EntityPainting.EnumArt.Wither;
default:
throw new AssertionError(art);
}
}
public Art getArt() {
EnumArt art = getHandle().art;
return CraftArt.NotchToBukkit(art);
}
public boolean setArt(Art art) {
return setArt(art, false);
}
public static Art NotchToBukkit(EnumArt art) {
switch (art) {
case KEBAB:
return Art.KEBAB;
case AZTEC:
return Art.AZTEC;
case ALBAN:
return Art.ALBAN;
case AZTEC_2:
return Art.AZTEC2;
case BOMB:
return Art.BOMB;
case PLANT:
return Art.PLANT;
case WASTELAND:
return Art.WASTELAND;
case POOL:
return Art.POOL;
case COURBET:
return Art.COURBET;
case SEA:
return Art.SEA;
case SUNSET:
return Art.SUNSET;
case CREEBET:
return Art.CREEBET;
case WANDERER:
return Art.WANDERER;
case GRAHAM:
return Art.GRAHAM;
case MATCH:
return Art.MATCH;
case BUST:
return Art.BUST;
case STAGE:
return Art.STAGE;
case VOID:
return Art.VOID;
case SKULL_AND_ROSES:
return Art.SKULL_AND_ROSES;
case FIGHTERS:
return Art.FIGHTERS;
case POINTER:
return Art.POINTER;
case PIGSCENE:
return Art.PIGSCENE;
case BURNING_SKULL:
return Art.BURNINGSKULL;
case SKELETON:
return Art.SKELETON;
case DONKEY_KONG:
return Art.DONKEYKONG;
case WITHER:
return Art.WITHER;
default:
throw new AssertionError(art);
}
}
public static EnumArt BukkitToNotch(Art art) {
switch (art) {
case KEBAB:
return EnumArt.KEBAB;
case AZTEC:
return EnumArt.AZTEC;
case ALBAN:
return EnumArt.ALBAN;
case AZTEC2:
return EnumArt.AZTEC_2;
case BOMB:
return EnumArt.BOMB;
case PLANT:
return EnumArt.PLANT;
case WASTELAND:
return EnumArt.WASTELAND;
case POOL:
return EnumArt.POOL;
case COURBET:
return EnumArt.COURBET;
case SEA:
return EnumArt.SEA;
case SUNSET:
return EnumArt.SUNSET;
case CREEBET:
return EnumArt.CREEBET;
case WANDERER:
return EnumArt.WANDERER;
case GRAHAM:
return EnumArt.GRAHAM;
case MATCH:
return EnumArt.MATCH;
case BUST:
return EnumArt.BUST;
case STAGE:
return EnumArt.STAGE;
case VOID:
return EnumArt.VOID;
case SKULL_AND_ROSES:
return EnumArt.SKULL_AND_ROSES;
case FIGHTERS:
return EnumArt.FIGHTERS;
case POINTER:
return EnumArt.POINTER;
case PIGSCENE:
return EnumArt.PIGSCENE;
case BURNINGSKULL:
return EnumArt.BURNING_SKULL;
case SKELETON:
return EnumArt.SKELETON;
case DONKEYKONG:
return EnumArt.DONKEY_KONG;
case WITHER:
return EnumArt.WITHER;
default:
throw new AssertionError(art);
}
}
public Art getArt() {
net.minecraft.entity.item.EntityPainting.EnumArt art = getHandle().art;
return CraftArt.NotchToBukkit(art);
}
public boolean setArt(Art art) {
return setArt(art, false);
}
/**
* Get the art on this painting
*
* @return The art
*/
public Art getArt();
/**
* Set the art on this painting
*
* @param art The new art
* @return False if the new art won't fit at the painting's current
* location
*/
public boolean setArt(Art art);
/**
* Set the art on this painting
*
* @param art The new art
* @param force If true, force the new art regardless of whether it fits
* at the current location. Note that forcing it where it can't fit
* normally causes it to drop as an item unless you override this by
* catching the {@link HangingBreakEvent}.
* @return False if force was false and the new art won't fit at the
* painting's current location
*/
public boolean setArt(Art art, boolean force);