Commits

md_5 authored b0c6dfe1ae6
SPIGOT-5976: Bees do not exit naturally spawned hives
No tags

nms-patches/TileEntityBeehive.patch

Modified
73 73 + // CraftBukkit start - This allows us to bypass the night/rain/emergency check
74 74 + return releaseBee(iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus, false);
75 75 + }
76 76 +
77 77 + private boolean releaseBee(IBlockData iblockdata, TileEntityBeehive.HiveBee tileentitybeehive_hivebee, @Nullable List<Entity> list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, boolean force) {
78 78 + if (!force && (this.world.isNight() || this.world.isRaining()) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) {
79 79 + // CraftBukkit end
80 80 return false;
81 81 } else {
82 82 BlockPosition blockposition = this.getPosition();
83 -@@ -157,6 +182,7 @@
83 +@@ -157,6 +182,18 @@
84 84 if (!entity.getEntityType().a((Tag) TagsEntity.BEEHIVE_INHABITORS)) {
85 85 return false;
86 86 } else {
87 ++ // CraftBukkit start
88 ++ if (entity instanceof EntityBee) {
89 ++ float f = entity.getWidth();
90 ++ double d0 = flag ? 0.0D : 0.55D + (double) (f / 2.0F);
91 ++ double d1 = (double) blockposition.getX() + 0.5D + d0 * (double) enumdirection.getAdjacentX();
92 ++ double d2 = (double) blockposition.getY() + 0.5D - (double) (entity.getHeight() / 2.0F);
93 ++ double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getAdjacentZ();
94 ++
95 ++ entity.setPositionRotation(d1, d2, d3, entity.yaw, entity.pitch);
96 ++ }
87 97 + if (!this.world.addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BEEHIVE)) return false; // CraftBukkit - SpawnReason, moved from below
98 ++ // CraftBukkit end
88 99 if (entity instanceof EntityBee) {
89 100 EntityBee entitybee = (EntityBee) entity;
90 101
91 -@@ -196,7 +222,7 @@
102 +@@ -186,6 +223,7 @@
103 + list.add(entitybee);
104 + }
105 +
106 ++ /* // CraftBukkit start
107 + float f = entity.getWidth();
108 + double d0 = flag ? 0.0D : 0.55D + (double) (f / 2.0F);
109 + double d1 = (double) blockposition.getX() + 0.5D + d0 * (double) enumdirection.getAdjacentX();
110 +@@ -193,10 +231,11 @@
111 + double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getAdjacentZ();
112 +
113 + entity.setPositionRotation(d1, d2, d3, entity.yaw, entity.pitch);
114 ++ */ // CraftBukkit end
92 115 }
93 116
94 117 this.world.playSound((EntityHuman) null, blockposition, SoundEffects.BLOCK_BEEHIVE_EXIT, SoundCategory.BLOCKS, 1.0F, 1.0F);
95 118 - return this.world.addEntity(entity);
96 119 + return true; // return this.world.addEntity(entity); // CraftBukkit - moved up
97 120 }
98 121 } else {
99 122 return false;
100 -@@ -235,6 +261,11 @@
123 +@@ -235,6 +274,11 @@
101 124 if (this.releaseBee(iblockdata, tileentitybeehive_hivebee, (List) null, tileentitybeehive_releasestatus)) {
102 125 iterator.remove();
103 126 }
104 127 + // CraftBukkit start
105 128 + else {
106 129 + tileentitybeehive_hivebee.ticksInHive = tileentitybeehive_hivebee.minOccupationTicks / 2; // Not strictly Vanilla behaviour in cases where bees cannot spawn but still reasonable
107 130 + }
108 131 + // CraftBukkit end
109 132 }
110 133 }
111 134
112 -@@ -276,6 +307,11 @@
135 +@@ -276,6 +320,11 @@
113 136 this.flowerPos = GameProfileSerializer.b(nbttagcompound.getCompound("FlowerPos"));
114 137 }
115 138
116 139 + // CraftBukkit start
117 140 + if (nbttagcompound.hasKey("Bukkit.MaxEntities")) {
118 141 + this.maxBees = nbttagcompound.getInt("Bukkit.MaxEntities");
119 142 + }
120 143 + // CraftBukkit end
121 144 }
122 145
123 146 @Override
124 -@@ -285,6 +321,7 @@
147 +@@ -285,6 +334,7 @@
125 148 if (this.x()) {
126 149 nbttagcompound.set("FlowerPos", GameProfileSerializer.a(this.flowerPos));
127 150 }
128 151 + nbttagcompound.setInt("Bukkit.MaxEntities", this.maxBees); // CraftBukkit
129 152
130 153 return nbttagcompound;
131 154 }

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut