Giter VIP home page Giter VIP logo

nbtschematic's Introduction

nbtschematic

A simple nbtlib Schema for reading or writing Schematic files for MCEdit and other world editors.

Installation

Python 3.8 or higher is required. You should probably create a new virtual environment before you install. Once you have activated your virtual environment, run

pip3 install nbtschematic

Examples

To load an existing MCEdit or other schematic file from disk, run:

from nbtschematic import SchematicFile
sf = SchematicFile.load('tests/test_schematic/simple.schematic')
print("The block at Y=%d, Z=%d, X=%d has block ID %d" %
(2, 3, 0, sf.blocks[2, 3, 0]))

To generate a schematic file in python, run:

from nbtschematic import SchematicFile
sf = SchematicFile(shape=(10, 8, 4))
assert sf.blocks.shape == (10, 8, 4)
sf.blocks[2, 3, 0] = 42
sf.save('example.schematic')

The size of the schematic should be defined at construction time. Resizing it will clear the blocks and block data.

Other fields of interest include:

  • data: Block data for each and every block
  • entities: Everything that is not a block
  • blockentities: Extended metadata for blocks

Further Reading

For more information about the underlying objects, see nbtlib's excellent examples page.


License - MIT

nbtschematic's People

Contributors

cbs228 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

demycode cassanof

nbtschematic's Issues

Invalaid syntax error (nbtschematic)

from nbtschematic import SchematicFile
orig = SchematicFile.load('LGA1.schematic')
print(orig.shape) # x,z,y => 33390
(Short(210), Short(159), Short(1))
new = SchematicFile(
... shape=(int(orig.shape[2]),int(orig.shape[1]),int(orig.shape[0]))
... ) # switch x,y
for y in range(int(orig.shape[0])):
... for z in range(int(orig.shape[1])):
... for x in range(int(orig.shape[2])):
... new.blocks[x,z,y] = orig.blocks[y,z,x] # switch x,y
... new.data[x,z,y] = orig.data[y,z,x] # preserve metadata
... new.save('flat.schematic')
File "", line 6
new.save('flat.schematic')
^
SyntaxError: invalid syntax

Unable to install

It seems like it's not possible to install nbtschematic.

python 3.8
numpy 1.18.2

But when i execute pip3 install nbtschematic i get this error:
ERROR: nbtlib 1.2.4 has requirement numpy==1.15.4, but you'll have numpy 1.14.6 which is incompatible.

nbtschematic nithub error

Requirement already satisfied: nbtlib in c:\users\naudi\appdata\local\programs\python\python36\lib\site-packages (1.2.4)
Collecting numpy==1.15.4 (from nbtlib)
Using cached https://files.pythonhosted.org/packages/51/70/7096a735b27359dbc0c380b23b9c9bd05fea62233f95849c43a6b02c5f40/numpy-1.15.4-cp36-none-win_amd64.whl
nbtschematic 0.1.0 has requirement numpy~=1.14.5, but you'll have numpy 1.15.4 which is incompatible.
Installing collected packages: numpy
Found existing installation: numpy 1.14.6
Uninstalling numpy-1.14.6:
Successfully uninstalled numpy-1.14.6
Successfully installed numpy-1.15.4
You are using pip version 10.0.1, however version 21.3.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

C:\Users\naudi>from nbtschematic import SchematicFile
'from' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\naudi>sf = SchematicFile.load('tests/test_schematic/simple.schematic')
'sf' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\naudi>print("The block at Y=%d, Z=%d, X=%d has block ID %d" %
Unable to initialize device PRN

C:\Users\naudi>pip install nbtschematic==0.1.0
Requirement already satisfied: nbtschematic==0.1.0 in c:\users\naudi\appdata\local\programs\python\python36\lib\site-packages (0.1.0)
Requirement already satisfied: nbtlib~=1.2.1 in c:\users\naudi\appdata\local\programs\python\python36\lib\site-packages (from nbtschematic==0.1.0) (1.2.4)
Collecting numpy~=1.14.5 (from nbtschematic==0.1.0)
Using cached https://files.pythonhosted.org/packages/dc/99/f824a73251589d9fcef2384f9dd21bd1601597fda92ced5882940586ec37/numpy-1.14.6-cp36-none-win_amd64.whl
nbtlib 1.2.4 has requirement numpy==1.15.4, but you'll have numpy 1.14.6 which is incompatible.
Installing collected packages: numpy
Found existing installation: numpy 1.15.4
Uninstalling numpy-1.15.4:
Successfully uninstalled numpy-1.15.4
Successfully installed numpy-1.14.6
You are using pip version 10.0.1, however version 21.3.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

C:\Users\naudi>from nbtschematic import SchematicFile
'from' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\naudi>sf = SchematicFile(shape=(10, 8, 4))
'sf' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\naudi>assert sf.blocks.shape == (10, 8, 4)
'assert' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\naudi>sf.blocks[2, 3, 0] = 42
'sf.blocks[2' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\naudi>sf.save('example.schematic')

*newbie*: Help!!

Thank you for helping me with the nbtschematic software! I have so much to learn! If you aren't aware I plan to remake make Nyc in Minecraft 1.12 1:3 scale to use the immersive vehicle mods and chisels and bits mod. It is basically a redo of BTE's NYC 1:1 scale with added mods. However I am a newbie and just starting with my python journey (You can tell from my previous questions). I have seen the post "Building 1:1 Scale Minecraft Replicas with Google Maps" by Nikhil Jha which was a year ago and used the editor tool as well as analyzing each part of the code he used for rotating each schematic file and implementing it into python by copying (newbie mistake). However from your previous reply and python errors, I have seen the extra things I can add to make the code more efficient, like the numpy.swapaxes(). I Honestly was a bit overwhelmed. My starting map is with a LGA Airport runway piece from the website https://minecraftart.netlify.app/ which I believe is all I need to start the project. Because of my determination, I wanted to speed up the process by asking you for a generic code for rotating the specific schematic map file so that I can use it for multiple maps which I plan to connect in the end with coordinates. I'm sure there is more that could have been shown in the post. This would be highly appreciated. Sorry for any misunderstandings.
Here are the Givens:
file name: 'LGA1.schematic'
dimensions: width(159) height(210) thickness(1).
Blocks: All
Entities: None
Block entities: None

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.