public List <Chunk> SelectChunks(Chunk StartingChunk, roomSize Size) { List <Chunk> SelectedChunks = new List <Chunk>((int)Size); CoordInt LastCoord = StartingChunk.Coordinates; for (int i = 0; i < (int)Size; i++) { float value = 0; bool first = true; Chunk SelectedChunk = null; for (int NeighbourX = LastCoord.x - 1; NeighbourX <= LastCoord.x + 1; NeighbourX++) { for (int NeighbourY = LastCoord.y - 1; NeighbourY <= LastCoord.y + 1; NeighbourY++) { CoordInt nextCoord = new CoordInt(NeighbourX, NeighbourY); if (LastCoord.isAdjacent(nextCoord) && nextCoord != LastCoord) { if (value < EvaluateChunk(map.nextRoomID, nextCoord) || first) { first = false; value = EvaluateChunk(map.nextRoomID, nextCoord); SelectedChunk = map.Chunks[nextCoord]; } } } } SelectedChunks.Add(SelectedChunk); } return(SelectedChunks); }
protected override void Parse(EndianBinaryReader r) { EID = ReadVarInt(r); Title = ReadString8(r); Position = CoordInt.Read(r); FaceDirection = (Face)r.ReadByte(); }
protected override void Parse(EndianBinaryReader r) { Pos = CoordInt.Read(r); Action = (Actions)r.ReadByte(); Data = NBT.Tag.ReadTag(r); #if DEBUGPACKET if (Action == Actions.Unknown2) { Console.WriteLine(this); } if (Action == Actions.Unknown3) { Console.WriteLine(this); } if (Action == Actions.Unknown4) { Console.WriteLine(this); } if (Action.ToString() == ((int)Action).ToString()) { throw new NotImplementedException(Action.ToString()); } #endif }
protected override void Parse(EndianBinaryReader r) { EID = ReadVarInt(r); Type = (Vehicles)r.ReadByte(); #if DEBUGPACKET if (Type.ToString() == ((int)Type).ToString()) { throw new NotImplementedException(Type.ToString()); } #endif if (Type == Vehicles.Unknown) { Console.WriteLine(); } Position = ReadAbsInt(r); Yaw = r.ReadSByte(); Pitch = r.ReadSByte(); SourceEntity = r.ReadInt32(); if (SourceEntity <= 0) { return; } short vx = r.ReadInt16(); short vy = r.ReadInt16(); short vz = r.ReadInt16(); Velocity = new CoordInt(vx, vy, vz); }
private static int CountNearWallTiles(CoordInt Coord, Map Map) { int Count = 0; for (int NeighbourX = Coord.x - 1; NeighbourX <= Coord.x + 1; NeighbourX++) { for (int NeighbourY = Coord.y - 1; NeighbourY <= Coord.y + 1; NeighbourY++) { CoordInt curCoord = new CoordInt(NeighbourX, NeighbourY); if (curCoord != Coord) { if (Map.ContainsCoord(curCoord)) { if (Map.GetTile(curCoord).Type == tileType.Wall) { Count++; } } else { return(9); } } } } return(Count); }
public int GetIndex(CoordInt c) { int x = c.X & 0xF; int z = c.Z & 0xF; return(x + z * 16 + c.Y * 16 * 16); }
private static int CountNearWallTiles(CoordInt Coord, Dictionary <CoordInt, Tile> Map) { int Count = 0; for (int NeighbourX = Coord.x - 1; NeighbourX <= Coord.x + 1; NeighbourX++) { for (int NeighbourY = Coord.y - 1; NeighbourY <= Coord.y + 1; NeighbourY++) { CoordInt curCoord = new CoordInt(NeighbourX, NeighbourY); if (curCoord != Coord) { if (Map.ContainsKey(curCoord)) { if (Map[curCoord].Type == tileType.Wall) { Count++; } else if (Coord.isAdjacent(curCoord)) { return(8); } } } } } return(Count); }
public BlockChange(CoordInt pos, BlockID block) { if (pos == null) throw new ArgumentNullException("pos"); Position = pos; BlockType = block; }
static void Spawner(Client player, string[] cmd, int iarg) { if (!player.Admin()) { throw new ErrorException("Spawn does no longer work"); } VanillaSession rs = player.Session as VanillaSession; if (rs.Spawners.Count == 0) { player.TellSystem(Chat.Purple, "No spawners yet detected"); return; } CoordInt nearby = rs.Spawners [0]; double dist = nearby.DistanceTo(rs.Position); foreach (CoordInt c in rs.Spawners) { double cdist = c.DistanceTo(rs.Position); if (cdist < 10) { continue; } if (cdist < dist) { dist = cdist; nearby = c; } } player.Warp(nearby.CloneDouble(), rs.Dimension, player.Session.World); }
protected override void Parse(EndianBinaryReader r) { Pos = CoordInt.Read(r); Action = (Actions)r.ReadByte(); int length = r.ReadInt16(); //Changes: compressed length if (length >= 0) { Data = r.ReadBytesOrThrow(length); } #if DEBUG if (Action == Actions.Unknown2) { Console.WriteLine(this); } if (Action == Actions.Unknown3) { Console.WriteLine(this); } if (Action == Actions.Unknown4) { Console.WriteLine(this); } if (Action.ToString() == ((int)Action).ToString()) { throw new NotImplementedException(Action.ToString()); } #endif }
public static BlockAction Chest(CoordInt pos, bool open) { BlockAction ba = new BlockAction(); ba.Position = pos; ba.TypeState = 1; ba.PitchDirection = open ? (byte)1 : (byte)0; return ba; }
public static BlockAction Piston(CoordInt pos, Face face, bool extend) { BlockAction ba = new BlockAction(); ba.Position = pos; ba.TypeState = extend ? (byte)0 : (byte)1; ba.PitchDirection = (byte)face; return ba; }
protected override void Parse(EndianBinaryReader r) { Command = ReadString8(r); if (r.ReadBoolean()) { Position = CoordInt.Read(r); } }
public BlockChange(CoordInt pos, byte blockID, byte meta) { if (pos == null) throw new ArgumentNullException("pos"); Position = pos; BlockType = (BlockID)blockID; Metadata = meta; }
public BlockChange(CoordInt pos, BlockID block) { if (pos == null) { throw new ArgumentNullException("pos"); } Position = pos; BlockType = block; }
public static BlockAction Chest(CoordInt pos, bool open) { BlockAction ba = new BlockAction(); ba.Position = pos; ba.TypeState = 1; ba.PitchDirection = open ? (byte)1 : (byte)0; return(ba); }
public static BlockAction Piston(CoordInt pos, Face face, bool extend) { BlockAction ba = new BlockAction(); ba.Position = pos; ba.TypeState = extend ? (byte)0 : (byte)1; ba.PitchDirection = (byte)face; return(ba); }
protected override void Parse(EndianBinaryReader r) { BlockPosition = CoordInt.Read(r); FaceDirection = (Face)r.ReadByte(); Item = SlotItem.Read(r); CursorX = r.ReadByte(); CursorY = r.ReadByte(); CursorZ = r.ReadByte(); }
public BlockChange(CoordInt pos, byte blockID, byte meta) { if (pos == null) { throw new ArgumentNullException("pos"); } Position = pos; BlockType = (BlockID)blockID; Metadata = meta; }
public void GenerateRandomFloorPosition(Base playbase, CoordInt center, int max = 6, int i = 0) { Outline _outline = new Outline(world.Collection.Layers[0], world.Collection.GroundTiles[1]); var positions = _outline.GetSurroundingPos(center.ToVector3Int()); var scattering_center = new List <CoordInt>(); var space_left = 0; //Determines how many unoccupied sorrounding tile in the floormap foreach (var position in positions) { if (!world.Map.Maps.FloorMap.ContainsKey(IlluminaConverter.ToCoordInt(position))) { space_left++; } } //If the space_left exceeds 3 use the minimum value which is 5, otherwise don't change the value space_left = space_left > 3 ? 5 : space_left; //Get the center of the next scattering positions for (int j = 0; j < space_left; j++) { var pos_index = 0; var pos = IlluminaConverter.ToCoordInt(positions[pos_index]); do { pos_index = Random.Range(0, 7); pos = IlluminaConverter.ToCoordInt(positions[pos_index]); } while (world.Map.Maps.FloorMap.ContainsKey(pos) || pos == center); scattering_center.Add(new CoordInt((int)pos.Y, (int)pos.X, (int)pos.Z)); //FIXME : x becomes y, and y becomes xs } //Adds all the positions to the FloorMap for (int l = 0; l < positions.Length; l++) { var _position = IlluminaConverter.ToCoordInt(positions[l]); _position = ReturnSafePos(new int[] { 0, 24, 0, 24 }, _position); if (!world.Map.Maps.FloorMap.ContainsKey(_position)) { world.Map.Maps.FloorMap.Add(_position, new Floor(playbase.owner, positions[l])); } } //Recursion : ScatterAgain if (i < max && scattering_center.Count > 0) { for (int k = 0; k < scattering_center.Count; k++) { i++; GenerateRandomFloorPosition(playbase, scattering_center[k], max, i); } } }
/// <param name='note'> /// 0 - 24 /// </param> public static BlockAction NoteBlock(CoordInt pos, Instrument ins, byte note) { BlockAction ba = new BlockAction(); ba.Position = pos; ba.TypeState = (byte)ins; if (note < 0 || note > 24) ba.PitchDirection = 0; else ba.PitchDirection = (byte)note; return ba; }
private bool FilterDirection(CoordInt block) { if (block.X == -1 && block.Y == 255 && block.Z == -1) { return(false); } //Player view is 1.5 above its position CoordDouble offset = block - this.Position + new CoordDouble(0.5, -1, 0.5); CoordDouble unit = new CoordDouble( -Math.Cos(Pitch * Math.PI / 180) * Math.Sin(Yaw * Math.PI / 180), -Math.Sin(Pitch * Math.PI / 180), Math.Cos(Pitch * Math.PI / 180) * Math.Cos(Yaw * Math.PI / 180)); double viewDist = offset.Scalar(unit); double perDist = (offset - unit * viewDist).Abs; #if DEBUG /*this.Tell ("Block: " + block + * //"Offset: " + offset.ToString ("0.0") + * //" Unit: " + unit.ToString ("0.0") + * " Dist: " + viewDist.ToString ("0.0") + * " Per: " + perDist.ToString ("0.0")); */ #endif //Ignore extreme values if (perDist > 20) { return(false); } if (viewDist > 20) { return(false); } //Logical max i 0.87 //Dont block anymore since client does not restore uncomfirmed blocks if (perDist > 1.5) { //Log.WritePlayer (this, "Aimed sideways: " + perDist.ToString ("0.00") + " > 0.87"); //return true; } if (viewDist > 6) { //Log.WritePlayer (this, "Aimed too far: " + viewDist.ToString ("0.0") + " > 6.0, " + block); //return true; } if (viewDist < -0.1) { //Log.WritePlayer (this, "Aimed behind: " + viewDist.ToString ("0.0") + " < 0"); //return true; } return(false); }
protected override void Parse(EndianBinaryReader r) { Position = CoordInt.Read(r); BlockType = (BlockID)ReadVarInt(r); Metadata = r.ReadByte(); #if DEBUG if (BlockType.ToString() == ((int)BlockType).ToString()) { throw new NotImplementedException(BlockType.ToString()); } #endif }
public static Dictionary <CoordInt, Tile> Smooth(Dictionary <CoordInt, Tile> TilesToSmooth, Tile startTile, int SmoothMultiplier, int ComparisonFactor) { Dictionary <CoordInt, Tile> SmoothedTiles = new Dictionary <CoordInt, Tile>(TilesToSmooth); for (int smooth = 0; smooth < SmoothMultiplier; smooth++) { Queue <Tile> queue = new Queue <Tile>(); queue.Enqueue(SmoothedTiles[startTile.Coord]); List <CoordInt> MapFlags = new List <CoordInt>(); MapFlags.Add(SmoothedTiles[startTile.Coord].Coord); while (queue.Count > 0) { Tile cur = queue.Dequeue(); int wallCount = CountNearWallTiles(cur.Coord, SmoothedTiles); if (wallCount > ComparisonFactor) { cur.SetType(tileType.Wall); } else if (wallCount < ComparisonFactor) { cur.SetType(tileType.Floor); } for (int NeighbourX = cur.Coord.x - 1; NeighbourX <= cur.Coord.x + 1; NeighbourX++) { for (int NeighbourY = cur.Coord.y - 1; NeighbourY <= cur.Coord.y + 1; NeighbourY++) { CoordInt curCoord = new CoordInt(NeighbourX, NeighbourY); if (cur.Coord.isAdjacent(curCoord)) { if (!MapFlags.Contains(curCoord)) { MapFlags.Add(curCoord); if (SmoothedTiles.ContainsKey(curCoord)) { queue.Enqueue(SmoothedTiles[curCoord]); } } } } } } } return(SmoothedTiles); }
public BlockChange(CoordInt pos, Block block) { if (pos == null) throw new ArgumentNullException("pos"); Position = pos; if (block != null) { BlockType = block.ID; Metadata = (byte)block.Meta; } }
protected override void Parse(EndianBinaryReader r) { EffectID = (SoundEffects)r.ReadInt32(); Position = CoordInt.Read(r); SoundData = r.ReadInt32(); SoundByte = r.ReadByte(); //Debug.WriteLine(DebugPacket.Read(r)); #if DEBUGPACKET if (EffectID.ToString() == ((int)EffectID).ToString()) { throw new NotImplementedException(EffectID.ToString()); } #endif }
protected override void Parse(EndianBinaryReader r) { Position = CoordInt.Read(r); int val = ReadVarInt(r); BlockType = (BlockID)(val >> 4); Metadata = (byte)(val & 0x0F); #if DEBUGPACKET if (BlockType.ToString() == ((int)BlockType).ToString()) { throw new NotImplementedException(BlockType.ToString()); } #endif }
public BlockChange(CoordInt pos, Block block) { if (pos == null) { throw new ArgumentNullException("pos"); } Position = pos; if (block != null) { BlockType = block.ID; Metadata = (byte)block.Meta; } }
/// <param name='note'> /// 0 - 24 /// </param> public static BlockAction NoteBlock(CoordInt pos, Instrument ins, byte note) { BlockAction ba = new BlockAction(); ba.Position = pos; ba.TypeState = (byte)ins; if (note < 0 || note > 24) { ba.PitchDirection = 0; } else { ba.PitchDirection = (byte)note; } return(ba); }
public DestinationEntity CheckDestinationEntity(CoordInt pos) { if (Maps.BasesMap.ContainsKey(pos)) { return(DestinationEntity.Base); } if (Maps.NavigatorsMap.ContainsKey(pos)) { return(DestinationEntity.Navigator); } if (Maps.GeneralsMap.ContainsKey(pos)) { return(DestinationEntity.General); } return(DestinationEntity.Trap); }
protected override void Parse(EndianBinaryReader r) { Status = (StatusEnum)r.ReadByte(); Position = CoordInt.Read(r); Face = (Face)r.ReadByte(); #if DEBUGPACKET if (Status.ToString() == ((int)Status).ToString()) { throw new NotImplementedException(Status.ToString()); } if (Face.ToString() == ((int)Face).ToString()) { throw new NotImplementedException(Face.ToString()); } #endif }
public void CreateRoomRandom(CoordInt StartingCoord) { List <Chunk> Chunks = SelectChunks(map.Chunks[StartingCoord], roomSize); if (coords.Count > 0) { if (queue.Count == 0) { queue.Enqueue(Chunks); RoomQueue(); } else { queue.Enqueue(Chunks); } coords.Clear(); } }
protected override void Parse(EndianBinaryReader r) { Position = CoordInt.Read(r); try { Text1 = ChatJson.Parse(ReadString8(r)); Text2 = ChatJson.Parse(ReadString8(r)); Text3 = ChatJson.Parse(ReadString8(r)); Text4 = ChatJson.Parse(ReadString8(r)); } #if !DEBUG catch (Exception ex) { Log.WriteServer(ex); } #endif finally { } }
public CoordInt ReturnSafePos(int[] p, CoordInt pos) { int x = (int)pos.X, y = (int)pos.Y, z = (int)pos.Z; if (pos.X > p[1]) { x = (int)pos.X - p[1] - 1; } if (pos.X < p[0]) { x = p[1] + (int)pos.X + 1; } if (pos.Y > p[3]) { y = (int)pos.Y - p[3] - 1; } if (pos.Y < p[2]) { y = p[3] + (int)pos.Y + 1; } return(new CoordInt(x, y, z)); }
protected override void Parse(EndianBinaryReader r) { EID = ReadVarInt(r); Type = (Vehicles)r.ReadByte(); #if DEBUGPACKET if (Type.ToString() == ((int)Type).ToString()) throw new NotImplementedException(Type.ToString()); #endif if (Type == Vehicles.Unknown) Console.WriteLine(); Position = ReadAbsInt(r); Yaw = r.ReadSByte(); Pitch = r.ReadSByte(); SourceEntity = r.ReadInt32(); if (SourceEntity <= 0) return; short vx = r.ReadInt16(); short vy = r.ReadInt16(); short vz = r.ReadInt16(); Velocity = new CoordInt(vx, vy, vz); }
public UseBed() { Position = new CoordInt(); }
public Effect(SoundEffects effect, CoordInt pos) : this(effect, pos, 0) { }
public BlockAction() { Position = new CoordInt(); }
public Effect(SoundEffects effect, CoordInt pos, int data = 0) { this.EffectID = effect; this.Position = pos; this.SoundData = data; }
public BlockPos(BlockID id, int meta, int light, CoordInt pos) : base(id, meta, light) { this.Position = pos; }
public UpdateSignClient() { Position = new CoordInt(); }
public PlayerDat(Tag tag) { if (tag == null) { tc = new TagCompound(); return; } tc = (TagCompound)tag; foreach (var tp in tc.CompoundList) { Tag v = tp.Value; switch (tp.Key) { case "SleepTimer": SleepTimer = v.Short; break; case "Motion": Motion [0] = ((TagList<TagDouble>)v) [0].Double; Motion [1] = ((TagList<TagDouble>)v) [1].Double; Motion [2] = ((TagList<TagDouble>)v) [2].Double; break; case "OnGround": OnGround = v.Byte; break; case "HurtTime": HurtTime = v.Short; break; case "Health": Health = v.Short; break; case "Dimension": Dimension = v.Int; break; case "Air": Air = v.Short; break; case "Inventory": if (v is TagList<TagCompound>) { foreach (TagCompound ti in ((TagList<TagCompound>)v)) { byte slot = ti ["Slot"].Byte; SlotItem item = new SlotItem((BlockID)ti ["id"].Short, ti ["Count"].Byte, ti ["Damage"].Short); if (100 <= slot && slot < 104) { InventoryWear [slot - 100] = item; } if (80 <= slot && slot < 84) { InventoryCraft [slot - 80] = item; } if (0 <= slot && slot < 36) { Inventory [slot] = item; } } } else if ((v is TagList<TagByte>) == false) { Console.Error.WriteLine("Player.dat: WARNING: No inventory"); Console.Error.WriteLine("Inventory: " + v.GetType() + "\t" + v); } break; case "Pos": Pos.X = ((TagList<TagDouble>)v) [0].Double; Pos.Y = ((TagList<TagDouble>)v) [1].Double; Pos.Z = ((TagList<TagDouble>)v) [2].Double; break; case "AttackTime": AttackTime = v.Short; break; case "Sleeping": Sleeping = v.Byte; break; case "Fire": Fire = v.Short; break; case "FallDistance": FallDistance = v.Float; break; case "Rotation": Rotation [0] = ((TagList<TagFloat>)v) [0].Float; Rotation [1] = ((TagList<TagFloat>)v) [1].Float; break; case "DeathTime": DeathTime = v.Short; break; case "SpawnX": if (Spawn == null) Spawn = new CoordInt(); Spawn.X = v.Int; break; case "SpawnY": if (Spawn == null) Spawn = new CoordInt(); Spawn.Y = v.Int; break; case "SpawnZ": if (Spawn == null) Spawn = new CoordInt(); Spawn.Z = v.Int; break; case "foodExhaustionLevel": foodExhaustionLevel = v.Float; break; case "foodTickTimer": foodTickTimer = v.Int; break; case "foodSaturationLevel": foodSaturationLevel = v.Float; break; case "foodLevel": foodLevel = v.Int; break; case "XpLevel": XpLevel = v.Int; break; case "XpTotal": XpTotal = v.Int; break; case "Xp": //not used anymore //Debug.Assert (false); Xp = v.Int; break; case "XpP": XpP = v.Float; break; case "playerGameType": playerGameType = v.Int; break; case "abilities": //TODO: booleans //flying, instabuild, mayfly, invulnerable break; case "EnderItems": //A list break; case "Attributes": //A list break; case "SelectedItemSlot": //integer break; case "UUIDLeast"://long break; case "UUIDMost"://long break; case "HealF"://float break; case "AbsorptionAmount"://float break; case "SpawnForced": //bool break; case "Score": //int break; case "PortalCooldown": //int break; case "Invulnerable": //bool break; #if DEBUG default: Console.WriteLine("Unknown: " + tp.Key + ": " + v); throw new NotImplementedException(); #endif } } }
public SpawnObject() { Velocity = new CoordInt(); }
public SpawnPosition(CoordInt pos) { this.Position = pos; }
protected override void Parse(EndianBinaryReader r) { Position = CoordInt.Read(r); }
public int GetIndex(CoordInt c) { int x = c.X & 0xF; int z = c.Z & 0xF; return x + z * 16 + c.Y * 16 * 16; }
protected override void Parse(EndianBinaryReader r) { Command = ReadString8(r); if (r.ReadBoolean()) Position = CoordInt.Read(r); }
public BlockAction() { Position = new CoordInt(); }
public SpawnObject() { Velocity = new CoordInt(); }