Emberveil source

tests/LumbridgeBankChestCheck.java

import com.rs2.world.clip.*;
import com.rs2.world.ObjectManager;
import com.rs2.game.items.ItemDefinitions;
import org.apollo.cache.IndexedFileSystem;
import org.apollo.cache.decoder.*;
import java.nio.file.Paths;
public final class LumbridgeBankChestCheck {
 static int checks;static void check(boolean ok,String label){checks++;if(!ok)throw new AssertionError(label);}
 public static void main(String[] args)throws Exception {
  IndexedFileSystem cache=new IndexedFileSystem(Paths.get("data/cache"),true);
  new ObjectDefinitionDecoder(cache).run();new ItemDefinitionDecoder(cache).run();ItemDefinitions.load();RegionFactory.load(cache);
  int clip=Region.getClipping(3231,3227,0);System.out.println("Original chest tile clip="+Integer.toHexString(clip));
  check((clip&0x1280100)==0,"chest site is originally walkable");
  check(QuestRouteCheck.route(3233,3229,3231,3227,0,1),"new player spawn reaches chest");
  check(QuestRouteCheck.route(3222,3218,3231,3227,0,1),"respawn reaches chest");
  MemberQuestsCheck.Fixture p=new MemberQuestsCheck.Fixture();p.pos(3233,3229,1);ObjectManager manager=new ObjectManager();manager.loadCustomSpawns(p);
  check(!Region.objectExists(4483,3231,3227,0),"upstairs visitor does not spawn chest");
  p.pos(3233,3229,0);manager.loadCustomSpawns(p);
  check(Region.objectExists(4483,3231,3227,0),"real region registers ground-floor chest");
  check((Region.getClipping(3231,3227,0)&0x1280100)!=0,"chest is clipped and cannot be walked through");
  check(QuestRouteCheck.route(3233,3229,3231,3227,0,1),"chest remains reachable after placement");
  check(QuestRouteCheck.route(3233,3229,3222,3218,0,0),"main walking route remains open");
  manager.loadCustomSpawns(p);check(Region.objectExists(4483,3231,3227,0),"repeat region loading keeps chest");
  p.pos(3232,3227,0);p.objectId=4483;p.objectX=3231;p.objectY=3227;p.getObjects().firstClickObject(4483,3231,3227);
  check(p.isBanking,"left-click chest opens normal bank");
  p.item(0,385);check(p.getItemAssistant().bankItem(385,0,1),"ordinary player deposits through chest");
  check(p.bankItems[0]==386&&p.bankItemsN[0]==1,"deposit stored in regular bank");
  p.getItemAssistant().fromBank(385,0,1);check(p.getItemAssistant().playerHasItem(385,1)&&p.bankItemsN[0]==0,"ordinary player withdraws through chest");
  p.isBanking=false;p.getObjects().secondClickObject(4483,3231,3227);check(p.isBanking,"second-click bank action opens normal bank");
  p.isBanking=false;p.pos(3232,3227,1);p.getPacketSender().openUpBank();check(!p.isBanking,"new bank area does not extend upstairs");
  p.pos(3234,3227,0);p.getPacketSender().openUpBank();check(!p.isBanking,"bank cannot open away from the chest");
  p.pos(3232,3227,0);p.hasBankpin=true;p.enterdBankpin=false;p.getPacketSender().openUpBank();check(!p.isBanking,"bank PIN remains required");
  System.out.println("PASS "+checks+" Lumbridge chest placement, routes, collision, reload and bank-handler checks");
 }
}