Skip to content

Commit

Permalink
suggested changes, add doc on the quicksand block mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexdoru committed Sep 13, 2023
1 parent ca9456d commit 99abc6b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
2 changes: 0 additions & 2 deletions src/main/java/com/mitchej123/hodgepodge/LoadingConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ public class LoadingConfig {
public boolean fixWorldGetBlock;
public boolean fixWorldServerLeakingUnloadedEntities;
public boolean fixXaerosWorldMapScroll;
public boolean fixXrayThroughBlockWithoutCollisionBoundingBox;
public boolean fixZTonesPackets;
public boolean hideCrosshairInThirdPerson;
public boolean hideIc2ReactorSlots;
Expand Down Expand Up @@ -272,7 +271,6 @@ public LoadingConfig(File file) {
fixWorldGetBlock = config.get(Category.FIXES.toString(), "fixWorldGetBlock", true, "Fix unprotected getBlock() in World").getBoolean();
fixWorldServerLeakingUnloadedEntities = config.get(Category.FIXES.toString(), "fixWorldServerLeakingUnloadedEntities", true, "Fix WorldServer leaking entities when no players are present in a dimension").getBoolean();
fixXaerosWorldMapScroll = config.get(Category.FIXES.toString(), "fixXaerosWorldMapScrolling", true, "Fix scrolling in the world map screen").getBoolean();
fixXrayThroughBlockWithoutCollisionBoundingBox = config.get(Category.FIXES.toString(), "fixXrayThroughBlockWithoutCollisionBoundingBox", true, "Fix the perspective camera not stopping on certain blocks without a collision bouding bow allowing you to have xray vision").getBoolean();
validatePacketEncodingBeforeSending = config.get(Category.FIXES.toString(), "validatePacketEncodingBeforeSending", true, "Validate vanilla packet encodings before sending in addition to on reception").getBoolean();
validatePacketEncodingBeforeSendingShouldCrash = config.get(Category.FIXES.toString(), "validatePacketEncodingBeforeSendingShouldCrash", false, "Should the extended packet validation error cause a crash (true) or just print out an error to the log (false)").getBoolean();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import net.minecraft.world.World;

public interface BlockInvoker {
public interface BlockInvoker_FixXray {

boolean hodgepodge$shouldRayTraceStopOnBlock(World worldIn, int x, int y, int z);
}
17 changes: 6 additions & 11 deletions 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 @@ -340,17 +344,8 @@ public enum Mixins {

// BOP
FIX_QUICKSAND_XRAY(new Builder("Fix Xray through block without collision boundingBox")
.addMixinClasses("biomesoplenty.MixinBlockMud")
.setApplyIf(
() -> Common.config.fixPerspectiveCamera
&& Common.config.fixXrayThroughBlockWithoutCollisionBoundingBox)
.addMixinClasses("biomesoplenty.MixinBlockMud_FixXray").setApplyIf(() -> Common.config.fixPerspectiveCamera)
.addTargetedMod(TargetedMod.BOP)),
FIX_QUICKSAND_XRAY2(new Builder("Fix Xray through block without collision boundingBox")
.addMixinClasses("minecraft.MixinBlock_FixXray", "minecraft.MixinWorld_FixXray")
.setApplyIf(
() -> Common.config.fixPerspectiveCamera
&& Common.config.fixXrayThroughBlockWithoutCollisionBoundingBox)
.addTargetedMod(TargetedMod.VANILLA).setPhase(Phase.EARLY)),
DEDUPLICATE_FORESTRY_COMPAT_IN_BOP(
new Builder("BOP Forestry Compat").addMixinClasses("biomesoplenty.MixinForestryIntegration")
.setApplyIf(() -> Common.config.deduplicateForestryCompatInBOP).addTargetedMod(TargetedMod.BOP)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

import com.mitchej123.hodgepodge.common.BlockInvoker;
import com.mitchej123.hodgepodge.common.BlockInvoker_FixXray;

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

@Shadow
public abstract AxisAlignedBB getCollisionBoundingBoxFromPool(World worldIn, int x, int y, int z);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

import com.mitchej123.hodgepodge.common.BlockInvoker;
import com.mitchej123.hodgepodge.common.BlockInvoker_FixXray;

@Mixin(World.class)
public class MixinWorld_FixXray {

@Unique
private static final AxisAlignedBB hodgepodge$dummyAABB = AxisAlignedBB.getBoundingBox(0, 0, 0, 0, 0, 0);
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) block).hodgepodge$shouldRayTraceStopOnBlock(world, x, y, z)) {
return hodgepodge$dummyAABB;
if (((BlockInvoker_FixXray) block).hodgepodge$shouldRayTraceStopOnBlock(world, x, y, z)) {
return hodgepodge$DUMMY_AABB;
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@

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 extends MixinBlock_FixXray {
public abstract class MixinBlockMud_FixXray extends MixinBlock_FixXray {

@Override
public boolean hodgepodge$shouldRayTraceStopOnBlock(World world, int x, int y, int z) {
Expand Down

0 comments on commit 99abc6b

Please sign in to comment.