summaryrefslogtreecommitdiffstats
path: root/nms-patches/EntityAgeable.patch
blob: 8aba8a6a094b58945ee5d2910b510b79721c4483 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
--- a/net/minecraft/server/EntityAgeable.java
+++ b/net/minecraft/server/EntityAgeable.java
@@ -8,6 +8,7 @@
     protected int c;
     private float bw = -1.0F;
     private float bx;
+    public boolean ageLocked; // CraftBukkit
 
     public EntityAgeable(World world) {
         super(world);
@@ -26,13 +27,16 @@
                     if (entityageable != null) {
                         entityageable.setAgeRaw(-24000);
                         entityageable.setPositionRotation(this.locX, this.locY, this.locZ, 0.0F, 0.0F);
-                        this.world.addEntity(entityageable);
+                        this.world.addEntity(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // CraftBukkit
                         if (itemstack.hasName()) {
                             entityageable.setCustomName(itemstack.getName());
                         }
 
                         if (!entityhuman.abilities.canInstantlyBuild) {
                             --itemstack.count;
+                            if (itemstack.count == 0) { // CraftBukkit - allow less than 0 stacks as "infinite"
+                                entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null);
+                            }
                         }
                     }
                 }
@@ -95,12 +99,14 @@
         super.b(nbttagcompound);
         nbttagcompound.setInt("Age", this.getAge());
         nbttagcompound.setInt("ForcedAge", this.b);
+        nbttagcompound.setBoolean("AgeLocked", this.ageLocked); // CraftBukkit
     }
 
     public void a(NBTTagCompound nbttagcompound) {
         super.a(nbttagcompound);
         this.setAgeRaw(nbttagcompound.getInt("Age"));
         this.b = nbttagcompound.getInt("ForcedAge");
+        this.ageLocked = nbttagcompound.getBoolean("AgeLocked"); // CraftBukkit
     }
 
     public void a(DataWatcherObject<?> datawatcherobject) {
@@ -113,7 +119,7 @@
 
     public void n() {
         super.n();
-        if (this.world.isClientSide) {
+        if (this.world.isClientSide || ageLocked) { // CraftBukkit
             if (this.c > 0) {
                 if (this.c % 4 == 0) {
                     this.world.addParticle(EnumParticle.VILLAGER_HAPPY, this.locX + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, this.locY + 0.5D + (double) (this.random.nextFloat() * this.length), this.locZ + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, 0.0D, 0.0D, 0.0D, new int[0]);