Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.20.4] Some Immersive Portals Fixes #256

Open
wants to merge 2 commits into
base: Multiloader-1.20.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
Expand Down Expand Up @@ -70,15 +71,17 @@ public static boolean isInsideOpaqueBlock(Vec3 in) {
}

public static Triple<Float, BlockState, BlockPos> getNearOpaqueBlock(Vec3 in, double dist) {
if (mc.level == null) {
// Prefer mc.player.level() to prevent getting the head stuck in block with ImmersivePortals.
Level level = mc.player != null && mc.player.level() != null ? mc.player.level() : mc.level;
if (level == null) {
return null;
} else {
AABB aabb = new AABB(in.subtract(dist, dist, dist), in.add(dist, dist, dist));
Stream<BlockPos> stream = BlockPos.betweenClosedStream(aabb).filter((bp) ->
mc.level.getBlockState(bp).isSolidRender(mc.level, bp));
level.getBlockState(bp).isSolidRender(level, bp));
Optional<BlockPos> optional = stream.findFirst();
return optional.isPresent()
? Triple.of(1.0F, mc.level.getBlockState(optional.get()), optional.get())
? Triple.of(1.0F, level.getBlockState(optional.get()), optional.get())
: null;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.vivecraft.mod_compat_vr.immersiveportals.mixin;

import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.Vec3;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.vivecraft.client_vr.gameplay.VRPlayer;
import qouteall.imm_ptl.core.McHelper;

@Mixin(McHelper.class)
public class McHelperMixin {

@Inject(at = @At("HEAD"), method = "updateBoundingBox")
private static void updateBoundingBox(Entity player, CallbackInfo ci) {
if (VRPlayer.get() != null) {
Vec3 newPos = player.position();
VRPlayer.get().setRoomOrigin(newPos.x, newPos.y, newPos.z, true);
}
}

}
10 changes: 10 additions & 0 deletions common/src/main/resources/vivecraft.immersiveportals.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"required": false,
"package": "org.vivecraft.mod_compat_vr.immersiveportals.mixin",
"plugin": "org.vivecraft.MixinConfig",
"compatibilityLevel": "JAVA_17",
"client": [
"McHelperMixin"
],
"minVersion": "0.8.4"
}
1 change: 1 addition & 0 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"vivecraft.dynamicfps.mixins.json",
"vivecraft.sodium.mixins.json",
"vivecraft.fabric.sodium.mixins.json",
"vivecraft.immersiveportals.mixins.json",
"vivecraft.iris.mixins.json",
"vivecraft.modmenu.mixins.json",
"vivecraft.physicsmod.mixins.json",
Expand Down
1 change: 1 addition & 0 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ loom {
mixinConfig "vivecraft.sodium.mixins.json"
mixinConfig "vivecraft.forge.sodium.mixins.json"
mixinConfig "vivecraft.iris.mixins.json"
mixinConfig "vivecraft.immersiveportals.mixins.json"
mixinConfig "vivecraft.physicsmod.mixins.json"
mixinConfig "vivecraft.rei.mixins.json"
mixinConfig "vivecraft.resolutioncontrol.mixins.json"
Expand Down