mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Fixed server crash when a player joins
This commit is contained in:
parent
fd3edb01c4
commit
38ec547662
9 changed files with 35 additions and 26 deletions
|
@ -6,7 +6,6 @@ import java.util.Map;
|
|||
import com.google.common.base.Strings;
|
||||
import com.minelittlepony.pony.data.PonyRace;
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
@ -59,18 +58,13 @@ public enum Race {
|
|||
return canFly() && this != CHANGELING;
|
||||
}
|
||||
|
||||
public String getDisplayString() {
|
||||
return I18n.format(getTranslationString());
|
||||
}
|
||||
|
||||
public String getTranslationString() {
|
||||
public String getTranslationKey() {
|
||||
return String.format("unicopia.race.%s", name().toLowerCase());
|
||||
}
|
||||
|
||||
public boolean isSameAs(String s) {
|
||||
return name().equalsIgnoreCase(s)
|
||||
|| getTranslationString().equalsIgnoreCase(s)
|
||||
|| getDisplayString().equalsIgnoreCase(s);
|
||||
|| getTranslationKey().equalsIgnoreCase(s);
|
||||
}
|
||||
|
||||
public static Race fromName(String s, Race def) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.minelittlepony.unicopia;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.forgebullshit.FUF;
|
||||
|
@ -43,6 +45,12 @@ public class UClient {
|
|||
return null;
|
||||
}
|
||||
|
||||
@FUF(reason = "Forced client Separation")
|
||||
@Nullable
|
||||
public EntityPlayer getPlayerByUUID(UUID playerId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@FUF(reason = "Forced client Separation")
|
||||
public boolean isClientPlayer(@Nullable EntityPlayer player) {
|
||||
return false;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.minelittlepony.unicopia;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.jumpingcastle.api.Target;
|
||||
|
@ -69,11 +71,24 @@ public class UnicopiaClient extends UClient {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public EntityPlayer getPlayer() {
|
||||
return Minecraft.getMinecraft().player;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public EntityPlayer getPlayerByUUID(UUID playerId) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
if (mc.player.getUniqueID().equals(playerId)) {
|
||||
return mc.player;
|
||||
}
|
||||
|
||||
return mc.world.getPlayerEntityByUUID(playerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClientPlayer(@Nullable EntityPlayer player) {
|
||||
if (getPlayer() == player) {
|
||||
|
|
|
@ -91,7 +91,7 @@ class CommandSpecies extends CommandBase {
|
|||
String name = "commands.race.tell.";
|
||||
name += player == sender ? "self" : "other";
|
||||
|
||||
ITextComponent race = new TextComponentTranslation(spec.getTranslationString());
|
||||
ITextComponent race = new TextComponentTranslation(spec.getTranslationKey());
|
||||
ITextComponent message = new TextComponentTranslation(name);
|
||||
|
||||
race.getStyle().setColor(TextFormatting.GOLD);
|
||||
|
|
|
@ -4,6 +4,8 @@ import net.minecraft.client.resources.I18n;
|
|||
import net.minecraft.init.MobEffects;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public enum Toxicity {
|
||||
SAFE(0, 0),
|
||||
|
@ -46,6 +48,7 @@ public enum Toxicity {
|
|||
return String.format("toxicity.%s.name", name().toLowerCase());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getTooltip() {
|
||||
TextFormatting color = toxicWhenCooked() ? TextFormatting.RED : toxicWhenRaw() ? TextFormatting.DARK_PURPLE : TextFormatting.GRAY;
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.minelittlepony.jumpingcastle.api.IChannel;
|
|||
import com.minelittlepony.jumpingcastle.api.IMessage;
|
||||
import com.minelittlepony.jumpingcastle.api.IMessageHandler;
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.UClient;
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.player.PlayerSpeciesList;
|
||||
|
@ -53,7 +54,7 @@ public class MsgPlayerCapabilities implements IMessage, IMessageHandler<MsgPlaye
|
|||
|
||||
@Override
|
||||
public void onPayload(MsgPlayerCapabilities message, IChannel channel) {
|
||||
EntityPlayer self = IPlayer.getPlayerFromClient(senderId);
|
||||
EntityPlayer self = UClient.instance().getPlayerByUUID(senderId);
|
||||
|
||||
if (self == null) {
|
||||
Unicopia.log.warn("[Unicopia] [CLIENT] [MsgPlayerCapabilities] Player with id %s was not found!\n", senderId.toString());
|
||||
|
|
|
@ -8,7 +8,6 @@ import com.minelittlepony.unicopia.enchanting.IPageOwner;
|
|||
import com.minelittlepony.unicopia.network.ITransmittable;
|
||||
import com.minelittlepony.unicopia.spell.ICaster;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
@ -62,14 +61,4 @@ public interface IPlayer extends ICaster<EntityPlayer>, IRaceContainer<EntityPla
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
static EntityPlayer getPlayerFromClient(UUID playerId) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
if (mc.player.getUniqueID().equals(playerId)) {
|
||||
return mc.player;
|
||||
}
|
||||
|
||||
return mc.world.getPlayerEntityByUUID(playerId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,9 @@ class PlayerAttributes {
|
|||
loadStrength += InventoryOfHolding.decodeStackWeight(item);
|
||||
}
|
||||
|
||||
entity.capabilities.setPlayerWalkSpeed(0.1F - (float)(loadStrength / 100000));
|
||||
if (entity.world.isRemote) {
|
||||
entity.capabilities.setPlayerWalkSpeed(0.1F - (float)(loadStrength / 100000));
|
||||
}
|
||||
|
||||
applyAttribute(entity, SharedMonsterAttributes.ATTACK_DAMAGE, EARTH_PONY_STRENGTH, race.canUseEarth());
|
||||
applyAttribute(entity, SharedMonsterAttributes.KNOCKBACK_RESISTANCE, EARTH_PONY_STRENGTH, race.canUseEarth());
|
||||
|
|
|
@ -127,8 +127,6 @@ class PlayerCapabilities implements IPlayer {
|
|||
@Override
|
||||
public void sendCapabilities(boolean full) {
|
||||
if (!getOwner().getEntityWorld().isRemote) {
|
||||
System.out.println("[SERVER] Sending player capabilities.");
|
||||
|
||||
if (full) {
|
||||
Unicopia.channel.broadcast(new MsgPlayerCapabilities(this));
|
||||
} else {
|
||||
|
@ -211,12 +209,11 @@ class PlayerCapabilities implements IPlayer {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean stepOnCloud() {
|
||||
EntityPlayer player = getOwner();
|
||||
|
||||
if ((player.fallDistance > 1) || player.distanceWalkedOnStepModified > nextStepDistance) {
|
||||
if (player.fallDistance > 1 || player.distanceWalkedOnStepModified > nextStepDistance) {
|
||||
nextStepDistance = player.distanceWalkedOnStepModified + 2;
|
||||
player.fallDistance = 0;
|
||||
|
||||
|
|
Loading…
Reference in a new issue