|
18 | 18 |
|
19 | 19 | package io.github.axolotlclient.oldanimations.mixin; |
20 | 20 |
|
| 21 | +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; |
| 22 | +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; |
| 23 | +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; |
21 | 24 | 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; |
23 | 29 | import net.minecraft.client.render.world.WorldRenderer; |
24 | | -import net.minecraft.entity.living.player.PlayerEntity; |
25 | | -import net.minecraft.world.HitResult; |
26 | 30 | import org.spongepowered.asm.mixin.Mixin; |
27 | 31 | 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; |
30 | 36 |
|
31 | 37 | @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; |
40 | 67 | } |
| 68 | + return original.call(instance); |
41 | 69 | } |
42 | 70 | } |
0 commit comments