Skip to content

Commit

Permalink
1.21.2
Browse files Browse the repository at this point in the history
  • Loading branch information
gliscowo committed Nov 24, 2024
1 parent 94ce06f commit faf8ab2
Show file tree
Hide file tree
Showing 19 changed files with 161 additions and 123 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//file:noinspection GradlePackageVersionRange
plugins {
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'fabric-loom' version '1.8-SNAPSHOT'
id 'maven-publish'
}

Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_base_version=1.21
minecraft_version=1.21
yarn_mappings=1.21+build.2
loader_version=0.15.11
minecraft_base_version=1.21.2
minecraft_version=1.21.3
yarn_mappings=1.21.3+build.2
loader_version=0.16.9
# Mod Properties
mod_version=0.4.7
maven_group=com.glisco
archives_base_name=isometric-renders

# Dependencies
fabric_version=0.100.1+1.21
fabric_version=0.109.0+1.21.3

# https://maven.wispforest.io/io/wispforest/worldmesher/
worldmesher_version=0.4.6+1.21
worldmesher_version=0.4.7+1.21.2

# https://maven.wispforest.io/io/wispforest/exo/
exo_version=0.1.5+1.19

# https://maven.wispforest.io/io/wispforest/owo-lib/
owo_version=0.12.10+1.21
# https://maven.wispforest.io/#/releases/io/wispforest/owo-lib/
owo_version=0.12.18+1.21.2
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.glisco.isometricrenders;

