use of com.lowdragmc.multiblocked.api.definition.PartDefinition in project Multiblocked by Low-Drag-MC.
the class PartScriptWidget method loadJson.
private void loadJson(ClickData clickData) {
if (selected != null && clickData.isRemote) {
JsonElement jsonElement = FileUtility.loadJson(selected);
if (jsonElement != null) {
try {
PartDefinition definition = Multiblocked.GSON.fromJson(jsonElement, PartDefinition.class);
part.setDefinition(definition);
MbdComponents.TEST_DEFINITION_REGISTRY.put(definition.location, definition);
writeClientAction(-1, buffer -> buffer.writeUtf(definition.location.toString()));
} catch (Exception e) {
Multiblocked.LOGGER.error("tester: error while loading the part json {}", selected.getName(), e);
}
textBox.setContent(Collections.singletonList(Multiblocked.GSON_PRETTY.toJson(jsonElement)));
tfGroup.computeMax();
}
}
}
use of com.lowdragmc.multiblocked.api.definition.PartDefinition in project Multiblocked by Low-Drag-MC.
the class MbdCapabilities method registerAnyCapabilityBlocks.
public static void registerAnyCapabilityBlocks() {
for (MultiblockCapability<?> capability : MbdCapabilities.CAPABILITY_REGISTRY.values()) {
ComponentDefinition definition = new PartDefinition(new ResourceLocation(Multiblocked.MODID, capability.name + ".any"));
definition.properties.isOpaque = false;
definition.properties.tabGroup = null;
definition.allowRotate = false;
definition.showInJei = false;
MbdComponents.registerComponent(definition);
}
}
use of com.lowdragmc.multiblocked.api.definition.PartDefinition in project Multiblocked by Low-Drag-MC.
the class PartBuilderWidget method updateList.
protected void updateList() {
setNewRenderer(null, "");
files.forEach(containers::waitToRemoved);
files.clear();
File path = new File(Multiblocked.location, "definition/part");
walkFile("Common", new ItemStackTexture(BlueprintTableTileEntity.partDefinition.getStackForm()), path, (jsonElement, file) -> {
PartDefinition definition = Multiblocked.GSON.fromJson(jsonElement, PartDefinition.class);
new PartWidget(this, definition, jsonObject -> {
if (jsonObject != null) {
FileUtility.saveJson(file, jsonObject);
}
});
});
if (Multiblocked.isCreateLoaded()) {
path = new File(path, "create");
walkFile("Create", new ItemStackTexture(AllBlocks.FLYWHEEL.asStack()), path, ((jsonElement, file) -> {
CreatePartDefinition definition = Multiblocked.GSON.fromJson(jsonElement, CreatePartDefinition.class);
new CreatePartWidget(this, definition, jsonObject -> {
if (jsonObject != null) {
FileUtility.saveJson(file, jsonObject);
}
});
}));
}
}
use of com.lowdragmc.multiblocked.api.definition.PartDefinition in project Multiblocked by Low-Drag-MC.
the class PartBuilderWidget method setNewRenderer.
private void setNewRenderer(IMultiblockedRenderer newRenderer, String type) {
PartDefinition definition = new PartDefinition(new ResourceLocation(Multiblocked.MODID, "i_renderer"));
definition.baseRenderer = newRenderer;
tileEntity.setDefinition(definition);
textTexture.updateText(type);
}
use of com.lowdragmc.multiblocked.api.definition.PartDefinition in project Multiblocked by Low-Drag-MC.
the class TemplateBuilderWidget method getComponentDefinition.
public static ComponentDefinition getComponentDefinition(ComponentDefinition definition, Set<BlockInfo> candidates) {
if (candidates.size() == 1) {
definition = new PartDefinition(new ResourceLocation(Multiblocked.MODID, "i_renderer"));
definition.baseRenderer = new MBDBlockStateRenderer(candidates.toArray(new BlockInfo[0])[0]);
} else if (!candidates.isEmpty()) {
definition = new PartDefinition(new ResourceLocation(Multiblocked.MODID, "i_renderer"));
definition.baseRenderer = new CycleBlockStateRenderer(candidates.toArray(new BlockInfo[0]));
}
return definition;
}
Aggregations