Human race is no longer a user settable race. You should only get it if some madman were to blacklist every race (which can be done by adding HUMAN alone to the whitelist).

This commit is contained in:
Sollace 2019-01-29 14:13:06 +02:00
parent 21e01ac93d
commit 841d326338
8 changed files with 34 additions and 20 deletions

View file

@ -11,6 +11,10 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public enum Race {
/**
* The default, unset race.
* This is used if there are no other races.
*/
HUMAN(false, false, false),
EARTH(false, false, true),
UNICORN(true, false, false),
@ -103,12 +107,16 @@ public enum Race {
case UNICORN:
return UNICORN;
default:
return HUMAN;
return EARTH;
}
}
public static Race fromName(String name) {
return fromName(name, EARTH);
}
public static Race fromId(int id) {
return raceIdMap.getOrDefault(id, HUMAN);
return raceIdMap.getOrDefault(id, EARTH);
}
}

View file

@ -65,7 +65,7 @@ public class UConfig {
"This is the race a client requests when first joining a game. " +
"It is the default used both when Mine Little Pony is not installed and when they respond with a human race.";
@Expose
private Race preferredRace = Race.HUMAN;
private Race preferredRace = Race.EARTH;
@Expose(deserialize = false)
private final String ignoreMineLPComment =
@ -98,7 +98,7 @@ public class UConfig {
public Race getPrefferedRace() {
if (preferredRace == null) {
setPreferredRace(Race.HUMAN);
setPreferredRace(Race.EARTH);
}
return preferredRace;

View file

@ -24,7 +24,6 @@ import net.minecraftforge.event.entity.item.ItemTossEvent;
import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent;
import net.minecraftforge.event.entity.player.PlayerDropsEvent;
import net.minecraftforge.event.entity.player.PlayerFlyableFallEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.entity.player.UseHoeEvent;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.fml.common.Mod;

View file

@ -38,7 +38,7 @@ class CommandRacelist extends CommandBase {
EntityPlayer player = getCommandSenderAsPlayer(sender);
Race race = Race.fromName(args[1], Race.HUMAN);
Race race = Race.fromName(args[1], Race.EARTH);
TextComponentTranslation formattedName = new TextComponentTranslation(race.name().toLowerCase());
formattedName.getStyle().setColor(TextFormatting.GOLD);

View file

@ -62,15 +62,18 @@ class CommandSpecies extends CommandBase {
}
if (args[0].contentEquals("set") && args.length >= 2) {
Race species = Race.fromName(args[1], null);
Race species = Race.fromName(args[1], Race.HUMAN);
if (species == null) {
player.sendMessage(new TextComponentTranslation("commands.race.fail", args[1].toUpperCase()));
if (species.isDefault()) {
ITextComponent message = new TextComponentTranslation("commands.race.fail", args[1].toUpperCase());
message.getStyle().setColor(TextFormatting.RED);
player.sendMessage(message);
} else {
if (PlayerSpeciesList.instance().speciesPermitted(species, player)) {
PlayerSpeciesList.instance().getPlayer(player).setPlayerSpecies(species);
TextComponentTranslation formattedName = new TextComponentTranslation(species.name().toLowerCase());
ITextComponent formattedName = new TextComponentTranslation(species.name().toLowerCase());
if (player != sender) {
notifyCommandListener(sender, this, 1, "commands.race.success.other", formattedName, player.getName());
@ -89,8 +92,7 @@ class CommandSpecies extends CommandBase {
name += player == sender ? "self" : "other";
ITextComponent race = new TextComponentTranslation(spec.getTranslationString());
TextComponentTranslation message = new TextComponentTranslation(name);
ITextComponent message = new TextComponentTranslation(name);
race.getStyle().setColor(TextFormatting.GOLD);
@ -104,7 +106,7 @@ class CommandSpecies extends CommandBase {
boolean first = true;
for (Race i : Race.values()) {
if (PlayerSpeciesList.instance().speciesPermitted(i, player)) {
if (!i.isDefault() && PlayerSpeciesList.instance().speciesPermitted(i, player)) {
message.appendSibling(new TextComponentString((!first ? "\n" : "") + " - " + i.name().toLowerCase()));
first = false;
}
@ -153,7 +155,7 @@ class CommandSpecies extends CommandBase {
EntityPlayer player = sender instanceof EntityPlayer ? (EntityPlayer)sender : null;
for (Race i : Race.values()) {
if (args[0].contentEquals("describe") || PlayerSpeciesList.instance().speciesPermitted(i, player)) {
if (args[0].contentEquals("describe") || !(i.isDefault() && PlayerSpeciesList.instance().speciesPermitted(i, player))) {
names.add(i.name().toLowerCase());
}
}

View file

@ -34,7 +34,7 @@ class ItemCapabilities implements IRaceContainer<EntityItem>, IOwned<EntityItem>
@Override
public void readFromNBT(NBTTagCompound compound) {
race = Race.fromName(compound.getString("owner_species"), Race.HUMAN);
race = Race.fromName(compound.getString("owner_species"));
}
@Override

View file

@ -65,7 +65,7 @@ class PlayerCapabilities implements IPlayer {
PlayerCapabilities(EntityPlayer player) {
setOwner(player);
player.getDataManager().register(PLAYER_RACE, Race.HUMAN.ordinal());
player.getDataManager().register(PLAYER_RACE, Race.EARTH.ordinal());
player.getDataManager().register(EXERTION, 0F);
player.getDataManager().register(ENERGY, 0F);
player.getDataManager().register(EFFECT, new NBTTagCompound());
@ -85,7 +85,11 @@ class PlayerCapabilities implements IPlayer {
EntityPlayer player = getOwner();
if (!PlayerSpeciesList.instance().speciesPermitted(race, player)) {
race = Race.HUMAN;
race = Race.EARTH;
if (!PlayerSpeciesList.instance().speciesPermitted(race, player)) {
race = Race.HUMAN;
}
}
player.getDataManager().set(PLAYER_RACE, race.ordinal());
@ -260,7 +264,7 @@ class PlayerCapabilities implements IPlayer {
@Override
public void readFromNBT(NBTTagCompound compound) {
setPlayerSpecies(Race.fromName(compound.getString("playerSpecies"), Race.HUMAN));
setPlayerSpecies(Race.fromName(compound.getString("playerSpecies")));
powers.readFromNBT(compound.getCompoundTag("powers"));
gravity.readFromNBT(compound.getCompoundTag("gravity"));

View file

@ -98,8 +98,9 @@ commands.race.tell.other=%s is a
commands.race.tell.other.alt=%s is an
commands.race.describe.title=%s
commands.race.describe.human.1=This is the default race for new players.
commands.race.describe.human.2=It has no special abilities.
commands.race.describe.human.1=This is a default race with no abilities.
commands.race.describe.human.2=If you have this, it means there are no other races available.
commands.race.describe.human.3=It has no special abilities.
commands.race.describe.earth.1=Earth Ponies can grow crops using mana and punch trees for apples (yeeeeeeehaaaaawwwwwwwwwww)
commands.race.describe.earth.2=Their offensive ability is to kick down whilst jumping for a deafening ground smash.