[Ruse] Male model on female characters?
I'm using ruse and the server isn't understanding when you're a female? When I wear an item as a female, it shows the male version of the model. And when I logout, the char file still says it's a male. However, when I manually change it to female, the items I wear converts perfectly. The game just doesn't register me as a female when switch genders via makeover mage.
This is my appearance.java
Code:
package com.ruse.model;
import com.ruse.world.entity.impl.player.Player;
/**
* This file manages a player's appearance and properties, such as head hints, gender, prayer head hints, etc.
*
* @author relex lawl
*/
public class Appearance {
/**
* Player's current gender.
*/
private static Gender gender = Gender.MALE;
/**
* Can the player change appearance right now?
*/
private static boolean canChangeAppearance = false;
/**
* The player's head icon hint.
*/
private int headHint = -1;
/**
* The player's bounty hunter skull.
*/
private int bountyHunterSkull = -1;
/**
* Gets the player's gender.
* @return gender.
*/
public static Gender getGender() {
return gender;
}
/**
* Sets the player's gender.
* @param gender Gender to set to.
*/
public Appearance setGender(Gender gender) {
this.gender = gender;
player.getUpdateFlag().flag(Flag.APPEARANCE);
return this;
}
/**
* Gets the player's current head hint index.
* @return The player's head hint.
*/
public int getHeadHint() {
return headHint;
}
/**
* Sets the player's head icon hint.
* @param headHint The hint index to use.
* @return The Appearance instance.
*/
public Appearance setHeadHint(int headHint) {
this.headHint = headHint;
player.getUpdateFlag().flag(Flag.APPEARANCE);
return this;
}
/**
* Gets the player's current bounty hunter skull.
* @return The player's skull hint.
*/
public int getBountyHunterSkull() {
return bountyHunterSkull;
}
/**
* Sets the player's bounty hunter skull.
* @param skullHint The skull hint index to use.
* @return The Appearance instance.
*/
public Appearance setBountyHunterSkull(int skullHint) {
this.bountyHunterSkull = skullHint;
player.getUpdateFlag().flag(Flag.APPEARANCE);
return this;
}
/**
* Checks if a player can change appearance right now
* @return the canChangeAppearance value
*/
public static boolean canChangeAppearance() {
return canChangeAppearance;
}
/**
* Sets if a player can change appearance right now
* @param l The value to set
*/
public void setCanChangeAppearance(boolean l) {
this.canChangeAppearance = l;
}
/**
* Gets the look array, which is an array with 13 elements describing the
* look of a player.
* @return The look array.
*/
public static int[] getLook() {
return look;
}
/**
* Sets the look array.
* @param look The look array.
* @throws IllegalArgumentException if the array length is not 12.
*/
public void set(int[] look) {
if(look.length < 12) {
throw new IllegalArgumentException("Array length must be 12.");
}
this.look = look;
player.getUpdateFlag().flag(Flag.APPEARANCE);
}
/**
* Sets a specific look.
* @param index Array index to set.
* @param look Value to change look[index] to.
*/
public void set(int index, int look) {
this.look[index] = look;
player.getUpdateFlag().flag(Flag.APPEARANCE);
}
/**
* The player's current character clothing.
*/
public static int[] look = new int[13];
/**
* The Appearance constructor, also sets
* the player's default clothing.
* @param player The associated player.
*/
public Appearance(Player player) {
this.player = player;
set();
}
/**
* Sets the player's default clothing.
*/
public void set() {
if (gender == Gender.MALE) {
look[HEAD] = 3;
look[CHEST] = 18;
look[ARMS] = 26;
look[HANDS] = 34;
look[LEGS] = 38;
look[FEET] = 42;
look[BEARD] = 14;
} else {
look[HEAD] = 48;
look[CHEST] = 57;
look[ARMS] = 65;
look[HANDS] = 68;
look[LEGS] = 77;
look[FEET] = 80;
look[BEARD] = 57;
}
look[HAIR_COLOUR] = 2;
look[TORSO_COLOUR] = 14;
look[LEG_COLOUR] = 5;
look[FEET_COLOUR] = 4;
look[SKIN_COLOUR] = 0;
player.getUpdateFlag().flag(Flag.APPEARANCE);
}
/**
* The associated player.
*/
private Player player;
/**
* The index of said body part color in the look array.
*/
public static final int HAIR_COLOUR = 8, TORSO_COLOUR = 9, LEG_COLOUR = 10, FEET_COLOUR = 11, SKIN_COLOUR = 12,
HEAD = 1, CHEST = 2, ARMS = 3, HANDS = 4, LEGS = 5, FEET = 6, BEARD = 7, GENDER = 0;
}
This is my changeapppearancepacketlistener.java
Code:
package com.ruse.net.packet.impl;
import com.ruse.model.Appearance;
import com.ruse.model.Flag;
import com.ruse.net.packet.Packet;
import com.ruse.net.packet.PacketListener;
import com.ruse.util.Misc;
import com.ruse.world.entity.impl.player.Player;
public class ChangeAppearancePacketListener implements PacketListener {
@Override
public void handleMessage(Player player, Packet packet) {
String appearanceAttributes = Misc.readString(packet.getBuffer());
if(appearanceAttributes == null || appearanceAttributes.length() <= 1)
return;
try {
String[] parts = appearanceAttributes.split(" ");
int gender = Integer.parseInt(parts[0]);
if(gender != 0 && gender != 1) {
return;
}
final int[] apperances = new int[MALE_VALUES.length];
final int[] colors = new int[ALLOWED_COLORS.length];
int currentPartIndex = 1;
for (int i = 0; i < apperances.length; i++, currentPartIndex++) {
int value = Integer.parseInt(parts[currentPartIndex]);
if (value < (gender == 0 ? MALE_VALUES[i][0] : FEMALE_VALUES[i][0]) || value > (gender == 0 ? MALE_VALUES[i][1] : FEMALE_VALUES[i][1]))
value = (gender == 0 ? MALE_VALUES[i][0] : FEMALE_VALUES[i][0]);
apperances[i] = value;
}
for (int i = 0; i < colors.length; i++, currentPartIndex++) {
int value = Integer.parseInt(parts[currentPartIndex]);
if (value < ALLOWED_COLORS[i][0] || value > ALLOWED_COLORS[i][1])
value = ALLOWED_COLORS[i][0];
colors[i] = value;
}
if(player.getAppearance().canChangeAppearance() && player.getInterfaceId() > 0) {
//Appearance looks
player.getAppearance().set(Appearance.GENDER, gender);
player.getAppearance().set(Appearance.HEAD, apperances[0]);
player.getAppearance().set(Appearance.CHEST, apperances[2]);
player.getAppearance().set(Appearance.ARMS, apperances[3]);
player.getAppearance().set(Appearance.HANDS, apperances[4]);
player.getAppearance().set(Appearance.LEGS, apperances[5]);
player.getAppearance().set(Appearance.FEET, apperances[6]);
player.getAppearance().set(Appearance.BEARD, apperances[1]);
//Colors
player.getAppearance().set(Appearance.HAIR_COLOUR, colors[0]);
player.getAppearance().set(Appearance.TORSO_COLOUR, colors[1]);
player.getAppearance().set(Appearance.LEG_COLOUR, colors[2]);
player.getAppearance().set(Appearance.FEET_COLOUR, colors[3]);
player.getAppearance().set(Appearance.SKIN_COLOUR, colors[4]);
player.getUpdateFlag().flag(Flag.APPEARANCE);
}
} catch(Exception e) {
player.getAppearance().set();
//e.printStackTrace();
}
player.getPacketSender().sendInterfaceRemoval();
player.getAppearance().setCanChangeAppearance(false);
}
private static final int[][] ALLOWED_COLORS = {
{ 0, 11 }, // hair color
{ 0, 15 }, // torso color
{ 0, 15 }, // legs color
{ 0, 5 }, // feet color
{ 0, 7 } // skin color
};
static final int[][] FEMALE_VALUES = {
{ 45, 54 }, // head
{ -1, -1 }, // jaw
{ 56, 60 }, // torso
{ 61, 65 }, // arms
{ 67, 68 }, // hands
{ 70, 77 }, // legs
{ 79, 80 }, // feet
};
static final int[][] MALE_VALUES = {
{ 0, 8 }, // head
{ 10, 17 }, // jaw
{ 18, 25 }, // torso
{ 26, 31 }, // arms
{ 33, 34 }, // hands
{ 36, 40 }, // legs
{ 42, 43 }, // feet
};
}