-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
123 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/java/net/ludocrypt/limlib/access/BakedModelAccess.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package net.ludocrypt.limlib.access; | ||
|
||
import java.util.Map; | ||
|
||
import net.minecraft.client.render.model.BakedModel; | ||
import net.minecraft.util.Identifier; | ||
|
||
public interface BakedModelAccess { | ||
|
||
public Map<Identifier, BakedModel> getSubModels(); | ||
|
||
} |
15 changes: 0 additions & 15 deletions
15
src/main/java/net/ludocrypt/limlib/access/ModelAccess.java
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
src/main/java/net/ludocrypt/limlib/access/UnbakedModelAccess.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package net.ludocrypt.limlib.access; | ||
|
||
import java.util.Map; | ||
|
||
import net.minecraft.client.util.ModelIdentifier; | ||
import net.minecraft.util.Identifier; | ||
|
||
public interface UnbakedModelAccess { | ||
|
||
public Map<Identifier, ModelIdentifier> getSubModels(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 7 additions & 10 deletions
17
src/main/java/net/ludocrypt/limlib/mixin/client/render/model/BakedModelMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,21 @@ | ||
package net.ludocrypt.limlib.mixin.client.render.model; | ||
|
||
import java.util.Optional; | ||
import java.util.Map; | ||
|
||
import org.jetbrains.annotations.Nullable; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
|
||
import net.ludocrypt.limlib.access.ModelAccess; | ||
import com.google.common.collect.Maps; | ||
|
||
import net.ludocrypt.limlib.access.BakedModelAccess; | ||
import net.minecraft.client.render.model.BakedModel; | ||
import net.minecraft.util.Identifier; | ||
|
||
@Mixin(BakedModel.class) | ||
public interface BakedModelMixin extends ModelAccess { | ||
|
||
@Override | ||
default Optional<Identifier> getLiminalQuadRenderer() { | ||
return Optional.empty(); | ||
} | ||
public interface BakedModelMixin extends BakedModelAccess { | ||
|
||
@Override | ||
default void setLiminalQuadRenderer(@Nullable Identifier id) { | ||
default Map<Identifier, BakedModel> getSubModels() { | ||
return Maps.newHashMap(); | ||
} | ||
|
||
} |
20 changes: 9 additions & 11 deletions
20
src/main/java/net/ludocrypt/limlib/mixin/client/render/model/GeneralBakedModelMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,25 @@ | ||
package net.ludocrypt.limlib.mixin.client.render.model; | ||
|
||
import java.util.Optional; | ||
import java.util.Map; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
|
||
import net.ludocrypt.limlib.access.ModelAccess; | ||
import com.google.common.collect.Maps; | ||
|
||
import net.ludocrypt.limlib.access.BakedModelAccess; | ||
import net.minecraft.client.render.model.BakedModel; | ||
import net.minecraft.util.Identifier; | ||
|
||
@Mixin(targets = { "net/minecraft/client/render/model/BasicBakedModel", "net/minecraft/client/render/model/BuiltinBakedModel", "net/minecraft/client/render/model/MultipartBakedModel", "net/minecraft/client/render/model/WeightedBakedModel", "net/fabricmc/fabric/api/renderer/v1/model/ForwardingBakedModel" }) | ||
public class GeneralBakedModelMixin implements ModelAccess { | ||
public class GeneralBakedModelMixin implements BakedModelAccess { | ||
|
||
@Unique | ||
private Optional<Identifier> liminalQuadRenderer = Optional.empty(); | ||
|
||
@Override | ||
public Optional<Identifier> getLiminalQuadRenderer() { | ||
return liminalQuadRenderer; | ||
} | ||
private Map<Identifier, BakedModel> subQuads = Maps.newHashMap(); | ||
|
||
@Override | ||
public void setLiminalQuadRenderer(Identifier id) { | ||
liminalQuadRenderer = Optional.ofNullable(id); | ||
public Map<Identifier, BakedModel> getSubModels() { | ||
return subQuads; | ||
} | ||
|
||
} |
25 changes: 14 additions & 11 deletions
25
...ava/net/ludocrypt/limlib/mixin/client/render/model/JsonUnbakedModelDeserializerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,41 @@ | ||
package net.ludocrypt.limlib.mixin.client.render.model; | ||
|
||
import java.lang.reflect.Type; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import com.google.common.collect.Maps; | ||
import com.google.gson.JsonDeserializationContext; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
|
||
import net.ludocrypt.limlib.access.ModelAccess; | ||
import net.ludocrypt.limlib.access.UnbakedModelAccess; | ||
import net.ludocrypt.limlib.impl.LimlibRendering; | ||
import net.minecraft.client.render.model.json.JsonUnbakedModel; | ||
import net.minecraft.client.render.model.json.ModelElement; | ||
import net.minecraft.client.util.ModelIdentifier; | ||
import net.minecraft.util.Identifier; | ||
|
||
@Mixin(JsonUnbakedModel.Deserializer.class) | ||
public abstract class JsonUnbakedModelDeserializerMixin { | ||
|
||
@Inject(method = "Lnet/minecraft/client/render/model/json/JsonUnbakedModel$Deserializer;deserialize(Lcom/google/gson/JsonElement;Ljava/lang/reflect/Type;Lcom/google/gson/JsonDeserializationContext;)Lnet/minecraft/client/render/model/json/JsonUnbakedModel;", at = @At("RETURN"), cancellable = true) | ||
private void limlib$deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext, CallbackInfoReturnable<JsonUnbakedModel> ci) { | ||
Map<Identifier, ModelIdentifier> map = Maps.newHashMap(); | ||
JsonObject jsonObject = jsonElement.getAsJsonObject(); | ||
if (jsonObject.has("limlib_renderer")) { | ||
if (LimlibRendering.LIMINAL_QUAD_RENDERER.containsId(new Identifier(jsonObject.get("limlib_renderer").getAsString()))) { | ||
((ModelAccess) ci.getReturnValue()).setLiminalQuadRenderer(new Identifier(jsonObject.get("limlib_renderer").getAsString())); | ||
} | ||
if (jsonObject.has("limlib_extra")) { | ||
LimlibRendering.LIMINAL_QUAD_RENDERER.getEntrySet().forEach((entry) -> { | ||
JsonObject limlibExtra = jsonObject.get("limlib_extra").getAsJsonObject(); | ||
if (limlibExtra.has(entry.getKey().getValue().toString())) { | ||
JsonObject renderer = limlibExtra.get(entry.getKey().getValue().toString()).getAsJsonObject(); | ||
map.put(entry.getKey().getValue(), new ModelIdentifier(renderer.getAsString())); | ||
} | ||
}); | ||
} | ||
((UnbakedModelAccess) ci.getReturnValue()).getSubModels().putAll(map); | ||
} | ||
|
||
@Shadow | ||
protected abstract List<ModelElement> elementsFromJson(JsonDeserializationContext context, JsonObject json); | ||
|
||
} |
Oops, something went wrong.