private void createWeightCollection() { weightCollection = new RandomCollection<Integer>(worldObj.rand); weightCollection.add(WEIGHT_POP, ACTION_POP); weightCollection.add(WEIGHT_SPAWNMOB, ACTION_SPAWNMOB); weightCollection.add(WEIGHT_POTION, ACTION_POTION); weightCollection.add(WEIGHT_SPAWNITEM, ACTION_SPAWNITEM); weightCollection.add(WEIGHT_LIGHTNING, ACTION_LIGHTNING); }
private void act() { int action = weightCollection.next(); switch (action) { case ACTION_POP: pop(); break; case ACTION_SPAWNMOB: spawnMob(); break; case ACTION_POTION: potion(); break; case ACTION_SPAWNITEM: spawnItem(); break; case ACTION_LIGHTNING: spawnLightning(); break; } }