Jump to content
  • 0
drakthuro

718 RSPS. Getworldtile region error.

Question

alright i have no clue anymore how to solve this.

i made a controler which builds a region.

the controler ports the player to specific coordinates, which works fine when the controler starts.

somewere in the controler the player has to start a dialogue which ports the player aswell. but when the dialogue starts the teleport, a error appears.

it does not matter how i execute the teleport, via the dialogue or via the controler or via the stages or public voids, it keeps giving me errors.

i will post the error first - then the controler - then the dialogue.

all help is appreciated.

ERROR.

ERROR! THREAD NAME: New I/O  worker #3java.lang.NullPointerException
        at com.rs.game.player.dialogues.Greyfieldpath.getWorldTile(Greyfieldpath
.java:22)
        at com.rs.game.player.dialogues.Greyfieldpath.run(Greyfieldpath.java:88)


        at com.rs.game.player.DialogueManager.continueDialogue(DialogueManager.j
ava:31)
        at com.rs.net.decoders.WorldPacketsDecoder.processPackets(WorldPacketsDe
coder.java:1122)
        at com.rs.net.decoders.WorldPacketsDecoder.decode(WorldPacketsDecoder.ja
va:280)
        at com.rs.net.ServerChannelHandler.messageReceived(ServerChannelHandler.
java:100)
        at org.jboss.netty.channel.SimpleChannelHandler.handleUpstream(SimpleCha
nnelHandler.java:95)
        at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultCh
annelPipeline.java:563)
        at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultCh
annelPipeline.java:558)
        at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:26
8)
        at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:25
5)
        at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:91)
        at org.jboss.netty.channel.socket.nio.AbstractNioWorker.processSelectedK
eys(AbstractNioWorker.java:373)
        at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioW
orker.java:247)
        at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:35)
        at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnabl
e.java:102)
        at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProof
Worker.java:42)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

the controler

