SPIGOT-4560: Add HumanEntity.sleep and related APIs

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2019-01-02 14:41:31 +11:00
parent 19795494f3
commit 1336c4afb9
3 changed files with 121 additions and 52 deletions

View File

@@ -330,7 +330,7 @@
return EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE;
}
@@ -1140,6 +1267,26 @@
@@ -1140,6 +1267,30 @@
}
}
}
@@ -338,9 +338,13 @@
+ }
+
+ public EntityHuman.EnumBedResult a(BlockPosition blockposition) {
+ // CraftBukkit start - moved checks into separate method above, add force
+ return this.a(blockposition, false);
+ }
+
+ public EntityHuman.EnumBedResult a(BlockPosition blockposition, boolean force) {
+ EnumDirection enumdirection = (EnumDirection) this.world.getType(blockposition).get(BlockFacingHorizontal.FACING);
+ // CraftBukkit start - moved checks into separate method above
+ EntityHuman.EnumBedResult bedResult = this.getBedResult(blockposition, enumdirection);
+ EntityHuman.EnumBedResult bedResult = force ? EnumBedResult.OK : this.getBedResult(blockposition, enumdirection);
+
+ if (bedResult == EntityHuman.EnumBedResult.OTHER_PROBLEM) {
+ return bedResult; // return immediately if the result is not bypassable by plugins
@@ -357,7 +361,7 @@
if (this.isPassenger()) {
this.stopRiding();
@@ -1206,6 +1353,24 @@
@@ -1206,6 +1357,24 @@
this.world.everyoneSleeping();
}
@@ -382,7 +386,7 @@
this.sleepTicks = flag ? 0 : 100;
if (flag2) {
this.setRespawnPosition(this.bedPosition, false);
@@ -1257,9 +1422,11 @@
@@ -1257,9 +1426,11 @@
if (blockposition != null) {
this.e = blockposition;
this.f = flag;
@@ -394,7 +398,7 @@
}
}
@@ -1325,7 +1492,11 @@
@@ -1325,7 +1496,11 @@
this.motY = d3 * 0.6D;
this.aU = f3;
this.fallDistance = 0.0F;
@@ -407,7 +411,7 @@
} else {
super.a(f, f1, f2);
}
@@ -1625,13 +1796,17 @@
@@ -1625,13 +1800,17 @@
}
protected void releaseShoulderEntities() {
@@ -430,7 +434,7 @@
if (!this.world.isClientSide && !nbttagcompound.isEmpty()) {
Entity entity = EntityTypes.a(nbttagcompound, this.world);
@@ -1640,9 +1815,10 @@
@@ -1640,9 +1819,10 @@
}
entity.setPosition(this.locX, this.locY + 0.699999988079071D, this.locZ);