Skip to content
This repository was archived by the owner on Jul 9, 2026. It is now read-only.

Commit 92c213c

Browse files
committed
sneaky little commit
1 parent a6541e9 commit 92c213c

7 files changed

Lines changed: 48 additions & 119 deletions

File tree

src/main/java/io/github/axolotlclient/oldanimations/mixin/ItemRendererMixin.java

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@
2727
import io.github.axolotlclient.oldanimations.util.*;
2828
import net.minecraft.block.Block;
2929
import net.minecraft.client.Minecraft;
30+
import net.minecraft.client.render.item.ItemModelShaper;
3031
import net.minecraft.client.render.item.ItemRenderer;
3132
import net.minecraft.client.render.model.block.ModelTransformations;
3233
import net.minecraft.client.render.texture.TextureManager;
34+
import net.minecraft.client.resource.ModelIdentifier;
3335
import net.minecraft.client.resource.model.BakedModel;
3436
import net.minecraft.client.resource.model.BakedQuad;
3537
import net.minecraft.entity.living.LivingEntity;
@@ -69,6 +71,9 @@ public abstract class ItemRendererMixin {
6971
@Shadow
7072
public abstract boolean isGui3d(ItemStack itemStack);
7173

74+
@Shadow
75+
public abstract ItemModelShaper getModelShaper();
76+
7277
@Unique
7378
private boolean axolotlclient$isGui;
7479

@@ -114,7 +119,7 @@ public abstract class ItemRendererMixin {
114119

115120
@ModifyArg(method = "renderItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/ItemRenderer;renderEnchantmentGlint(Lnet/minecraft/client/resource/model/BakedModel;)V"))
116121
public BakedModel axolotlclient$replaceModel(BakedModel model) {
117-
return OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.oldGlint.get() ? GlintModel.getModel(model) : model;
122+
return OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.oldGlint.get() ? GlintHandler.getModel(model) : model;
118123
}
119124

120125
@ModifyArg(method = "render(Lnet/minecraft/client/resource/model/BakedModel;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/ItemRenderer;render(Lnet/minecraft/client/resource/model/BakedModel;ILnet/minecraft/item/ItemStack;)V"), index = 1)
@@ -125,11 +130,13 @@ public abstract class ItemRendererMixin {
125130

126131
@Inject(method = "renderEnchantmentGlint", at = @At("HEAD"), cancellable = true)
127132
private void axolotlclient$disableDefaultGlint(CallbackInfo ci) {
128-
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.oldGuiGlint.get() && axolotlclient$isGui) {
129-
ci.cancel();
130-
}
131-
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.fastItems.get() && !axolotlclient$isGui && !axolotlclient$isHeld) {
132-
ci.cancel();
133+
if (OldAnimationsConfig.isEnabled()) {
134+
if (OldAnimationsConfig.instance.oldGuiGlint.get() && axolotlclient$isGui) {
135+
ci.cancel();
136+
}
137+
if (OldAnimationsConfig.instance.fastItems.get() && !axolotlclient$isGui && !axolotlclient$isHeld) {
138+
ci.cancel();
139+
}
133140
}
134141
}
135142

@@ -177,7 +184,7 @@ public abstract class ItemRendererMixin {
177184
!axolotlclient$isGui && stack.getItem() instanceof PotionItem &&
178185
/* just to be safe, let's skip rendering while projectiles and dropped items are 2d */
179186
(!OldAnimationsConfig.instance.fastItems.get() || axolotlclient$isHeld)) {
180-
model = ModelUtil.getModel("bottle_overlay");
187+
model = axolotlclient$getModel("bottle_overlay");
181188
}
182189
original.call(instance, model, stack);
183190
}
@@ -191,7 +198,7 @@ public abstract class ItemRendererMixin {
191198
/* renders the splash/drinkable bottle AFTER the glint rendering like in 1.7 */
192199
String id = PotionItem.isSplashPotion(stack.getMetadata()) ? "bottle_splash_empty" : "bottle_drinkable_empty";
193200
/* hacky way of rendering the bottle without using the potion's overlay color */
194-
render(ModelUtil.getModel(id), DummyItem.getStack());
201+
render(axolotlclient$getModel(id), ItemUtil.DummyItem.getStack());
195202
}
196203
}
197204

