下面列出了怎么用org.bukkit.entity.MushroomCow的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public boolean checkTrait(Entity original, Entity nearby) {
if (original instanceof MushroomCow) {
return ((MushroomCow) original).getVariant() != ((MushroomCow) nearby).getVariant();
}
return false;
}
@Override
public void applyTrait(Entity original, Entity spawned) {
if (original instanceof MushroomCow) {
((MushroomCow) spawned).setVariant(((MushroomCow) original).getVariant());
}
}
@Override
protected boolean init(@Nullable Class<? extends MushroomCow> c, @Nullable MushroomCow mushroomCow) {
if (mushroomCow != null)
variant = mushroomCow.getVariant();
return true;
}
@Override
public void set(MushroomCow entity) {
if (variant != null)
entity.setVariant(variant);
}
@Override
protected boolean match(MushroomCow entity) {
return variant == null || variant == entity.getVariant();
}
@Override
public Class<? extends MushroomCow> getType() {
return MushroomCow.class;
}
@EventHandler
public void onShear(PlayerShearEntityEvent event) {
if (event.getEntity() instanceof MushroomCow && EntityTracker.isSuperMob(event.getEntity())) {
MushroomCow mushroomCow = (MushroomCow) event.getEntity();
ItemStack mushroomStack = new ItemStack(RED_MUSHROOM, 5);
for (int i = 0; i < 50; i++) {
mushroomCow.getWorld().dropItem(mushroomCow.getLocation(), mushroomStack).setVelocity(ItemDropVelocity.ItemDropVelocity());
}
}
}