本文整理汇总了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");
}
}
示例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");
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}