From 1004106b59ff5f6d9a56c607d439fded76a591dd Mon Sep 17 00:00:00 2001 From: Robijnvogel Date: Mon, 2 Jul 2018 21:37:46 +0200 Subject: [PATCH] Teleporting from Limbo to ocean surface -Eternal Fabric no longer teleports you to the bottom of the sea, but instead to the surface. (Same with surface Lava lakes, probably :) Fixes #78 --- src/main/java/org/dimdev/pocketlib/VirtualLocation.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/dimdev/pocketlib/VirtualLocation.java b/src/main/java/org/dimdev/pocketlib/VirtualLocation.java index e020c147..89217d68 100644 --- a/src/main/java/org/dimdev/pocketlib/VirtualLocation.java +++ b/src/main/java/org/dimdev/pocketlib/VirtualLocation.java @@ -1,6 +1,8 @@ package org.dimdev.pocketlib; import lombok.*; +import net.minecraft.block.Block; +import net.minecraft.block.material.MaterialLiquid; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -50,7 +52,11 @@ import org.dimdev.dimdoors.shared.world.limbo.WorldProviderLimbo; float spread = ModConfig.general.depthSpreadFactor * depth; // TODO: gaussian spread, handle air-filled/pocket world int newX = (int) (x + spread * 2 * (Math.random() - 0.5)); int newZ = (int) (z + spread * 2 * (Math.random() - 0.5)); - BlockPos pos = world.getTopSolidOrLiquidBlock(new BlockPos(newX, 0, newZ)); + BlockPos pos = world.getTopSolidOrLiquidBlock(new BlockPos(newX, 0, newZ)); // Does not actually detect liquid blocks and returns the position above the surface + do { + pos = pos.up(); + } while (world.getBlockState(pos).getMaterial() instanceof MaterialLiquid); + return new Location(world, pos); } }