mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-04 22:14:40 +01:00
SPIGOT-4753: Add Pose API
This commit is contained in:
parent
86f149ff77
commit
6606cd88d2
2 changed files with 46 additions and 30 deletions
|
@ -1,6 +1,6 @@
|
|||
--- a/net/minecraft/server/Entity.java
|
||||
+++ b/net/minecraft/server/Entity.java
|
||||
@@ -20,8 +20,55 @@
|
||||
@@ -20,8 +20,57 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
@ -22,10 +22,12 @@
|
|||
+import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.entity.Pose;
|
||||
+import org.bukkit.event.entity.EntityAirChangeEvent;
|
||||
+import org.bukkit.event.entity.EntityCombustEvent;
|
||||
+import org.bukkit.event.entity.EntityDropItemEvent;
|
||||
+import org.bukkit.event.entity.EntityPortalEvent;
|
||||
+import org.bukkit.event.entity.EntityPoseChangeEvent;
|
||||
+import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
+import org.bukkit.plugin.PluginManager;
|
||||
+// CraftBukkit end
|
||||
|
@ -56,7 +58,7 @@
|
|||
protected static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final AtomicInteger entityCount = new AtomicInteger();
|
||||
private static final List<ItemStack> c = Collections.emptyList();
|
||||
@@ -106,6 +153,16 @@
|
||||
@@ -106,6 +155,16 @@
|
||||
private long aH;
|
||||
private EntitySize size;
|
||||
private float headHeight;
|
||||
|
@ -73,7 +75,15 @@
|
|||
|
||||
public Entity(EntityTypes<?> entitytypes, World world) {
|
||||
this.id = Entity.entityCount.incrementAndGet();
|
||||
@@ -212,6 +269,33 @@
|
||||
@@ -204,6 +263,7 @@
|
||||
}
|
||||
|
||||
protected void b(EntityPose entitypose) {
|
||||
+ this.world.getServer().getPluginManager().callEvent(new EntityPoseChangeEvent(this.getBukkitEntity(), Pose.values()[entitypose.ordinal()])); // CraftBukkit
|
||||
this.datawatcher.set(Entity.X, entitypose);
|
||||
}
|
||||
|
||||
@@ -212,6 +272,33 @@
|
||||
}
|
||||
|
||||
protected void setYawPitch(float f, float f1) {
|
||||
|
@ -107,7 +117,7 @@
|
|||
this.yaw = f % 360.0F;
|
||||
this.pitch = f1 % 360.0F;
|
||||
}
|
||||
@@ -224,6 +308,7 @@
|
||||
@@ -224,6 +311,7 @@
|
||||
float f1 = this.size.height;
|
||||
|
||||
this.a(new AxisAlignedBB(d0 - (double) f, d1, d2 - (double) f, d0 + (double) f, d1 + (double) f1, d2 + (double) f));
|
||||
|
@ -115,7 +125,7 @@
|
|||
}
|
||||
|
||||
public void tick() {
|
||||
@@ -234,6 +319,15 @@
|
||||
@@ -234,6 +322,15 @@
|
||||
this.entityBaseTick();
|
||||
}
|
||||
|
||||
|
@ -131,7 +141,7 @@
|
|||
public void entityBaseTick() {
|
||||
this.world.getMethodProfiler().enter("entityBaseTick");
|
||||
if (this.isPassenger() && this.getVehicle().dead) {
|
||||
@@ -250,7 +344,7 @@
|
||||
@@ -250,7 +347,7 @@
|
||||
this.lastZ = this.locZ;
|
||||
this.lastPitch = this.pitch;
|
||||
this.lastYaw = this.yaw;
|
||||
|
@ -140,7 +150,7 @@
|
|||
this.az();
|
||||
this.m();
|
||||
if (this.world.isClientSide) {
|
||||
@@ -300,12 +394,44 @@
|
||||
@@ -300,12 +397,44 @@
|
||||
|
||||
protected void burnFromLava() {
|
||||
if (!this.isFireProof()) {
|
||||
|
@ -186,7 +196,7 @@
|
|||
int j = i * 20;
|
||||
|
||||
if (this instanceof EntityLiving) {
|
||||
@@ -401,6 +527,28 @@
|
||||
@@ -401,6 +530,28 @@
|
||||
block1.a((IBlockAccess) this.world, this);
|
||||
}
|
||||
|
||||
|
@ -215,7 +225,7 @@
|
|||
if (this.playStepSound() && (!this.onGround || !this.isSneaking() || !(this instanceof EntityHuman)) && !this.isPassenger()) {
|
||||
double d0 = vec3d1.x;
|
||||
double d1 = vec3d1.y;
|
||||
@@ -454,7 +602,14 @@
|
||||
@@ -454,7 +605,14 @@
|
||||
if (!flag) {
|
||||
++this.fireTicks;
|
||||
if (this.fireTicks == 0) {
|
||||
|
@ -231,7 +241,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -565,7 +720,7 @@
|
||||
@@ -565,7 +723,7 @@
|
||||
VoxelShape voxelshape = this.world.getWorldBorder().a();
|
||||
Stream<VoxelShape> stream = VoxelShapes.c(voxelshape, VoxelShapes.a(axisalignedbb.shrink(1.0E-7D)), OperatorBoolean.AND) ? Stream.empty() : Stream.of(voxelshape);
|
||||
AxisAlignedBB axisalignedbb1 = axisalignedbb.a(vec3d).g(1.0E-7D);
|
||||
|
@ -240,7 +250,7 @@
|
|||
return !this.x(entity);
|
||||
}).flatMap((entity) -> {
|
||||
return Stream.of(entity.ap(), this.j(entity));
|
||||
@@ -649,6 +804,7 @@
|
||||
@@ -649,6 +807,7 @@
|
||||
this.locX = (axisalignedbb.minX + axisalignedbb.maxX) / 2.0D;
|
||||
this.locY = axisalignedbb.minY;
|
||||
this.locZ = (axisalignedbb.minZ + axisalignedbb.maxZ) / 2.0D;
|
||||
|
@ -248,7 +258,7 @@
|
|||
}
|
||||
|
||||
protected SoundEffect getSoundSwim() {
|
||||
@@ -820,7 +976,7 @@
|
||||
@@ -820,7 +979,7 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -257,7 +267,7 @@
|
|||
if (!this.isFireProof()) {
|
||||
this.damageEntity(DamageSource.FIRE, (float) i);
|
||||
}
|
||||
@@ -1053,6 +1209,13 @@
|
||||
@@ -1053,6 +1212,13 @@
|
||||
}
|
||||
|
||||
public void spawnIn(World world) {
|
||||
|
@ -271,7 +281,7 @@
|
|||
this.world = world;
|
||||
}
|
||||
|
||||
@@ -1078,6 +1241,7 @@
|
||||
@@ -1078,6 +1244,7 @@
|
||||
this.lastYaw -= 360.0F;
|
||||
}
|
||||
|
||||
|
@ -279,7 +289,7 @@
|
|||
this.setPosition(this.locX, this.locY, this.locZ);
|
||||
this.setYawPitch(f, f1);
|
||||
}
|
||||
@@ -1246,7 +1410,7 @@
|
||||
@@ -1246,7 +1413,7 @@
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
String s = this.getSaveID();
|
||||
|
||||
|
@ -288,7 +298,7 @@
|
|||
nbttagcompound.setString("id", s);
|
||||
this.save(nbttagcompound);
|
||||
return true;
|
||||
@@ -1265,6 +1429,18 @@
|
||||
@@ -1265,6 +1432,18 @@
|
||||
Vec3D vec3d = this.getMot();
|
||||
|
||||
nbttagcompound.set("Motion", this.a(vec3d.x, vec3d.y, vec3d.z));
|
||||
|
@ -307,7 +317,7 @@
|
|||
nbttagcompound.set("Rotation", this.a(this.yaw, this.pitch));
|
||||
nbttagcompound.setFloat("FallDistance", this.fallDistance);
|
||||
nbttagcompound.setShort("Fire", (short) this.fireTicks);
|
||||
@@ -1274,6 +1450,12 @@
|
||||
@@ -1274,6 +1453,12 @@
|
||||
nbttagcompound.setBoolean("Invulnerable", this.invulnerable);
|
||||
nbttagcompound.setInt("PortalCooldown", this.portalCooldown);
|
||||
nbttagcompound.a("UUID", this.getUniqueID());
|
||||
|
@ -320,7 +330,7 @@
|
|||
IChatBaseComponent ichatbasecomponent = this.getCustomName();
|
||||
|
||||
if (ichatbasecomponent != null) {
|
||||
@@ -1331,6 +1513,11 @@
|
||||
@@ -1331,6 +1516,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -332,7 +342,7 @@
|
|||
return nbttagcompound;
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.a(throwable, "Saving entity NBT");
|
||||
@@ -1414,6 +1601,42 @@
|
||||
@@ -1414,6 +1604,42 @@
|
||||
} else {
|
||||
throw new IllegalStateException("Entity has invalid position");
|
||||
}
|
||||
|
@ -375,7 +385,7 @@
|
|||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT");
|
||||
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded");
|
||||
@@ -1489,9 +1712,22 @@
|
||||
@@ -1489,9 +1715,22 @@
|
||||
} else if (this.world.isClientSide) {
|
||||
return null;
|
||||
} else {
|
||||
|
@ -398,7 +408,7 @@
|
|||
this.world.addEntity(entityitem);
|
||||
return entityitem;
|
||||
}
|
||||
@@ -1595,7 +1831,7 @@
|
||||
@@ -1595,7 +1834,7 @@
|
||||
}
|
||||
|
||||
this.vehicle = entity;
|
||||
|
@ -407,7 +417,7 @@
|
|||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1620,15 +1856,36 @@
|
||||
@@ -1620,15 +1859,36 @@
|
||||
Entity entity = this.vehicle;
|
||||
|
||||
this.vehicle = null;
|
||||
|
@ -446,7 +456,7 @@
|
|||
if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.getRidingPassenger() instanceof EntityHuman)) {
|
||||
this.passengers.add(0, entity);
|
||||
} else {
|
||||
@@ -1636,15 +1893,33 @@
|
||||
@@ -1636,15 +1896,33 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -481,7 +491,7 @@
|
|||
}
|
||||
|
||||
protected boolean q(Entity entity) {
|
||||
@@ -1687,11 +1962,17 @@
|
||||
@@ -1687,11 +1965,17 @@
|
||||
int i = this.ab();
|
||||
|
||||
if (this.ai) {
|
||||
|
@ -501,7 +511,7 @@
|
|||
this.world.getMethodProfiler().exit();
|
||||
}
|
||||
|
||||
@@ -1771,6 +2052,13 @@
|
||||
@@ -1771,6 +2055,13 @@
|
||||
}
|
||||
|
||||
public void setSwimming(boolean flag) {
|
||||
|
@ -515,7 +525,7 @@
|
|||
this.setFlag(4, flag);
|
||||
}
|
||||
|
||||
@@ -1831,16 +2119,56 @@
|
||||
@@ -1831,16 +2122,56 @@
|
||||
}
|
||||
|
||||
public void setAirTicks(int i) {
|
||||
|
@ -575,7 +585,7 @@
|
|||
}
|
||||
|
||||
public void j(boolean flag) {
|
||||
@@ -1988,20 +2316,33 @@
|
||||
@@ -1988,20 +2319,33 @@
|
||||
|
||||
@Nullable
|
||||
public Entity a(DimensionManager dimensionmanager) {
|
||||
|
@ -612,7 +622,7 @@
|
|||
if (dimensionmanager1 == DimensionManager.THE_END && dimensionmanager == DimensionManager.OVERWORLD) {
|
||||
blockposition = worldserver1.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver1.getSpawn());
|
||||
} else if (dimensionmanager == DimensionManager.THE_END) {
|
||||
@@ -2039,6 +2380,25 @@
|
||||
@@ -2039,6 +2383,25 @@
|
||||
vec3d = shapedetector_c.b;
|
||||
f = (float) shapedetector_c.c;
|
||||
}
|
||||
|
@ -638,7 +648,7 @@
|
|||
|
||||
this.world.getMethodProfiler().exitEnter("reloading");
|
||||
Entity entity = this.getEntityType().a((World) worldserver1);
|
||||
@@ -2048,6 +2408,14 @@
|
||||
@@ -2048,6 +2411,14 @@
|
||||
entity.setPositionRotation(blockposition, entity.yaw + f, entity.pitch);
|
||||
entity.setMot(vec3d);
|
||||
worldserver1.addEntityTeleport(entity);
|
||||
|
@ -653,7 +663,7 @@
|
|||
}
|
||||
|
||||
this.dead = true;
|
||||
@@ -2239,7 +2607,26 @@
|
||||
@@ -2239,7 +2610,26 @@
|
||||
}
|
||||
|
||||
public void a(AxisAlignedBB axisalignedbb) {
|
||||
|
|
|
@ -150,6 +150,7 @@ import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer;
|
|||
import org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry;
|
||||
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
import org.bukkit.craftbukkit.util.CraftVector;
|
||||
import org.bukkit.entity.Pose;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
|
@ -893,6 +894,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|||
return persistentDataContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pose getPose() {
|
||||
return Pose.values()[getHandle().Z().ordinal()];
|
||||
}
|
||||
|
||||
public void storeBukkitValues(NBTTagCompound c) {
|
||||
if (!this.persistentDataContainer.isEmpty()) {
|
||||
c.set("BukkitValues", this.persistentDataContainer.toTagCompound());
|
||||
|
|
Loading…
Reference in a new issue