@Override public void setCreatureTypeByName(String creatureType) { EntityType type = EntityType.fromName(creatureType); if (type != null) { spawnedType = type; } }
@Deprecated public EntityType toEntityType() { return EntityType.fromName(getName()); }
@Override public boolean isValidMobType(String type) { final EntityType entityType = EntityType.fromName(type); return entityType != null && entityType.isAlive(); }
public static org.bukkit.entity.EntityType adapt(EntityType entityType) { if (!entityType.getId().startsWith("minecraft:")) { throw new IllegalArgumentException("Bukkit only supports vanilla entities"); } return org.bukkit.entity.EntityType.fromName(entityType.getId().substring(10).toLowerCase()); }
@Override void readNbt(CompoundTag tag) { super.readNbt(tag); tag.readCompound("EntityTag", entityTag -> { this.entityTag = entityTag; entityTag.readString("id", id -> { if (id.startsWith("minecraft:")) { id = id.substring("minecraft:".length()); } spawnedType = EntityType.fromName(id); }); }); }
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); } }
EntityType entityType = EntityType.fromName(statisticString.substring(statisticString.lastIndexOf(".") + 1));
return false; EntityType entityType = EntityType.fromName(type); if (entityType == null && EntityRegistry.isCustomEntityRegistered(type)) { CustomEntityDescriptor descriptor = EntityRegistry.getCustomEntityDescriptor(type);
public static EntityType creatureTypeFromEntity(Entity entity) { if (!(entity instanceof Creature)) { return null; } String name = entity.getClass().getSimpleName(); name = name.substring(5); // Remove "Craft" return EntityType.fromName(name); }
@Deprecated public EntityType toEntityType() { return EntityType.fromName(getName()); }
@Nullable @SuppressWarnings("deprecation") public static EntityType parseEntityType(String typeString) { if (typeString == null) return null; EntityType returnType = null; try { returnType = EntityType.valueOf(typeString.toUpperCase()); } catch (Exception ex) { returnType = null; } if (returnType == null) { returnType = EntityType.fromName(typeString); } return returnType; }
/** * Gets a random tree from available types * * @param fs * @return */ public static EntityType getEntity(FieldSettings fs) { Random r = new Random(); List<String> creatureTypes = fs.getCreatureTypes(); if (creatureTypes.isEmpty()) { return null; } int rand = r.nextInt(creatureTypes.size()); String entity = creatureTypes.get(rand); PreciousStones.debug("entity: " + entity); if (entity.equalsIgnoreCase("None")) { return null; } return EntityType.fromName(entity); } }
@SuppressWarnings("deprecation") @Override public EntityInfo parseEntityInfo(String json) { try { NBTTagCompound compound = MojangsonParser.parse(json); return new EntityInfo( EntityType.fromName(compound.getString("type")), UUID.fromString(compound.getString("id")), compound.getString("name") ); } catch (CommandSyntaxException e) { throw new RuntimeException(e); } }
@SuppressWarnings("deprecation") private static EntityType matchEntityType(String toMatch) { EntityType type; try { type = EntityType.valueOf(toMatch); } catch (IllegalArgumentException ex) { type = EntityType.fromName(toMatch); } if (type != null) return type; return matchEnum(EntityType.values(), toMatch); }
@Override @SuppressWarnings("deprecation") public void load(DataKey key) { try { type = EntityType.valueOf(key.getString("")); } catch (IllegalArgumentException ex) { type = EntityType.fromName(key.getString("")); } if (type == null) { type = EntityType.PLAYER; } }
return EntityType.fromName(nbtEntityID);
EntityType.fromName(distribution.getAlternate()).getEntityClass());
EntityType type = EntityType.fromName(s); if (type != null && type.equals(e.getType())) { specified = true;
type = EntityType.fromName(config.getString("type"));