mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Switching a player's race to unset using the /race command will now force them to choose a new one
This commit is contained in:
parent
56737c1c28
commit
165f415f28
2 changed files with 10 additions and 2 deletions
|
@ -3,6 +3,8 @@ package com.minelittlepony.unicopia.command;
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.Race;
|
||||||
import com.minelittlepony.unicopia.Unicopia;
|
import com.minelittlepony.unicopia.Unicopia;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
|
import com.minelittlepony.unicopia.network.Channel;
|
||||||
|
import com.minelittlepony.unicopia.network.MsgTribeSelect;
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
|
|
||||||
|
@ -11,6 +13,7 @@ import net.minecraft.command.argument.RegistryKeyArgumentType;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.server.command.CommandManager;
|
import net.minecraft.server.command.CommandManager;
|
||||||
import net.minecraft.server.command.CommandManager.RegistrationEnvironment;
|
import net.minecraft.server.command.CommandManager.RegistrationEnvironment;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.text.MutableText;
|
import net.minecraft.text.MutableText;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
@ -64,6 +67,10 @@ class SpeciesCommand {
|
||||||
pony.setSpecies(race);
|
pony.setSpecies(race);
|
||||||
pony.setDirty();
|
pony.setDirty();
|
||||||
|
|
||||||
|
if (race.isUnset()) {
|
||||||
|
Channel.SERVER_SELECT_TRIBE.sendToPlayer(new MsgTribeSelect(Race.allPermitted(player), "gui.unicopia.tribe_selection.respawn"), (ServerPlayerEntity)player);
|
||||||
|
}
|
||||||
|
|
||||||
if (player == source.getPlayer()) {
|
if (player == source.getPlayer()) {
|
||||||
source.sendFeedback(Text.translatable("commands.race.success.self", race.getDisplayName()), true);
|
source.sendFeedback(Text.translatable("commands.race.success.self", race.getDisplayName()), true);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -698,10 +698,11 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
||||||
@Override
|
@Override
|
||||||
public void copyFrom(Pony oldPlayer, boolean alive) {
|
public void copyFrom(Pony oldPlayer, boolean alive) {
|
||||||
|
|
||||||
boolean forcedSwap = !alive
|
boolean forcedSwap = (!alive
|
||||||
&& entity instanceof ServerPlayerEntity
|
&& entity instanceof ServerPlayerEntity
|
||||||
&& entity.world.getGameRules().getBoolean(UGameRules.SWAP_TRIBE_ON_DEATH)
|
&& entity.world.getGameRules().getBoolean(UGameRules.SWAP_TRIBE_ON_DEATH)
|
||||||
&& oldPlayer.respawnRace == Race.UNSET;
|
&& oldPlayer.respawnRace.isUnset())
|
||||||
|
|| oldPlayer.getActualSpecies().isUnset();
|
||||||
|
|
||||||
if (alive) {
|
if (alive) {
|
||||||
oldPlayer.getSpellSlot().stream(true).forEach(getSpellSlot()::put);
|
oldPlayer.getSpellSlot().stream(true).forEach(getSpellSlot()::put);
|
||||||
|
|
Loading…
Reference in a new issue