mirror of
https://github.com/GeyserMC/PackConverter.git
synced 2025-12-20 15:29:15 +00:00
Update deprecated methods
This commit is contained in:
@@ -48,11 +48,11 @@ import org.geysermc.pack.converter.data.ModelConversionData;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import team.unnamed.creative.ResourcePack;
|
import team.unnamed.creative.ResourcePack;
|
||||||
import team.unnamed.creative.base.CubeFace;
|
import team.unnamed.creative.base.CubeFace;
|
||||||
import team.unnamed.creative.base.Vector4Float;
|
|
||||||
import team.unnamed.creative.model.Element;
|
import team.unnamed.creative.model.Element;
|
||||||
import team.unnamed.creative.model.ElementFace;
|
import team.unnamed.creative.model.ElementFace;
|
||||||
import team.unnamed.creative.model.ElementRotation;
|
import team.unnamed.creative.model.ElementRotation;
|
||||||
import team.unnamed.creative.model.Model;
|
import team.unnamed.creative.model.Model;
|
||||||
|
import team.unnamed.creative.texture.TextureUV;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -151,7 +151,7 @@ public class ModelConverter implements Converter<ModelConversionData> {
|
|||||||
for (Map.Entry<CubeFace, ElementFace> entry : element.faces().entrySet()) {
|
for (Map.Entry<CubeFace, ElementFace> entry : element.faces().entrySet()) {
|
||||||
CubeFace face = entry.getKey();
|
CubeFace face = entry.getKey();
|
||||||
ElementFace elementFace = entry.getValue();
|
ElementFace elementFace = entry.getValue();
|
||||||
if (elementFace.uv() == null) {
|
if (elementFace.uv0() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +159,7 @@ public class ModelConverter implements Converter<ModelConversionData> {
|
|||||||
// divides the UV by 16, so we need to multiply it by 16
|
// divides the UV by 16, so we need to multiply it by 16
|
||||||
|
|
||||||
String texture = elementFace.texture().replace("#", "");
|
String texture = elementFace.texture().replace("#", "");
|
||||||
applyUv(uv, face, texture, elementFace.uv().multiply(ElementFace.MINECRAFT_UV_UNIT));
|
applyUv(uv, face, texture, multiplyUv(elementFace.uv0(), 16f));
|
||||||
}
|
}
|
||||||
|
|
||||||
cube.uv(uv);
|
cube.uv(uv);
|
||||||
@@ -188,17 +188,21 @@ public class ModelConverter implements Converter<ModelConversionData> {
|
|||||||
return new ModelConversionData(inputDirectory, outputDirectory);
|
return new ModelConversionData(inputDirectory, outputDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void applyUv(Uv uv, CubeFace face, String texture, Vector4Float faceUv) {
|
private TextureUV multiplyUv(TextureUV textureUV, float mult) {
|
||||||
|
return TextureUV.uv(textureUV.from().multiply(mult), textureUV.to().multiply(mult));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void applyUv(Uv uv, CubeFace face, String texture, TextureUV faceUv) {
|
||||||
float[] uvs;
|
float[] uvs;
|
||||||
float[] uvSize;
|
float[] uvSize;
|
||||||
|
|
||||||
// These values are flipped for some reason
|
// These values are flipped for some reason
|
||||||
if (face == CubeFace.DOWN || face == CubeFace.UP) {
|
if (face == CubeFace.DOWN || face == CubeFace.UP) {
|
||||||
uvs = new float[] { faceUv.x2(), faceUv.y2() };
|
uvs = new float[] { faceUv.to().x(), faceUv.to().y() };
|
||||||
uvSize = new float[] { faceUv.x() - faceUv.x2(), faceUv.y() - faceUv.y2() };
|
uvSize = new float[] { faceUv.from().x() - faceUv.to().x(), faceUv.from().y() - faceUv.to().y() };
|
||||||
} else {
|
} else {
|
||||||
uvs = new float[] { faceUv.x(), faceUv.y() };
|
uvs = new float[] { faceUv.from().x(), faceUv.from().y() };
|
||||||
uvSize = new float[] { faceUv.x2() - faceUv.x(), faceUv.y2() - faceUv.y() };
|
uvSize = new float[] { faceUv.to().x() - faceUv.from().x(), faceUv.to().y() - faceUv.from().y() };
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (face) {
|
switch (face) {
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ public class ModelStitcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Model stitch() {
|
public Model stitch() {
|
||||||
return Model.builder()
|
return Model.model()
|
||||||
.key(this.baseModel.key())
|
.key(this.baseModel.key())
|
||||||
.ambientOcclusion(this.ambientOcclusion)
|
.ambientOcclusion(this.ambientOcclusion)
|
||||||
.display(this.display)
|
.display(this.display)
|
||||||
@@ -191,6 +191,7 @@ public class ModelStitcher {
|
|||||||
// Need to download the client jar, then use the
|
// Need to download the client jar, then use the
|
||||||
// client jar to get the vanilla models, so we can
|
// client jar to get the vanilla models, so we can
|
||||||
// ensure all parents exist to convert them to Bedrock.
|
// ensure all parents exist to convert them to Bedrock.
|
||||||
|
// TODO Make the location of this configurable
|
||||||
Path vanillaPackPath = Paths.get("vanilla-pack.zip");
|
Path vanillaPackPath = Paths.get("vanilla-pack.zip");
|
||||||
VanillaPackProvider.create(vanillaPackPath, log);
|
VanillaPackProvider.create(vanillaPackPath, log);
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ public class TransformContext {
|
|||||||
* @throws IOException if an error occurs while converting the image to bytes
|
* @throws IOException if an error occurs while converting the image to bytes
|
||||||
*/
|
*/
|
||||||
public void offer(@NotNull Key key, @NotNull BufferedImage image, @NotNull String format) throws IOException {
|
public void offer(@NotNull Key key, @NotNull BufferedImage image, @NotNull String format) throws IOException {
|
||||||
this.offer(Texture.of(key, Writable.bytes(ImageUtil.toByteArray(image, format))));
|
this.offer(Texture.texture(key, Writable.bytes(ImageUtil.toByteArray(image, format))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user