Skip to content

Commit 3d9e114

Browse files
committed
old animations are working
1 parent 0f2a14d commit 3d9e114

File tree

6 files changed

+218
-0
lines changed

6 files changed

+218
-0
lines changed

simpleclient-1.8.9/src/main/java/simpleclient/feature/FeatureManagerImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public void init() {
2020
addFeature(new Fullbright());
2121
addFeature(new Lowfire());
2222
addFeature(new Motionblur());
23+
addFeature(new OldAnimations());
2324
addFeature(new Ping());
2425
addFeature(new PvPImprovements());
2526
addFeature(new Zoom());
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package simpleclient.feature;
2+
3+
import com.google.gson.JsonObject;
4+
5+
public class OldAnimations extends EnableableFeature {
6+
public static boolean ENABLED = false;
7+
8+
public OldAnimations() {
9+
super(FeatureType.OLD_ANIMATIONS);
10+
refresh();
11+
}
12+
13+
public void refresh() {
14+
ENABLED = isEnabled();
15+
}
16+
17+
@Override
18+
public void setData(JsonObject data) {
19+
super.setData(data);
20+
refresh();
21+
}
22+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package simpleclient.mixin.feature.old_animations;
2+
3+
import net.minecraft.client.render.entity.model.BiPedModel;
4+
import org.spongepowered.asm.mixin.Mixin;
5+
import org.spongepowered.asm.mixin.injection.Constant;
6+
import org.spongepowered.asm.mixin.injection.ModifyConstant;
7+
import simpleclient.feature.OldAnimations;
8+
9+
@Mixin(BiPedModel.class)
10+
public class BiPedModelMixin {
11+
@ModifyConstant(method = "setAngles", constant = @Constant(floatValue = -0.5235988F))
12+
private float cancelRotation(float value) {
13+
return OldAnimations.ENABLED ? 0.0F : value;
14+
}
15+
}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
package simpleclient.mixin.feature.old_animations;
2+
3+
import com.mojang.blaze3d.platform.GlStateManager;
4+
import net.minecraft.client.MinecraftClient;
5+
import net.minecraft.client.network.AbstractClientPlayerEntity;
6+
import net.minecraft.client.render.item.HeldItemRenderer;
7+
import net.minecraft.entity.effect.StatusEffect;
8+
import net.minecraft.entity.player.ClientPlayerEntity;
9+
import net.minecraft.item.ItemStack;
10+
import net.minecraft.item.Items;
11+
import net.minecraft.util.hit.BlockHitResult;
12+
import net.minecraft.util.math.MathHelper;
13+
import org.spongepowered.asm.mixin.Final;
14+
import org.spongepowered.asm.mixin.Mixin;
15+
import org.spongepowered.asm.mixin.Shadow;
16+
import org.spongepowered.asm.mixin.Unique;
17+
import org.spongepowered.asm.mixin.injection.At;
18+
import org.spongepowered.asm.mixin.injection.Constant;
19+
import org.spongepowered.asm.mixin.injection.Inject;
20+
import org.spongepowered.asm.mixin.injection.ModifyConstant;
21+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
22+
import simpleclient.feature.OldAnimations;
23+
24+
@Mixin(HeldItemRenderer.class)
25+
public class HeldItemRendererMixin {
26+
@Shadow private float equipProgress;
27+
@Shadow @Final private MinecraftClient client;
28+
@Shadow private ItemStack mainHand;
29+
30+
@Unique
31+
private float swingProgress;
32+
33+
@Inject(method = "renderArmHoldingItem", at = @At("HEAD"))
34+
private void renderArmHoldingItem1(float partialTicks, CallbackInfo ci) {
35+
if (OldAnimations.ENABLED) swingProgress = client.player.getHandSwingProgress(partialTicks);
36+
}
37+
38+
@Inject(method = "applyEquipAndSwingOffset", at = @At(value = "HEAD"))
39+
private void applyEquipAndSwingOffset1(CallbackInfo ci) {
40+
if (OldAnimations.ENABLED) {
41+
if (client.options.attackKey.isPressed() && client.options.useKey.isPressed() && client.result.type == BlockHitResult.Type.BLOCK) {
42+
ClientPlayerEntity player = client.player;
43+
int swingAnimationEnd = player.hasStatusEffect(StatusEffect.HASTE) ? (6 - (1 +
44+
player.getEffectInstance(StatusEffect.HASTE).getAmplifier())) : (player.hasStatusEffect(StatusEffect.MINING_FATIGUE) ? (6 + (1 +
45+
player.getEffectInstance(StatusEffect.MINING_FATIGUE).getAmplifier()) * 2) : 6);
46+
if (!player.handSwinging || player.handSwingTicks >= swingAnimationEnd / 2 || player.handSwingTicks < 0) {
47+
player.handSwingTicks = -1;
48+
player.handSwinging = true;
49+
}
50+
}
51+
}
52+
}
53+
54+
// Fishing Rod
55+
@Inject(method = "renderArmHoldingItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getItem()Lnet/minecraft/item/Item;"))
56+
public void renderArmHoldingItem2(float partialTicks, CallbackInfo ci) {
57+
if (OldAnimations.ENABLED && mainHand.getItem() == Items.FISHING_ROD) {
58+
GlStateManager.translate(0.08F, -0.027F, -0.33F);
59+
GlStateManager.scale(0.93F, 1.0F, 1.0F);
60+
}
61+
}
62+
63+
// Eating, Drinking
64+
@Inject(at = @At(value = "HEAD"), method = "applyEatOrDrinkTransformation", cancellable = true)
65+
private void applyEatOrDrinkTransformation(AbstractClientPlayerEntity abstractClientPlayerEntity, float partialTicks, CallbackInfo ci) {
66+
if (OldAnimations.ENABLED) {
67+
ci.cancel();
68+
float useAmount = (float) abstractClientPlayerEntity.getItemUseTicks() - partialTicks + 1.0F;
69+
float f1 = 1.0F - useAmount / (float) mainHand.getMaxUseTime();
70+
float f2 = 1.0F - f1;
71+
f2 = f2 * f2 * f2;
72+
f2 = f2 * f2 * f2;
73+
f2 = f2 * f2 * f2;
74+
float f3 = 1.0F - f2;
75+
GlStateManager.translate(0.0F, MathHelper.abs(MathHelper.cos(useAmount / 4.0F * 3.1415927F) * 0.1F) * (float) ((double) f1 > 0.2D ? 1 : 0), 0.0F);
76+
GlStateManager.translate(f3 * 0.6F, -f3 * 0.5F, 0.0F);
77+
GlStateManager.rotate(f3 * 90.0F, 0.0F, 1.0F, 0.0F);
78+
GlStateManager.rotate(f3 * 10.0F, 1.0F, 0.0F, 0.0F);
79+
GlStateManager.rotate(f3 * 30.0F, 0.0F, 0.0F, 1.0F);
80+
}
81+
}
82+
83+
// Blocking
84+
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;applySwordBlockTransformation()V", shift = At.Shift.AFTER), method = "renderArmHoldingItem")
85+
private void applySwordBlockTransformation(CallbackInfo ci) {
86+
if (OldAnimations.ENABLED) {
87+
GlStateManager.scale(0.83F, 0.88F, 0.85F);
88+
GlStateManager.translate(-0.3F, 0.1F, 0.0F);
89+
}
90+
}
91+
92+
// Bow
93+
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;applyBowTransformation(FLnet/minecraft/client/network/AbstractClientPlayerEntity;)V", shift = At.Shift.AFTER), method = "renderArmHoldingItem")
94+
private void transformBow(float f, CallbackInfo ci) {
95+
if (OldAnimations.ENABLED) GlStateManager.translate(0.0F, 0.1F, -0.15F);
96+
}
97+
98+
@ModifyConstant(method = "renderArmHoldingItem", constant = @Constant(floatValue = 0.0F))
99+
private float enableBlockHits(float constant) {
100+
return OldAnimations.ENABLED ? swingProgress : constant;
101+
}
102+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package simpleclient.mixin.feature.old_animations;
2+
3+
import com.mojang.blaze3d.platform.GlStateManager;
4+
import net.minecraft.block.Block;
5+
import net.minecraft.client.MinecraftClient;
6+
import net.minecraft.client.render.entity.LivingEntityRenderer;
7+
import net.minecraft.client.render.entity.feature.HeldItemRenderer;
8+
import net.minecraft.client.render.entity.model.BiPedModel;
9+
import net.minecraft.client.render.model.json.ModelTransformation;
10+
import net.minecraft.entity.LivingEntity;
11+
import net.minecraft.entity.player.PlayerEntity;
12+
import net.minecraft.item.*;
13+
import org.spongepowered.asm.mixin.Final;
14+
import org.spongepowered.asm.mixin.Mixin;
15+
import org.spongepowered.asm.mixin.Shadow;
16+
import org.spongepowered.asm.mixin.injection.At;
17+
import org.spongepowered.asm.mixin.injection.Inject;
18+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
19+
import simpleclient.feature.OldAnimations;
20+
21+
@Mixin(HeldItemRenderer.class)
22+
public class ItemFeatureRendererMixin {
23+
@Shadow @Final private LivingEntityRenderer<?> entityRenderer;
24+
25+
@Inject(at = @At("HEAD"), method = "render", cancellable = true)
26+
public void render(LivingEntity entity, float handSwing, float handSwingAmount, float tickDelta, float age, float headYaw, float headPitch, float scale, CallbackInfo ci) {
27+
ItemStack itemStack = entity.getStackInHand();
28+
if (OldAnimations.ENABLED && itemStack != null && itemStack.getItem() instanceof SwordItem) ci.cancel(); else return;
29+
GlStateManager.pushMatrix();
30+
if (entityRenderer.getModel().child) {
31+
float f = 0.5F;
32+
GlStateManager.translate(0.0F, 0.625F, 0.0F);
33+
GlStateManager.rotate(-20.0F, -1.0F, 0.0F, 0.0F);
34+
GlStateManager.scale(f, f, f);
35+
}
36+
Label_0327:
37+
if (entity instanceof PlayerEntity player) {
38+
if (player.isUsingItem()) {
39+
if (entity.isSneaking()) {
40+
((BiPedModel) entityRenderer.getModel()).setArmAngle(0.0325f);
41+
GlStateManager.scale(1.05f, 1.05f, 1.05f);
42+
GlStateManager.translate(-0.58f, 0.32f, -0.07f);
43+
GlStateManager.rotate(-24405.0f, 137290.0f, -2009900.0f, -2654900.0f);
44+
} else {
45+
((BiPedModel) entityRenderer.getModel()).setArmAngle(0.0325f);
46+
GlStateManager.scale(1.05f, 1.05f, 1.05f);
47+
GlStateManager.translate(-0.45f, 0.25f, -0.07f);
48+
GlStateManager.rotate(-24405.0f, 137290.0f, -2009900.0f, -2654900.0f);
49+
}
50+
} else ((BiPedModel) entityRenderer.getModel()).setArmAngle(0.0625f);
51+
if (!player.isUsingItem()) {
52+
GlStateManager.translate(-0.0855f, 0.4775f, 0.1585f);
53+
GlStateManager.rotate(-19.0f, 20.0f, 0.0f, -6.0f);
54+
break Label_0327;
55+
}
56+
if (player.isUsingItem()) GlStateManager.translate(-0.0625f, 0.4375f, 0.0625f);
57+
} else {
58+
((BiPedModel) entityRenderer.getModel()).setArmAngle(0.0625f);
59+
GlStateManager.translate(-0.0625f, 0.4375f, 0.0625f);
60+
}
61+
if (entity instanceof PlayerEntity player && player.fishHook != null) itemStack = new ItemStack(Items.FISHING_ROD, 0);
62+
Item item = itemStack.getItem();
63+
MinecraftClient minecraft = MinecraftClient.getInstance();
64+
if (item instanceof BlockItem && Block.getBlockFromItem(item).getBlockType() == 2) {
65+
GlStateManager.translate(0.0f, 0.1875f, -0.3125f);
66+
GlStateManager.rotate(20.0f, 1.0f, 0.0f, 0.0f);
67+
GlStateManager.rotate(45.0f, 0.0f, 1.0f, 0.0f);
68+
float f2 = 0.375f;
69+
GlStateManager.scale(-f2, -f2, f2);
70+
}
71+
if (entity.isSneaking()) GlStateManager.translate(0.0f, 0.203125f, 0.0f);
72+
minecraft.getHeldItemRenderer().renderItem(entity, itemStack, ModelTransformation.Mode.THIRD_PERSON);
73+
GlStateManager.popMatrix();
74+
}
75+
}

simpleclient-1.8.9/src/main/resources/simpleclient.mixins.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
"feature.lowfire.HeldItemRendererMixin",
1414
"feature.motionblur.MinecraftClientMixin",
1515
"feature.motionblur.ReloadableResourceManagerImplMixin",
16+
"feature.old_animations.BiPedModelMixin",
17+
"feature.old_animations.HeldItemRendererMixin",
18+
"feature.old_animations.ItemFeatureRendererMixin",
1619
"feature.pvp_improvements.LivingEntityMixin",
1720
"feature.pvp_improvements.MinecraftClientMixin",
1821
"feature.zoom.GameRendererMixin"

0 commit comments

Comments
 (0)