PageRenderTime 49ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/src/main/java/net/minecraft/server/EntityPainting.java

https://bitbucket.org/agaricusb/craftbukkit
Java | 73 lines | 55 code | 18 blank | 0 comment | 7 complexity | a7d380e59eeea78adb7109cc9f875992 MD5 | raw file
  1. package net.minecraft.server;
  2. import java.util.ArrayList;
  3. public class EntityPainting extends EntityHanging {
  4. public EnumArt art;
  5. public EntityPainting(World world) {
  6. super(world);
  7. this.art = EnumArt.values()[this.random.nextInt(EnumArt.values().length)]; // CraftBukkit - generate a non-null painting
  8. }
  9. public EntityPainting(World world, int i, int j, int k, int l) {
  10. super(world, i, j, k, l);
  11. ArrayList arraylist = new ArrayList();
  12. EnumArt[] aenumart = EnumArt.values();
  13. int i1 = aenumart.length;
  14. for (int j1 = 0; j1 < i1; ++j1) {
  15. EnumArt enumart = aenumart[j1];
  16. this.art = enumart;
  17. this.setDirection(l);
  18. if (this.survives()) {
  19. arraylist.add(enumart);
  20. }
  21. }
  22. if (!arraylist.isEmpty()) {
  23. this.art = (EnumArt) arraylist.get(this.random.nextInt(arraylist.size()));
  24. }
  25. this.setDirection(l);
  26. }
  27. public void b(NBTTagCompound nbttagcompound) {
  28. nbttagcompound.setString("Motive", this.art.B);
  29. super.b(nbttagcompound);
  30. }
  31. public void a(NBTTagCompound nbttagcompound) {
  32. String s = nbttagcompound.getString("Motive");
  33. EnumArt[] aenumart = EnumArt.values();
  34. int i = aenumart.length;
  35. for (int j = 0; j < i; ++j) {
  36. EnumArt enumart = aenumart[j];
  37. if (enumart.B.equals(s)) {
  38. this.art = enumart;
  39. }
  40. }
  41. if (this.art == null) {
  42. this.art = EnumArt.KEBAB;
  43. }
  44. super.a(nbttagcompound);
  45. }
  46. public int d() {
  47. return this.art.C;
  48. }
  49. public int g() {
  50. return this.art.D;
  51. }
  52. public void h() {
  53. this.a(new ItemStack(Item.PAINTING), 0.0F);
  54. }
  55. }