public void setCustomName(String name) { if (!(getHandle() instanceof EntityInsentient)) { return; } if (name == null) { name = ""; } // Names cannot be more than 64 characters due to DataWatcher limitations if (name.length() > 64) { name = name.substring(0, 64); } ((EntityInsentient) getHandle()).setCustomName(name); }
public boolean setLeashHolder(Entity holder) { if ((getHandle() instanceof EntityWither) || !(getHandle() instanceof EntityInsentient)) { return false; } if (holder == null) { return unleash(); } if (holder.isDead()) { return false; } unleash(); ((EntityInsentient) getHandle()).setLeashHolder(((CraftEntity) holder).getHandle(), true); return true; }
@Override public FilterState evaluate(final Object... objects) { boolean abstain = true; for (Object object : objects) { if (object instanceof Entity) { if (((CraftEntity)object).getHandle() instanceof EntityInsentient) { return allow ? FilterState.ALLOW : FilterState.DENY; } abstain = false; } } if (abstain) { return (getParent() == null ? ABSTAIN : getParent().evaluate(objects)); } return allow ? FilterState.DENY : FilterState.ALLOW; }
public CraftLivingEntity(final CraftServer server, final EntityLiving entity) { super(server, entity); if (entity instanceof EntityInsentient) { equipment = new CraftEntityEquipment(this); } }
public String getCustomName() { if (!(getHandle() instanceof EntityInsentient)) { return null; } String name = ((EntityInsentient) getHandle()).getCustomName(); if (name == null || name.length() == 0) { return null; } return name; }
private boolean unleash() { if (!isLeashed()) { return false; } ((EntityInsentient) getHandle()).unleash(true, false); return true; }
/** * EntityTameEvent */ public static EntityTameEvent callEntityTameEvent(EntityInsentient entity, EntityHuman tamer) { org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity(); org.bukkit.entity.AnimalTamer bukkitTamer = (tamer != null ? tamer.getBukkitEntity() : null); CraftServer craftServer = (CraftServer) bukkitEntity.getServer(); entity.persistent = true; EntityTameEvent event = new EntityTameEvent((LivingEntity) bukkitEntity, bukkitTamer); craftServer.getPluginManager().callEvent(event); return event; }
public CraftLivingEntity(final CraftServer server, final EntityLiving entity) { super(server, entity); if (entity instanceof EntityInsentient || entity instanceof EntityArmorStand) { equipment = new CraftEntityEquipment(this); } }
@Override public FilterState evaluate(Object... objects) { for (Object object : objects) { if (object instanceof Entity) { if (((CraftEntity)object).getHandle() instanceof EntityInsentient && mobType.equals(((CraftEntity) object).getType())) return ALLOW; else return DENY; } } return (getParent() == null ? ABSTAIN : getParent().evaluate(objects)); }
private void setDropChance(EnumItemSlot slot, float chance) { if (slot == EnumItemSlot.MAINHAND || slot == EnumItemSlot.OFFHAND) { ((EntityInsentient) entity.getHandle()).dropChanceHand[slot.b()] = chance - 0.1F; } else { ((EntityInsentient) entity.getHandle()).dropChanceArmor[slot.b()] = chance - 0.1F; } }
private float getDropChance(EnumItemSlot slot) { if (slot == EnumItemSlot.MAINHAND || slot == EnumItemSlot.OFFHAND) { return ((EntityInsentient) entity.getHandle()).dropChanceHand[slot.b()] + 0.1F; } else { return ((EntityInsentient) entity.getHandle()).dropChanceArmor[slot.b()] + 0.1F; } }
public boolean getRemoveWhenFarAway() { return getHandle() instanceof EntityInsentient && !((EntityInsentient) getHandle()).persistent; }
public void setRemoveWhenFarAway(boolean remove) { if (getHandle() instanceof EntityInsentient) { ((EntityInsentient) getHandle()).persistent = !remove; } }
public void setCanPickupItems(boolean pickup) { if (getHandle() instanceof EntityInsentient) { ((EntityInsentient) getHandle()).canPickUpLoot = pickup; } }
public boolean getCanPickupItems() { return getHandle() instanceof EntityInsentient && ((EntityInsentient) getHandle()).canPickUpLoot; }
public void setCustomNameVisible(boolean flag) { if (getHandle() instanceof EntityInsentient) { ((EntityInsentient) getHandle()).setCustomNameVisible(flag); } }
public boolean isCustomNameVisible() { return getHandle() instanceof EntityInsentient && ((EntityInsentient) getHandle()).getCustomNameVisible(); }
public boolean isLeashed() { if (!(getHandle() instanceof EntityInsentient)) { return false; } return ((EntityInsentient) getHandle()).getLeashHolder() != null; }
public Entity getLeashHolder() throws IllegalStateException { if (!isLeashed()) { throw new IllegalStateException("Entity not leashed"); } return ((EntityInsentient) getHandle()).getLeashHolder().getBukkitEntity(); }
private void setDropChance(int slot, float chance) { ((EntityInsentient) entity.getHandle()).dropChances[slot] = chance - 0.1F; }
private float getDropChance(int slot) { return ((EntityInsentient) entity.getHandle()).dropChances[slot] + 0.1F; }
public static PlayerUnleashEntityEvent callPlayerUnleashEntityEvent(EntityInsentient entity, EntityHuman player) { PlayerUnleashEntityEvent event = new PlayerUnleashEntityEvent(entity.getBukkitEntity(), (Player) player.getBukkitEntity()); entity.world.getServer().getPluginManager().callEvent(event); return event; }
public static PlayerLeashEntityEvent callPlayerLeashEntityEvent(EntityInsentient entity, Entity leashHolder, EntityHuman player) { PlayerLeashEntityEvent event = new PlayerLeashEntityEvent(entity.getBukkitEntity(), leashHolder.getBukkitEntity(), (Player) player.getBukkitEntity()); entity.world.getServer().getPluginManager().callEvent(event); return event; }