Skip to content

Commit

Permalink
updated mixin names + model parenting stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
LudoCrypt committed Jul 23, 2022
1 parent 046de9c commit 188cd09
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ satin_version=1.8.0
sodium_version=mc1.19-0.4.2
iris_version=1.19.x-v1.2.5

mod_version = 6.0.3
mod_version = 6.0.4
maven_group = net.ludocrypt
archives_base_name = limlib
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public abstract class BackgroundRendererMixin {

@ModifyVariable(method = "render", at = @At(value = "STORE", ordinal = 4), ordinal = 2)
private static float corners$modifySkyColor(float in) {
private static float limlib$modifySkyColor(float in) {
MinecraftClient client = MinecraftClient.getInstance();

LiminalEffects effects = ((DimensionTypeAccess) (Object) client.world.getDimension()).getLiminalEffects();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,19 @@ public void renderHands(Framebuffer framebuffer, float tickDelta, MatrixStack ma
client.getFramebuffer().beginWrite(true);
}

framebuffer.clear(MinecraftClient.IS_SYSTEM_MAC);
framebuffer.beginWrite(true);

LimlibRendering.LIMINAL_QUAD_RENDERER.forEach((renderer) -> {
renderer.heldItemRenderQueue.forEach(Runnable::run);
renderer.heldItemRenderQueue.clear();
});

framebuffer.endWrite();
client.getFramebuffer().beginWrite(true);

framebuffer.draw(framebuffer.textureWidth, framebuffer.textureHeight);

RenderSystem.setProjectionMatrix(projectionMatrix);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
package net.ludocrypt.limlib.mixin.client.render.model;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;

import org.apache.commons.compress.utils.Lists;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.At.Shift;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

import com.google.common.collect.Maps;
import com.mojang.datafixers.util.Pair;
Expand All @@ -22,9 +27,11 @@
import net.minecraft.client.render.model.BakedQuad;
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.JsonUnbakedModel;
import net.minecraft.client.render.model.json.ModelElement;
import net.minecraft.client.render.model.json.ModelElementFace;
import net.minecraft.client.texture.MissingSprite;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.util.Identifier;
Expand All @@ -36,9 +43,27 @@ public abstract class JsonUnbakedModelMixin implements UnbakedModelAccess {
@Unique
private Map<Identifier, List<ModelElement>> subElements = Maps.newHashMap();

@Shadow
public String id;

@Shadow
protected JsonUnbakedModel parent;

@Inject(method = "Lnet/minecraft/client/render/model/json/JsonUnbakedModel;getTextureDependencies(Ljava/util/function/Function;Ljava/util/Set;)Ljava/util/Collection;", at = @At(value = "INVOKE", target = "Ljava/util/List;forEach(Ljava/util/function/Consumer;)V", ordinal = 0, shift = Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILHARD)
private void limlib$getTextureDependencies(Function<Identifier, UnbakedModel> unbakedModelGetter, Set<Pair<String, String>> unresolvedTextureReferences, CallbackInfoReturnable<Collection<SpriteIdentifier>> ci, Set<JsonUnbakedModel> set, JsonUnbakedModel jsonUnbakedModel, Set<SpriteIdentifier> set2) {
this.getSubElements().forEach((subElementId, subElement) -> {
subElement.forEach((modelElement) -> {
modelElement.faces.values().forEach((modelElementFace) -> {
SpriteIdentifier spriteIdentifier = this.resolveSprite(modelElementFace.textureId);
if (Objects.equals(spriteIdentifier.getTextureId(), MissingSprite.getMissingSpriteId())) {
unresolvedTextureReferences.add(Pair.of(modelElementFace.textureId, this.id));
}
set2.add(spriteIdentifier);
});
});
});
}

@Inject(method = "Lnet/minecraft/client/render/model/json/JsonUnbakedModel;bake(Lnet/minecraft/client/render/model/ModelLoader;Lnet/minecraft/client/render/model/json/JsonUnbakedModel;Ljava/util/function/Function;Lnet/minecraft/client/render/model/ModelBakeSettings;Lnet/minecraft/util/Identifier;Z)Lnet/minecraft/client/render/model/BakedModel;", at = @At("RETURN"), cancellable = true)
private void limlib$bake(ModelLoader loader, JsonUnbakedModel parent, Function<SpriteIdentifier, Sprite> textureGetter, ModelBakeSettings settings, Identifier id, boolean hasDepth, CallbackInfoReturnable<BakedModel> ci) {
Map<Identifier, List<Pair<BakedQuad, Optional<Direction>>>> subQuads = Maps.newHashMap();
Expand Down Expand Up @@ -66,6 +91,9 @@ public abstract class JsonUnbakedModelMixin implements UnbakedModelAccess {
@Shadow
private native static BakedQuad createQuad(ModelElement element, ModelElementFace elementFace, Sprite sprite, Direction side, ModelBakeSettings settings, Identifier id);

@Shadow
public abstract SpriteIdentifier resolveSprite(String spriteName);

@Override
public Map<Identifier, List<ModelElement>> getSubElements() {
Map<Identifier, List<ModelElement>> conjoinedElements = Maps.newHashMap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
public class DimensionTypeRegistrarMixin {

@Inject(method = "Lnet/minecraft/world/dimension/DimensionTypeRegistrar;initAndGetDefault(Lnet/minecraft/util/registry/Registry;)Lnet/minecraft/util/registry/RegistryEntry;", at = @At("RETURN"))
private static void limlib$InitAndGetDefault(Registry<DimensionType> registry, CallbackInfoReturnable<RegistryEntry<DimensionType>> ci) {
private static void limlib$initAndGetDefault(Registry<DimensionType> registry, CallbackInfoReturnable<RegistryEntry<DimensionType>> ci) {
LimlibRegistries.LIMINAL_WORLD.forEach((world) -> BuiltinRegistries.add(registry, world.getDimensionTypeKey(), world.getDimensionType()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
public class WorldPresetsRegistrarMixin {

@Inject(method = "Lnet/minecraft/world/gen/WorldPresets$Registrar;createPreset(Lnet/minecraft/world/dimension/DimensionOptions;)Lnet/minecraft/world/gen/WorldPreset;", at = @At("RETURN"))
private void limlib$CreatePreset(DimensionOptions dimensionOptions, CallbackInfoReturnable<WorldPreset> ci) {
private void limlib$createPreset(DimensionOptions dimensionOptions, CallbackInfoReturnable<WorldPreset> ci) {
Map<RegistryKey<DimensionOptions>, DimensionOptions> map = Maps.newHashMap();
map.putAll(((WorldPresetAccessor) ci.getReturnValue()).getDimensions());
LimlibRegistries.LIMINAL_WORLD.forEach((world) -> map.put(world.getDimensionKey(), world.getDimensionOptions()));
Expand Down

0 comments on commit 188cd09

Please sign in to comment.