Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
1package net.minecraft.server;
2
3// CraftBukkit start
4
5import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
6
7import org.bukkit.event.entity.PigZapEvent;
8import uk.betacraft.uberbukkit.UberbukkitConfig;
9// CraftBukkit end
10
11public class EntityPig extends EntityAnimal {
12
13 public EntityPig(World world) {
14 super(world);
15 this.texture = "/mob/pig.png";
16 this.b(0.9F, 0.9F);
17 }
18
19 protected void b() {
20 this.datawatcher.a(16, Byte.valueOf((byte) 0));
21 }
22
23 public void b(NBTTagCompound nbttagcompound) {
24 super.b(nbttagcompound);
25 nbttagcompound.a("Saddle", this.hasSaddle());
26 }
27
28 public void a(NBTTagCompound nbttagcompound) {
29 super.a(nbttagcompound);
30 this.setSaddle(nbttagcompound.m("Saddle"));
31 }
32
33 protected String g() {
34 return "mob.pig";
35 }
36
37 protected String h() {
38 return "mob.pig";
39 }
40
41 protected String i() {
42 return "mob.pigdeath";
43 }
44
45 public boolean a(EntityHuman entityhuman) {
46 if (this.hasSaddle() && !this.world.isStatic && (this.passenger == null || this.passenger == entityhuman)) {
47 entityhuman.mount(this);
48 return true;
49 } else {
50 return false;
51 }
52 }
53
54 protected int j() {
55 // uberbukkit
56 if (UberbukkitConfig.getInstance().getBoolean("mechanics.burning_pig_drop_cooked_meat", true) && this.fireTicks > 0) {
57 return Item.GRILLED_PORK.id;
58 } else {
59 return Item.PORK.id;
60 }
61 }
62
63 public boolean hasSaddle() {
64 return (this.datawatcher.a(16) & 1) != 0;
65 }
66
67 public void setSaddle(boolean flag) {
68 if (flag) {
69 this.datawatcher.watch(16, Byte.valueOf((byte) 1));
70 } else {
71 this.datawatcher.watch(16, Byte.valueOf((byte) 0));
72 }
73 }
74
75 public void a(EntityWeatherStorm entityweatherstorm) {
76 if (!this.world.isStatic) {
77 EntityPigZombie entitypigzombie = new EntityPigZombie(this.world);
78
79 // CraftBukkit start
80 PigZapEvent event = new PigZapEvent(this.getBukkitEntity(), entityweatherstorm.getBukkitEntity(), entitypigzombie.getBukkitEntity());
81 this.world.getServer().getPluginManager().callEvent(event);
82
83 if (event.isCancelled()) {
84 return;
85 }
86 // CraftBukkit end
87
88 entitypigzombie.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
89 // CraftBukkit - added a reason for spawning this creature
90 this.world.addEntity(entitypigzombie, SpawnReason.LIGHTNING);
91 this.die();
92 }
93 }
94
95 protected void a(float f) {
96 super.a(f);
97 if (f > 5.0F && this.passenger instanceof EntityHuman) {
98 ((EntityHuman) this.passenger).a((Statistic) AchievementList.u);
99 }
100 }
101}