Skip to content

Commit

Permalink
allow for parent in generated item model, cleanup, v1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
tomalbrc committed Apr 8, 2024
1 parent 1b7af7c commit 3eb4585
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ minecraft_version=1.20.4
loader_version=0.15.7

# Mod Properties
mod_version = 1.1.0
mod_version = 1.1.1
maven_group = de.tomalbrc
archives_base_name = blockbench-import-library

Expand Down
7 changes: 0 additions & 7 deletions src/main/java/de/tomalbrc/bil/BIL.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

import com.mojang.logging.LogUtils;
import de.tomalbrc.bil.command.BILCommand;
import de.tomalbrc.bil.file.loader.BbModelLoader;
import de.tomalbrc.bil.util.ResourcePackUtil;
import eu.pb4.polymer.resourcepack.api.PolymerResourcePackUtils;
import gg.moonflower.molangcompiler.api.MolangCompiler;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.minecraft.resources.ResourceLocation;
import org.slf4j.Logger;

public class BIL implements ModInitializer {
Expand All @@ -23,10 +21,5 @@ public void onInitialize() {
});

PolymerResourcePackUtils.RESOURCE_PACK_AFTER_INITIAL_CREATION_EVENT.register(ResourcePackUtil::addAdditional);

BbModelLoader.load(new ResourceLocation("bil:rana"));
BbModelLoader.load(new ResourceLocation("bil:alex"));
BbModelLoader.load(new ResourceLocation("bil:fatass"));
BbModelLoader.load(new ResourceLocation("bil:dragon"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ public record DisplayTransform(Vector3f rotation, Vector3f translation, Vector3f

public static ResourcePackItemModel.DisplayTransform DEFAULT_TRANSFORM = new ResourcePackItemModel.DisplayTransform(new Vector3f(0,180,0), null, null); // default BIL model transform

private final String parent;
private final Map<String, ResourceLocation> textures;
private final List<BbElement> elements;

private final Map<String, DisplayTransform> display;

ResourcePackItemModel(Map<String, ResourceLocation> textures, List<BbElement> elements, Map<String, DisplayTransform> transformMap) {
ResourcePackItemModel(String parent, Map<String, ResourceLocation> textures, List<BbElement> elements, Map<String, DisplayTransform> transformMap) {
this.parent = parent;
this.textures = textures;
this.elements = elements;
if (transformMap == null) {
Expand All @@ -40,6 +41,9 @@ public byte[] getBytes() {

public static class Builder {
final String modelId;

String parent = null;

Map<String, ResourceLocation> textureMap = null;
List<BbElement> elements = null;

Expand All @@ -49,6 +53,11 @@ public Builder(String modelId) {
this.modelId = modelId;
}

public Builder withParent(String parent) {
this.parent = parent;
return this;
}

public Builder withTextures(Int2ObjectOpenHashMap<BbTexture> intTextureMap) {
this.textureMap = new Object2ObjectLinkedOpenHashMap<>();
if (intTextureMap != null) {
Expand All @@ -71,7 +80,7 @@ public Builder addDisplayTransform(String transformName, DisplayTransform transf


public ResourcePackItemModel build() {
return new ResourcePackItemModel(this.textureMap, this.elements, this.transformMap);
return new ResourcePackItemModel(this.parent, this.textureMap, this.elements, this.transformMap);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ protected Reference2ObjectOpenHashMap<UUID, Pose> poses(BbAnimation animation, O
Sampler.sample(animator.keyframes, model.animationVariablePlaceholders, environment, time);

Quaternionf localRot = node.transform().rotation().mul(createQuaternion(triple.getMiddle().mul(-1, -1, 1)), new Quaternionf());
Vector3f localPos = triple.getLeft().div(16).add(origin);
Vector3f localPos = triple.getLeft().mul(-1,1,1).div(16).add(origin);

matrix4f.translate(localPos);
matrix4f.rotate(localRot);
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/de/tomalbrc/bil/file/importer/Sampler.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.util.Iterator;
import java.util.List;

class Sampler {
public class Sampler {
private static Vector3f interpolateKeyframeChannelAt(Iterator<BbKeyframe> iterator, BbVariablePlaceholders placeholders, MolangEnvironment environment, float time) throws MolangRuntimeException {
// Find the closest keyframes before and after the target time, including those before "before" and after "after"
BbKeyframe before = null;
Expand Down Expand Up @@ -70,8 +70,6 @@ public static Triple<Vector3f, Vector3f, Vector3f> sample(List<BbKeyframe> keyfr
}

if (pos == null) pos = new Vector3f();
else pos.mul(-1,1,-1);

if (rot == null) rot = new Vector3f();
if (scale == null) scale = new Vector3f(1, 1, 1);

Expand Down

0 comments on commit 3eb4585

Please sign in to comment.