diff --git a/src/main/java/club/sk1er/patcher/mixins/features/WorldMixin_CameraPerspective.java b/src/main/java/club/sk1er/patcher/mixins/features/WorldMixin_CameraPerspective.java new file mode 100644 index 00000000..e15cf572 --- /dev/null +++ b/src/main/java/club/sk1er/patcher/mixins/features/WorldMixin_CameraPerspective.java @@ -0,0 +1,34 @@ +package club.sk1er.patcher.mixins.features; + +import club.sk1er.patcher.config.PatcherConfig; +import com.google.common.collect.Sets; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import java.util.Set; + +@Mixin(World.class) +public abstract class WorldMixin_CameraPerspective { + @Unique + private static final Set patcher$ignoredBlocks = Sets.newHashSet( + Blocks.glass, + Blocks.stained_glass, + Blocks.glass_pane, + Blocks.stained_glass_pane, + Blocks.iron_bars + ); + + @Redirect(method = "rayTraceBlocks(Lnet/minecraft/util/Vec3;Lnet/minecraft/util/Vec3;ZZZ)Lnet/minecraft/util/MovingObjectPosition;", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;getCollisionBoundingBox(Lnet/minecraft/world/World;Lnet/minecraft/util/BlockPos;Lnet/minecraft/block/state/IBlockState;)Lnet/minecraft/util/AxisAlignedBB;", ordinal = 1)) + private AxisAlignedBB patcher$shouldCancel(Block instance, World world, BlockPos blockPos, IBlockState iBlockState) { + if (PatcherConfig.betterCamera && patcher$ignoredBlocks.contains(iBlockState.getBlock())) return null; + return instance.getCollisionBoundingBox(world, blockPos, iBlockState); + } +} diff --git a/src/main/resources/mixins.patcher.json b/src/main/resources/mixins.patcher.json index 4f7c60f2..4d0abaca 100644 --- a/src/main/resources/mixins.patcher.json +++ b/src/main/resources/mixins.patcher.json @@ -190,6 +190,7 @@ "features.TileEntityEndPortalRendererMixins_CancelRender", "features.TileEntityMixin_RenderDistance", "features.TileEntitySkullRendererMixin_CancelRender", + "features.WorldMixin_CameraPerspective", "features.containeropacity.GuiChestMixin_ContainerOpacity", "features.containeropacity.GuiInventoryMixin_ContainerOpacity", "features.cropheight.BlockCactusMixin_CropHitbox",