public class 1 extends Controler implements Serializable { private static final long serialVersionUID = -5085199980760260952L;


private static final int QUEST_GUIDE_NPC = 949;
private static final int DYINGADV = 19610;
private static final int CAPTAIN = 13707;
private static final int JACK = 19061;

private int[] boundChuncks;
private boolean spawned;
public int selectedMusic;
private int stage;
private NPC peacekeeper;

//private transient Player player;
private transient int[] mapBaseCoords;


@Override
public void start() {
player.setYellOff(true);
refreshStage();
//player.getPackets().sendMusicEffect(13);
// player.getMusicsManager().forcePlayMusic(239); //Brain Battle
}

private static final int[] MUSICS = { 876, 597, 1003 };


public void playMusic() {
player.getMusicsManager().playMusic(selectedMusic) ;
}

public NPC findNPC(int id) {
for (NPC npc : World.getNPCs()) {
if (npc == null || npc.getId() != id)
continue;
return npc;
}
return null;
}


@Override
public void process() {
if (getStage() == 2 && player.isvyrekill1())
updateProgress();
}


@Override
public boolean processObjectClick1(WorldObject object) {
int id = object.getId();
return true;
}


@Override
public boolean processObjectClick2(WorldObject object) {
return false;
}


@Override
public boolean processObjectClick3(WorldObject object) {
return false;
}

@Override
public boolean processNPCClick1(NPC npc) {
if (npc.getId() == CAPTAIN) {
player.getDialogueManager().startDialogue("Captain ",
CAPTAIN, this);
npc.faceEntity(player);
npc.resetWalkSteps();
player.lock();
updateProgress();
}
if (npc.getId() == JACK) {
player.getDialogueManager().startDialogue("Greyfie ldpath",
JACK, this);
npc.faceEntity(player);
npc.resetWalkSteps();
player.lock();
updateProgress();
}
return false;
}

@Override
public boolean processNPCClick2(NPC npc) {
if (npc.getId() == CAPTAIN) {
npc.faceEntity(player);
npc.resetWalkSteps();
return false;
}
return false;
}
@Override
public boolean processNPCClick3(NPC npc) {
if (npc.getId() == CAPTAIN) {
npc.faceEntity(player);
npc.resetWalkSteps();
return false;
}
return false;
}


public void refreshStage() {
int stage = getStage();
if (stage == 0) {
} else if (stage == 1) {
} else if (stage == 4) {

}
sendInterfaces();
}


@Override
public void sendInterfaces() {
int stage = getStage();
player.getInterfaceManager().replaceRealChatBoxInt erface(372);
if (stage == 0) {
selectedMusic = MUSICS[Utils.random(MUSICS.length)];
playMusic();
} else if (stage == 1) {
selectedMusic = MUSICS[Utils.random(MUSICS.length)];
playMusic();
player.getInterfaceManager().closeMagicBook();
player.getInterfaceManager().closeEmotes();
player.getInterfaceManager().closeTaskSystem();
player.getInterfaceManager().closeSkills();
player.getInterfaceManager().closeEquipment();
player.getInterfaceManager().closeXPDisplay();
player.getInterfaceManager().closeEmotes();
BuildRegion();
} else if (stage == 2) {
selectedMusic = MUSICS[Utils.random(MUSICS.length)];
playMusic();
player.getInterfaceManager().closeMagicBook();
player.getInterfaceManager().closeEmotes();
player.getInterfaceManager().closeTaskSystem();
player.getInterfaceManager().closeSkills();
player.getInterfaceManager().closeEquipment();
player.getInterfaceManager().closeXPDisplay();
player.getInterfaceManager().closeEmotes();
//player.getAppearence().setRenderEmote(2391);
NPC captain = findNPC(CAPTAIN);
if (captain != null)
player.getHintIconsManager().addHintIcon(captain, 0, -1, false);
player.getPackets().sendIComponentText(372, 2,"");
player.getPackets().sendIComponentText(372, 3, "");
player.getPackets().sendIComponentText(372, 4, "");
player.getPackets().sendIComponentText(372, 5, "");
player.getPackets().sendIComponentText(372, 6, "");
} else if (stage == 3) {
NPC captain = findNPC(CAPTAIN);
NPC jack = findNPC(JACK);
if (jack != null)
player.getHintIconsManager().addHintIcon(captain, 0, -1, false);
player.getHintIconsManager().addHintIcon(jack, 0, -1, false);
selectedMusic = MUSICS[Utils.random(MUSICS.length)];
playMusic();
player.getInterfaceManager().closeMagicBook();
player.getInterfaceManager().closeEmotes();
player.getInterfaceManager().closeTaskSystem();
player.getInterfaceManager().closeSkills();
player.getInterfaceManager().closeEquipment();
player.getInterfaceManager().closeXPDisplay();
player.getInterfaceManager().closeEmotes();
player.getPackets().sendIComponentText(372, 2,"");
player.getPackets().sendIComponentText(372, 3, "");
player.getPackets().sendIComponentText(372, 4, "");
player.getPackets().sendIComponentText(372, 5, "");
player.getPackets().sendIComponentText(372, 6, "");
} else if (stage == 4) {
selectedMusic = MUSICS[Utils.random(MUSICS.length)];
playMusic();
player.getInterfaceManager().closeMagicBook();
player.getInterfaceManager().closeEmotes();
player.getInterfaceManager().closeTaskSystem();
player.getInterfaceManager().closeSkills();
player.getInterfaceManager().closeEquipment();
player.getInterfaceManager().closeXPDisplay();
player.getInterfaceManager().closeEmotes();
player.getPackets().sendIComponentText(372, 3, "");
player.getPackets().sendIComponentText(372, 4, "");
player.getPackets().sendIComponentText(372, 5, "");
player.getPackets().sendIComponentText(372, 6, "");

}
}


public void updateProgress() {
setStage(getStage() + 1);
refreshStage();
}

public void setStage(int stage) {
getArguments()[0] = stage;
}


public int getStage() {
if (getArguments() == null)
setArguments(new Object[] { 0 }); // index 0 = stage
return (Integer) getArguments()[0];
}


/*
* return remove controler
*/
@Override
public boolean login() {
start();
return false;
}


/*
* return remove controler
*/
@Override
public boolean logout() {
//RegionBuilder.destroyMap(boundChuncks[0], boundChuncks[1], 8, 8);
return false;
}


@Override
public boolean processMagicTeleport(WorldTile toTile) {
return false;
}


@Override
public boolean processItemTeleport(WorldTile toTile) {
return false;
}


@Override
public boolean processObjectTeleport(WorldTile toTile) {
return false;
}

private void BuildRegion() {
boundChuncks = RegionBuilder.findEmptyChunkBound(8, 8);
RegionBuilder.copyAllPlanesMap(429, 392, boundChuncks[0], boundChuncks[1], 40);
player.setNextWorldTile(getWorldTile(169, 27, 1));
NPC dharim = new NPC(19062, getWorldTile(159, 76, 1), -1, false);
NPC jack = new NPC(19061, getWorldTile(157, 76, 1), -1, false);
NPC peacekeeper = new NPC(19060, getWorldTile(163, 32, 1), -1, false);
NPC captain = new NPC(13707, getWorldTile(158, 38, 1), -1, false);
NPC dead = new NPC(3077, getWorldTile(157, 41, 1), -1, false);
NPC dead2 = new NPC(3077, getWorldTile(157, 63, 1), -1, false);
captain.setDirection(Utils.EntityDirection.WEST.ge tValue());
dead.setDirection(Utils.EntityDirection.SOUTH.getV alue());
dead2.setDirection(Utils.EntityDirection.EAST.getV alue());
peacekeeper.setDirection(Utils.EntityDirection.EAS T.getValue());
jack.setDirection(Utils.EntityDirection.SOUTH.getV alue());
dead.setRandomWalk(false);
dead2.setRandomWalk(false);
World.spawnObject(new WorldObject(66741, 10, 1, getWorldTile(158, 40, 1)), true);
World.spawnObject(new WorldObject(66741, 10, 0, getWorldTile(157, 39, 1)), true);
player.getAppearence().generateAppearenceData();
player.getEquipment().refresh(0);
player.getEquipment().refresh(4);
player.getEquipment().refresh(7);
player.getEquipment().refresh(10);
player.getEquipment().refresh(9);
player.getEquipment().refresh(3);
player.getEquipment().refresh(5);
player.getEquipment().refresh(1);
selectedMusic = MUSICS[Utils.random(MUSICS.length)];
player.setForceMultiArea(true);
playMusic();
player.setMeiyerWar(this);
player.canSpawn();
setStage(getStage() + 1);
}

public WorldTile getWorldTile(int mapX, int mapY, int plane) {
return new WorldTile(boundChuncks[0] * 8 + mapX, boundChuncks[1] * 8 + mapY, plane);
}




@Override
public void forceClose() {
WorldTasksManager.schedule(new WorldTask() {
@Override
public void run() {
player.getInterfaceManager().sendInterfaces();
player.getInterfaceManager().closeReplacedRealChat BoxInterface();
}
});
}
}

 

