
The previous layout and class hierarchy of the skeleton API defined variances of the skeleton, such as the wither skeleton or the stray, as child types of the normal skeleton variance, which is technically incorrect, yet did not produce any specific issue as the normal skeleton variance did not have any unique logic. With the introduction of powdered snow in the 1.17 update, the normal skeleton variance now has unique logic, specifically the conversion to a stay when stuck inside powdered snow, which cannot be represented in the current API layout due to the prior mentioned hierarchy. This commit implements the hierarchy changes made in the bukkit repository by representing the new hierarchy on the craftbukkit side through the CraftAbstractSkeleton and the respective additions to the skeleton implementation in regards to the stray conversion. This commit does not break ABI yet breaks backwards compatibility due to the mentioned hierarchy changes. Plugins that previously used the Skelton interface to compute whether or not an entity is skeleton-like through instanceOf checks will now only match the normal skeleton variance instead of any skeleton-like entity.
57 lines
1.5 KiB
Java
57 lines
1.5 KiB
Java
package org.bukkit.craftbukkit.entity;
|
|
|
|
import com.google.common.base.Preconditions;
|
|
import net.minecraft.world.entity.monster.EntitySkeleton;
|
|
import net.minecraft.world.entity.monster.EntitySkeletonAbstract;
|
|
import org.bukkit.craftbukkit.CraftServer;
|
|
import org.bukkit.entity.EntityType;
|
|
import org.bukkit.entity.Skeleton;
|
|
|
|
public class CraftSkeleton extends CraftAbstractSkeleton implements Skeleton {
|
|
|
|
public CraftSkeleton(CraftServer server, EntitySkeleton entity) {
|
|
super(server, entity);
|
|
}
|
|
|
|
@Override
|
|
public boolean isConverting() {
|
|
return this.getHandle().fw(); // PAIL rename isStrayConverting
|
|
}
|
|
|
|
@Override
|
|
public int getConversionTime() {
|
|
Preconditions.checkState(this.isConverting(), "Entity is not converting");
|
|
return this.getHandle().conversionTime;
|
|
}
|
|
|
|
@Override
|
|
public void setConversionTime(int time) {
|
|
if (time < 0) {
|
|
this.getHandle().conversionTime = -1;
|
|
this.getHandle().getDataWatcher().set(EntitySkeleton.DATA_STRAY_CONVERSION_ID, false);
|
|
} else {
|
|
this.getHandle().a(time); // PAIL rename startStrayConversion
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public EntitySkeleton getHandle() {
|
|
return (EntitySkeleton) entity;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "CraftSkeleton";
|
|
}
|
|
|
|
@Override
|
|
public EntityType getType() {
|
|
return EntityType.SKELETON;
|
|
}
|
|
|
|
@Override
|
|
public SkeletonType getSkeletonType() {
|
|
return SkeletonType.NORMAL;
|
|
}
|
|
}
|