@Override public String getCreatureTypeName() { return spawnedType.getName(); }
public EntityStore(Class<? extends T> type, EntityType entityType) { this.type = type; this.entityType = entityType.getName(); }
/** * Creates a new boss, whose boss-bar title is equal to its type name. * @param loc The location of the non-passive mob. * @param type The type of mob. * @param maxHealth The max health for this mob. * @param color The boss bar color. * @param style The boss bar style. * @param barFlags Flags controlling the boss bar. */ public GlowBoss(Location loc, EntityType type, double maxHealth, BarColor color, BarStyle style, BarFlag... barFlags) { this(loc, type, maxHealth, type.getName(), color, style, barFlags); }
public static CreatureType fromEntityType(EntityType creatureType) { return fromName(creatureType.getName()); } }
@Override public String getName() { return getType().getName(); }
@Override public Map<String, Object> serialize() { Map<String, Object> result = super.serialize(); result.put("meta-type", "MONSTER_EGG"); if (hasSpawnedType()) { result.put("entity-id", "minecraft:" + getSpawnedType().getName()); } return result; }
@Override public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { Preconditions.checkNotNull(sender, "Sender cannot be null"); Preconditions.checkNotNull(args, "Arguments cannot be null"); Preconditions.checkNotNull(alias, "Alias cannot be null"); if (args.length == 1) { String arg = args[0]; ArrayList<String> completion = new ArrayList<>(); for (EntityType type : EntityType.values()) { if (checkSummon(null, type.getName()) && type.getName().toLowerCase() .startsWith(arg)) { completion.add(type.getName()); } } EntityRegistry.getRegisteredCustomEntities().forEach((d) -> { if (d.getId().toLowerCase().startsWith(arg)) { completion.add(d.getId().toLowerCase()); } }); return completion; } else { return Collections.emptyList(); } } }
/** * Gets the name of an entity. * * @param entity an entity * @return the first of the following that exists and is non-empty: {@code * entity.getCustomName()}, {@code entity.getName()}, {@code * entity.getType().getName()} */ public static String getName(Entity entity) { String customName = entity.getCustomName(); if (customName != null && !customName.isEmpty()) { return customName; } String name = entity.getName(); if (name == null || name.isEmpty()) { name = entity.getType().getName(); } return name; }
@Override public void saveNbt(CompoundTag tag) { super.saveNbt(tag); tag.putString("EntityId", spawning == null ? "" : spawning.getName()); tag.putInt("Delay", delay); } }
private List<EntityType> getTypes() { if (arguments.containsKey("type")) { SelectorValue value = arguments.get("type"); if (!value.isInverted()) { EntityType type = EntityType.fromName(value.getValue()); if (type == null) { try { type = EntityType.valueOf(value.getValue().toUpperCase()); } catch (IllegalArgumentException ex) { return Collections.emptyList(); } } return Arrays.asList(type); } else { return Arrays.stream(EntityType.values()).filter(mode -> { if (mode.getName() == null) { return !mode.name().equalsIgnoreCase(value.getValue()); } return !mode.getName().equalsIgnoreCase(value.getValue()); }).collect(Collectors.toList()); } } if (selector == SelectorType.ALL_ENTITIES) { return Arrays.asList(EntityType.values()); } else { return Arrays.asList(EntityType.PLAYER); } }
CustomEntityDescriptor descriptor = EntityRegistry.getCustomEntityDescriptor(type); if (!descriptor.isSummonable()) { sender.sendMessage(ChatColor.RED + "The entity '" + entityType.getName() + "' cannot be summoned."); return false; sender.sendMessage(ChatColor.RED + "The entity '" + entityType.getName() + "' is not implemented yet."); .isAssignableFrom(EntityRegistry.getEntity(entityType)))) { if (sender != null) { sender.sendMessage(ChatColor.RED + "The entity '" + entityType.getName() + "' cannot be summoned.");
@Override void writeNbt(CompoundTag tag) { super.writeNbt(tag); CompoundTag entityTag = getEntityTag() != null ? getEntityTag() : new CompoundTag(); if (hasSpawnedType()) { entityTag.putString("id", "minecraft:" + getSpawnedType().getName()); } tag.putCompound("EntityTag", entityTag); }
@Override public void rightClickBlock(GlowPlayer player, GlowBlock target, BlockFace face, ItemStack holding, Vector clickedLoc, EquipmentSlot hand) { if (target == null || target.getType() != Material.RAILS) { return; } if (minecartType.getMinecartClass() == null) { player.sendMessage( ChatColor.RED + "Minecart type '" + minecartType.getEntityType().getName() + "' is not implemented."); return; } Rails rails = (Rails) target.getState().getData(); Location location = target.getLocation().clone() .add(Math.abs(rails.getDirection().getModX()) * 0.5, 0.1, Math.abs(rails.getDirection().getModZ()) * 0.5); location.setYaw(getYaw(rails.getDirection())); target.getWorld().spawn(location, minecartType.getEntityClass()); if (player.getGameMode() != GameMode.CREATIVE) { player.getInventory().remove(holding); } super.rightClickBlock(player, target, face, holding, clickedLoc, hand); }
public static String getName_EntityType(EntityType et) { return et.getName(); } }
public static String getName(EntityType entityType) { // @deprecated Magic value String name = entityType.getName(); return WordUtils.capitalize(name); }
public static CreatureType fromEntityType(EntityType creatureType) { return fromName(creatureType.getName()); } }
@SuppressWarnings("deprecation") @Override public int getMobTypeNetworkId(EntityType type) { return IRegistry.ENTITY_TYPE.a(EntityTypes.a(type.getName())); }
@SuppressWarnings("deprecation") protected ItemStack setDisplayName(ItemStack is, EntityType type) { ItemMeta meta = is.getItemMeta(); String displayName; if (entityToDisplayName.containsKey(type)) { displayName = entityToDisplayName.get(type); } else { displayName = type.getName(); } meta.setDisplayName(ChatColor.RESET + displayName + " Spawner"); is.setItemMeta(meta); return is; } }
public HoverAction(EntityInfo entityinfo) { this.type = Type.SHOW_ENTITY; //TODO: use nbt compound after implementing our own mojangson serializer this.value = "{type:\"" + entityinfo.getType().getName() + "\", id:\"" + entityinfo.getUUID().toString() + "\", name:\"" + entityinfo.getName() + "\"}"; }
/** * Creates a show_entity action: when the component is hovered some entity information will be displayed * * @param entity the item to display * @return a new HoverAction instance */ static HoverAction showEntity(Entity entity) { return showEntity(entity.getUniqueId(), entity.getType().getName(), entity.getName()); }