the dialogue -- yes it contains chat info but its not relevent. the only thing that is relevent is the port at stage 9.

package com.rs.game.player.dialogues;


import com.rs.Settings;
import com.rs.game.item.Item;
import com.rs.game.player.Player;
import com.rs.game.player.controlers.1;
import com.rs.game.player.content.FadingScreen;
import com.rs.game.WorldTile;
import com.rs.game.World;


public class Greyfieldpath extends Dialogue {


int npcId = 19061;
int npcId2 = 19062;

private int[] boundChuncks;

private 1 controler;

public WorldTile getWorldTile(int mapX, int mapY, int plane) {
return new WorldTile(boundChuncks[0] * 8 + mapX, boundChuncks[1] * 8 + mapY, plane);
}
@Override
public void start() {
controler = (MeiyerWar) parameters[1];
}


@Override
public void run(int interfaceId, int componentId) {
switch (stage) {
case -1:
stage = 0;
break;
case 0:
stage = 1;
break;
case 1:
stage = 2;
break;
case 2:
stage = 3;
break;
case 3:
stage = 4;
break;
case 4:
stage = 5;
break;
case 5:
stage = 6;
break;
case 6:
stage = 7;
break;
case 7:
sendOptionsDialogue(SEND_DEFAULT_OPTIONS_TITLE,
stage = 8;
break;
case 8:
if (componentId == OPTION_1) {
stage = 9;
} else if (componentId == OPTION_2) {
stage = 20;
}
break;
case 9:
stage = 10;
break;
case 10:
player.unlock();
controler.setStage(4);
player.setNextWorldTile(new WorldTile(getWorldTile(40, 179, 0)));
stage = 11;
break;
case 11:
stage = -2;
break;
default:
end();
break;
}
}


@Override
public void finish() {


}
}
 

Share this post


Link to post
Share on other sites

14 answers to this question

Recommended Posts

  • 1

Controller was created twice, boundChuncks was only initialized in the first instance of the controller. This was due to the controller being started before the controller manager finished its startup checks.

Share this post


Link to post
Share on other sites
  • 0

public WorldTile getWorldTile(int mapX, int mapY, int plane) {
return new WorldTile(boundChuncks[0] * 8 + mapX, boundChuncks[1] * 8 + mapY, plane);
}

to my understanding, mapX and mapY and plane are not defined.

Share this post


Link to post
Share on other sites
  • 0

i looked in different controlers which build regions aswell, which also ports the player to different worldtiles like fightkilln etc.

they contain the same information as my controler?

so i dont really know what is not defined. 

 

I may need an example here :/

Share this post


Link to post
Share on other sites
  • 0

Where do you set private int[] boundChuncks? You are trying to access an array that is not yet initialized. I assume you can get the array from the controller? If so you can just fill that in in the dialogue start considering you receive the controller there.

Share this post


Link to post
Share on other sites
  • 0

^ that is exactly your problem. 

in dialogue.java

private int[] boundChuncks;
 

this is empty, yet it's called here:

return new WorldTile(boundChuncks[0] * 8 + mapX, boundChuncks[1] * 8 + mapY, plane);

 

Share this post


Link to post
Share on other sites
  • 0

.

Edited by drakthuro

Share this post


Link to post
Share on other sites
  • 0

even if i do not port the player with the dialogue and only update the stage.

and port the player with the controler itself on the updated stage then the same error appears. and it is initialized in the controler?

if not then i dont get it.

Share this post


Link to post
Share on other sites
  • 0

even if i do not port the player with the dialogue and only update the stage.

and port the player with the controler itself on the updated stage then the same error appears. and it is initialized in the controler?

if not then i dont get it.

Can you post this dialogue that loads a bound region? I may know what you are missing and I will say it now... Imports or something of equal value is missing.

Share this post


Link to post
Share on other sites
  • 0

Can you post this dialogue that loads a bound region? I may know what you are missing and I will say it now... Imports or something of equal value is missing.

hey oneg, everything i used in the controler is only 1 dialogue and the controler itself.

it's in my first post as hidden content :P. beneath the error message

Share this post


Link to post
Share on other sites
  • 0

i have to bump :/

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×