Skip to content

Commit

Permalink
add all blocks for better camera (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
MicrocontrollersDev authored Nov 11, 2024
1 parent 911aa28 commit 11eede6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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<Block> 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);
}
}
1 change: 1 addition & 0 deletions src/main/resources/mixins.patcher.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 11eede6

Please sign in to comment.