Skip to content

Commit

Permalink
fix interaction bug with pocket dimension exit
Browse files Browse the repository at this point in the history
  • Loading branch information
UpcraftLP committed Jan 31, 2025
1 parent bfb2981 commit 13e5650
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import dev.cammiescorner.arcanuscontinuum.common.blocks.entities.SpatialRiftExitBlockEntity;
import dev.cammiescorner.arcanuscontinuum.common.components.level.PocketDimensionComponent;
import dev.cammiescorner.arcanuscontinuum.common.registry.ArcanusBlocks;
import dev.upcraft.sparkweave.api.util.scheduler.Tasks;
import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
Expand All @@ -28,11 +29,14 @@ public SpatialRiftExitBlock() {
}

@Override
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if(!world.isClientSide() && !PocketDimensionComponent.get(world).teleportOutOfPocketDimension(player))
return InteractionResult.FAIL;

return InteractionResult.sidedSuccess(world.isClientSide());
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if(!level.isClientSide()) {
// the game assumes that at the end of the right click, the player is still in the same dimension.
// therefore we need to schedule the teleportation at some later point
Tasks.scheduleEphemeral(() -> PocketDimensionComponent.get(level).teleportOutOfPocketDimension(player), 0L);
}

return InteractionResult.sidedSuccess(level.isClientSide());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ else if(!chunksExist(plot, pocketDim)) {
}

public boolean teleportOutOfPocketDimension(Entity entity) {
if((entity instanceof Player player && FakePlayerHelper.isFakePlayer(player)) || entity.level().isClientSide() || entity.level().dimension() != ArcanusDimensions.POCKET_DIMENSION)
if((entity instanceof Player player && FakePlayerHelper.isFakePlayer(player)) || entity.level().dimension() != ArcanusDimensions.POCKET_DIMENSION)
return false;

UUID ownerId = existingPlots.values().stream().filter(plot -> entity.getBoundingBox().intersects(AABB.of(plot.getBounds()))).map(PocketDimensionPlot::ownerId).findFirst().orElse(null);
Expand Down

0 comments on commit 13e5650

Please sign in to comment.