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

Commit 20c8b33

Browse files
committed
this was a nightmare to work on ngl
1 parent ba500e0 commit 20c8b33

10 files changed

Lines changed: 320 additions & 89 deletions

File tree

src/main/java/io/github/axolotlclient/oldanimations/OldAnimations.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ blocks item positions (rotations) + fix trapdoors and pressure plates and other
3636
tops of certain blocks have switch uvs
3737
tripwire texture and model changes
3838
couldrons model and texture
39+
improve fake block mining believability
3940
*/
4041

4142
public static final String MODID = "axolotlclient-oldanimations";
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* This program is free software; you can redistribute it and/or
3+
* modify it under the terms of the GNU Lesser General Public
4+
* License as published by the Free Software Foundation; either
5+
* version 3 of the License, or (at your option) any later version.
6+
*
7+
* This program is distributed in the hope that it will be useful,
8+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10+
* Lesser General Public License for more details.
11+
*
12+
* You should have received a copy of the GNU Lesser General Public License
13+
* along with this program; if not, write to the Free Software Foundation,
14+
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15+
*
16+
* For more information, see the LICENSE file.
17+
*/
18+
19+
package io.github.axolotlclient.oldanimations.mixin;
20+
21+
import io.github.axolotlclient.oldanimations.config.OldAnimationsConfig;
22+
import io.github.axolotlclient.oldanimations.util.PlayerUtil;
23+
import net.minecraft.block.Block;
24+
import net.minecraft.util.math.BlockPos;
25+
import net.minecraft.util.math.Direction;
26+
import net.minecraft.world.WorldView;
27+
import org.spongepowered.asm.mixin.Mixin;
28+
import org.spongepowered.asm.mixin.injection.At;
29+
import org.spongepowered.asm.mixin.injection.Inject;
30+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
31+
32+
@Mixin(Block.class)
33+
public abstract class BlockMixin {
34+
35+
@Inject(method = "shouldRenderFace", at = @At("HEAD"), cancellable = true)
36+
private void axolotlclient$showFaces(WorldView worldView, BlockPos blockPos, Direction direction, CallbackInfoReturnable<Boolean> cir) {
37+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.useAndMineDestroyVisual.get() &&
38+
PlayerUtil.INSTANCE.isFakeMinedBlock(blockPos)) {
39+
cir.setReturnValue(true);
40+
}
41+
}
42+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* This program is free software; you can redistribute it and/or
3+
* modify it under the terms of the GNU Lesser General Public
4+
* License as published by the Free Software Foundation; either
5+
* version 3 of the License, or (at your option) any later version.
6+
*
7+
* This program is distributed in the hope that it will be useful,
8+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10+
* Lesser General Public License for more details.
11+
*
12+
* You should have received a copy of the GNU Lesser General Public License
13+
* along with this program; if not, write to the Free Software Foundation,
14+
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15+
*
16+
* For more information, see the LICENSE file.
17+
*/
18+
19+
package io.github.axolotlclient.oldanimations.mixin;
20+
21+
import com.mojang.blaze3d.vertex.BufferBuilder;
22+
import io.github.axolotlclient.oldanimations.config.OldAnimationsConfig;
23+
import io.github.axolotlclient.oldanimations.util.PlayerUtil;
24+
import net.minecraft.block.state.BlockState;
25+
import net.minecraft.client.render.block.BlockModelRenderer;
26+
import net.minecraft.client.resource.model.BakedModel;
27+
import net.minecraft.util.math.BlockPos;
28+
import net.minecraft.world.WorldView;
29+
import org.spongepowered.asm.mixin.Mixin;
30+
import org.spongepowered.asm.mixin.injection.At;
31+
import org.spongepowered.asm.mixin.injection.Inject;
32+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
33+
34+
@Mixin(BlockModelRenderer.class)
35+
public abstract class BlockModelRendererMixin {
36+
37+
@Inject(method = "render(Lnet/minecraft/world/WorldView;Lnet/minecraft/client/resource/model/BakedModel;Lnet/minecraft/block/state/BlockState;Lnet/minecraft/util/math/BlockPos;Lcom/mojang/blaze3d/vertex/BufferBuilder;Z)Z", at = @At("HEAD"), cancellable = true)
38+
private void axolotlclient$makeBlockInvisible(WorldView worldView, BakedModel bakedModel, BlockState blockState, BlockPos blockPos, BufferBuilder bufferBuilder, boolean bl, CallbackInfoReturnable<Boolean> cir) {
39+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.useAndMineDestroyVisual.get() &&
40+
PlayerUtil.INSTANCE.isFakeMinedBlock(blockPos)) {
41+
/* in order to sell the illusion, we must make the fake mined blocks invisible! */
42+
cir.setReturnValue(false);
43+
}
44+
}
45+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public abstract class EntityRendererMixin {
4949

5050
@ModifyExpressionValue(method = "renderOnFire", at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/entity/Entity;y:D"))
5151
private double axolotlclient$includeEyeHeight$Y(double original, @Local(argsOnly = true) Entity entity) {
52-
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.flameOffset.get() && PlayerUtil.isSelf(entity)) {
52+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.flameOffset.get() && PlayerUtil.INSTANCE.isSelf(entity)) {
5353
/* taken from 1.7 */
5454
/* we must make sure the flame is synced with the interpolated player model position */
5555
original += (OldAnimationsConfig.instance.thirdPersonSneaking.get() ? ((Sneaky) Minecraft.getInstance().gameRenderer).axolotlclient$getEyeHeight() : entity.getEyeHeight());
@@ -59,7 +59,7 @@ public abstract class EntityRendererMixin {
5959

6060
@WrapOperation(method = "postRender", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/EntityRenderer;renderOnFire(Lnet/minecraft/entity/Entity;DDDF)V"))
6161
private void axolotlclient$includeEyeHeight$renderFire(EntityRenderer<?> instance, Entity entity, double dx, double dy, double dz, float tickDelta, Operation<Void> original) {
62-
boolean oldFlameHeight = OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.flameOffset.get() && PlayerUtil.isSelf(entity);
62+
boolean oldFlameHeight = OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.flameOffset.get() && PlayerUtil.INSTANCE.isSelf(entity);
6363
if (oldFlameHeight) {
6464
GlStateManager.pushMatrix();
6565
/* taken from 1.7 */

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ protected LivingEntityRendererMixin(EntityRenderDispatcher entityRenderDispatche
112112
@Inject(method = "render(Lnet/minecraft/entity/living/LivingEntity;DDDFF)V", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/GlStateManager;translatef(FFF)V"))
113113
private void axolotlclient$addSneakingTranslation(LivingEntity livingEntity, double d, double e, double f, float g, float h, CallbackInfo ci) {
114114
/* in order to match 1.7, we need to elevate the player model while sneaking */
115-
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.thirdPersonSneaking.get() && PlayerUtil.isSelf(livingEntity)) {
115+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.thirdPersonSneaking.get() && PlayerUtil.INSTANCE.isSelf(livingEntity)) {
116116
if (livingEntity.isSneaking()) {
117117
/* we need to remove the already existing sneaking offset */
118118
/* which is present in BiPedModel#render, PlayerEntityModel#render, and related classes */
@@ -143,7 +143,7 @@ protected LivingEntityRendererMixin(EntityRenderDispatcher entityRenderDispatche
143143

144144
@ModifyArg(method = "renderNameTag(Lnet/minecraft/entity/living/LivingEntity;DDD)V", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/GlStateManager;translatef(FFF)V", ordinal = 0), index = 1)
145145
private float axolotlclient$syncNameTag(float f, @Local(argsOnly = true) LivingEntity livingEntity) {
146-
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.thirdPersonSneaking.get() && PlayerUtil.isSelf(livingEntity)) {
146+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.thirdPersonSneaking.get() && PlayerUtil.INSTANCE.isSelf(livingEntity)) {
147147
/* we must ensurethe nametag is synced with the interpolated player model position */
148148
f += ((Sneaky) Minecraft.getInstance().gameRenderer).axolotlclient$getEyeHeight() - 1.62F;
149149
}
@@ -152,7 +152,7 @@ protected LivingEntityRendererMixin(EntityRenderDispatcher entityRenderDispatche
152152

153153
@ModifyArg(method = "renderNameTag(Lnet/minecraft/entity/living/LivingEntity;DDD)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/LivingEntityRenderer;renderNameTag(Lnet/minecraft/entity/Entity;DDDLjava/lang/String;FD)V"), index = 2)
154154
private double axolotlclient$syncNameTag2(double par2, @Local(argsOnly = true) LivingEntity livingEntity) {
155-
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.thirdPersonSneaking.get() && PlayerUtil.isSelf(livingEntity)) {
155+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.thirdPersonSneaking.get() && PlayerUtil.INSTANCE.isSelf(livingEntity)) {
156156
/* we must ensure the nametag is synced with the interpolated player model position once again */
157157
par2 += ((Sneaky) Minecraft.getInstance().gameRenderer).axolotlclient$getEyeHeight() - 1.62F;
158158
}

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public abstract class MinecraftMixin {
8282
BlockPos blockPos = crosshairTarget.getPos();
8383
if (!world.isAir(blockPos)) {
8484
if (OldAnimationsConfig.instance.useAndMineDestroyVisual.get()) {
85-
PlayerUtil.INSTANCE.fakeDestroyBlock(minecraft, blockPos);
85+
PlayerUtil.INSTANCE.fakeUpdateBlockMining(minecraft, blockPos);
8686
}
8787
PlayerUtil.INSTANCE.fakeSwing(player);
8888
if (OldAnimationsConfig.instance.useAndMineParticles.get()) {
@@ -110,6 +110,7 @@ public abstract class MinecraftMixin {
110110

111111
@ModifyExpressionValue(method = "doUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/ClientPlayerInteractionManager;isMiningBlock()Z"))
112112
private boolean axolotlclient$allowMiningCancel(boolean original) {
113+
/* this may flag an anticheat... but so does lunar, badlion, feather, forge mods, etc... we should be as safe as them */
113114
return (!OldAnimationsConfig.isEnabled() || !OldAnimationsConfig.instance.allowMiningCancel.get()) && original;
114115
}
115116

@@ -141,6 +142,14 @@ public abstract class MinecraftMixin {
141142
}
142143
}
143144

145+
@Inject(method = "tick", at = @At("HEAD"))
146+
private void axolotlclient$updatePendingFakeMinedBlocks(CallbackInfo ci) {
147+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.useAndMineDestroyVisual.get()) {
148+
/* this will restore the block by updating the chunk*/
149+
PlayerUtil.INSTANCE.updatePendingRestorations();
150+
}
151+
}
152+
144153
@Inject(method = "tick", at = @At("TAIL"))
145154
private void axolotlclient$spoofTitleVersion(CallbackInfo ci) {
146155
/* nostalgia! */
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* This program is free software; you can redistribute it and/or
3+
* modify it under the terms of the GNU Lesser General Public
4+
* License as published by the Free Software Foundation; either
5+
* version 3 of the License, or (at your option) any later version.
6+
*
7+
* This program is distributed in the hope that it will be useful,
8+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10+
* Lesser General Public License for more details.
11+
*
12+
* You should have received a copy of the GNU Lesser General Public License
13+
* along with this program; if not, write to the Free Software Foundation,
14+
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15+
*
16+
* For more information, see the LICENSE file.
17+
*/
18+
19+
package io.github.axolotlclient.oldanimations.mixin;
20+
21+
import io.github.axolotlclient.oldanimations.config.OldAnimationsConfig;
22+
import io.github.axolotlclient.oldanimations.util.PlayerUtil;
23+
import net.minecraft.client.render.world.WorldRenderer;
24+
import net.minecraft.entity.living.player.PlayerEntity;
25+
import net.minecraft.world.HitResult;
26+
import org.spongepowered.asm.mixin.Mixin;
27+
import org.spongepowered.asm.mixin.injection.At;
28+
import org.spongepowered.asm.mixin.injection.Inject;
29+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
30+
31+
@Mixin(WorldRenderer.class)
32+
public abstract class WorldRendererMixin {
33+
34+
@Inject(method = "renderBlockOutline", at = @At("HEAD"), cancellable = true)
35+
private void axolotlclient$removeOutlineOnFakeMinedBlock(PlayerEntity playerEntity, HitResult hitResult, int i, float f, CallbackInfo ci) {
36+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.useAndMineDestroyVisual.get() &&
37+
PlayerUtil.INSTANCE.isFakeMinedBlock(hitResult.getPos())) {
38+
/* in order to REALLY sell the illusion, we must cancel the block outline */
39+
ci.cancel();
40+
}
41+
}
42+
}

0 commit comments

Comments
 (0)