Git Product home page Git Product logo

mcmaketest's People

Contributors

mathuin avatar xgkkp avatar

Stargazers

 avatar

Watchers

 avatar

mcmaketest's Issues

Patch to remove NBT dependency

I have removed the need for the NBT module. I tried to push my patch but I don't have permission so here it is!

diff --git a/maketest.py b/maketest.py
index dbd4999..e4a4e89 100644
--- a/maketest.py
+++ b/maketest.py
@@ -22,7 +22,6 @@ Reqires:
"""

from pymclevel import mclevel
-import nbt
import base64

from gzip import GzipFile
@@ -43,75 +42,33 @@ def get_int(question, default=0):
except:
return default

-def PlayerTag():

  • player = nbt.TAG_Compound()
  • player.name = "Player"
  • Rest of the player data

  • position = nbt.TAG_List(name="Pos", type=nbt.TAG_Double)
  • position.tags.extend([nbt.TAG_Double(0.5), nbt.TAG_Double(options.groundheight+2), nbt.TAG_Double(0.5)])
  • player.tags.append(position)
  • motion = nbt.TAG_List(name="Motion", type=nbt.TAG_Double)
  • motion.tags.extend([nbt.TAG_Double(0.), nbt.TAG_Double(0.), nbt.TAG_Double(0.)])
  • player.tags.append(motion)
  • rotation = nbt.TAG_List(name="Rotation", type=nbt.TAG_Float)
  • rotation.tags.extend([nbt.TAG_Float(0.), nbt.TAG_Float(0.)])

- player.tags.append(rotation)

  • player.tags.append(nbt.TAG_Byte(name="OnGround", value=1))
  • player.tags.append(nbt.TAG_Short(name="Air", value=300))
  • player.tags.append(nbt.TAG_Short(name="HurtTime", value=0))
  • player.tags.append(nbt.TAG_Short(name="AttackTime", value=0))
  • player.tags.append(nbt.TAG_Short(name="DeathTime", value=0))
  • player.tags.append(nbt.TAG_Short(name="Health", value=20))
  • player.tags.append(nbt.TAG_Short(name="Fire", value=-20))
  • player.tags.append(nbt.TAG_Int(name="Score", value=0))

- player.tags.append(nbt.TAG_Long(name="Dimension", value=0))

- player.tags.append(nbt.TAG_Float(name="FallDistance", value=0.0))

  • inventory = nbt.TAG_List(name="Inventory", type=nbt.TAG_Compound)
  • inventory.tags.append(Itemstack(278, slot=8))
  • inventory.tags.append(Itemstack(50, slot=0, count=-1)) # Torches
  • inventory.tags.append(Itemstack(1, slot=1, count=-1)) # Stone
  • inventory.tags.append(Itemstack(3, slot=2, count=-1)) # Dirt

- inventory.tags.append(Itemstack(345, slot=35, count=1)) # Compass

- player.tags.append(inventory)

  • return player
    +def PlayerTag(level=None):
  • currently only populates player inventory

  • no real support for this in mclevel

  • inventory = level.root_tag['Data']['Player']['Inventory']
  • inventory.append(Itemstack(278, slot=8))
  • inventory.append(Itemstack(50, slot=0, count=-1)) # Torches
  • inventory.append(Itemstack(1, slot=1, count=-1)) # Stone
  • inventory.append(Itemstack(3, slot=2, count=-1)) # Dirt
  • inventory.append(Itemstack(345, slot=35, count=1)) # Compass

def Itemstack(item, slot, count=1):

  • stack = nbt.TAG_Compound()
  • stack = mclevel.TAG_Compound()
    stack.name = ''
  • stack.tags.append(nbt.TAG_Short(name="id", value=item))
  • stack.tags.append(nbt.TAG_Byte(name="Slot", value=slot))
  • stack.tags.append(nbt.TAG_Byte(name="Count", value=count))
  • stack.tags.append(nbt.TAG_Short(name="Damage", value=0))
  • stack["id"] = mclevel.TAG_Short(item)
  • stack["Slot"] = mclevel.TAG_Byte(slot)
  • stack["Count"] = mclevel.TAG_Byte(count)
  • stack["Damage"] = mclevel.TAG_Short(0)
    return stack

def Create_LevelDat(filename):
"Creates a blank level.dat suitable for initializing fresh worlds"

Make a blank NBT

  • level = nbt.NBTFile()
  • level.name = ''
  • data compound

  • data = nbt.TAG_Compound()
  • data.name = "Data"
  • data.tags.append(nbt.TAG_Int(name="SpawnX", value=0))
  • data.tags.append(nbt.TAG_Int(name="SpawnY", value=64))
  • data.tags.append(nbt.TAG_Int(name="SpawnZ", value=0))
  • data.tags.append(nbt.TAG_Long(name="LastPlayed", value=time.time()))
  • data.tags.append(nbt.TAG_Long(name="RandomSeed", value=42))
  • data.tags.append(nbt.TAG_Long(name="SizeOnDisk", value=0))

- data.tags.append(nbt.TAG_Long(name="Time", value=0))

- data.tags.append(PlayerTag())

  • level.tags.append(data)

- level.write_file(filename)

  • level = mclevel.MCInfdevOldLevel(filename, create=True, random_seed=42)
  • level.setPlayerPosition((0, 67, 0))
  • level.setPlayerSpawnPosition((0, 64, 0))
  • PlayerTag(level)
  • level.saveInPlace()

def FillChunk(chunk):
"""Creates the block data for a new chunk, based on program options"""
@@ -189,7 +146,7 @@ if name == 'main':

Create the world folder and level.dat

os.makedirs(worldpath)

  • Create_LevelDat(worldleveldat)
  • Create_LevelDat(worldpath)

Open the world

world = mclevel.fromFile(worldpath)

Need more specifics on other modules!

I used git clone to make a copy of your repository after doing the same for pymclevel and NBT. However, the maketest.py script cannot see the pymclevel and nbt modules, and neither module has a proper "installation" procedure. Did you do anything else, like copy the other modules into a module path or modify the path or something? Please let me know as I am very eager to use this code. :-) Thanks!

Jack.

Player information is lost on second load

Just thought I would add this, as it's a pretty big known issue:

The test world loads fine inside minecraft the first time, however once you quit+save, the next time you load the level all the players inventory for this world will have reset, along with the player position.

I suspect it is something to do with the way the player details are being written in the .nbt.

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.