当前位置: 首页>>代码示例>>Java>>正文


Java DimensionVector3类代码示例

本文整理汇总了Java中com.protolambda.blocktopograph.util.math.DimensionVector3的典型用法代码示例。如果您正苦于以下问题:Java DimensionVector3类的具体用法?Java DimensionVector3怎么用?Java DimensionVector3使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DimensionVector3类属于com.protolambda.blocktopograph.util.math包,在下文中一共展示了DimensionVector3类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSpawnPos

import com.protolambda.blocktopograph.util.math.DimensionVector3; //导入依赖的package包/类
public static DimensionVector3<Integer> getSpawnPos(WorldProvider worldProvider) throws Exception {
    try {
        CompoundTag level = worldProvider.getWorld().level;
        int spawnX = ((IntTag) level.getChildTagByKey("SpawnX")).getValue();
        int spawnY = ((IntTag) level.getChildTagByKey("SpawnY")).getValue();
        int spawnZ = ((IntTag) level.getChildTagByKey("SpawnZ")).getValue();
        if (spawnY == 256) {
            TerrainChunkData data = worldProvider.getChunkManager(Dimension.OVERWORLD)
                    .getChunk(spawnX >> 4, spawnZ >> 4)
                    .getTerrain((byte) 0);
            if (data.load2DData()) {
                spawnY = data.getHeightMapValue(spawnX % 16, spawnZ % 16) + 1;
            }
        }
        return new DimensionVector3<>(spawnX, spawnY, spawnZ, Dimension.OVERWORLD);
    } catch (Exception e) {
        throw new Exception("Could not find spawn");
    }
}
 
开发者ID:jocopa3,项目名称:blocktopograph-library,代码行数:20,代码来源:Map.java

示例2: getSpawnPos

import com.protolambda.blocktopograph.util.math.DimensionVector3; //导入依赖的package包/类
public DimensionVector3<Integer> getSpawnPos() throws Exception {
    try {
        CompoundTag level = this.worldProvider.getWorld().level;
        int spawnX = ((IntTag) level.getChildTagByKey("SpawnX")).getValue();
        int spawnY = ((IntTag) level.getChildTagByKey("SpawnY")).getValue();
        int spawnZ = ((IntTag) level.getChildTagByKey("SpawnZ")).getValue();
        if(spawnY == 256){
            TerrainChunkData data = new ChunkManager(
                        this.worldProvider.getWorld().getWorldData(), Dimension.OVERWORLD)
                    .getChunk(spawnX >> 4, spawnZ >> 4)
                    .getTerrain((byte) 0);
            if(data.load2DData()) spawnY = data.getHeightMapValue(spawnX % 16, spawnZ % 16) + 1;
        }
        return new DimensionVector3<>( spawnX, spawnY, spawnZ, Dimension.OVERWORLD);
    } catch (Exception e){
        throw new Exception("Could not find spawn");
    }
}
 
开发者ID:protolambda,项目名称:blocktopograph,代码行数:19,代码来源:MapFragment.java

示例3: getMultiPlayerPos

import com.protolambda.blocktopograph.util.math.DimensionVector3; //导入依赖的package包/类
public DimensionVector3<Float> getMultiPlayerPos(String dbKey) throws Exception {
    try {
        WorldData wData = worldProvider.getWorld().getWorldData();
        wData.openDB();
        byte[] data = wData.db.get(dbKey.getBytes(NBTConstants.CHARSET));
        if(data == null) throw new Exception("no data!");
        final CompoundTag player = (CompoundTag) DataConverter.read(data).get(0);

        ListTag posVec = (ListTag) player.getChildTagByKey("Pos");
        if (posVec == null || posVec.getValue() == null)
            throw new Exception("No \"Pos\" specified");
        if (posVec.getValue().size() != 3)
            throw new Exception("\"Pos\" value is invalid. value: " + posVec.getValue().toString());

        IntTag dimensionId = (IntTag) player.getChildTagByKey("DimensionId");
        if(dimensionId == null || dimensionId.getValue() == null)
            throw new Exception("No \"DimensionId\" specified");
        Dimension dimension = Dimension.getDimension(dimensionId.getValue());
        if(dimension == null) dimension = Dimension.OVERWORLD;

        return new DimensionVector3<>(
                (float) posVec.getValue().get(0).getValue(),
                (float) posVec.getValue().get(1).getValue(),
                (float) posVec.getValue().get(2).getValue(),
                dimension);

    } catch (Exception e) {
        Log.e(e.getMessage());

        Exception e2 = new Exception("Could not find "+dbKey);
        e2.setStackTrace(e.getStackTrace());
        throw e2;
    }
}
 
