Idea pass on model generation

This commit is contained in:
modmuss50 2019-03-01 21:42:56 +00:00
parent 001dd9ac74
commit 046fcba860
3 changed files with 88 additions and 3 deletions

View file

@ -5,7 +5,6 @@ import org.gradle.api.tasks.TaskAction;
import techreborn.build.model.ModelBuilder;
import java.io.File;
public class GenerateResourcesTask extends DefaultTask {
private File outputDir;
@ -13,11 +12,37 @@ public class GenerateResourcesTask extends DefaultTask {
@TaskAction
public void run(){
System.out.println("Generating Resources for " + getProject().getName());
ModelBuilder modelBuilder = new ModelBuilder(outputDir)
.model("techreborn:grdiner")
new ModelBuilder(outputDir)
.model("techreborn:grinder")
.machine(texture -> {
texture.top_on = "techreborn:block/machines/tier1_machines/grinder_top_on";
texture.front_on = "techreborn:block/machines/tier1_machines/grinder_front_on";
texture.side_on = "techreborn:block/machines/tier1_machines/machine_side";
texture.top_off = "techreborn:block/machines/tier1_machines/grinder_top_off";
texture.front_off = "techreborn:block/machines/tier1_machines/grinder_front_off";
texture.side_off = "techreborn:block/machines/tier1_machines/machine_side";
})
.build()
.model("techreborn:alloy_smelter")
.machine(texture -> {
texture.top_on = "techreborn:blocks/machines/tier1_machines/machine_top";
texture.front_on = "techreborn:blocks/machines/tier1_machines/electric_alloy_smelter_front_on";
texture.side_on = "techreborn:blocks/machines/tier1_machines/machine_side";
texture.bottom_on = "techreborn:blocks/machines/tier1_machines/machine_bottom";
texture.front_off = "techreborn:blocks/machines/tier1_machines/electric_alloy_smelter_front_off";
//TODO possibly not have to do this
texture.top_off = texture.top_on;
texture.side_off = texture.side_on;
texture.bottom_off = texture.bottom_on;
})
.build()
//Generates the json files
.generate();
}

View file

@ -0,0 +1,48 @@
package techreborn.build.model;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
public class MachineModelBuilder {
private ModelBuilder.Model model;
Consumer<MachineTextures> textureConsumer;
MachineModelBuilder(ModelBuilder.Model model, Consumer<MachineTextures> textureConsumer) {
this.model = model;
this.textureConsumer = textureConsumer;
}
public List<ModelBuilder.Component> getComponents(){
//Loads the textures in
MachineTextures textures = new MachineTextures(this);
textureConsumer.accept(textures);
return Collections.emptyList();
}
public static class MachineTextures {
MachineModelBuilder modelBuilder;
public String top_off;
public String top_on;
public String front_off;
public String front_on;
public String side_off;
public String side_on;
public String bottom_off;
public String bottom_on;
public MachineTextures(MachineModelBuilder modelBuilder) {
this.modelBuilder = modelBuilder;
}
}
}

View file

@ -3,6 +3,7 @@ package techreborn.build.model;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
public class ModelBuilder {
@ -27,14 +28,25 @@ public class ModelBuilder {
public static class Model {
String name;
ModelBuilder modelBuilder;
List<Component> components = new ArrayList<>();
private Model(String name, ModelBuilder modelBuilder) {
this.name = name;
this.modelBuilder = modelBuilder;
}
public Model machine(Consumer<MachineModelBuilder.MachineTextures> textureConsumer){
components.addAll(new MachineModelBuilder(this, textureConsumer).getComponents());
return this;
}
public ModelBuilder build(){
return modelBuilder;
}
}
public static abstract class Component {
}
}