Permalink
Browse files

entity.py: remove import all of the nbt module in favor of using the …

…already imported nbt module namespace
  • Loading branch information...
1 parent a2364dc commit 0b146ea4adce8133f556edce8c426471dd4d607d @zothar zothar committed Feb 27, 2012
Showing with 27 additions and 28 deletions.
  1. +27 −28 entity.py
View
@@ -3,8 +3,7 @@
@author: Rio
'''
-#from mclevelbase import *
-from nbt import *
+
import nbt
from copy import deepcopy
@@ -20,38 +19,38 @@
class TileEntity(object):
baseStructures = {
"Furnace": (
- ("BurnTime", TAG_Short),
- ("CookTime", TAG_Short),
- ("Items", TAG_List),
+ ("BurnTime", nbt.TAG_Short),
+ ("CookTime", nbt.TAG_Short),
+ ("Items", nbt.TAG_List),
),
"Sign": (
- ("Items", TAG_List),
+ ("Items", nbt.TAG_List),
),
"MobSpawner": (
- ("Items", TAG_List),
+ ("Items", nbt.TAG_List),
),
"Chest": (
- ("Items", TAG_List),
+ ("Items", nbt.TAG_List),
),
"Music": (
- ("note", TAG_Byte),
+ ("note", nbt.TAG_Byte),
),
"Trap": (
- ("Items", TAG_List),
+ ("Items", nbt.TAG_List),
),
"RecordPlayer": (
- ("Record", TAG_Int),
+ ("Record", nbt.TAG_Int),
),
"Piston": (
- ("blockId", TAG_Int),
- ("blockData", TAG_Int),
- ("facing", TAG_Int),
- ("progress", TAG_Float),
- ("extending", TAG_Byte),
+ ("blockId", nbt.TAG_Int),
+ ("blockData", nbt.TAG_Int),
+ ("facing", nbt.TAG_Int),
+ ("progress", nbt.TAG_Float),
+ ("extending", nbt.TAG_Byte),
),
"Cauldron": (
- ("Items", TAG_List),
- ("BrewTime", TAG_Int),
+ ("Items", nbt.TAG_List),
+ ("BrewTime", nbt.TAG_Int),
),
}
@@ -78,8 +77,8 @@ class TileEntity(object):
@classmethod
def Create(cls, tileEntityID, **kw):
- tileEntityTag = TAG_Compound()
- tileEntityTag[id] = TAG_String(tileEntityID)
+ tileEntityTag = nbt.TAG_Compound()
+ tileEntityTag[id] = nbt.TAG_String(tileEntityID)
base = cls.baseStructures.get(tileEntityID, None)
if base:
for (name, tag) in base:
@@ -95,14 +94,14 @@ def pos(cls, tag):
@classmethod
def setpos(cls, tag, pos):
for a, p in zip('xyz', pos):
- tag[a] = TAG_Int(p)
+ tag[a] = nbt.TAG_Int(p)
@classmethod
def copyWithOffset(cls, tileEntity, copyOffset):
eTag = deepcopy(tileEntity)
- eTag['x'] = TAG_Int(tileEntity['x'].value + copyOffset[0])
- eTag['y'] = TAG_Int(tileEntity['y'].value + copyOffset[1])
- eTag['z'] = TAG_Int(tileEntity['z'].value + copyOffset[2])
+ eTag['x'] = nbt.TAG_Int(tileEntity['x'].value + copyOffset[0])
+ eTag['y'] = nbt.TAG_Int(tileEntity['y'].value + copyOffset[1])
+ eTag['z'] = nbt.TAG_Int(tileEntity['z'].value + copyOffset[2])
return eTag
@@ -147,8 +146,8 @@ class Entity(object):
@classmethod
def Create(cls, entityID, **kw):
- entityTag = TAG_Compound()
- entityTag[id] = TAG_String(entityID)
+ entityTag = nbt.TAG_Compound()
+ entityTag[id] = nbt.TAG_String(entityID)
Entity.setpos(entityTag, (0, 0, 0))
return entityTag
@@ -160,14 +159,14 @@ def pos(cls, tag):
@classmethod
def setpos(cls, tag, pos):
- tag["Pos"] = TAG_List([TAG_Double(p) for p in pos])
+ tag["Pos"] = nbt.TAG_List([nbt.TAG_Double(p) for p in pos])
@classmethod
def copyWithOffset(cls, entity, copyOffset):
eTag = deepcopy(entity)
positionTags = map(lambda p, co: nbt.TAG_Double(p.value + co), eTag["Pos"], copyOffset)
- eTag["Pos"] = TAG_List(positionTags)
+ eTag["Pos"] = nbt.TAG_List(positionTags)
if eTag["id"].value == "Painting":
eTag["TileX"].value += copyOffset[0]

0 comments on commit 0b146ea

Please sign in to comment.