mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 06:20:29 +08:00
Add EntityToggleSwimEvent and isSwimming / setSwimming API
This commit is contained in:
parent
72cf620d47
commit
fe7db9d53b
@ -497,7 +497,21 @@
|
|||||||
this.passengers.remove(entity);
|
this.passengers.remove(entity);
|
||||||
entity.k = 60;
|
entity.k = 60;
|
||||||
}
|
}
|
||||||
@@ -1859,14 +2178,49 @@
|
@@ -1799,6 +2118,13 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
public void g(boolean flag) {
|
||||||
|
+ // CraftBukkit start
|
||||||
|
+ if (this.bb() != flag && this instanceof EntityLiving) {
|
||||||
|
+ if (CraftEventFactory.callToggleSwimEvent((EntityLiving) this, flag).isCancelled()) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // CraftBukkit end
|
||||||
|
this.setFlag(4, flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1859,14 +2185,49 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAirTicks(int i) {
|
public void setAirTicks(int i) {
|
||||||
@ -550,7 +564,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2035,19 +2389,76 @@
|
@@ -2035,19 +2396,76 @@
|
||||||
if (!this.world.isClientSide && !this.dead) {
|
if (!this.world.isClientSide && !this.dead) {
|
||||||
this.world.methodProfiler.a("changeDimension");
|
this.world.methodProfiler.a("changeDimension");
|
||||||
MinecraftServer minecraftserver = this.bK();
|
MinecraftServer minecraftserver = this.bK();
|
||||||
@ -630,7 +644,7 @@
|
|||||||
BlockPosition blockposition;
|
BlockPosition blockposition;
|
||||||
|
|
||||||
if (i == 1) {
|
if (i == 1) {
|
||||||
@@ -2076,12 +2487,18 @@
|
@@ -2076,12 +2494,18 @@
|
||||||
blockposition = new BlockPosition(this);
|
blockposition = new BlockPosition(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -650,7 +664,7 @@
|
|||||||
if (j == 1 && i == 1) {
|
if (j == 1 && i == 1) {
|
||||||
BlockPosition blockposition1 = worldserver1.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver1.getSpawn());
|
BlockPosition blockposition1 = worldserver1.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver1.getSpawn());
|
||||||
|
|
||||||
@@ -2089,6 +2506,7 @@
|
@@ -2089,6 +2513,7 @@
|
||||||
} else {
|
} else {
|
||||||
entity.setPositionRotation(blockposition, entity.yaw, entity.pitch);
|
entity.setPositionRotation(blockposition, entity.yaw, entity.pitch);
|
||||||
}
|
}
|
||||||
@ -658,7 +672,7 @@
|
|||||||
|
|
||||||
boolean flag = entity.attachedToPlayer;
|
boolean flag = entity.attachedToPlayer;
|
||||||
|
|
||||||
@@ -2096,13 +2514,21 @@
|
@@ -2096,13 +2521,21 @@
|
||||||
worldserver1.addEntity(entity);
|
worldserver1.addEntity(entity);
|
||||||
entity.attachedToPlayer = flag;
|
entity.attachedToPlayer = flag;
|
||||||
worldserver1.entityJoinedWorld(entity, false);
|
worldserver1.entityJoinedWorld(entity, false);
|
||||||
@ -681,7 +695,7 @@
|
|||||||
return entity;
|
return entity;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
@@ -2242,7 +2668,26 @@
|
@@ -2242,7 +2675,26 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void a(AxisAlignedBB axisalignedbb) {
|
public void a(AxisAlignedBB axisalignedbb) {
|
||||||
|
@ -469,6 +469,16 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|||||||
getHandle().setFlag(7, gliding);
|
getHandle().setFlag(7, gliding);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSwimming() {
|
||||||
|
return getHandle().bb();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSwimming(boolean swimming) {
|
||||||
|
getHandle().g(swimming);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AttributeInstance getAttribute(Attribute attribute) {
|
public AttributeInstance getAttribute(Attribute attribute) {
|
||||||
return getHandle().craftAttributes.getAttribute(attribute);
|
return getHandle().craftAttributes.getAttribute(attribute);
|
||||||
|
@ -1015,6 +1015,12 @@ public class CraftEventFactory {
|
|||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static EntityToggleSwimEvent callToggleSwimEvent(EntityLiving entity, boolean swimming) {
|
||||||
|
EntityToggleSwimEvent event = new EntityToggleSwimEvent((LivingEntity) entity.getBukkitEntity(), swimming);
|
||||||
|
entity.world.getServer().getPluginManager().callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
public static AreaEffectCloudApplyEvent callAreaEffectCloudApplyEvent(EntityAreaEffectCloud cloud, List<LivingEntity> entities) {
|
public static AreaEffectCloudApplyEvent callAreaEffectCloudApplyEvent(EntityAreaEffectCloud cloud, List<LivingEntity> entities) {
|
||||||
AreaEffectCloudApplyEvent event = new AreaEffectCloudApplyEvent((AreaEffectCloud) cloud.getBukkitEntity(), entities);
|
AreaEffectCloudApplyEvent event = new AreaEffectCloudApplyEvent((AreaEffectCloud) cloud.getBukkitEntity(), entities);
|
||||||
cloud.world.getServer().getPluginManager().callEvent(event);
|
cloud.world.getServer().getPluginManager().callEvent(event);
|
||||||
|
Loading…
Reference in New Issue
Block a user