import com.glisco.isometricrenders.command.IsorenderCommand;
import com.glisco.isometricrenders.render.TooltipRenderable;
import com.glisco.isometricrenders.util.AreaSelectionHelper;
import com.glisco.isometricrenders.util.ImageIO;
import com.glisco.isometricrenders.util.ParticleRestriction;
Expand All @@ -16,12 +15,12 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gl.Framebuffer;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.util.Identifier;
import org.apache.logging.log4j.LogManager;
Expand All @@ -41,6 +40,8 @@ public class IsometricRenders implements ClientModInitializer {
public static boolean skipWorldRender = false;
public static boolean centerNextTooltip = false;

public static Framebuffer mainTargetOverride = null;

public static final KeyBinding SELECT = new KeyBinding("key.isometric-renders.area_select", GLFW.GLFW_KEY_C, KeyBinding.MISC_CATEGORY);

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class TagArgumentType implements ArgumentType<TagArgumentType.TagArgument
private final RegistryWrapper<Item> registryWrapper;

public TagArgumentType(CommandRegistryAccess registryAccess) {
this.registryWrapper = registryAccess.getWrapperOrThrow(RegistryKeys.ITEM);
this.registryWrapper = registryAccess.getOrThrow(RegistryKeys.ITEM);
}

public static <S> TagArgument getTag(String name, CommandContext<S> context) {
Expand All @@ -46,7 +46,7 @@ public TagArgument parse(StringReader reader) throws CommandSyntaxException {

@Override
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {
return CommandSource.suggestIdentifiers(this.registryWrapper.streamTags().map(named -> named.getTag().id()), builder, String.valueOf('#'));
return CommandSource.suggestIdentifiers(this.registryWrapper.getTags().map(named -> named.getTag().id()), builder, String.valueOf('#'));
}

public record TagArgument(Identifier id, RegistryEntryList<Item> entries) {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package com.glisco.isometricrenders.mixin;

import com.glisco.isometricrenders.IsometricRenders;
import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.tooltip.TooltipComponent;
import net.minecraft.client.gui.tooltip.TooltipPositioner;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Nullable;
import org.joml.Vector2ic;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -18,32 +22,20 @@
@Mixin(DrawContext.class)
public class DrawContextMixin {

@Unique
private int isometric$tooltipWidth = 0;
@Unique
private int isometric$tooltipHeight = 0;

@Inject(method = "drawTooltip(Lnet/minecraft/client/font/TextRenderer;Ljava/util/List;IILnet/minecraft/client/gui/tooltip/TooltipPositioner;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;push()V"), locals = LocalCapture.CAPTURE_FAILHARD)
private void captureTooltipDimensions(TextRenderer textRenderer, List<TooltipComponent> components, int x, int y, TooltipPositioner positioner, CallbackInfo ci, int width, int height) {
this.isometric$tooltipWidth = width;
this.isometric$tooltipHeight = height;
}

@ModifyVariable(method = "drawTooltip(Lnet/minecraft/client/font/TextRenderer;Ljava/util/List;IILnet/minecraft/client/gui/tooltip/TooltipPositioner;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;push()V"), ordinal = 6)
private int centerXIfNeeded(int orig) {
@ModifyVariable(method = "drawTooltip(Lnet/minecraft/client/font/TextRenderer;Ljava/util/List;IILnet/minecraft/client/gui/tooltip/TooltipPositioner;Lnet/minecraft/util/Identifier;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;push()V"), ordinal = 6)
private int centerXIfNeeded(int orig, @Local(ordinal = 2) int width) {
if (!IsometricRenders.centerNextTooltip) return orig;
return orig - 12 - isometric$tooltipWidth / 2;
return orig - 12 - width / 2;
}

@ModifyVariable(method = "drawTooltip(Lnet/minecraft/client/font/TextRenderer;Ljava/util/List;IILnet/minecraft/client/gui/tooltip/TooltipPositioner;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;push()V"), ordinal = 7)
private int centerYIfNeeded(int orig) {
@ModifyVariable(method = "drawTooltip(Lnet/minecraft/client/font/TextRenderer;Ljava/util/List;IILnet/minecraft/client/gui/tooltip/TooltipPositioner;Lnet/minecraft/util/Identifier;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;push()V"), ordinal = 7)
private int centerYIfNeeded(int orig, @Local(ordinal = 3) int height) {
if (!IsometricRenders.centerNextTooltip) return orig;
return orig + 12 - isometric$tooltipHeight / 2;
return orig + 12 - height / 2;
}

@Inject(method = "drawTooltip(Lnet/minecraft/client/font/TextRenderer;Ljava/util/List;IILnet/minecraft/client/gui/tooltip/TooltipPositioner;)V", at = @At("TAIL"))
private void resetCenterState(TextRenderer textRenderer, List<TooltipComponent> components, int x, int y, TooltipPositioner positioner, CallbackInfo ci) {
@Inject(method = "drawTooltip(Lnet/minecraft/client/font/TextRenderer;Ljava/util/List;IILnet/minecraft/client/gui/tooltip/TooltipPositioner;Lnet/minecraft/util/Identifier;)V", at = @At("TAIL"))
private void resetCenterState(TextRenderer textRenderer, List<TooltipComponent> components, int x, int y, TooltipPositioner positioner, @Nullable Identifier texture, CallbackInfo ci) {
IsometricRenders.centerNextTooltip = false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
import com.glisco.isometricrenders.IsometricRenders;
import net.minecraft.client.render.entity.LivingEntityRenderer;
import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.render.entity.state.LivingEntityRenderState;
import net.minecraft.entity.LivingEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(LivingEntityRenderer.class)
public class LivingEntityRendererMixin<T extends LivingEntity, M extends EntityModel<T>> {
public class LivingEntityRendererMixin<T extends LivingEntity, S extends LivingEntityRenderState, M extends EntityModel<? super S>> {

@Inject(method = "hasLabel(Lnet/minecraft/entity/LivingEntity;)Z", at = @At("HEAD"), cancellable = true)
private void disablePlayerLabels(T livingEntity, CallbackInfoReturnable<Boolean> cir) {
@Inject(method = "hasLabel(Lnet/minecraft/entity/LivingEntity;D)Z", at = @At("HEAD"), cancellable = true)
private void disablePlayerLabels(T livingEntity, double d, CallbackInfoReturnable<Boolean> cir) {
if (IsometricRenders.inRenderableDraw) {
cir.setReturnValue(false);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.glisco.isometricrenders.mixin;

import com.glisco.isometricrenders.IsometricRenders;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import net.minecraft.client.gl.Framebuffer;
import net.minecraft.client.render.RenderPhase;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(RenderPhase.class)
public class RenderPhaseMixin {

@ModifyExpressionValue(method = {"method_62272", "method_34555", "method_29377"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;getFramebuffer()Lnet/minecraft/client/gl/Framebuffer;"))
private static Framebuffer injectProperRenderTarget(Framebuffer original) {
if (IsometricRenders.mainTargetOverride != null) {
return IsometricRenders.mainTargetOverride;
}

return original;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,30 @@
import com.glisco.isometricrenders.IsometricRenders;
import com.glisco.isometricrenders.util.AreaSelectionHelper;
import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.*;
import net.minecraft.client.util.Handle;
import net.minecraft.client.util.ObjectAllocator;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.profiler.Profiler;
import org.joml.Matrix4f;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Final;
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.CallbackInfo;

@Mixin(WorldRenderer.class)
public class WorldRendererMixin {

@Shadow
@Final
private MinecraftClient client;

@Inject(method = "render", at = @At("HEAD"), cancellable = true)
public void dontRenderInScreen(RenderTickCounter tickCounter, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci) {
public void dontRenderInScreen(ObjectAllocator allocator, RenderTickCounter tickCounter, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f positionMatrix, Matrix4f projectionMatrix, CallbackInfo ci) {
if (!IsometricRenders.skipWorldRender) return;

IsometricRenders.skipWorldRender = false;
ci.cancel();
}

@Inject(method = "render", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;crosshairTarget:Lnet/minecraft/util/hit/HitResult;", opcode = Opcodes.GETFIELD, ordinal = 1))
public void drawAreaSelection(RenderTickCounter tickCounter, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci, @Local(ordinal = 0) MatrixStack matrices) {
@Inject(method = "method_62214", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;renderTargetBlockOutline(Lnet/minecraft/client/render/Camera;Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;Lnet/minecraft/client/util/math/MatrixStack;Z)V"))
public void drawAreaSelection(Fog fog, RenderTickCounter renderTickCounter, Camera camera, Profiler profiler, Matrix4f matrix4f, Matrix4f matrix4f2, Handle<?> handle, Handle<?> handle2, Handle<?> handle3, Handle<?> handle4, boolean bl, Frustum frustum, Handle<?> handle5, CallbackInfo ci, @Local(ordinal = 0) MatrixStack matrices) {
AreaSelectionHelper.renderSelectionBox(matrices, camera);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.glisco.isometricrenders.mixin.access;

import net.minecraft.client.texture.NativeImage;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;

import java.nio.channels.WritableByteChannel;

@Mixin(NativeImage.class)
public interface NativeImageInvoker {

@Invoker("write")
boolean isometric$write(WritableByteChannel channel);

}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void emitVertices(MatrixStack matrices, VertexConsumerProvider vertexCons
vec3d = entry.entity().getLerpedPos(effectiveDelta).subtract(mesh.startPos().getX(), mesh.startPos().getY(), mesh.startPos().getZ());
}

client.getEntityRenderDispatcher().render(entry.entity(), vec3d.x, vec3d.y, vec3d.z, entry.entity().getYaw(effectiveDelta), effectiveDelta, matrices, vertexConsumers, entry.light());
client.getEntityRenderDispatcher().render(entry.entity(), vec3d.x, vec3d.y, vec3d.z, effectiveDelta, matrices, vertexConsumers, entry.light());
super.draw(RenderSystem.getModelViewMatrix());
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ protected void renderParticles(Matrix4f transform, float tickDelta) {
var modelView = RenderSystem.getModelViewStack();
modelView.pushMatrix();
modelView.mul(transform);
RenderSystem.applyModelViewMatrix();

var client = MinecraftClient.getInstance();
this.withParticleCamera(camera -> {
Expand All @@ -44,7 +43,6 @@ protected void renderParticles(Matrix4f transform, float tickDelta) {
});

modelView.popMatrix();
RenderSystem.applyModelViewMatrix();
}

protected void withParticleCamera(Consumer<Camera> action) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.registry.Registries;
Expand Down Expand Up @@ -42,7 +43,7 @@ public static EntityRenderable of(EntityType<?> type, @Nullable NbtCompound nbt)

nbt.putString("id", type.getRegistryEntry().registryKey().getValue().toString());

final var entity = EntityType.loadEntityWithPassengers(nbt, client.world, Function.identity());
final var entity = EntityType.loadEntityWithPassengers(nbt, client.world, SpawnReason.LOAD, Function.identity());
entity.updatePosition(client.player.getX(), client.player.getY(), client.player.getZ());

return new EntityRenderable(entity);
Expand All @@ -55,7 +56,7 @@ public static EntityRenderable copyOf(Entity source) {
source.writeNbt(nbt);
nbt.putString("id", source.getType().getRegistryEntry().registryKey().getValue().toString());

final var entity = EntityType.loadEntityWithPassengers(nbt, client.world, Function.identity());
final var entity = EntityType.loadEntityWithPassengers(nbt, client.world, SpawnReason.LOAD, Function.identity());
applyToEntityAndPassengers(entity, Entity::tick);

return new EntityRenderable(entity);
Expand Down Expand Up @@ -90,7 +91,7 @@ public void emitVertices(MatrixStack matrices, VertexConsumerProvider vertexCons
}

var offsetPos = offset.getValue();
client.getEntityRenderDispatcher().render(entity, offsetPos.getX(), offsetPos.getY(), offsetPos.getZ(), 0, tickDelta, matrices, vertexConsumers, LightmapTextureManager.MAX_LIGHT_COORDINATE);
client.getEntityRenderDispatcher().render(entity, offsetPos.getX(), offsetPos.getY(), offsetPos.getZ(), tickDelta, matrices, vertexConsumers, LightmapTextureManager.MAX_LIGHT_COORDINATE);
});

matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-180));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import net.minecraft.client.render.LightmapTextureManager;
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.model.json.ModelTransformationMode;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ModelTransformationMode;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RotationAxis;
import org.joml.Matrix4fStack;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.json.ModelTransformation;
import net.minecraft.client.render.model.json.ModelTransformationMode;
import net.minecraft.client.util.ModelIdentifier;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.ModelTransformationMode;
import net.minecraft.registry.Registries;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.RotationAxis;
import org.joml.Matrix4fStack;

Expand Down Expand Up @@ -54,9 +55,9 @@ public ItemRenderable(ItemStack stack) {
public void prepare() {
var itemRenderer = MinecraftClient.getInstance().getItemRenderer();
if (this.stack.isOf(Items.TRIDENT)) {
currentModel = itemRenderer.getModels().getModelManager().getModel(ModelIdentifier.ofVanilla("trident", "inventory"));
currentModel = MinecraftClient.getInstance().getBakedModelManager().getModel(ModelIdentifier.ofInventoryVariant(Identifier.of("trident")));
} else if (this.stack.isOf(Items.SPYGLASS)) {
currentModel = itemRenderer.getModels().getModelManager().getModel(ModelIdentifier.ofVanilla("spyglass", "inventory"));
currentModel = MinecraftClient.getInstance().getBakedModelManager().getModel(ModelIdentifier.ofInventoryVariant(Identifier.of("spyglass")));
} else {
currentModel = itemRenderer.getModel(this.stack, MinecraftClient.getInstance().world, null, 0);
}
Expand Down
Loading

0 comments on commit faf8ab2

Please sign in to comment.