public ChestEditor(TileEntity e) { Chest = (Chest)e; InitializeComponent(); for(byte i=0;i<54;i++) { InvControls[i] = new InventoryItemControl(i,ref Chest.Inventory); InvControls[i].Click += new EventHandler(inv_Click); InvControls[i].Changed += new InventoryItemControl.ChangedHandler(ChestEditor_Changed); } DoLayout(); cmbType.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; cmbType.DrawItem +=new DrawItemEventHandler(cmbType_DrawItem); cmbType.Items.Clear(); cmbType.ValueMember = "ID"; cmbType.DisplayMember = "Name"; foreach (KeyValuePair<short, Block> k in Blocks.BlockList) { cmbType.Items.Add(k.Value); } }
void tileEntityEditor1_EntityModified(TileEntity e) { _Map.SetTileEntity(e); }
void tileEntityEditor1_EntityDeleted(TileEntity e) { _Map.RemoveTileEntity(e); }
void mapCtrl_TileEntityClicked(TileEntity e) { tileEntityEditor1.SetSelectedTEnt(e); tabControl.SelectedTab=tabTileEntities; }
public abstract void RemoveTileEntity(TileEntity e);
public abstract void SetTileEntity(TileEntity e);
public void RemoveTileEntity(TileEntity e) { long CX = e.Pos.X / 16; long CY = e.Pos.Y / 16; string f = GetChunkFilename((int)CX, (int)CY); try { mChunk = new NbtFile(f); mChunk.LoadFile(); NbtCompound level = (NbtCompound)mChunk.RootTag["Level"]; NbtList TileEntities = (NbtList)level["TileEntities"]; int found = -1; for (int i = 0; i < TileEntities.Tags.Count; i++) { TileEntity te = new TileEntity((NbtCompound)TileEntities[i]); if (te.Pos == e.Pos) { found = i; } } if (found > -1) TileEntities.Tags.RemoveAt(found); level["TileEntities"] = TileEntities; mChunk.RootTag["Level"] = level; mChunk.SaveFile(f); } catch (Exception) { } }
public void SetTileEntity(TileEntity e) { long CX=e.Pos.X/16; long CY=e.Pos.Y/16; string f = GetChunkFilename((int)CX, (int)CY); try { mChunk = new NbtFile(f); mChunk.LoadFile(); NbtCompound level = (NbtCompound)mChunk.RootTag["Level"]; NbtList tents = (NbtList)level["TileEntities"]; int found = -1; for(int i = 0;i<tents.Tags.Count;i++) { TileEntity te = new TileEntity((NbtCompound)tents[i]); if (te.Pos == e.Pos) { found = i; } } if (found > -1) tents[found] = e.ToNBT(); else tents.Tags.Add(e.ToNBT()); level["TileEntities"] = tents; mChunk.RootTag["Level"] = level; mChunk.SaveFile(f); } catch (Exception) { } }
void mapCtrl_TileEntityClicked(TileEntity e) { tileEntityEditor1.SetSelectedTEnt(e); tclMap.SelectedTab=tabTEnts; }
public SpawnerEditor(TileEntity e) { InitializeComponent(); TileEntity = e; }
public override void RemoveTileEntity(TileEntity e) { long CX = e.Pos.X / ChunkX; long CZ = e.Pos.Z / ChunkZ; int x = (int)e.Pos.X - (((int)e.Pos.X >> 4) * ChunkX); //(px >> 4) & 0xf; int y = (int)e.Pos.Y; int z = (int)e.Pos.Z - (((int)e.Pos.Z >> 4) * ChunkZ); //(py >> 4) & 0xf; Chunk c = GetChunk(CX, CZ); if (c == null) return; if (c.TileEntities.ContainsKey(e.UUID)) c.TileEntities.Remove(e.UUID); if (mTileEntities.ContainsKey(e.UUID)) mTileEntities.Remove(e.UUID); SetChunk(c); }