Skip to content

Commit

Permalink
Merge pull request #5 from ArisuOngaku/mc-1.15.x
Browse files Browse the repository at this point in the history
Update to minecraft 1.15.x
  • Loading branch information
abused authored Feb 13, 2020
2 parents 75e47b0 + eb23f08 commit 53bd1d5
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 27 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '0.2.5-SNAPSHOT'
id 'fabric-loom' version '0.2.6-SNAPSHOT'
id 'maven-publish'
}

Expand Down Expand Up @@ -93,4 +93,4 @@ publishing {
}
}
}
tasks.publish.dependsOn build
tasks.publish.dependsOn build
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
org.gradle.jvmargs=-Xmx1G

mc_version = 1.14.4
yarn_mappings = 1.14.4+build.5
loader_version = 0.4.8+build.159
fabric_version = 0.3.0+build.207
mc_version = 1.15.2
yarn_mappings = 1.15.2+build.12:v2
loader_version = 0.7.8+build.184
fabric_version = 0.4.30+build.291-1.15
javagl_version = 0.3.0

mod_version = 1.1.0
mod_version = 1.2.0
mod_group = com.github.NerdHubMC
mod_name = FOML
mod_name = FOML
Empty file modified gradlew
100644 → 100755
Empty file.
18 changes: 13 additions & 5 deletions src/main/java/nerdhub/foml/obj/OBJBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,25 @@
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.MathHelper;

import java.util.List;
import java.util.Map;
import java.util.function.Function;

public class OBJBuilder {

public static final Sprite DEFAULT_SPRITE = MinecraftClient.getInstance().getSpriteAtlas().getSprite(SpriteAtlasTexture.BLOCK_ATLAS_TEX);
public static final SpriteIdentifier DEFAULT_SPRITE = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX, null);

private MeshBuilder meshBuilder;
private QuadEmitter quadEmitter;

private final Obj obj;
private final List<Mtl> mtlList;
private Function<SpriteIdentifier, Sprite> textureGetter;

public OBJBuilder(Obj obj, List<Mtl> mtlList) {
meshBuilder = RendererAccess.INSTANCE.getRenderer().meshBuilder();
Expand Down Expand Up @@ -64,12 +68,12 @@ public Mesh build() {
Mtl mtl = findMtlForName(matName);
FloatTuple diffuseColor = null;
FloatTuple specularColor = null;
Sprite mtlSprite = DEFAULT_SPRITE;
Sprite mtlSprite = textureGetter.apply(DEFAULT_SPRITE);

if(mtl != null) {
diffuseColor = mtl.getKd();
specularColor = mtl.getKs();
mtlSprite = getMtlSprite(mtl.getMapKd());
mtlSprite = getMtlSprite(new Identifier(mtl.getMapKd()));
}

for (int i = 0; i < matGroupObj.getNumFaces(); i++) {
Expand Down Expand Up @@ -114,7 +118,11 @@ public Mtl findMtlForName(String name) {
return null;
}

public Sprite getMtlSprite(String name) {
return MinecraftClient.getInstance().getSpriteAtlas().getSprite(name);
public Sprite getMtlSprite(Identifier name) {
return textureGetter.apply(new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX, name));
}

public void setTextureGetter(Function<SpriteIdentifier, Sprite> textureGetter) {
this.textureGetter = textureGetter;
}
}
17 changes: 11 additions & 6 deletions src/main/java/nerdhub/foml/obj/baked/OBJBakedModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.ExtendedBlockView;
import net.minecraft.world.BlockRenderView;

import java.util.List;
import java.util.Random;
Expand All @@ -39,15 +39,15 @@ public List<BakedQuad> getQuads(BlockState blockState, Direction direction, Rand
}

@Override
public void emitBlockQuads(ExtendedBlockView blockView, BlockState state, BlockPos pos, Supplier<Random> randomSupplier, RenderContext context) {
if(mesh != null) {
public void emitBlockQuads(BlockRenderView blockRenderView, BlockState blockState, BlockPos blockPos, Supplier<Random> supplier, RenderContext context) {
if (mesh != null) {
context.meshConsumer().accept(mesh);
}
}

@Override
public void emitItemQuads(ItemStack stack, Supplier<Random> randomSupplier, RenderContext context) {
if(mesh != null) {
if (mesh != null) {
context.meshConsumer().accept(mesh);
}
}
Expand All @@ -58,18 +58,23 @@ public boolean useAmbientOcclusion() {
}

@Override
public boolean hasDepthInGui() {
public boolean hasDepth() {
return true;
}

@Override
public boolean isSideLit() {
return false;
}

@Override
public boolean isBuiltin() {
return false;
}

@Override
public Sprite getSprite() {
return MinecraftClient.getInstance().getSpriteAtlas().getSprite(SpriteAtlasTexture.BLOCK_ATLAS_TEX);
return MinecraftClient.getInstance().getSpriteAtlas(SpriteAtlasTexture.BLOCK_ATLAS_TEX).apply(null);
}

@Override
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/nerdhub/foml/obj/baked/OBJUnbakedModel.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package nerdhub.foml.obj.baked;

import com.mojang.datafixers.util.Pair;
import nerdhub.foml.obj.OBJBuilder;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.ModelBakeSettings;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.render.model.UnbakedModel;
import net.minecraft.client.render.model.json.ModelTransformation;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.util.Identifier;

import java.util.*;
Expand All @@ -31,15 +34,16 @@ public Collection<Identifier> getModelDependencies() {
}

@Override
public Collection<Identifier> getTextureDependencies(Function<Identifier, UnbakedModel> var1, Set<String> var2) {
List<Identifier> sprites = new ArrayList<>();
builder.getMtlList().forEach(mtl -> sprites.add(new Identifier(mtl.getMapKd())));
public Collection<SpriteIdentifier> getTextureDependencies(Function<Identifier, UnbakedModel> unbakedModelGetter, Set<Pair<String, String>> unresolvedTextureReferences) {
List<SpriteIdentifier> sprites = new ArrayList<>();
builder.getMtlList().forEach(mtl -> sprites.add(new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX, new Identifier(mtl.getMapKd()))));

return sprites;
}

@Override
public BakedModel bake(ModelLoader var1, Function<Identifier, Sprite> var2, ModelBakeSettings var3) {
public BakedModel bake(ModelLoader loader, Function<SpriteIdentifier, Sprite> textureGetter, ModelBakeSettings rotationContainer, Identifier modelId) {
builder.setTextureGetter(textureGetter);
return new OBJBakedModel(builder, transform);
}
}
}
6 changes: 3 additions & 3 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"schemaVersion": 1,
"id": "foml",
"version": "1.1.0",
"version": "1.2.0",
"name": "FOML",
"description": "Fabric OBJ Model Loader",
"authors": [
"abused_master"
],
"contact": {
"homepage": "https://minecraft.curseforge.com/projects/FOML",
"sources": "https://github.com/NerdHubMC/FOML"
"sources": "https://github.com/OnyxStudios/FOML"
},
"license": "MIT",
"icon": "assets/foml/icon.png",
Expand All @@ -20,7 +20,7 @@
]
},
"depends": {
"fabricloader": ">=0.4.0",
"fabricloader": ">=0.7.0",
"fabric": "*"
},
"custom": {
Expand Down

0 comments on commit 53bd1d5

Please sign in to comment.