@@ -265,4 +272,9 @@ public abstract class ItemRendererMixin {
265272
}
266273
}
267274
}
275+
276+
@Unique
277+
private BakedModel axolotlclient$getModel(String model) {
278+
return getModelShaper().getManager().getModel(new ModelIdentifier(model, "inventory"));
279+
}
268280
}

src/main/java/io/github/axolotlclient/oldanimations/util/DebugComponents.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,18 @@ public static List<String> getLeftBottom() {
7474
String enumfacingString = enumfacing.toString();
7575
enumfacingString = enumfacingString.toUpperCase(Locale.ROOT);
7676
list.add(var32.append(enumfacingString).append(") / ").append(MathHelper.wrapDegrees(mc.player.yaw)).toString());
77-
int light = chunk.getLight(blockpos, 0);
78-
String biomeName = chunk.getBiome(blockpos, mc.world.getBiomeSource()).name;
79-
int blockLight = chunk.getLight(LightType.BLOCK, blockpos);
80-
int skyLight = chunk.getLight(LightType.SKY, blockpos);
81-
list.add("lc: " + light + " b: " + biomeName + " bl: " + blockLight + " sl: " + skyLight + " rl: " + light);
77+
78+
try {
79+
int light = chunk.getLight(blockpos, 0);
80+
String biomeName = chunk.getBiome(blockpos, mc.world.getBiomeSource()).name;
81+
int blockLight = chunk.getLight(LightType.BLOCK, blockpos);
82+
int skyLight = chunk.getLight(LightType.SKY, blockpos);
83+
list.add("lc: " + light + " b: " + biomeName + " bl: " + blockLight + " sl: " + skyLight + " rl: " + light);
84+
} catch (Exception e) {
85+
/* yeah, in 1.7, this actually is empty when ur in the void LMFAO */
86+
list.add("");
87+
}
88+
8289
String var17 = "ws: %.3f, fs: %.3f, g: %b, fl: %.0f";
8390
Object[] var18 = new Object[]{mc.player.abilities.getWalkSpeed(), mc.player.abilities.getFlySpeed(), mc.player.onGround, playerPosY};
8491
String var33 = String.format(var17, Arrays.copyOf(var18, var18.length));

src/main/java/io/github/axolotlclient/oldanimations/util/DummyItem.java

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/main/java/io/github/axolotlclient/oldanimations/util/GlintHandler.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,21 @@
2626
import net.minecraft.client.Minecraft;
2727
import net.minecraft.client.render.texture.TextureAtlas;
2828
import net.minecraft.client.render.texture.TextureManager;
29+
import net.minecraft.client.resource.model.BakedModel;
30+
import net.minecraft.client.resource.model.BasicBakedModel;
2931
import net.minecraft.resource.Identifier;
3032

3133
import java.awt.*;
34+
import java.util.HashMap;
3235

3336
public final class GlintHandler {
37+
private static final HashMap<HashedModel, BakedModel> glintMap = new HashMap<>();
38+
39+
/* custom glint model */
40+
public static BakedModel getModel(BakedModel model) {
41+
return glintMap.computeIfAbsent(new HashedModel(model),
42+
key -> new BasicBakedModel.Builder(model, CustomTextureAtlasSprite.INSTANCE).build());
43+
}
3444

3545
public static void renderEnchantmentGlintPre(TextureManager textureManager, Identifier glintTexture, int color) {
3646
GlStateManager.enableRescaleNormal();

src/main/java/io/github/axolotlclient/oldanimations/util/GlintModel.java

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/main/java/io/github/axolotlclient/oldanimations/util/ItemUtil.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,10 @@ public static boolean shouldRotateBlock(ItemStack stack) {
9393
return false;
9494
}
9595
}
96+
97+
public static final class DummyItem extends Item {
98+
public static ItemStack getStack() {
99+
return new ItemStack(new DummyItem());
100+
}
101+
}
96102
}

src/main/java/io/github/axolotlclient/oldanimations/util/ModelUtil.java

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)