#1468: Expand riptiding API

By: ShreyasAyyengar <shreyas.ayyengar@gmail.com>
This commit is contained in:
CraftBukkit/Spigot 2024-09-07 18:08:13 +10:00
parent 106225f127
commit 7657f347d2
3 changed files with 36 additions and 6 deletions

View File

@ -33,6 +33,15 @@
public abstract class EntityLiving extends Entity implements Attackable {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -157,7 +183,7 @@
private static final double MAX_LINE_OF_SIGHT_TEST_RANGE = 128.0D;
protected static final int LIVING_ENTITY_FLAG_IS_USING = 1;
protected static final int LIVING_ENTITY_FLAG_OFF_HAND = 2;
- protected static final int LIVING_ENTITY_FLAG_SPIN_ATTACK = 4;
+ public static final int LIVING_ENTITY_FLAG_SPIN_ATTACK = 4;
protected static final DataWatcherObject<Byte> DATA_LIVING_ENTITY_FLAGS = DataWatcher.defineId(EntityLiving.class, DataWatcherRegistry.BYTE);
public static final DataWatcherObject<Float> DATA_HEALTH_ID = DataWatcher.defineId(EntityLiving.class, DataWatcherRegistry.FLOAT);
private static final DataWatcherObject<List<ParticleParam>> DATA_EFFECT_PARTICLES = DataWatcher.defineId(EntityLiving.class, DataWatcherRegistry.PARTICLES);
@@ -249,6 +275,19 @@
protected boolean skipDropExperience;
private final Reference2ObjectMap<Enchantment, Set<EnchantmentLocationBasedEffect>> activeLocationDependentEnchantments;
@ -1008,7 +1017,7 @@
this.setSharedFlag(7, flag);
}
@@ -3141,14 +3634,21 @@
@@ -3141,13 +3634,20 @@
@Override
public boolean isPickable() {
@ -1020,18 +1029,26 @@
public boolean isPushable() {
- return this.isAlive() && !this.isSpectator() && !this.onClimbable();
+ return this.isAlive() && !this.isSpectator() && !this.onClimbable() && this.collides; // CraftBukkit
}
+ }
+
+ // CraftBukkit start - collidable API
+ @Override
+ public boolean canCollideWithBukkit(Entity entity) {
+ return isPushable() && this.collides != this.collidableExemptions.contains(entity.getUUID());
+ }
}
+ // CraftBukkit end
+
@Override
public float getYHeadRot() {
return this.yHeadRot;
@@ -3245,7 +3745,7 @@
}
- protected void setLivingEntityFlag(int i, boolean flag) {
+ public void setLivingEntityFlag(int i, boolean flag) {
int j = (Byte) this.entityData.get(EntityLiving.DATA_LIVING_ENTITY_FLAGS);
if (flag) {
@@ -3346,7 +3846,26 @@
} else {
if (!this.useItem.isEmpty() && this.isUsingItem()) {

View File

@ -160,6 +160,14 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
getHandle().stopSleepInBed(true, setSpawnLocation);
}
@Override
public void startRiptideAttack(int duration, float damage, ItemStack attackItem) {
Preconditions.checkArgument(duration > 0, "Duration must be greater than 0");
Preconditions.checkArgument(damage >= 0, "Damage must not be negative");
getHandle().startAutoSpinAttack(duration, damage, CraftItemStack.asNMSCopy(attackItem));
}
@Override
public Location getBedLocation() {
Preconditions.checkState(isSleeping(), "Not sleeping");

View File

@ -656,6 +656,11 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
return getHandle().isAutoSpinAttack();
}
@Override
public void setRiptiding(boolean riptiding) {
getHandle().setLivingEntityFlag(EntityLiving.LIVING_ENTITY_FLAG_SPIN_ATTACK, riptiding);
}
@Override
public boolean isSleeping() {
return getHandle().isSleeping();