Fix inconsistencies with model/blockstate datagen

This commit is contained in:
tterrag committed 2020-07-18 18:34:35 -04:00
1 parent 96b9a057b7
commit a3edfd3748
54 files changed
+247 -146

No files matched your search

@@ -35,6 +35,7 @@ import org.apache.logging.log4j.Logger;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
@@ -54,9 +55,11 @@ import net.minecraft.block.SlabBlock;
import net.minecraft.block.StairsBlock;
import net.minecraft.block.TrapDoorBlock;
import net.minecraft.block.WallBlock;
import net.minecraft.block.WallHeight;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.DirectoryCache;
import net.minecraft.data.IDataProvider;
import net.minecraft.state.Property;
import net.minecraft.state.properties.AttachFace;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.state.properties.DoorHingeSide;
@@ -202,17 +205,17 @@ public abstract class BlockStateProvider implements IDataProvider {
}
public void axisBlock(RotatedPillarBlock block, ResourceLocation side, ResourceLocation end) {
axisBlock(block, models().cubeColumn(name(block), side, end));
axisBlock(block, models().cubeColumn(name(block), side, end), models().cubeColumnHorizontal(name(block) + "_horizontal", side, end));
}
public void axisBlock(RotatedPillarBlock block, ModelFile model) {
public void axisBlock(RotatedPillarBlock block, ModelFile vertical, ModelFile horizontal) {
getVariantBuilder(block)
.partialState().with(RotatedPillarBlock.AXIS, Axis.Y)
.modelForState().modelFile(model).addModel()
.modelForState().modelFile(vertical).addModel()
.partialState().with(RotatedPillarBlock.AXIS, Axis.Z)
.modelForState().modelFile(model).rotationX(90).addModel()
.modelForState().modelFile(horizontal).rotationX(90).addModel()
.partialState().with(RotatedPillarBlock.AXIS, Axis.X)
.modelForState().modelFile(model).rotationX(90).rotationY(90).addModel();
.modelForState().modelFile(horizontal).rotationX(90).rotationY(90).addModel();
}
private static final int DEFAULT_ANGLE_OFFSET = 180;
@@ -417,14 +420,35 @@ public abstract class BlockStateProvider implements IDataProvider {
}
private void wallBlockInternal(WallBlock block, String baseName, ResourceLocation texture) {
wallBlock(block, models().wallPost(baseName + "_post", texture), models().wallSide(baseName + "_side", texture));
wallBlock(block, models().wallPost(baseName + "_post", texture), models().wallSide(baseName + "_side", texture), models().wallSideTall(baseName + "_side_tall", texture));
}
public static final ImmutableMap<Direction, Property<WallHeight>> WALL_PROPS = ImmutableMap.<Direction, Property<WallHeight>>builder()
.put(Direction.EAST, BlockStateProperties.field_235908_S_)
.put(Direction.NORTH, BlockStateProperties.field_235909_T_)
.put(Direction.SOUTH, BlockStateProperties.field_235910_U_)
.put(Direction.WEST, BlockStateProperties.field_235911_V_)
.build();
public void wallBlock(WallBlock block, ModelFile post, ModelFile side) {
public void wallBlock(WallBlock block, ModelFile post, ModelFile side, ModelFile sideTall) {
MultiPartBlockStateBuilder builder = getMultipartBuilder(block)
.part().modelFile(post).addModel()
.condition(WallBlock.UP, true).end();
fourWayMultipart(builder, side);
WALL_PROPS.entrySet().stream()
.filter(e -> e.getKey().getAxis().isHorizontal())
.forEach(e -> {
wallSidePart(builder, side, e, WallHeight.LOW);
wallSidePart(builder, sideTall, e, WallHeight.TALL);
});
}
private void wallSidePart(MultiPartBlockStateBuilder builder, ModelFile model, Map.Entry<Direction, Property<WallHeight>> entry, WallHeight height) {
builder.part()
.modelFile(model)
.rotationY((((int) entry.getKey().getHorizontalAngle()) + 180) % 360)
.uvLock(true)
.addModel()
.condition(entry.getValue(), height);
}
public void paneBlock(PaneBlock block, ResourceLocation pane, ResourceLocation edge) {
@@ -92,9 +92,9 @@ public class ItemModelBuilder extends ModelBuilder<ItemModelBuilder> {
JsonObject toJson() {
JsonObject ret = new JsonObject();
JsonObject predicatesJson = new JsonObject();
predicates.forEach((key, val) -> predicatesJson.addProperty(serializeLoc(key), val));
predicates.forEach((key, val) -> predicatesJson.addProperty(key.toString(), val));
ret.add("predicate", predicatesJson);
ret.addProperty("model", serializeLoc(model.getLocation()));
ret.addProperty("model", model.getLocation().toString());
return ret;
}
}
@@ -198,7 +198,7 @@ public class ModelBuilder<T extends ModelBuilder<T>> extends ModelFile {
public JsonObject toJson() {
JsonObject root = new JsonObject();
if (this.parent != null) {
root.addProperty("parent", serializeLoc(this.parent.getLocation()));
root.addProperty("parent", this.parent.getLocation().toString());
}
if (!this.ambientOcclusion) {
@@ -296,14 +296,7 @@ public class ModelBuilder<T extends ModelBuilder<T>> extends ModelFile {
if (tex.charAt(0) == '#') {
return tex;
}
return serializeLoc(new ResourceLocation(tex));
}
String serializeLoc(ResourceLocation loc) {
if (loc.getNamespace().equals("minecraft")) {
return loc.getPath();
}
return loc.toString();
return new ResourceLocation(tex).toString();
}
private JsonArray serializeVector3f(Vector3f vec) {
@@ -173,6 +173,12 @@ public abstract class ModelProvider<T extends ModelBuilder<T>> implements IDataP
.texture("end", end);
}
public T cubeColumnHorizontal(String name, ResourceLocation side, ResourceLocation end) {
return withExistingParent(name, BLOCK_FOLDER + "/cube_column_horizontal")
.texture("side", side)
.texture("end", end);
}
public T orientableVertical(String name, ResourceLocation side, ResourceLocation front) {
return withExistingParent(name, BLOCK_FOLDER + "/orientable_vertical")
.texture("side", side)
@@ -257,6 +263,10 @@ public abstract class ModelProvider<T extends ModelBuilder<T>> implements IDataP
public T wallSide(String name, ResourceLocation wall) {
return singleTexture(name, BLOCK_FOLDER + "/template_wall_side", "wall", wall);
}
public T wallSideTall(String name, ResourceLocation wall) {
return singleTexture(name, BLOCK_FOLDER + "/template_wall_side_tall", "wall", wall);
}
public T wallInventory(String name, ResourceLocation wall) {
return singleTexture(name, BLOCK_FOLDER + "/wall_inventory", "wall", wall);
@@ -339,7 +349,7 @@ public abstract class ModelProvider<T extends ModelBuilder<T>> implements IDataP
}
public T torchWall(String name, ResourceLocation torch) {
return singleTexture(name, BLOCK_FOLDER + "/torch_wall", "torch", torch);
return singleTexture(name, BLOCK_FOLDER + "/template_torch_wall", "torch", torch);
}
public T carpet(String name, ResourceLocation wool) {