Skip to content

Commit 49288bf

Browse files
committed
oops forgot this file :P
1 parent 0bcc1da commit 49288bf

File tree

1 file changed

+41
-13
lines changed

1 file changed

+41
-13
lines changed

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

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,53 @@
1818

1919
package io.github.axolotlclient.oldanimations.mixin;
2020

21+
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
22+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
23+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
2124
import io.github.axolotlclient.oldanimations.config.OldAnimationsConfig;
22-
import io.github.axolotlclient.oldanimations.util.PlayerUtil;
25+
import net.minecraft.block.Block;
26+
import net.minecraft.block.Blocks;
27+
import net.minecraft.block.state.BlockState;
28+
import net.minecraft.client.render.world.BlockMiningProgress;
2329
import net.minecraft.client.render.world.WorldRenderer;
24-
import net.minecraft.entity.living.player.PlayerEntity;
25-
import net.minecraft.world.HitResult;
2630
import org.spongepowered.asm.mixin.Mixin;
2731
import org.spongepowered.asm.mixin.injection.At;
28-
import org.spongepowered.asm.mixin.injection.Inject;
29-
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
32+
33+
import java.util.Collection;
34+
import java.util.Collections;
35+
import java.util.Map;
3036

3137
@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();
38+
public class WorldRendererMixin {
39+
40+
@WrapWithCondition(method = "renderEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/world/WorldRenderer;setupMiningProgressState()V"))
41+
private boolean axolotlclient$removeMiningProgressGLState(WorldRenderer instance) {
42+
/* we should stop setting these GL states */
43+
return !OldAnimationsConfig.isEnabled() || !OldAnimationsConfig.instance.blockEntityMiningProgress.get();
44+
}
45+
46+
@WrapOperation(method = "renderEntities", at = @At(value = "INVOKE", target = "Ljava/util/Map;values()Ljava/util/Collection;"))
47+
private <V extends BlockMiningProgress> Collection<V> axolotlclient$doNotRenderMiningProgress(Map<Integer, BlockMiningProgress> instance, Operation<Collection<V>> original) {
48+
/* goodbye france. hello paris */
49+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.blockEntityMiningProgress.get()) {
50+
return Collections.emptyList();
51+
}
52+
return original.call(instance);
53+
}
54+
55+
@WrapWithCondition(method = "renderEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/world/WorldRenderer;restoreMiningProgressState()V"))
56+
private boolean axolotlclient$removeMiningProgressGLState2(WorldRenderer instance) {
57+
/* we should stop setting these GL states again */
58+
return !OldAnimationsConfig.isEnabled() || !OldAnimationsConfig.instance.blockEntityMiningProgress.get();
59+
}
60+
61+
@WrapOperation(method = "renderMiningProgress", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/state/BlockState;getBlock()Lnet/minecraft/block/Block;", ordinal = 0))
62+
private Block axolotlclient$skipBlockEntityCheck(BlockState instance, Operation<Block> original) {
63+
/* this should remove the blockentity check stopping the mining progress from showing on them. */
64+
/* i definitely don't think this will do anything tho just due to how the block entity rendering works */
65+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.blockEntityMiningProgress.get()) {
66+
return Blocks.AIR;
4067
}
68+
return original.call(instance);
4169
}
4270
}

0 commit comments

Comments
 (0)