Code style fix, interface rename, custom item getter
This commit is contained in:
parent
179ada3296
commit
c6afa74529
134 changed files with 3404 additions and 1244 deletions
|
@ -23,31 +23,71 @@ public class BaseChestBlockModel {
|
|||
MeshDefinition modelData = new MeshDefinition();
|
||||
PartDefinition modelPartData = modelData.getRoot();
|
||||
CubeDeformation deformation_partC = new CubeDeformation(0.0f);
|
||||
modelPartData.addOrReplaceChild("partC", CubeListBuilder.create().texOffs(0, 19).addBox(1.0f, 0.0f, 1.0f, 14.0f, 9.0f, 14.0f, deformation_partC), PartPose.ZERO);
|
||||
modelPartData.addOrReplaceChild(
|
||||
"partC",
|
||||
CubeListBuilder.create().texOffs(0, 19).addBox(1.0f, 0.0f, 1.0f, 14.0f, 9.0f, 14.0f, deformation_partC),
|
||||
PartPose.ZERO
|
||||
);
|
||||
|
||||
CubeDeformation deformation_partA = new CubeDeformation(0.0f);
|
||||
modelPartData.addOrReplaceChild("partA", CubeListBuilder.create().texOffs(0, 0).addBox(1.0f, 0.0f, 0.0f, 14.0f, 5.0f, 14.0f, deformation_partA), PartPose.offset(0.0f, 9.0f, 1.0f));
|
||||
modelPartData.addOrReplaceChild(
|
||||
"partA",
|
||||
CubeListBuilder.create().texOffs(0, 0).addBox(1.0f, 0.0f, 0.0f, 14.0f, 5.0f, 14.0f, deformation_partA),
|
||||
PartPose.offset(0.0f, 9.0f, 1.0f)
|
||||
);
|
||||
|
||||
CubeDeformation deformation_partB = new CubeDeformation(0.0f);
|
||||
modelPartData.addOrReplaceChild("partB", CubeListBuilder.create().texOffs(0, 0).addBox(7.0f, -1.0f, 15.0f, 2.0f, 4.0f, 1.0f, deformation_partB), PartPose.offset(0.0f, 8.0f, 0.0f));
|
||||
modelPartData.addOrReplaceChild(
|
||||
"partB",
|
||||
CubeListBuilder.create().texOffs(0, 0).addBox(7.0f, -1.0f, 15.0f, 2.0f, 4.0f, 1.0f, deformation_partB),
|
||||
PartPose.offset(0.0f, 8.0f, 0.0f)
|
||||
);
|
||||
|
||||
CubeDeformation deformation_partRightC = new CubeDeformation(0.0f);
|
||||
modelPartData.addOrReplaceChild("partRightC", CubeListBuilder.create().texOffs(0, 19).addBox(1.0f, 0.0f, 1.0f, 15.0f, 9.0f, 14.0f, deformation_partRightC), PartPose.ZERO);
|
||||
modelPartData.addOrReplaceChild(
|
||||
"partRightC",
|
||||
CubeListBuilder.create()
|
||||
.texOffs(0, 19)
|
||||
.addBox(1.0f, 0.0f, 1.0f, 15.0f, 9.0f, 14.0f, deformation_partRightC),
|
||||
PartPose.ZERO
|
||||
);
|
||||
|
||||
CubeDeformation deformation_partRightA = new CubeDeformation(0.0f);
|
||||
modelPartData.addOrReplaceChild("partRightA", CubeListBuilder.create().texOffs(0, 0).addBox(1.0f, 0.0f, 0.0f, 15.0f, 5.0f, 14.0f, deformation_partRightA), PartPose.offset(0.0f, 9.0f, 1.0f));
|
||||
modelPartData.addOrReplaceChild(
|
||||
"partRightA",
|
||||
CubeListBuilder.create().texOffs(0, 0).addBox(1.0f, 0.0f, 0.0f, 15.0f, 5.0f, 14.0f, deformation_partRightA),
|
||||
PartPose.offset(0.0f, 9.0f, 1.0f)
|
||||
);
|
||||
|
||||
CubeDeformation deformation_partRightB = new CubeDeformation(0.0f);
|
||||
PartDefinition partRightB = modelPartData.addOrReplaceChild("partRightB", CubeListBuilder.create().texOffs(0, 0).addBox(15.0f, -1.0f, 15.0f, 1.0f, 4.0f, 1.0f, deformation_partRightB), PartPose.offset(0.0f, 8.0f, 0.0f));
|
||||
PartDefinition partRightB = modelPartData.addOrReplaceChild(
|
||||
"partRightB",
|
||||
CubeListBuilder.create()
|
||||
.texOffs(0, 0)
|
||||
.addBox(15.0f, -1.0f, 15.0f, 1.0f, 4.0f, 1.0f, deformation_partRightB),
|
||||
PartPose.offset(0.0f, 8.0f, 0.0f)
|
||||
);
|
||||
|
||||
CubeDeformation deformation_partLeftC = new CubeDeformation(0.0f);
|
||||
modelPartData.addOrReplaceChild("partLeftC", CubeListBuilder.create().texOffs(0, 19).addBox(0.0f, 0.0f, 1.0f, 15.0f, 9.0f, 14.0f, deformation_partLeftC), PartPose.ZERO);
|
||||
modelPartData.addOrReplaceChild(
|
||||
"partLeftC",
|
||||
CubeListBuilder.create().texOffs(0, 19).addBox(0.0f, 0.0f, 1.0f, 15.0f, 9.0f, 14.0f, deformation_partLeftC),
|
||||
PartPose.ZERO
|
||||
);
|
||||
|
||||
CubeDeformation deformation_partLeftA = new CubeDeformation(0.0f);
|
||||
modelPartData.addOrReplaceChild("partLeftA", CubeListBuilder.create().texOffs(0, 0).addBox(0.0f, 0.0f, 0.0f, 15.0f, 5.0f, 14.0f, deformation_partLeftA), PartPose.offset(0.0f, 9.0f, 1.0f));
|
||||
modelPartData.addOrReplaceChild(
|
||||
"partLeftA",
|
||||
CubeListBuilder.create().texOffs(0, 0).addBox(0.0f, 0.0f, 0.0f, 15.0f, 5.0f, 14.0f, deformation_partLeftA),
|
||||
PartPose.offset(0.0f, 9.0f, 1.0f)
|
||||
);
|
||||
|
||||
CubeDeformation deformation_partLeftB = new CubeDeformation(0.0f);
|
||||
modelPartData.addOrReplaceChild("partLeftB", CubeListBuilder.create().texOffs(0, 0).addBox(0.0f, -1.0f, 15.0f, 1.0f, 4.0f, 1.0f, deformation_partLeftB), PartPose.offset(0.0f, 8.0f, 0.0f));
|
||||
modelPartData.addOrReplaceChild(
|
||||
"partLeftB",
|
||||
CubeListBuilder.create().texOffs(0, 0).addBox(0.0f, -1.0f, 15.0f, 1.0f, 4.0f, 1.0f, deformation_partLeftB),
|
||||
PartPose.offset(0.0f, 8.0f, 0.0f)
|
||||
);
|
||||
|
||||
return LayerDefinition.create(modelData, 64, 64);
|
||||
}
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
package ru.bclib.client.models;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.BCLib;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import static net.minecraft.client.resources.model.ModelBakery.MISSING_MODEL_LOCATION;
|
||||
|
||||
public interface BlockModelProvider extends ItemModelProvider {
|
||||
@Environment(EnvType.CLIENT)
|
||||
default @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
Optional<String> pattern = PatternsHelper.createBlockSimple(resourceLocation);
|
||||
return ModelsHelper.fromPattern(pattern);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
default UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath());
|
||||
registerBlockModel(stateId, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createBlockSimple(modelId);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
default void registerBlockModel(ResourceLocation stateId, ResourceLocation modelId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
if (!modelCache.containsKey(modelId)) {
|
||||
BlockModel model = getBlockModel(stateId, blockState);
|
||||
if (model != null) {
|
||||
model.name = modelId.toString();
|
||||
modelCache.put(modelId, model);
|
||||
}
|
||||
else {
|
||||
BCLib.LOGGER.warning("Error loading model: {}", modelId);
|
||||
modelCache.put(modelId, modelCache.get(MISSING_MODEL_LOCATION));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package ru.bclib.client.models;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public interface ItemModelProvider {
|
||||
@Environment(EnvType.CLIENT)
|
||||
default BlockModel getItemModel(ResourceLocation resourceLocation) {
|
||||
return ModelsHelper.createItemModel(resourceLocation);
|
||||
}
|
||||
}
|
|
@ -78,7 +78,12 @@ public class ModelsHelper {
|
|||
}
|
||||
|
||||
public static MultiVariant createRandomTopModel(ResourceLocation resourceLocation) {
|
||||
return new MultiVariant(Lists.newArrayList(new Variant(resourceLocation, Transformation.identity(), false, 1), new Variant(resourceLocation, BlockModelRotation.X0_Y90.getRotation(), false, 1), new Variant(resourceLocation, BlockModelRotation.X0_Y180.getRotation(), false, 1), new Variant(resourceLocation, BlockModelRotation.X0_Y270.getRotation(), false, 1)));
|
||||
return new MultiVariant(Lists.newArrayList(
|
||||
new Variant(resourceLocation, Transformation.identity(), false, 1),
|
||||
new Variant(resourceLocation, BlockModelRotation.X0_Y90.getRotation(), false, 1),
|
||||
new Variant(resourceLocation, BlockModelRotation.X0_Y180.getRotation(), false, 1),
|
||||
new Variant(resourceLocation, BlockModelRotation.X0_Y270.getRotation(), false, 1)
|
||||
));
|
||||
}
|
||||
|
||||
public static class MultiPartBuilder {
|
||||
|
|
|
@ -52,7 +52,8 @@ public class PatternsHelper {
|
|||
public static Optional<String> createJson(ResourceLocation patternId, Map<String, String> textures) {
|
||||
ResourceManager resourceManager = Minecraft.getInstance().getResourceManager();
|
||||
try (InputStream input = resourceManager.getResource(patternId).getInputStream()) {
|
||||
String json = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8)).lines().collect(Collectors.joining());
|
||||
String json = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8)).lines()
|
||||
.collect(Collectors.joining());
|
||||
for (Map.Entry<String, String> texture : textures.entrySet()) {
|
||||
json = json.replace(texture.getKey(), texture.getValue());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue