Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static BlockPos getBlockPosFromCompound(NBTTagCompound pos) {
- return new BlockPos(pos.getInt("x"), pos.getInt("y"), pos.getInt("z"));
- }
- /**
- * Translates BlockPos to a String form
- * @param coords
- * @return
- */
- static NBTTagCompound serializePos(BlockPos coords) {
- if (coords == null) {
- return null;
- }
- NBTTagCompound cmp = new NBTTagCompound();
- cmp.setInt("x", coords.x);
- cmp.setInt("y", coords.y);
- cmp.setInt("z", coords.z);
- return cmp;
- }
- private static final Pattern COLON_SPLIT = Pattern.compile(":");
- /**
- * Parses a string into BlockPos
- *
- * @deprecated Only used for reading old data
- * @param loc
- * @return
- */
- static BlockPos deserializeOldLoc(String loc) {
- if (loc != null) {
- String[] args = COLON_SPLIT.split(loc, 3);
- if (args.length == 3) {
- try {
- int x = (int) Math.floor(Float.parseFloat(args[0]));
- int y = (int) Math.floor(Float.parseFloat(args[1]));
- int z = (int) Math.floor(Float.parseFloat(args[2]));
- return new BlockPos(x, y, z);
- } catch (NumberFormatException inored) {}
- }
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement