Skip to content

Commit 47e44b1

Browse files
committed
improve fake block mining
1 parent af60030 commit 47e44b1

File tree

7 files changed

+210
-11
lines changed

7 files changed

+210
-11
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +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
39+
improve fake block mining believability - paneblock and tripwireblock are still not accurate
4040
*/
4141

4242
public static final String MODID = "axolotlclient-oldanimations";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public abstract class HeldItemRendererMixin {
116116
@Inject(method = "renderInFirstPerson", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/HeldItemRenderer;render(Lnet/minecraft/entity/living/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/block/ModelTransformations$Type;)V"))
117117
private void axolotlclient$applyRodRotation(float partialTicks, CallbackInfo ci) {
118118
/* original transformation from 1.7 */
119-
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.oldRodRotation.get() && item.getItem().shouldRotate()) {
119+
if (OldAnimationsConfig.isEnabled() && (OldAnimationsConfig.instance.oldRodRotation.get() || OldAnimationsConfig.instance.disableResourcePackItemTransformations.get()) && item.getItem().shouldRotate()) {
120120
GlStateManager.rotatef(180.0F, 0.0F, 1.0F, 0.0F);
121121
}
122122
}

src/main/java/io/github/axolotlclient/oldanimations/mixin/BlockMixin.java renamed to src/main/java/io/github/axolotlclient/oldanimations/mixin/blocks/FenceBlockMixin.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,26 @@
1616
* For more information, see the LICENSE file.
1717
*/
1818

19-
package io.github.axolotlclient.oldanimations.mixin;
19+
package io.github.axolotlclient.oldanimations.mixin.blocks;
2020

2121
import io.github.axolotlclient.oldanimations.config.OldAnimationsConfig;
2222
import io.github.axolotlclient.oldanimations.util.PlayerUtil;
23-
import net.minecraft.block.Block;
23+
import net.minecraft.block.FenceBlock;
2424
import net.minecraft.util.math.BlockPos;
25-
import net.minecraft.util.math.Direction;
2625
import net.minecraft.world.WorldView;
2726
import org.spongepowered.asm.mixin.Mixin;
2827
import org.spongepowered.asm.mixin.injection.At;
2928
import org.spongepowered.asm.mixin.injection.Inject;
3029
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
3130

32-
@Mixin(Block.class)
33-
public abstract class BlockMixin {
31+
@Mixin(FenceBlock.class)
32+
public abstract class FenceBlockMixin {
3433

35-
@Inject(method = "shouldRenderFace", at = @At("HEAD"), cancellable = true)
36-
private void axolotlclient$showFaces(WorldView worldView, BlockPos blockPos, Direction direction, CallbackInfoReturnable<Boolean> cir) {
34+
@Inject(method = "shouldConnectTo", at = @At("HEAD"), cancellable = true)
35+
private void axolotlclient$disconnectBlock(WorldView worldView, BlockPos blockPos, CallbackInfoReturnable<Boolean> cir) {
3736
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.useAndMineDestroyVisual.get() &&
3837
PlayerUtil.INSTANCE.isFakeMinedBlock(blockPos)) {
39-
cir.setReturnValue(true);
38+
cir.setReturnValue(false);
4039
}
4140
}
4241
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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.blocks;
20+
21+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
22+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
23+
import com.llamalad7.mixinextras.sugar.Local;
24+
import io.github.axolotlclient.oldanimations.config.OldAnimationsConfig;
25+
import io.github.axolotlclient.oldanimations.util.PlayerUtil;
26+
import net.minecraft.block.RedstoneWireBlock;
27+
import net.minecraft.block.state.BlockState;
28+
import net.minecraft.util.math.BlockPos;
29+
import net.minecraft.util.math.Direction;
30+
import net.minecraft.world.WorldView;
31+
import org.spongepowered.asm.mixin.Mixin;
32+
import org.spongepowered.asm.mixin.injection.At;
33+
34+
@Mixin(RedstoneWireBlock.class)
35+
public abstract class RedstoneWireBlockMixin {
36+
37+
@WrapOperation(method = "getConnection", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/RedstoneWireBlock;shouldConnectTo(Lnet/minecraft/block/state/BlockState;Lnet/minecraft/util/math/Direction;)Z"))
38+
private boolean axolotlclient$disconnectBlock(BlockState blockState, Direction direction, Operation<Boolean> original, @Local(index = 4, ordinal = 1) BlockPos blockPos2) {
39+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.useAndMineDestroyVisual.get() &&
40+
PlayerUtil.INSTANCE.isFakeMinedBlock(blockPos2)) {
41+
return false;
42+
}
43+
return original.call(blockState, direction);
44+
}
45+
46+
@WrapOperation(method = "getConnection", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/RedstoneWireBlock;shouldConnectTo(Lnet/minecraft/block/state/BlockState;)Z"))
47+
private boolean axolotlclient$disconnectBlock2(BlockState blockState, Operation<Boolean> original, @Local(index = 4, ordinal = 1) BlockPos blockPos2) {
48+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.useAndMineDestroyVisual.get() &&
49+
PlayerUtil.INSTANCE.isFakeMinedBlock(blockPos2)) {
50+
return false;
51+
}
52+
return original.call(blockState);
53+
}
54+
55+
@WrapOperation(method = "connectsTo", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/RedstoneWireBlock;shouldConnectTo(Lnet/minecraft/block/state/BlockState;Lnet/minecraft/util/math/Direction;)Z"))
56+
private boolean axolotlclient$disconnectBlock3(BlockState blockState, Direction direction, Operation<Boolean> original, @Local(index = 4, ordinal = 1) BlockPos blockPos2) {
57+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.useAndMineDestroyVisual.get() &&
58+
PlayerUtil.INSTANCE.isFakeMinedBlock(blockPos2)) {
59+
return false;
60+
}
61+
return original.call(blockState, direction);
62+
}
63+
64+
@WrapOperation(method = "connectsTo", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/RedstoneWireBlock;shouldConnectTo(Lnet/minecraft/world/WorldView;Lnet/minecraft/util/math/BlockPos;)Z"))
65+
private boolean axolotlclient$disconnectBlock4(WorldView worldView, BlockPos blockPos, Operation<Boolean> original, @Local(index = 4, ordinal = 1) BlockPos blockPos2) {
66+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.useAndMineDestroyVisual.get() &&
67+
PlayerUtil.INSTANCE.isFakeMinedBlock(blockPos2)) {
68+
return false;
69+
}
70+
return original.call(worldView, blockPos);
71+
}
72+
73+
@WrapOperation(method = "getConnection", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/RedstoneWireBlock;shouldConnectTo(Lnet/minecraft/block/state/BlockState;Lnet/minecraft/util/math/Direction;)Z"))
74+
private boolean axolotlclient$disconnectBlock5(BlockState blockState, Direction direction, Operation<Boolean> original, @Local(index = 4, ordinal = 1) BlockPos blockPos2) {
75+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.useAndMineDestroyVisual.get() &&
76+
PlayerUtil.INSTANCE.isFakeMinedBlock(blockPos2)) {
77+
return false;
78+
}
79+
return original.call(blockState, direction);
80+
}
81+
82+
@WrapOperation(method = "getConnection", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/RedstoneWireBlock;shouldConnectTo(Lnet/minecraft/block/state/BlockState;)Z"))
83+
private boolean axolotlclient$disconnectBlock6(BlockState blockState, Operation<Boolean> original, @Local(index = 4, ordinal = 1) BlockPos blockPos2) {
84+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.useAndMineDestroyVisual.get() &&
85+
PlayerUtil.INSTANCE.isFakeMinedBlock(blockPos2)) {
86+
return false;
87+
}
88+
return original.call(blockState);
89+
}
90+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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.blocks;
20+
21+
import io.github.axolotlclient.oldanimations.config.OldAnimationsConfig;
22+
import io.github.axolotlclient.oldanimations.util.PlayerUtil;
23+
import net.minecraft.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(
33+
value = {
34+
Block.class,
35+
AnvilBlock.class,
36+
BlockWithCulling.class,
37+
CarpetBlock.class,
38+
DiodeBlock.class,
39+
DragonEggBlock.class,
40+
EndPortalBlock.class,
41+
FarmlandBlock.class,
42+
FenceBlock.class,
43+
FenceGateBlock.class,
44+
HopperBlock.class,
45+
LiquidBlock.class,
46+
PaneBlock.class,
47+
PistonHeadBlock.class,
48+
PortalBlock.class,
49+
SlabBlock.class,
50+
SnowLayerBlock.class,
51+
TransparentBlock.class,
52+
WallBlock.class
53+
}
54+
)
55+
public class RenderBlockFaceMixin {
56+
57+
@Inject(method = "shouldRenderFace", at = @At("HEAD"), cancellable = true)
58+
private void axolotlclient$showFaces(WorldView worldView, BlockPos blockPos, Direction direction, CallbackInfoReturnable<Boolean> cir) {
59+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.useAndMineDestroyVisual.get() &&
60+
PlayerUtil.INSTANCE.isFakeMinedBlock(blockPos)) {
61+
cir.setReturnValue(true);
62+
}
63+
}
64+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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.blocks;
20+
21+
import io.github.axolotlclient.oldanimations.config.OldAnimationsConfig;
22+
import io.github.axolotlclient.oldanimations.util.PlayerUtil;
23+
import net.minecraft.block.WallBlock;
24+
import net.minecraft.util.math.BlockPos;
25+
import net.minecraft.world.WorldView;
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.CallbackInfoReturnable;
30+
31+
@Mixin(WallBlock.class)
32+
public class WallBlockMixin {
33+
34+
@Inject(method = "shouldConnectTo", at = @At("HEAD"), cancellable = true)
35+
private void axolotlclient$disconnectBlock(WorldView worldView, BlockPos blockPos, CallbackInfoReturnable<Boolean> cir) {
36+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.useAndMineDestroyVisual.get() &&
37+
PlayerUtil.INSTANCE.isFakeMinedBlock(blockPos)) {
38+
cir.setReturnValue(false);
39+
}
40+
}
41+
}

src/main/resources/oldanimations.mixins.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"minVersion": "0.5.0-rc.2"
77
},
88
"client": [
9-
"BlockMixin",
109
"BlockModelAccessor",
1110
"BlockModelRendererMixin",
1211
"CapeLayerMixin",
@@ -41,6 +40,12 @@
4140
"ServerListEntryWidgetMixin",
4241
"ServerPlayerEntityMixin",
4342
"WorldRendererMixin",
43+
"blocks.FenceBlockMixin",
44+
"blocks.PaneBlockMixin",
45+
"blocks.RedstoneWireBlockMixin",
46+
"blocks.RenderBlockFaceMixin",
47+
"blocks.TripwireBlockMixin",
48+
"blocks.WallBlockMixin",
4449
"mob_layers.AbstractArmorLayerMixin",
4550
"mob_layers.EnderDragonEyesLayerMixin",
4651
"mob_layers.EndermanEyesLayerMixin",

0 commit comments

Comments
 (0)