Really ugly, but working rescue (+S direction)
This commit is contained in:
parent
5172dcd059
commit
cbe720198c
|
@ -5,6 +5,8 @@ import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.network.ClientConnection;
|
import net.minecraft.network.ClientConnection;
|
||||||
import net.minecraft.server.PlayerManager;
|
import net.minecraft.server.PlayerManager;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
import org.samo_lego.simpleauth.SimpleAuth;
|
import org.samo_lego.simpleauth.SimpleAuth;
|
||||||
import org.samo_lego.simpleauth.event.entity.player.PlayerJoinServerCallback;
|
import org.samo_lego.simpleauth.event.entity.player.PlayerJoinServerCallback;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
@ -25,15 +27,35 @@ public abstract class MixinPlayerManager {
|
||||||
// Tries to rescue player from nether portal
|
// Tries to rescue player from nether portal
|
||||||
// Teleport - serverPlayerEntity.getBlockState().isOpaque();
|
// Teleport - serverPlayerEntity.getBlockState().isOpaque();
|
||||||
BlockState portalState = serverPlayerEntity.getBlockState();
|
BlockState portalState = serverPlayerEntity.getBlockState();
|
||||||
|
BlockPos portalBlockPos = serverPlayerEntity.getBlockPos();
|
||||||
|
|
||||||
|
World world = serverPlayerEntity.getEntityWorld();
|
||||||
|
|
||||||
|
double x = serverPlayerEntity.getX();
|
||||||
|
double y = serverPlayerEntity.getY();
|
||||||
|
double z = serverPlayerEntity.getZ();
|
||||||
|
|
||||||
if(portalState.get(AXIS) == Z) {
|
if(portalState.get(AXIS) == Z) {
|
||||||
// Player should be put to northern or southern block
|
// Player should be put to eastern or western block
|
||||||
System.out.println("(N/S is ok) Position %s" + serverPlayerEntity.getBlockPos().toString());
|
System.out.println("(W/E is ok) Position " + serverPlayerEntity.getBlockPos().toString());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Player should be put to eastern or western block
|
// Player should be put to northern or southern block
|
||||||
System.out.println("(W/E is ok) Position %s" + serverPlayerEntity.getBlockPos().toString());
|
System.out.println("(N/S is ok) Position " + serverPlayerEntity.getBlockPos().toString());
|
||||||
|
System.out.println("Feet: " + serverPlayerEntity.getEntityWorld().getBlockState(new BlockPos(x, y, z + 1)).isAir());
|
||||||
|
System.out.println("Head: " + serverPlayerEntity.getEntityWorld().getBlockState(new BlockPos(x, y + 1, z + 1)).isAir());
|
||||||
|
System.out.println("Ground: " + serverPlayerEntity.getEntityWorld().getBlockState(new BlockPos(x, y -1, z + 1)).isOpaque());
|
||||||
|
if(
|
||||||
|
world.getBlockState(new BlockPos(x, y, z + 1)).isAir() &&
|
||||||
|
world.getBlockState(new BlockPos(x, y + 1, z + 1)).isAir() &&
|
||||||
|
(world.getBlockState(new BlockPos(x, y - 1, z + 1)).isOpaque() || world.getBlockState(new BlockPos(x, y - 1, z + 1)).hasSolidTopSurface(world,new BlockPos(x, y - 1, z + 1), serverPlayerEntity))
|
||||||
|
) {
|
||||||
|
System.out.println("+z je ok");
|
||||||
|
z++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
serverPlayerEntity.teleport(x, y, z);
|
||||||
|
System.out.println("TPying on x:" + x+ ", y: " +y + ", z:" + z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue