1
0
mirror of https://github.com/GeyserMC/PackConverter.git synced 2026-01-04 15:31:36 +00:00

Store stitched models

This commit is contained in:
RednedEpic
2023-07-09 16:03:45 -05:00
parent 19a4cbea4e
commit 7e85e30e63
2 changed files with 63 additions and 4 deletions

View File

@@ -42,9 +42,9 @@ import org.geysermc.pack.bedrock.resource.models.entity.modelentity.geometry.bon
import org.geysermc.pack.bedrock.resource.models.entity.modelentity.geometry.bones.cubes.uv.Up;
import org.geysermc.pack.bedrock.resource.models.entity.modelentity.geometry.bones.cubes.uv.West;
import org.geysermc.pack.converter.PackConversionContext;
import org.geysermc.pack.converter.converter.BaseConverter;
import org.geysermc.pack.converter.PackConverter;
import org.geysermc.pack.converter.converter.Converter;
import org.geysermc.pack.converter.data.BaseConversionData;
import org.geysermc.pack.converter.data.ModelConversionData;
import org.geysermc.pack.converter.util.VanillaPackHandler;
import org.jetbrains.annotations.NotNull;
import team.unnamed.creative.ResourcePack;
@@ -64,14 +64,14 @@ import java.util.List;
import java.util.Map;
@AutoService(Converter.class)
public class ModelConverter extends BaseConverter {
public class ModelConverter implements Converter<ModelConversionData> {
private static final String FORMAT_VERSION = "1.12.0";
private static final String GEOMETRY_FORMAT = "geometry.%s";
private static final float[] ELEMENT_OFFSET = new float[] { 8, 0, 8 };
@Override
public void convert(@NotNull PackConversionContext<BaseConversionData> context) throws Exception {
public void convert(@NotNull PackConversionContext<ModelConversionData> context) throws Exception {
ResourcePack javaPack = context.javaResourcePack();
BedrockResourcePack bedrockPack = context.bedrockResourcePack();
Collection<Model> models = javaPack.models();
@@ -191,9 +191,16 @@ public class ModelConverter extends BaseConverter {
// Bedrock only has a concept of entity or block models
bedrockPack.addBlockModel(modelEntity, fileName + ".json");
}
context.data().addStitchedModel(model);
}
}
@Override
public ModelConversionData createConversionData(@NotNull PackConverter converter, @NotNull Path inputDirectory, @NotNull Path outputDirectory) {
return new ModelConversionData(inputDirectory, outputDirectory);
}
private static void applyUv(Uv uv, CubeFace face, String texture, Vector4Float faceUv) {
float[] uvs;
float[] uvSize;

View File

@@ -0,0 +1,52 @@
/*
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/PackConverter
*
*/
package org.geysermc.pack.converter.data;
import net.kyori.adventure.key.Key;
import org.jetbrains.annotations.NotNull;
import team.unnamed.creative.model.Model;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
public class ModelConversionData extends BaseConversionData {
private final Map<Key, Model> stitchedModels = new HashMap<>();
public ModelConversionData(@NotNull Path inputDirectory, @NotNull Path outputDirectory) {
super(inputDirectory, outputDirectory);
}
public void addStitchedModel(@NotNull Model model) {
this.stitchedModels.put(model.key(), model);
}
@NotNull
public Model model(@NotNull Key key) {
return this.stitchedModels.get(key);
}
}