Skip to content

Commit

Permalink
Fix having xray vision when looking in F5 through quicksand blocks (#240
Browse files Browse the repository at this point in the history
)

fix having xray vision through solid opaque blocks that don't have a collision box such as quicksand when looking in F5
  • Loading branch information
Alexdoru authored Sep 13, 2023
1 parent fa909af commit 71a9500
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.mitchej123.hodgepodge.common;

import net.minecraft.world.World;

public interface BlockInvoker_FixXray {

boolean hodgepodge$shouldRayTraceStopOnBlock(World worldIn, int x, int y, int z);
}
11 changes: 10 additions & 1 deletion src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,18 @@ public enum Mixins {
FIX_PLAYER_SKIN_FETCHING(new Builder("Fix player skin fetching").setPhase(Phase.EARLY)
.addMixinClasses("minecraft.MixinAbstractClientPlayer").setSide(Side.CLIENT)
.setApplyIf(() -> Common.config.fixPlayerSkinFetching).addTargetedMod(TargetedMod.VANILLA)),

VALIDATE_PACKET_ENCODING_BEFORE_SENDING(new Builder("Validate packet encoding before sending").setPhase(Phase.EARLY)
.addMixinClasses("minecraft.packets.MixinDataWatcher", "minecraft.packets.MixinS3FPacketCustomPayload")
.setSide(Side.BOTH).setApplyIf(() -> Common.config.validatePacketEncodingBeforeSending)
.addTargetedMod(TargetedMod.VANILLA)),
FIX_FLUID_CONTAINER_REGISTRY_KEY(new Builder("Fix Forge fluid container registry key").setPhase(Phase.EARLY)
.addMixinClasses("forge.FluidContainerRegistryAccessor", "forge.MixinFluidRegistry").setSide(Side.BOTH)
.setApplyIf(() -> Common.config.fixFluidContainerRegistryKey).addTargetedMod(TargetedMod.VANILLA)),
FIX_XRAY_BLOCK_WITHOUT_COLLISION_AABB(new Builder("Fix Xray through block without collision boundingBox")
.addMixinClasses("minecraft.MixinBlock_FixXray", "minecraft.MixinWorld_FixXray")
.setApplyIf(() -> Common.config.fixPerspectiveCamera).addTargetedMod(TargetedMod.VANILLA)
.setPhase(Phase.EARLY)),

// Ic2 adjustments
IC2_UNPROTECTED_GET_BLOCK_FIX(
new Builder("IC2 Kinetic Fix").setPhase(Phase.EARLY).addMixinClasses("ic2.MixinIc2WaterKinetic")
Expand Down Expand Up @@ -339,6 +343,9 @@ public enum Mixins {
.setApplyIf(() -> Common.config.fixThaumcraftGolemMarkerLoading).addTargetedMod(TargetedMod.THAUMCRAFT)),

// BOP
FIX_QUICKSAND_XRAY(new Builder("Fix Xray through block without collision boundingBox")
.addMixinClasses("biomesoplenty.MixinBlockMud_FixXray").setApplyIf(() -> Common.config.fixPerspectiveCamera)
.addTargetedMod(TargetedMod.BOP)),
DEDUPLICATE_FORESTRY_COMPAT_IN_BOP(
new Builder("BOP Forestry Compat").addMixinClasses("biomesoplenty.MixinForestryIntegration")
.setApplyIf(() -> Common.config.deduplicateForestryCompatInBOP).addTargetedMod(TargetedMod.BOP)),
Expand All @@ -353,6 +360,8 @@ public enum Mixins {
JAVA12_BOP(new Builder("BOP Java12-safe reflection").addMixinClasses("biomesoplenty.MixinBOPBiomes")
.addMixinClasses("biomesoplenty.MixinBOPReflectionHelper").setApplyIf(() -> Common.config.java12BopCompat)
.addTargetedMod(TargetedMod.BOP)),

// Immersive engineering
JAVA12_IMMERSIVE_ENGINERRING(new Builder("Immersive Engineering Java-12 safe potion array resizing")
.addMixinClasses("immersiveengineering.MixinIEPotions")
.setApplyIf(() -> Common.config.java12ImmersiveEngineeringCompat)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.mitchej123.hodgepodge.mixins.early.minecraft;

import net.minecraft.block.Block;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

import com.mitchej123.hodgepodge.common.BlockInvoker_FixXray;

@Mixin(Block.class)
public abstract class MixinBlock_FixXray implements BlockInvoker_FixXray {

@Shadow
public abstract AxisAlignedBB getCollisionBoundingBoxFromPool(World worldIn, int x, int y, int z);

public boolean hodgepodge$shouldRayTraceStopOnBlock(World worldIn, int x, int y, int z) {
return this.getCollisionBoundingBoxFromPool(worldIn, x, y, z) != null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.mitchej123.hodgepodge.mixins.early.minecraft;

import net.minecraft.block.Block;
import net.minecraft.util.AxisAlignedBB;
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 com.mitchej123.hodgepodge.common.BlockInvoker_FixXray;

@Mixin(World.class)
public class MixinWorld_FixXray {

@Unique
private static final AxisAlignedBB hodgepodge$DUMMY_AABB = AxisAlignedBB.getBoundingBox(0, 0, 0, 0, 0, 0);

@Redirect(
method = "func_147447_a",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/block/Block;getCollisionBoundingBoxFromPool(Lnet/minecraft/world/World;III)Lnet/minecraft/util/AxisAlignedBB;"))
private AxisAlignedBB hodgepodge$fixXray(Block block, World world, int x, int y, int z) {
if (((BlockInvoker_FixXray) block).hodgepodge$shouldRayTraceStopOnBlock(world, x, y, z)) {
return hodgepodge$DUMMY_AABB;
}
return null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.mitchej123.hodgepodge.mixins.late.biomesoplenty;

import net.minecraft.world.World;

import org.spongepowered.asm.mixin.Mixin;

import com.mitchej123.hodgepodge.mixins.early.minecraft.MixinBlock_FixXray;

import biomesoplenty.common.blocks.BlockMud;

/**
* Blocks that are rendered as full blocks but override the
* {@link net.minecraft.block.Block#getCollisionBoundingBoxFromPool(World, int, int, int)} method to return null should
* be added to this mixin so that the player can't look through them in F5 and have xray vision
*
* @author Alexdoru
*/
@Mixin(BlockMud.class)
public abstract class MixinBlockMud_FixXray extends MixinBlock_FixXray {

@Override
public boolean hodgepodge$shouldRayTraceStopOnBlock(World world, int x, int y, int z) {
return true;
}

}

0 comments on commit 71a9500

Please sign in to comment.