use of net.minecraft.block.entity.BlockEntityType in project meteor-client by MeteorDevelopment.
the class StorageBlockListSetting method parseImpl.
@Override
protected List<BlockEntityType<?>> parseImpl(String str) {
String[] values = str.split(",");
List<BlockEntityType<?>> blocks = new ArrayList<>(values.length);
try {
for (String value : values) {
BlockEntityType<?> block = parseId(Registry.BLOCK_ENTITY_TYPE, value);
if (block != null)
blocks.add(block);
}
} catch (Exception ignored) {
}
return blocks;
}
use of net.minecraft.block.entity.BlockEntityType in project Client by MatHax.
the class StorageBlockListSetting method parseImpl.
@Override
protected List<BlockEntityType<?>> parseImpl(String str) {
String[] values = str.split(",");
List<BlockEntityType<?>> blocks = new ArrayList<>(values.length);
try {
for (String value : values) {
BlockEntityType<?> block = parseId(Registry.BLOCK_ENTITY_TYPE, value);
if (block != null)
blocks.add(block);
}
} catch (Exception ignored) {
}
return blocks;
}
use of net.minecraft.block.entity.BlockEntityType in project cem by dorianpb.
the class EntityModelLoaderMixin method loadResourceFromId.
private void loadResourceFromId(ResourceManager manager, Identifier id, String namespace) {
if (!id.getNamespace().equals(namespace)) {
return;
}
CemFairy.getLogger().info(id.toString());
try (InputStream stream = manager.getResource(id).getInputStream()) {
// initialize the file
@SuppressWarnings("unchecked") LinkedTreeMap<String, Object> json = CemFairy.getGson().fromJson(new InputStreamReader(stream, StandardCharsets.UTF_8), LinkedTreeMap.class);
if (json == null) {
throw new Exception("Invalid File");
}
JemFile file = new JemFile(json, id, manager);
String entityName = CemFairy.getEntityNameFromId(id);
Optional<EntityType<?>> entityTypeOptional = EntityType.get(entityName);
Optional<BlockEntityType<?>> blockEntityTypeOptional = Registry.BLOCK_ENTITY_TYPE.getOrEmpty(Identifier.tryParse(entityName));
if (entityTypeOptional.isPresent()) {
EntityType<? extends Entity> entityType = entityTypeOptional.get();
if (CemFairy.isUnsupported(entityType)) {
throw new Exception("Entity \"" + EntityType.getId(entityType) + "\" is unsupported!");
}
CemRegistryManager.addRegistry(entityType, file);
} else if (blockEntityTypeOptional.isPresent()) {
BlockEntityType<? extends BlockEntity> entityType = blockEntityTypeOptional.get();
if (CemFairy.isUnsupported(entityType)) {
throw new Exception("Block Entity \"" + BlockEntityType.getId(entityType) + "\" is unsupported!");
}
CemRegistryManager.addRegistry(entityType, file);
} else {
if (CemFairy.isUnsupported(entityName)) {
throw new Exception("Unknown object \"" + entityName + "\"!");
} else {
CemRegistryManager.addRegistry(entityName, file);
}
}
} catch (Exception exception) {
CemFairy.getLogger().error("Error parsing " + id + ":");
String message = exception.getMessage();
CemFairy.getLogger().error(exception);
if (message == null || message.trim().equals("")) {
CemFairy.getLogger().error(exception.getStackTrace()[0]);
CemFairy.getLogger().error(exception.getStackTrace()[1]);
CemFairy.getLogger().error(exception.getStackTrace()[2]);
}
}
}
Aggregations