public void Disconnect(string title, string reason) { SetNewScreen(new ErrorScreen(this, title, reason)); Map.Reset(); Map.mapData = null; Drawer2D.InitColours(); for (int tile = BlockInfo.CpeBlocksCount; tile < BlockInfo.BlocksCount; tile++) { BlockInfo.ResetBlockInfo((byte)tile, false); } BlockInfo.SetupCullingCache(); BlockInfo.InitLightOffsets(); GC.Collect(); }
public void Disconnect(string title, string reason) { SetNewScreen(new ErrorScreen(this, title, reason)); World.Reset(); World.blocks = null; Drawer2D.InitColours(); for (int block = BlockInfo.CpeCount; block < BlockInfo.BlocksCount; block++) { BlockInfo.ResetBlockInfo((byte)block, false); } BlockInfo.SetupCullingCache(); BlockInfo.InitLightOffsets(); GC.Collect(); }
void ParseBlockDefinition(NbtCompound compound) { byte id = (byte)compound["ID"].Value; BlockInfo info = game.BlockInfo; info.Name[id] = (string)compound["Name"].Value; info.CollideType[id] = (BlockCollideType)compound["CollideType"].Value; info.SpeedMultiplier[id] = (float)compound["Speed"].Value; byte[] data = (byte[])compound["Textures"].Value; info.SetTex(data[0], TileSide.Top, (Block)id); info.SetTex(data[1], TileSide.Bottom, (Block)id); info.SetTex(data[2], TileSide.Left, (Block)id); info.SetTex(data[3], TileSide.Right, (Block)id); info.SetTex(data[4], TileSide.Front, (Block)id); info.SetTex(data[5], TileSide.Back, (Block)id); info.BlocksLight[id] = (byte)compound["TransmitsLight"].Value == 0; byte soundId = (byte)compound["WalkSound"].Value; info.DigSounds[id] = NetworkProcessor.breakSnds[soundId]; info.StepSounds[id] = NetworkProcessor.stepSnds[soundId]; info.FullBright[id] = (byte)compound["FullBright"].Value != 0; info.IsSprite[id] = (byte)compound["Shape"].Value == 0; NetworkProcessor.SetBlockDraw(info, id, (byte)compound["BlockDraw"].Value); data = (byte[])compound["Fog"].Value; info.FogDensity[id] = (data[0] + 1) / 128f; info.FogColour[id] = new FastColour(data[1], data[2], data[3]); data = (byte[])compound["Coords"].Value; info.MinBB[id] = new Vector3(data[0] / 16f, data[1] / 16f, data[2] / 16f); info.MaxBB[id] = new Vector3(data[3] / 16f, data[4] / 16f, data[5] / 16f); if (info.CollideType[id] != BlockCollideType.Solid) { info.IsTransparent[id] = true; info.IsOpaque[id] = false; } info.SetupCullingCache(id); info.InitLightOffsets(); game.Events.RaiseBlockDefinitionChanged(); info.DefinedCustomBlocks[id >> 5] |= (1u << (id & 0x1F)); game.Inventory.CanPlace.SetNotOverridable(true, id); game.Inventory.CanDelete.SetNotOverridable(true, id); game.Events.RaiseBlockPermissionsChanged(); }
void HandleCpeDefineBlockCommonEnd(byte block) { BlockInfo info = game.BlockInfo; byte blockDraw = reader.ReadUInt8(); SetBlockDraw(info, block, blockDraw); byte fogDensity = reader.ReadUInt8(); info.FogDensity[block] = fogDensity == 0 ? 0 : (fogDensity + 1) / 128f; info.FogColour[block] = new FastColour( reader.ReadUInt8(), reader.ReadUInt8(), reader.ReadUInt8()); info.SetupCullingCache(block); info.InitLightOffsets(); game.Events.RaiseBlockDefinitionChanged(); }
void HandleCpeDefineBlockCommonEnd(byte block) { BlockInfo info = game.BlockInfo; byte blockDraw = reader.ReadUInt8(); if (blockDraw == 1) { info.IsTransparent[block] = true; } else if (blockDraw == 2) { info.IsTransparent[block] = true; info.CullWithNeighbours[block] = false; } else if (blockDraw == 3) { info.IsTranslucent[block] = true; } else if (blockDraw == 4) { info.IsTransparent[block] = true; info.IsAir[block] = true; } if (info.IsOpaque[block]) { info.IsOpaque[block] = blockDraw == 0; } byte fogDensity = reader.ReadUInt8(); info.FogDensity[block] = fogDensity == 0 ? 0 : (fogDensity + 1) / 128f; info.FogColour[block] = new FastColour( reader.ReadUInt8(), reader.ReadUInt8(), reader.ReadUInt8()); info.SetupCullingCache(); info.InitLightOffsets(); }