mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 05:03:34 -04:00
Less reliant on old GetTile/GetBlock
This commit is contained in:
parent
ec96484611
commit
471552f47a
@ -35,13 +35,14 @@ namespace MCGalaxy.Blocks {
|
||||
// Looking straight up or down
|
||||
byte pitch = p.Rot.HeadX;
|
||||
if (pitch >= 192 && pitch <= 196 || pitch >= 60 && pitch <= 64) { dx = 0; dz = 0; }
|
||||
Vec3U16 head = new Vec3U16((ushort)(x + dx * 2), (ushort)(y + dy * 2), (ushort)(z + dz * 2));
|
||||
Vec3U16 tail = new Vec3U16((ushort)(x + dx), (ushort)(y + dy), (ushort)(z + dz));
|
||||
|
||||
byte b1 = p.level.GetBlock(x + dx * 2, y + dy * 2, z + dz * 2);
|
||||
byte b2 = p.level.GetBlock(x + dx , y + dy, z + dz);
|
||||
if ( b1 == Block.air && b2 == Block.air && p.level.CheckClear((ushort)( x + dx * 2 ), (ushort)( y + dy * 2 ), (ushort)( z + dz * 2 ))
|
||||
&& p.level.CheckClear((ushort)( x + dx ), (ushort)( y + dy ), (ushort)( z + dz )) ) {
|
||||
p.level.Blockchange((ushort)( x + dx * 2 ), (ushort)( y + dy * 2 ), (ushort)( z + dz * 2 ), (ExtBlock)Block.rockethead);
|
||||
p.level.Blockchange((ushort)( x + dx ), (ushort)( y + dy ), (ushort)( z + dz ), (ExtBlock)Block.lava_fire);
|
||||
bool headFree = p.level.IsAirAt(head.X, head.Y, head.Z) && p.level.CheckClear(head.X, head.Y, head.Z);
|
||||
bool tailFree = p.level.IsAirAt(tail.X, tail.Y, tail.Z) && p.level.CheckClear(tail.X, tail.Y, tail.Z);
|
||||
if (headFree && tailFree) {
|
||||
p.level.Blockchange(head.X, head.Y, head.Z, (ExtBlock)Block.rockethead);
|
||||
p.level.Blockchange(tail.X, tail.Y, tail.Z, (ExtBlock)Block.lava_fire);
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,19 +50,21 @@ namespace MCGalaxy.Blocks {
|
||||
if (p.level.physics == 0 || p.level.physics == 5) { p.RevertBlock(x, y, z); return; }
|
||||
|
||||
Random rand = new Random();
|
||||
ushort x2 = (ushort)(x + rand.Next(0, 2) - 1);
|
||||
ushort z2 = (ushort)(z + rand.Next(0, 2) - 1);
|
||||
byte b1 = p.level.GetBlock(x2, y + 2, z2);
|
||||
byte b2 = p.level.GetBlock(x2, y + 1, z2);
|
||||
// Offset the firework randomly
|
||||
Vec3U16 pos = new Vec3U16(0, 0, 0);
|
||||
pos.X = (ushort)(x + rand.Next(0, 2) - 1);
|
||||
pos.Z = (ushort)(z + rand.Next(0, 2) - 1);
|
||||
ushort headY = (ushort)(y + 2), tailY = (ushort)(y + 1);
|
||||
|
||||
if (b1 == Block.air && b2 == Block.air && p.level.CheckClear(x2, (ushort)(y + 1), z2)
|
||||
&& p.level.CheckClear(x2, (ushort)(y + 2), z2)) {
|
||||
p.level.Blockchange(x2, (ushort)(y + 2), z2, (ExtBlock)Block.firework);
|
||||
bool headFree = p.level.IsAirAt(pos.X, headY, pos.Z) && p.level.CheckClear(pos.X, headY, pos.Z);
|
||||
bool tailFree = p.level.IsAirAt(pos.X, tailY, pos.Z) && p.level.CheckClear(pos.X, tailY, pos.Z);
|
||||
if (headFree && tailFree) {
|
||||
p.level.Blockchange(pos.X, headY, pos.Z, (ExtBlock)Block.firework);
|
||||
|
||||
PhysicsArgs args = default(PhysicsArgs);
|
||||
args.Type1 = PhysicsArgs.Wait; args.Value1 = 1;
|
||||
args.Type2 = PhysicsArgs.Dissipate; args.Value2 = 100;
|
||||
p.level.Blockchange(x2, (ushort)(y + 1), z2, (ExtBlock)Block.lavastill, false, args);
|
||||
p.level.Blockchange(pos.X, tailY, pos.Z, (ExtBlock)Block.lavastill, false, args);
|
||||
}
|
||||
p.RevertBlock(x, y, z);
|
||||
}
|
||||
|
@ -27,12 +27,12 @@ namespace MCGalaxy.Blocks.Physics {
|
||||
|
||||
switch (rand.Next(1, 15)) {
|
||||
case 1:
|
||||
if (lvl.GetTile(x, (ushort)(y - 1), z) == Block.air)
|
||||
if (lvl.IsAirAt(x, (ushort)(y - 1), z))
|
||||
lvl.AddUpdate(lvl.PosToInt(x, (ushort)(y - 1), z), lvl.blocks[C.b]);
|
||||
else goto case 3;
|
||||
break;
|
||||
case 2:
|
||||
if (lvl.GetTile(x, (ushort)(y + 1), z) == Block.air)
|
||||
if (lvl.IsAirAt(x, (ushort)(y + 1), z))
|
||||
lvl.AddUpdate(lvl.PosToInt(x, (ushort)(y + 1), z), lvl.blocks[C.b]);
|
||||
else goto case 6;
|
||||
break;
|
||||
|
@ -52,8 +52,7 @@ namespace MCGalaxy.Blocks.Physics {
|
||||
int i = indices[j];
|
||||
ushort posX = (ushort)(x + (i / 5) - 2);
|
||||
ushort posZ = (ushort)(z + (i % 5) - 2);
|
||||
if (lvl.GetTile(posX, (ushort)(y - 1), posZ) == Block.air &&
|
||||
lvl.GetTile(posX, y, posZ) == Block.air)
|
||||
if (lvl.IsAirAt(posX, (ushort)(y - 1), posZ) && lvl.IsAirAt(posX, y, posZ))
|
||||
{
|
||||
if (posX < x) {
|
||||
posX = (ushort)((posX + x) / 2);
|
||||
|
@ -120,7 +120,7 @@ namespace MCGalaxy.Blocks.Physics {
|
||||
tree.SetData(rand, tree.DefaultSize(rand));
|
||||
tree.Generate(x, y, z, (xT, yT, zT, bT) =>
|
||||
{
|
||||
if (bT == Block.leaf && lvl.GetTile(xT, yT, zT) != Block.air) return;
|
||||
if (bT == Block.leaf && !lvl.IsAirAt(xT, yT, zT)) return;
|
||||
lvl.Blockchange(xT, yT, zT, (ExtBlock)bT);
|
||||
});
|
||||
|
||||
|
@ -75,8 +75,8 @@ namespace MCGalaxy.Commands.Fun {
|
||||
class AimState {
|
||||
public Player player;
|
||||
public Position oldPos = default(Position);
|
||||
public List<Vec3U16> lastSent = new List<Vec3U16>();
|
||||
public List<Vec3U16> toSend = new List<Vec3U16>();
|
||||
public List<Vec3U16> lastGlass = new List<Vec3U16>();
|
||||
public List<Vec3U16> glassCoords = new List<Vec3U16>();
|
||||
}
|
||||
|
||||
static void AimCallback(SchedulerTask task) {
|
||||
@ -84,7 +84,7 @@ namespace MCGalaxy.Commands.Fun {
|
||||
Player p = state.player;
|
||||
if (state.player.aiming) { DoAim(state); return; }
|
||||
|
||||
foreach (Vec3U16 cP in state.lastSent) {
|
||||
foreach (Vec3U16 cP in state.lastGlass) {
|
||||
if (!p.level.IsValidPos(cP)) continue;
|
||||
p.RevertBlock(cP.X, cP.Y, cP.Z);
|
||||
}
|
||||
@ -99,39 +99,39 @@ namespace MCGalaxy.Commands.Fun {
|
||||
ushort z = (ushort)Math.Round(p.Pos.BlockZ + dir.Z * 3);
|
||||
|
||||
int signX = Math.Sign(dir.X) >= 0 ? 1 : -1, signZ = Math.Sign(dir.Z) >= 0 ? 1 : -1;
|
||||
CheckTile(p.level, state.toSend, x, y, z);
|
||||
CheckTile(p.level, state.toSend, x + signX, y, z);
|
||||
CheckTile(p.level, state.toSend, x, y, z + signZ);
|
||||
CheckTile(p.level, state.toSend, x + signX, y, z + signZ);
|
||||
CheckTile(p.level, state.glassCoords, x, y, z);
|
||||
CheckTile(p.level, state.glassCoords, x + signX, y, z);
|
||||
CheckTile(p.level, state.glassCoords, x, y, z + signZ);
|
||||
CheckTile(p.level, state.glassCoords, x + signX, y, z + signZ);
|
||||
|
||||
// Revert all glass blocks now not in the ray from the player's direction
|
||||
for (int i = 0; i < state.lastSent.Count; i++) {
|
||||
Vec3U16 cP = state.lastSent[i];
|
||||
if (state.toSend.Contains(cP)) continue;
|
||||
for (int i = 0; i < state.lastGlass.Count; i++) {
|
||||
Vec3U16 cP = state.lastGlass[i];
|
||||
if (state.glassCoords.Contains(cP)) continue;
|
||||
|
||||
if (p.level.IsValidPos(cP))
|
||||
p.RevertBlock(cP.X, cP.Y, cP.Z);
|
||||
state.lastSent.RemoveAt(i); i--;
|
||||
state.lastGlass.RemoveAt(i); i--;
|
||||
}
|
||||
|
||||
// Place the new glass blocks that are in the ray from the player's direction
|
||||
foreach (Vec3U16 cP in state.toSend) {
|
||||
if (state.lastSent.Contains(cP)) continue;
|
||||
state.lastSent.Add(cP);
|
||||
foreach (Vec3U16 cP in state.glassCoords) {
|
||||
if (state.lastGlass.Contains(cP)) continue;
|
||||
state.lastGlass.Add(cP);
|
||||
p.SendBlockchange(cP.X, cP.Y, cP.Z, (ExtBlock)Block.glass);
|
||||
}
|
||||
state.toSend.Clear();
|
||||
state.glassCoords.Clear();
|
||||
}
|
||||
|
||||
static void CheckTile(Level lvl, List<Vec3U16> toSend, int x, int y, int z) {
|
||||
static void CheckTile(Level lvl, List<Vec3U16> glassCoords, int x, int y, int z) {
|
||||
Vec3U16 pos;
|
||||
if (lvl.GetBlock(x, y - 1, z) == Block.air) {
|
||||
if (lvl.IsAirAt(x, y - 1, z)) {
|
||||
pos.X = (ushort)x; pos.Y = (ushort)(y - 1); pos.Z = (ushort)z;
|
||||
toSend.Add(pos);
|
||||
glassCoords.Add(pos);
|
||||
}
|
||||
if (lvl.GetBlock(x, y, z) == Block.air) {
|
||||
if (lvl.IsAirAt(x, y, z)) {
|
||||
pos.X = (ushort)x; pos.Y = (ushort)y; pos.Z = (ushort)z;
|
||||
toSend.Add(pos);
|
||||
glassCoords.Add(pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ namespace MCGalaxy.Commands.Misc {
|
||||
|
||||
Thread.Sleep(250);
|
||||
p.level.Blockchange(p, cur.X, cur.Y, cur.Z, (ExtBlock)Block.mushroom);
|
||||
if (p.level.GetTile(next.X, next.Y, next.Z) != 0) {
|
||||
if (!p.level.IsAirAt(next.X, next.Y, next.Z)) {
|
||||
PullBack(p, next, target, dirX, dirZ);
|
||||
p.level.Blockchange(p, x, y, z, ExtBlock.Air); return;
|
||||
}
|
||||
@ -83,7 +83,7 @@ namespace MCGalaxy.Commands.Misc {
|
||||
cur.X = (ushort)(cur.X - dirX); cur.Z = (ushort)(cur.Z - dirZ);
|
||||
if (cur.X >= p.level.Width || cur.Z >= p.level.Length) return;
|
||||
|
||||
curBlock.BlockID = p.level.GetTile(cur.X, cur.Y, cur.Z);
|
||||
curBlock = p.level.GetExtBlock(cur.X, cur.Y, cur.Z);
|
||||
if (curBlock.BlockID == Block.mushroom)
|
||||
p.level.Blockchange(p, cur.X, cur.Y, cur.Z, block);
|
||||
Thread.Sleep(250);
|
||||
|
@ -48,8 +48,8 @@ namespace MCGalaxy.Commands.Misc {
|
||||
class FlyState {
|
||||
public Player player;
|
||||
public Position oldPos = default(Position);
|
||||
public List<Vec3U16> last = new List<Vec3U16>();
|
||||
public List<Vec3U16> next = new List<Vec3U16>();
|
||||
public List<Vec3U16> lastGlass = new List<Vec3U16>();
|
||||
public List<Vec3U16> glassCoords = new List<Vec3U16>();
|
||||
}
|
||||
|
||||
static void FlyCallback(SchedulerTask task) {
|
||||
@ -57,7 +57,7 @@ namespace MCGalaxy.Commands.Misc {
|
||||
Player p = state.player;
|
||||
if (state.player.isFlying) { DoFly(state); return; }
|
||||
|
||||
foreach (Vec3U16 cP in state.last) {
|
||||
foreach (Vec3U16 cP in state.lastGlass) {
|
||||
p.SendBlockchange(cP.X, cP.Y, cP.Z, ExtBlock.Air);
|
||||
}
|
||||
Player.Message(p, "Stopped flying");
|
||||
@ -76,29 +76,26 @@ namespace MCGalaxy.Commands.Misc {
|
||||
for (int zz = z - 2; zz <= z + 2; zz++)
|
||||
for (int xx = x - 2; xx <= x + 2; xx++)
|
||||
{
|
||||
ushort offX = (ushort)xx, offY = (ushort)yy, offZ = (ushort)zz;
|
||||
if (p.level.GetTile(offX, offY, offZ) != Block.air) continue;
|
||||
|
||||
Vec3U16 pos;
|
||||
pos.X = offX; pos.Y = offY; pos.Z = offZ;
|
||||
state.next.Add(pos);
|
||||
pos.X = (ushort)xx; pos.Y = (ushort)yy; pos.Z = (ushort)zz;
|
||||
if (!p.level.IsAirAt(pos.X, pos.Y, pos.Z)) state.glassCoords.Add(pos);
|
||||
}
|
||||
|
||||
foreach (Vec3U16 P in state.next) {
|
||||
if (state.last.Contains(P)) continue;
|
||||
state.last.Add(P);
|
||||
foreach (Vec3U16 P in state.glassCoords) {
|
||||
if (state.lastGlass.Contains(P)) continue;
|
||||
state.lastGlass.Add(P);
|
||||
p.SendBlockchange(P.X, P.Y, P.Z, glass);
|
||||
}
|
||||
|
||||
for (int i = 0; i < state.last.Count; i++) {
|
||||
Vec3U16 P = state.last[i];
|
||||
if (state.next.Contains(P)) continue;
|
||||
for (int i = 0; i < state.lastGlass.Count; i++) {
|
||||
Vec3U16 P = state.lastGlass[i];
|
||||
if (state.glassCoords.Contains(P)) continue;
|
||||
|
||||
p.SendBlockchange(P.X, P.Y, P.Z, ExtBlock.Air);
|
||||
state.last.RemoveAt(i); i--;
|
||||
p.RevertBlock(P.X, P.Y, P.Z);
|
||||
state.lastGlass.RemoveAt(i); i--;
|
||||
}
|
||||
|
||||
state.next.Clear();
|
||||
state.glassCoords.Clear();
|
||||
state.oldPos = p.Pos;
|
||||
}
|
||||
|
||||
|
@ -17,11 +17,10 @@
|
||||
*/
|
||||
//StormCom Object Generator
|
||||
//
|
||||
//Full use to all StormCom Server System codes (in regards to minecraft classic) have been granted to MCGalaxy without restriction.
|
||||
//Full use to all StormCom Server System codes (in regards to minecraft classic) have been granted to MCForge without restriction.
|
||||
//
|
||||
// ~Merlin33069
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MCGalaxy.Drawing.Brushes;
|
||||
using MCGalaxy.Maths;
|
||||
|
||||
@ -52,9 +51,7 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
int dist = xx * xx + zz * zz;
|
||||
if (dist > curRadius * curRadius) continue;
|
||||
|
||||
byte ctile = Level.GetTile(x, y, z);
|
||||
if (ctile != 0) continue;
|
||||
output(Place(x, y, z, brush));
|
||||
if (Level.IsAirAt(x, y, z)) output(Place(x, y, z, brush));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -88,9 +85,7 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
if (dist > curRadius * curRadius || dist < (curRadius - 1) * (curRadius - 1))
|
||||
continue;
|
||||
|
||||
byte ctile = Level.GetTile(x, y, z);
|
||||
if (ctile != 0) continue;
|
||||
output(Place(x, y, z, brush));
|
||||
if (Level.IsAirAt(x, y, z)) output(Place(x, y, z, brush));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -120,9 +115,7 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
double curRadius = Radius * ((double)curHeight / (double)height);
|
||||
int dist = xx * xx + zz * zz;
|
||||
if (dist > curRadius * curRadius) continue;
|
||||
|
||||
byte ctile = Level.GetTile(x, y, z);
|
||||
if (ctile != 0) continue;
|
||||
if (!Level.IsAirAt(x, y, z)) continue;
|
||||
|
||||
bool layer = dist >= (curRadius - 1) * (curRadius - 1);
|
||||
block.BlockID = layer ? Block.grass : Block.lavastill;
|
||||
|
@ -17,11 +17,10 @@
|
||||
*/
|
||||
//StormCom Object Generator
|
||||
//
|
||||
//Full use to all StormCom Server System codes (in regards to minecraft classic) have been granted to MCGalaxy without restriction.
|
||||
//Full use to all StormCom Server System codes (in regards to minecraft classic) have been granted to MCForge without restriction.
|
||||
//
|
||||
// ~Merlin33069
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MCGalaxy.Drawing.Brushes;
|
||||
using MCGalaxy.Maths;
|
||||
|
||||
@ -51,9 +50,7 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
double curRadius = Radius * ((double)curHeight / (double)height);
|
||||
if (Math.Abs(xx) > curRadius || Math.Abs(zz) > curRadius) continue;
|
||||
|
||||
byte ctile = Level.GetTile(x, y, z);
|
||||
if (ctile != 0) continue;
|
||||
output(Place(x, y, z, brush));
|
||||
if (Level.IsAirAt(x, y, z)) output(Place(x, y, z, brush));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -87,9 +84,7 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
if (absx > curRadius || absz > curRadius) continue;
|
||||
if (absx < (curRadius - 1) && absz < (curRadius - 1)) continue;
|
||||
|
||||
byte ctile = Level.GetTile(x, y, z);
|
||||
if (ctile != 0) continue;
|
||||
output(Place(x, y, z, brush));
|
||||
if (Level.IsAirAt(x, y, z)) output(Place(x, y, z, brush));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
int startX = i;
|
||||
for (ushort x = p1.X; x <= p2.X; x++) {
|
||||
i = (i + stepX) % 13;
|
||||
if (Level.GetTile(x, y, z) != Block.air) {
|
||||
if (!Level.IsAirAt(x, y, z)) {
|
||||
block.BlockID = (byte)(Block.red + i);
|
||||
output(Place(x, y, z, block));
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
|
||||
Tree.Generate(P.X, P.Y, P.Z, (xT, yT, zT, bT) =>
|
||||
{
|
||||
if (bT == Block.leaf && lvl.GetTile(xT, yT, zT) != Block.air) return;
|
||||
if (bT == Block.leaf && !lvl.IsAirAt(xT, yT, zT)) return;
|
||||
|
||||
if (bT != Block.leaf) {
|
||||
output(Place(xT, yT, zT, (ExtBlock)bT));
|
||||
|
@ -46,9 +46,9 @@ namespace MCGalaxy.Games {
|
||||
case "base.red.z":
|
||||
redbase.z = ushort.Parse(value); break;
|
||||
case "base.red.block":
|
||||
redbase.block = Block.Byte(value); break;
|
||||
redbase.block = ExtBlock.FromRaw(byte.Parse(value)); break;
|
||||
case "base.blue.block":
|
||||
bluebase.block = Block.Byte(value); break;
|
||||
bluebase.block = ExtBlock.FromRaw(byte.Parse(value)); break;
|
||||
case "base.blue.spawnx":
|
||||
bluebase.spawnx = ushort.Parse(value); break;
|
||||
case "base.blue.spawny":
|
||||
|
@ -63,7 +63,7 @@ namespace MCGalaxy.Games {
|
||||
internal sealed class Base {
|
||||
public ushort x, y, z;
|
||||
public ushort spawnx, spawny, spawnz;
|
||||
public byte block;
|
||||
public ExtBlock block;
|
||||
|
||||
public void SendToSpawn(Level mainlevel, CTFGame game, Player p1) {
|
||||
Position pos = new Position(spawnx, spawny, spawny);
|
||||
@ -74,7 +74,7 @@ namespace MCGalaxy.Games {
|
||||
xx = (ushort)(rand.Next(0, mainlevel.Width));
|
||||
yy = (ushort)(rand.Next(0, mainlevel.Height));
|
||||
zz = (ushort)(rand.Next(0, mainlevel.Length));
|
||||
} while (mainlevel.GetTile(xx, yy, zz) != Block.air && game.OnSide(zz, this));
|
||||
} while (!mainlevel.IsAirAt(xx, yy, zz) && game.OnSide(zz, this));
|
||||
|
||||
pos.X = xx * 32; pos.Y = yy * 32; pos.Z = zz * 32;
|
||||
}
|
||||
@ -191,7 +191,7 @@ namespace MCGalaxy.Games {
|
||||
if (GetPlayer(other).hasflag) {
|
||||
Chat.MessageLevel(mainlevel, redteam.color + p.name + " DROPPED THE FLAG!");
|
||||
GetPlayer(other).points -= caplose;
|
||||
mainlevel.Blockchange(b.x, b.y, b.z, (ExtBlock)b.block);
|
||||
mainlevel.Blockchange(b.x, b.y, b.z, b.block);
|
||||
GetPlayer(other).hasflag = false;
|
||||
}
|
||||
|
||||
@ -251,8 +251,8 @@ namespace MCGalaxy.Games {
|
||||
LoadMap(maps[new Random().Next(maps.Count)]);
|
||||
|
||||
if (needSetup) AutoSetup();
|
||||
redbase.block = Block.red;
|
||||
bluebase.block = Block.blue;
|
||||
redbase.block = (ExtBlock)Block.red;
|
||||
bluebase.block = (ExtBlock)Block.blue;
|
||||
Server.s.Log("[Auto_CTF] Running...");
|
||||
started = true;
|
||||
|
||||
|
@ -51,7 +51,7 @@ namespace MCGalaxy.Games {
|
||||
cache[p].bx = x;
|
||||
cache[p].by = y;
|
||||
cache[p].bz = z;
|
||||
cache[p].blue = p.level.GetTile(x, y, z);
|
||||
cache[p].blue = p.level.GetExtBlock(x, y, z);
|
||||
Player.Message(p, "Ok! I got the blue flag, now can you show me the red flag?");
|
||||
Player.Message(p, "Just hit it");
|
||||
cache[p].s = Step.GetRedFlag;
|
||||
@ -60,7 +60,7 @@ namespace MCGalaxy.Games {
|
||||
cache[p].rx = x;
|
||||
cache[p].ry = y;
|
||||
cache[p].rz = z;
|
||||
cache[p].red = p.level.GetTile(x, y, z);
|
||||
cache[p].red = p.level.GetExtBlock(x, y, z);
|
||||
Player.Message(p, "Got it!");
|
||||
Player.Message(p, "Now I can do random spawns, or do you have a spawn in mind?");
|
||||
Player.Message(p, "Say - (Random/Set)");
|
||||
@ -172,7 +172,7 @@ namespace MCGalaxy.Games {
|
||||
public int middle = 0;
|
||||
public int bx, by, bz;
|
||||
public int rx, ry, rz;
|
||||
public byte blue, red;
|
||||
public ExtBlock blue, red;
|
||||
public int bluex, bluey, bluez;
|
||||
}
|
||||
|
||||
|
@ -185,25 +185,25 @@ namespace MCGalaxy.Games {
|
||||
//beneath this is checking the glass next to the square
|
||||
bool up = false, left = false, right = false, down = false;
|
||||
//directly next to
|
||||
if (mapon.GetBlock(x1, y, z2 + 2) == Block.air) //right
|
||||
if (mapon.IsAirAt(x1, y, z2 + 2)) //right
|
||||
{
|
||||
mapon.Blockchange(x1, y, (ushort)(z2 + 1), ExtBlock.Air);
|
||||
mapon.Blockchange(x2, y, (ushort)(z2 + 1), ExtBlock.Air);
|
||||
right = true;
|
||||
}
|
||||
if (mapon.GetBlock(x1, y, z1 - 2) == Block.air) //left
|
||||
if (mapon.IsAirAt(x1, y, z1 - 2)) //left
|
||||
{
|
||||
mapon.Blockchange(x1, y, (ushort)(z1 - 1), ExtBlock.Air);
|
||||
mapon.Blockchange(x2, y, (ushort)(z1 - 1), ExtBlock.Air);
|
||||
left = true;
|
||||
}
|
||||
if (mapon.GetBlock(x2 + 2, y, z1) == Block.air) //up
|
||||
if (mapon.IsAirAt(x2 + 2, y, z1)) //up
|
||||
{
|
||||
mapon.Blockchange((ushort)(x2 + 1), y, z1, ExtBlock.Air);
|
||||
mapon.Blockchange((ushort)(x2 + 1), y, z2, ExtBlock.Air);
|
||||
up = true;
|
||||
}
|
||||
if (mapon.GetBlock(x1 - 2, y, z1) == Block.air) //down
|
||||
if (mapon.IsAirAt(x1 - 2, y, z1)) //down
|
||||
{
|
||||
mapon.Blockchange((ushort)(x1 - 1), y, z1, ExtBlock.Air);
|
||||
mapon.Blockchange((ushort)(x1 - 1), y, z2, ExtBlock.Air);
|
||||
@ -211,19 +211,19 @@ namespace MCGalaxy.Games {
|
||||
}
|
||||
|
||||
//diagonal >:(
|
||||
if ((mapon.GetBlock(x1 - 2, y, z1 - 2) == Block.air) && left && down) //bottom left
|
||||
if (mapon.IsAirAt(x1 - 2, y, z1 - 2) && left && down) //bottom left
|
||||
{
|
||||
mapon.Blockchange((ushort)(x1 - 1), y, (ushort)(z1 - 1), ExtBlock.Air);
|
||||
}
|
||||
if ((mapon.GetBlock(x1 - 2, y, z2 + 2) == Block.air) && right && down) //bottom right
|
||||
if (mapon.IsAirAt(x1 - 2, y, z2 + 2) && right && down) //bottom right
|
||||
{
|
||||
mapon.Blockchange((ushort)(x1 - 1), y, (ushort)(z2 + 1), ExtBlock.Air);
|
||||
}
|
||||
if ((mapon.GetBlock(x2 + 2, y, z1 - 2) == Block.air) && left && up) //top left
|
||||
if (mapon.IsAirAt(x2 + 2, y, z1 - 2) && left && up) //top left
|
||||
{
|
||||
mapon.Blockchange((ushort)(x2 + 1), y, (ushort)(z1 - 1), ExtBlock.Air);
|
||||
}
|
||||
if ((mapon.GetBlock(x2 + 2, y, z2 + 2) == Block.air) && right && up) //top right
|
||||
if (mapon.IsAirAt(x2 + 2, y, z2 + 2) && right && up) //top right
|
||||
{
|
||||
mapon.Blockchange((ushort)(x2 + 1), y, (ushort)(z2 + 1), ExtBlock.Air);
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ namespace MCGalaxy.Generator {
|
||||
}
|
||||
|
||||
if (genParams.GenTrees && overlay[index] < 0.65f && overlay2[index] < treeDens) {
|
||||
if (Lvl.GetTile(x, (ushort)(y + 1), z) == Block.air) {
|
||||
if (Lvl.IsAirAt(x, (ushort)(y + 1), z)) {
|
||||
if (Lvl.GetTile(x, y, z) == Block.grass || genParams.UseCactus) {
|
||||
if (rand.Next(13) == 0 && !Tree.TreeCheck(Lvl, x, y, z, treeDist)) {
|
||||
Tree tree = null;
|
||||
@ -143,7 +143,7 @@ namespace MCGalaxy.Generator {
|
||||
tree.SetData(rand, tree.DefaultSize(rand));
|
||||
tree.Generate(x, (ushort)(y + 1), z, (xT, yT, zT, bT) =>
|
||||
{
|
||||
if (Lvl.GetTile(xT, yT, zT) == Block.air)
|
||||
if (Lvl.IsAirAt(xT, yT, zT))
|
||||
Lvl.SetTile(xT, yT, zT, bT);
|
||||
});
|
||||
}
|
||||
|
@ -57,6 +57,20 @@ namespace MCGalaxy {
|
||||
return block;
|
||||
}
|
||||
|
||||
/// <summary> Gets whether the block at the given coordinates is air. </summary>
|
||||
public bool IsAirAt(ushort x, ushort y, ushort z) {
|
||||
if (x >= Width || y >= Height || z >= Length || blocks == null) return false;
|
||||
return blocks[x + Width * (z + y * Length)] == Block.air;
|
||||
}
|
||||
|
||||
/// <summary> Gets whether the block at the given coordinates is air. </summary>
|
||||
public bool IsAirAt(int x, int y, int z) {
|
||||
if (x < 0 || y < 0 || z < 0 || blocks == null) return false;
|
||||
if (x >= Width || y >= Height || z >= Length) return false;
|
||||
|
||||
return blocks[x + Width * (z + y * Length)] == Block.air;
|
||||
}
|
||||
|
||||
/// <summary> Gets the block at the given coordinates. </summary>
|
||||
/// <returns> Block.Invalid if coordinates outside map. </returns>
|
||||
public byte GetBlock(int x, int y, int z) {
|
||||
@ -99,12 +113,6 @@ namespace MCGalaxy {
|
||||
chunk[(y & 0x0F) << 8 | (z & 0x0F) << 4 | (x & 0x0F)];
|
||||
}
|
||||
|
||||
public byte GetFallbackExtTile(ushort x, ushort y, ushort z) {
|
||||
byte tile = GetExtTile(x, y, z);
|
||||
BlockDefinition def = CustomBlockDefs[tile];
|
||||
return def == null ? Block.air : def.FallBack;
|
||||
}
|
||||
|
||||
public byte GetFallbackExtTile(int index) {
|
||||
byte tile = GetExtTile(index);
|
||||
BlockDefinition def = CustomBlockDefs[tile];
|
||||
|
Loading…
x
Reference in New Issue
Block a user