Requirements; Palidino's region class
Purpose; Stopping ppl with cheat clients from noclipping all over your server
First add this in your region class.
Code:
public static boolean canMove(int startX, int startY, int endX, int endY,
int height, int xLength, int yLength) {
int diffX = endX - startX;
int diffY = endY - startY;
int max = Math.max(Math.abs(diffX), Math.abs(diffY));
for (int ii = 0; ii < max; ii++) {
int currentX = endX - diffX;
int currentY = endY - diffY;
for (int i = 0; i < xLength; i++) {
for (int i2 = 0; i2 < yLength; i2++)
if (diffX < 0 && diffY < 0) {
if ((getClipping((currentX + i) - 1,
(currentY + i2) - 1, height) & 0x128010e) != 0
|| (getClipping((currentX + i) - 1, currentY
+ i2, height) & 0x1280108) != 0
|| (getClipping(currentX + i,
(currentY + i2) - 1, height) & 0x1280102) != 0)
return false;
} else if (diffX > 0 && diffY > 0) {
if ((getClipping(currentX + i + 1, currentY + i2 + 1,
height) & 0x12801e0) != 0
|| (getClipping(currentX + i + 1,
currentY + i2, height) & 0x1280180) != 0
|| (getClipping(currentX + i,
currentY + i2 + 1, height) & 0x1280120) != 0)
return false;
} else if (diffX < 0 && diffY > 0) {
if ((getClipping((currentX + i) - 1, currentY + i2 + 1,
height) & 0x1280138) != 0
|| (getClipping((currentX + i) - 1, currentY
+ i2, height) & 0x1280108) != 0
|| (getClipping(currentX + i,
currentY + i2 + 1, height) & 0x1280120) != 0)
return false;
} else if (diffX > 0 && diffY < 0) {
if ((getClipping(currentX + i + 1, (currentY + i2) - 1,
height) & 0x1280183) != 0
|| (getClipping(currentX + i + 1,
currentY + i2, height) & 0x1280180) != 0
|| (getClipping(currentX + i,
(currentY + i2) - 1, height) & 0x1280102) != 0)
return false;
} else if (diffX > 0 && diffY == 0) {
if ((getClipping(currentX + i + 1, currentY + i2,
height) & 0x1280180) != 0)
return false;
} else if (diffX < 0 && diffY == 0) {
if ((getClipping((currentX + i) - 1, currentY + i2,
height) & 0x1280108) != 0)
return false;
} else if (diffX == 0 && diffY > 0) {
if ((getClipping(currentX + i, currentY + i2 + 1,
height) & 0x1280120) != 0)
return false;
} else if (diffX == 0
&& diffY < 0
&& (getClipping(currentX + i, (currentY + i2) - 1,
height) & 0x1280102) != 0)
return false;
}
if (diffX < 0)
diffX++;
else if (diffX > 0)
diffX--;
if (diffY < 0)
diffY++;
else if (diffY > 0)
diffY--;
}
return true;
}
Next thing you do is go into your NPC class and find "int getNextWalkingDirection() {" below "dir = Misc.direction(absX, absY, (absX + moveX), (absY + moveY));" add
Code:
if (!Region.canMove(absX, absY, (absX + moveX), (absY + moveY), heightLevel, 1, 1))
return -1;
If you wanna use NPC sizes, here's a dump that you can use(Only goes up to 474 npcs).
Download npcsize.txt @ UppIT
Player walking, go into your player class and find "int getNextWalkingDirection() {" and under "currentY += Misc.directionDeltaY[dir];" add
Code:
if (!Region.canMove(absX, absY, (absX + Misc.directionDeltaX[dir]), (absY + Misc.directionDeltaY[dir]), heightLevel, 1, 1))
return -1;
Done.
To dump npc sizes
Code:
public static void dumpSizes() {
BufferedWriter writer = null;
try {
writer = new BufferedWriter( new FileWriter("npcsize.txt", true));
for (int j = 0; j < npc amount; j++) {
EntityDef n = EntityDef.forID(j);
writer.write(j + " " + n.aByte68);
writer.newLine();
}
//writer.write(-1);
writer.close();
} catch (IOException ioexception) {
ioexception.printStackTrace();
}
}