mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-12 18:01:07 +01:00
128 lines
6.2 KiB
Diff
128 lines
6.2 KiB
Diff
--- a/net/minecraft/server/TileEntityBeehive.java
|
|
+++ b/net/minecraft/server/TileEntityBeehive.java
|
|
@@ -10,6 +10,7 @@
|
|
private final List<TileEntityBeehive.HiveBee> bees = Lists.newArrayList();
|
|
@Nullable
|
|
public BlockPosition flowerPos = null;
|
|
+ public int maxBees = 3; // CraftBukkit - allow setting max amount of bees a hive can hold
|
|
|
|
public TileEntityBeehive() {
|
|
super(TileEntityTypes.BEEHIVE);
|
|
@@ -49,7 +50,7 @@
|
|
}
|
|
|
|
public boolean isFull() {
|
|
- return this.bees.size() == 3;
|
|
+ return this.bees.size() == this.maxBees; // CraftBukkit
|
|
}
|
|
|
|
public void a(@Nullable EntityHuman entityhuman, IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) {
|
|
@@ -77,11 +78,17 @@
|
|
|
|
}
|
|
|
|
- private List<Entity> a(IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) {
|
|
+ // CraftBukkit start - This allows us to bypass the night/rain/emergency check
|
|
+ private List<Entity> a(IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) { // PAIL rename releaseBees
|
|
+ return releaseBees(iblockdata, tileentitybeehive_releasestatus, false);
|
|
+ }
|
|
+
|
|
+ public List<Entity> releaseBees(IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, boolean force) {
|
|
List<Entity> list = Lists.newArrayList();
|
|
|
|
this.bees.removeIf((tileentitybeehive_hivebee) -> {
|
|
- return this.a(iblockdata, tileentitybeehive_hivebee.entityData, list, tileentitybeehive_releasestatus);
|
|
+ return this.releaseBee(iblockdata, tileentitybeehive_hivebee.entityData, list, tileentitybeehive_releasestatus, force);
|
|
+ // CraftBukkit end
|
|
});
|
|
return list;
|
|
}
|
|
@@ -107,7 +114,19 @@
|
|
}
|
|
|
|
public void a(Entity entity, boolean flag, int i) {
|
|
- if (this.bees.size() < 3) {
|
|
+ if (this.bees.size() < this.maxBees) { // CraftBukkit
|
|
+ // 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();
|
|
@@ -132,10 +151,16 @@
|
|
}
|
|
}
|
|
|
|
- private boolean a(IBlockData iblockdata, NBTTagCompound nbttagcompound, @Nullable List<Entity> list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) {
|
|
+ // CraftBukkit start - This allows us to bypass the night/rain/emergency check
|
|
+ private boolean a(IBlockData iblockdata, NBTTagCompound nbttagcompound, @Nullable List<Entity> list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) { // PAIL rename releaseBee
|
|
+ return releaseBee(iblockdata, nbttagcompound, list, tileentitybeehive_releasestatus, false);
|
|
+ }
|
|
+
|
|
+ private boolean releaseBee(IBlockData iblockdata, NBTTagCompound nbttagcompound, @Nullable List<Entity> list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, boolean force) {
|
|
BlockPosition blockposition = this.getPosition();
|
|
|
|
- if ((this.world.isNight() || this.world.isRaining()) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) {
|
|
+ if (!force && (this.world.isNight() || this.world.isRaining()) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) {
|
|
+ // CraftBukkit end
|
|
return false;
|
|
} else {
|
|
nbttagcompound.remove("Passengers");
|
|
@@ -163,6 +188,7 @@
|
|
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;
|
|
|
|
@@ -196,7 +222,7 @@
|
|
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);
|
|
+ return true; // return this.world.addEntity(entity); // CraftBukkit - moved up
|
|
}
|
|
} else {
|
|
return false;
|
|
@@ -223,6 +249,11 @@
|
|
if (this.a(iblockdata, nbttagcompound, (List) null, tileentitybeehive_releasestatus)) {
|
|
iterator.remove();
|
|
}
|
|
+ // CraftBukkit start
|
|
+ else {
|
|
+ tileentitybeehive_hivebee.ticksInHive = tileentitybeehive_hivebee.minOccupationTicks / 2; // Not strictly Vanilla behaviour in cases where bees cannot spawn but still reasonable
|
|
+ }
|
|
+ // CraftBukkit end
|
|
} else {
|
|
tileentitybeehive_hivebee.ticksInHive++;
|
|
}
|
|
@@ -266,6 +297,11 @@
|
|
this.flowerPos = GameProfileSerializer.c(nbttagcompound.getCompound("FlowerPos"));
|
|
}
|
|
|
|
+ // CraftBukkit start
|
|
+ if (nbttagcompound.hasKey("Bukkit.MaxEntities")) {
|
|
+ this.maxBees = nbttagcompound.getInt("Bukkit.MaxEntities");
|
|
+ }
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
@Override
|
|
@@ -275,6 +311,7 @@
|
|
if (this.x()) {
|
|
nbttagcompound.set("FlowerPos", GameProfileSerializer.a(this.flowerPos));
|
|
}
|
|
+ nbttagcompound.setInt("Bukkit.MaxEntities", this.maxBees); // CraftBukkit
|
|
|
|
return nbttagcompound;
|
|
}
|