-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix having xray vision when looking in F5 through quicksand blocks (#240
) 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
Showing
5 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
src/main/java/com/mitchej123/hodgepodge/common/BlockInvoker_FixXray.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinBlock_FixXray.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinWorld_FixXray.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/com/mitchej123/hodgepodge/mixins/late/biomesoplenty/MixinBlockMud_FixXray.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |