Files
Opis/mcp/mobius/opis/data/holders/stats/StatsPlayer.java
T
ProfMobius 7c4568a2eb Using username instead of getDisplayName for registrations.
Fake buttons are now normal buttons so they are not automatically activated.
Moved the profiler registration out of a if statement (so they register client side too).
SSP players have an automatic PRIVILEGED elevation.
Fixed Center On Map for Entities not selecting the chunk.
2014-03-23 12:13:58 +01:00

48 lines
1.3 KiB
Java

package mcp.mobius.opis.data.holders.stats;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import mcp.mobius.opis.data.holders.basetypes.CoordinatesBlock;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.packet.Packet;
public class StatsPlayer extends StatAbstract {
int eid;
public StatsPlayer(EntityPlayer player){
this.eid = player.entityId;
this.name = player.username;
this.coord = new CoordinatesBlock(player.worldObj.provider.dimensionId, player.posX, player.posY, player.posZ);
this.chunk = this.coord.asCoordinatesChunk();
}
public StatsPlayer(String name, int eid, CoordinatesBlock coord){
this.eid = eid;
this.name = name;
this.coord = coord;
this.chunk = coord.asCoordinatesChunk();
}
public int getEID(){
return this.eid;
}
@Override
public void writeToStream(DataOutputStream stream) throws IOException {
stream.writeInt(this.eid);
this.coord.writeToStream(stream);
Packet.writeString(this.name, stream);
}
public static StatsPlayer readFromStream(DataInputStream stream) throws IOException {
int eid = stream.readInt();
CoordinatesBlock coords = CoordinatesBlock.readFromStream(stream);
String name = Packet.readString(stream, 255);
return new StatsPlayer(name, eid, coords);
}
}