2019-12-18 11:07:49 +01:00
--- a/net/minecraft/server/TileEntityBeehive.java
+++ b/net/minecraft/server/TileEntityBeehive.java
2020-01-22 18:34:03 +01:00
@@ -108,6 +108,18 @@
public void a(Entity entity, boolean flag, int i) {
if (this.bees.size() < 3) {
+ // CraftBukkit start
+ if (this.world != null) {
+ org.bukkit.event.entity.EntityEnterBlockEvent event = new org.bukkit.event.entity.EntityEnterBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, getPosition()));
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ if (entity instanceof EntityBee) {
+ ((EntityBee) entity).setCannotEnterHiveTicks(400);
+ }
+ return;
+ }
+ }
+ // CraftBukkit end
entity.stopRiding();
entity.ejectPassengers();
NBTTagCompound nbttagcompound = new NBTTagCompound();
@@ -163,6 +175,7 @@
2019-12-23 14:25:03 +01:00
if (!entity.getEntityType().a(TagsEntity.BEEHIVE_INHABITORS)) {
return false;
} else {
+ if (!this.world.addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BEEHIVE)) return false; // CraftBukkit - SpawnReason, moved from below
if (entity instanceof EntityBee) {
EntityBee entitybee = (EntityBee) entity;
2020-01-22 18:34:03 +01:00
@@ -196,7 +209,7 @@
2019-12-18 11:07:49 +01:00
BlockPosition blockposition2 = this.getPosition();
this.world.playSound((EntityHuman) null, (double) blockposition2.getX(), (double) blockposition2.getY(), (double) blockposition2.getZ(), SoundEffects.BLOCK_BEEHIVE_EXIT, SoundCategory.BLOCKS, 1.0F, 1.0F);
- return this.world.addEntity(entity);
2019-12-23 14:25:03 +01:00
+ return true; // return this.world.addEntity(entity); // CraftBukkit - moved up
2019-12-18 11:07:49 +01:00
}
} else {
return false;
2020-01-22 18:34:03 +01:00
@@ -223,6 +236,11 @@
2019-12-23 02:20:35 +01:00
if (this.a(iblockdata, nbttagcompound, (List) null, tileentitybeehive_releasestatus)) {
iterator.remove();
}
+ // CraftBukkit start
+ else {
2020-01-21 22:00:00 +01:00
+ tileentitybeehive_hivebee.ticksInHive = tileentitybeehive_hivebee.minOccupationTicks / 2; // Not strictly Vanilla behaviour in cases where bees cannot spawn but still reasonable
2019-12-23 02:20:35 +01:00
+ }
+ // CraftBukkit end
} else {
2020-01-21 22:00:00 +01:00
tileentitybeehive_hivebee.ticksInHive++;
2019-12-23 02:20:35 +01:00
}