开发者ID:protolambda,项目名称:blocktopograph,代码行数:35,代码来源:MapFragment.java

示例4: getPlayerPos

import com.protolambda.blocktopograph.util.math.DimensionVector3; //导入依赖的package包/类
public DimensionVector3<Float> getPlayerPos() throws Exception {
    try {
        WorldData wData = worldProvider.getWorld().getWorldData();
        wData.openDB();
        byte[] data = wData.db.get(World.SpecialDBEntryType.LOCAL_PLAYER.keyBytes);

        final CompoundTag player = data != null
                ? (CompoundTag) DataConverter.read(data).get(0)
                : (CompoundTag) worldProvider.getWorld().level.getChildTagByKey("Player");

        ListTag posVec = (ListTag) player.getChildTagByKey("Pos");
        if (posVec == null || posVec.getValue() == null)
            throw new Exception("No \"Pos\" specified");
        if (posVec.getValue().size() != 3)
            throw new Exception("\"Pos\" value is invalid. value: " + posVec.getValue().toString());

        IntTag dimensionId = (IntTag) player.getChildTagByKey("DimensionId");
        if(dimensionId == null || dimensionId.getValue() == null)
            throw new Exception("No \"DimensionId\" specified");
        Dimension dimension = Dimension.getDimension(dimensionId.getValue());
        if(dimension == null) dimension = Dimension.OVERWORLD;

        return new DimensionVector3<>(
                (float) posVec.getValue().get(0).getValue(),
                (float) posVec.getValue().get(1).getValue(),
                (float) posVec.getValue().get(2).getValue(),
                dimension);

    } catch (Exception e) {
        Log.e(e.toString());

        Exception e2 = new Exception("Could not find player.");
        e2.setStackTrace(e.getStackTrace());
        throw e2;
    }
}
 
开发者ID:protolambda,项目名称:blocktopograph,代码行数:37,代码来源:MapFragment.java

示例5: getPlayerPos

import com.protolambda.blocktopograph.util.math.DimensionVector3; //导入依赖的package包/类
public static DimensionVector3<Float> getPlayerPos(WorldProvider worldProvider) throws Exception {
    try {
        WorldData wData = worldProvider.getWorld().getWorldData();
        //wData.openDB();
        byte[] data = wData.db.get(World.SpecialDBEntryType.LOCAL_PLAYER.keyBytes, wData.globalReadOptions);

        final CompoundTag player = data != null
                ? (CompoundTag) DataConverter.read(data).get(0)
                : (CompoundTag) worldProvider.getWorld().level.getChildTagByKey("Player");

        ListTag posVec = (ListTag) player.getChildTagByKey("Pos");
        if (posVec == null || posVec.getValue() == null) {
            throw new Exception("No \"Pos\" specified");
        }
        if (posVec.getValue().size() != 3) {
            throw new Exception("\"Pos\" value is invalid. value: " + posVec.getValue().toString());
        }

        IntTag dimensionId = (IntTag) player.getChildTagByKey("DimensionId");
        if (dimensionId == null || dimensionId.getValue() == null) {
            throw new Exception("No \"DimensionId\" specified");
        }
        Dimension dimension = Dimension.getDimension(dimensionId.getValue());
        if (dimension == null) {
            dimension = Dimension.OVERWORLD;
        }

        return new DimensionVector3<>(
                (float) posVec.getValue().get(0).getValue(),
                (float) posVec.getValue().get(1).getValue(),
                (float) posVec.getValue().get(2).getValue(),
                dimension);

    } catch (Exception e) {
        //Log.e(e.toString());
        e.printStackTrace();

        Exception e2 = new Exception("Could not find player.");
        e2.setStackTrace(e.getStackTrace());
        throw e2;
    }
}
 
开发者ID:jocopa3,项目名称:blocktopograph-library,代码行数:43,代码来源:Map.java


注:本文中的com.protolambda.blocktopograph.util.math.DimensionVector3类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。