character selector
This commit is contained in:
parent
0af8ca57d1
commit
74f730e450
24 changed files with 554 additions and 154 deletions
|
@ -1,5 +1,6 @@
|
|||
package game.network;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
@ -20,10 +21,12 @@ import game.entity.effect.EntityLightning;
|
|||
import game.entity.item.EntityBoat;
|
||||
import game.entity.item.EntityXp;
|
||||
import game.entity.npc.EntityNPC;
|
||||
import game.entity.npc.PlayerCharacter;
|
||||
import game.entity.projectile.EntityProjectile;
|
||||
import game.entity.types.EntityLiving;
|
||||
import game.gui.Gui;
|
||||
import game.gui.GuiConsole;
|
||||
import game.gui.GuiSkin;
|
||||
import game.gui.container.GuiMachine;
|
||||
import game.gui.container.GuiMerchant;
|
||||
import game.init.EntityRegistry;
|
||||
|
@ -73,6 +76,7 @@ import game.packet.SPacketBlockAction;
|
|||
import game.packet.SPacketBlockBreakAnim;
|
||||
import game.packet.SPacketBlockChange;
|
||||
import game.packet.SPacketCamera;
|
||||
import game.packet.SPacketCharacterList;
|
||||
import game.packet.SPacketChunkData;
|
||||
import game.packet.SPacketCollectItem;
|
||||
import game.packet.SPacketDestroyEntities;
|
||||
|
@ -137,8 +141,9 @@ public class ClientPlayer extends NetHandler
|
|||
private boolean doneLoadingTerrain;
|
||||
// private boolean travelSound;
|
||||
private final Map<String, Integer> playerList = Maps.<String, Integer>newTreeMap();
|
||||
private final Map<Integer, PlayerCharacter> characterList = Maps.<Integer, PlayerCharacter>newHashMap();
|
||||
// private final List<Entry<String, Integer>> players = Lists.newArrayList();
|
||||
// private boolean field_147308_k = false;
|
||||
private int selectedCharacter = -1;
|
||||
|
||||
/**
|
||||
* Just an ordinary random number generator, used to randomize audio pitch of item/orb pickup and randomize both
|
||||
|
@ -168,13 +173,14 @@ public class ClientPlayer extends NetHandler
|
|||
public void handleJoinGame(SPacketJoinGame packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController);
|
||||
this.gameController.charEditor = packetIn.isInEditor();
|
||||
this.gameController.controller = new PlayerController(this.gameController, this);
|
||||
this.clientWorldController = new WorldClient(this.gameController.debugWorld, packetIn.getDimension());
|
||||
// this.gameController.gameSettings.difficulty = packetIn.getDifficulty();
|
||||
this.gameController.loadWorld(this.clientWorldController, packetIn.getEntityType());
|
||||
// this.gameController.thePlayer.dimension = this.clientWorldController.dimension.getDimensionId();
|
||||
this.gameController.displayGuiScreen(null);
|
||||
this.gameController.thePlayer.setId(packetIn.getEntityId());
|
||||
this.gameController.displayGuiScreen(this.gameController.charEditor ? GuiSkin.INSTANCE : null);
|
||||
// this.currentServerMaxPlayers = packetIn.getMaxPlayers();
|
||||
// this.gameController.controller.setCheat(packetIn.getCheat());
|
||||
// this.gameController.updateViewDistance();
|
||||
|
@ -435,6 +441,9 @@ public class ClientPlayer extends NetHandler
|
|||
if (entity != null && packetIn.func_149376_c() != null)
|
||||
{
|
||||
entity.getDataWatcher().updateWatchedObjectsFromList(packetIn.func_149376_c());
|
||||
|
||||
if(entity == this.gameController.thePlayer && this.gameController.open instanceof GuiSkin)
|
||||
((GuiSkin)this.gameController.open).checkReopen();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -993,6 +1002,7 @@ public class ClientPlayer extends NetHandler
|
|||
public void handleRespawn(SPacketRespawn packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
this.gameController.charEditor = packetIn.isInEditor();
|
||||
|
||||
Dimension dim = packetIn.getDimension();
|
||||
if (dim.getDimensionId() != this.clientWorldController.dimension.getDimensionId()) // this.gameController.thePlayer.dimension)
|
||||
|
@ -1006,10 +1016,13 @@ public class ClientPlayer extends NetHandler
|
|||
// this.clientWorldController.setWorldScoreboard(scoreboard);
|
||||
this.gameController.loadWorld(this.clientWorldController, packetIn.getEntityType());
|
||||
// this.gameController.thePlayer.dimension = dim.getDimensionId();
|
||||
this.gameController.displayGuiScreen(null);
|
||||
}
|
||||
// else if(this.gameController.charEditor) {
|
||||
// this.gameController.displayGuiScreen(GuiSkin.INSTANCE);
|
||||
// }
|
||||
|
||||
this.gameController.setDimensionAndSpawnPlayer(dim.getDimensionId(), packetIn.getEntityType());
|
||||
this.gameController.displayGuiScreen(this.gameController.charEditor ? GuiSkin.INSTANCE : null);
|
||||
// this.gameController.controller.setCheat(packetIn.getCheat());
|
||||
}
|
||||
|
||||
|
@ -1506,6 +1519,19 @@ public class ClientPlayer extends NetHandler
|
|||
// this.gameController.infolist(list, data);
|
||||
}
|
||||
|
||||
public void handleCharacterList(SPacketCharacterList packet)
|
||||
{
|
||||
NetHandler.checkThread(packet, this, this.gameController);
|
||||
|
||||
for(Entry<Integer, PlayerCharacter> data : packet.getEntries()) {
|
||||
if(data.getValue() == null)
|
||||
this.characterList.remove(data.getKey());
|
||||
else
|
||||
this.characterList.put(data.getKey(), data.getValue());
|
||||
}
|
||||
this.selectedCharacter = packet.getSelected();
|
||||
}
|
||||
|
||||
public void handleKeepAlive(SPacketKeepAlive packetIn)
|
||||
{
|
||||
this.addToSendQueue(new CPacketKeepAlive(packetIn.getValue()));
|
||||
|
@ -1858,6 +1884,16 @@ public class ClientPlayer extends NetHandler
|
|||
return this.playerList.entrySet();
|
||||
}
|
||||
|
||||
public Collection<PlayerCharacter> getCharacterList()
|
||||
{
|
||||
return this.characterList.values();
|
||||
}
|
||||
|
||||
public int getSelectedCharacter()
|
||||
{
|
||||
return this.selectedCharacter;
|
||||
}
|
||||
|
||||
public Iterable<String> getPlayerNames()
|
||||
{
|
||||
return this.playerList.keySet();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue