mirror of
https://github.com/GTNewHorizons/Opis.git
synced 2026-11-25 22:44:47 +00:00
All (most ?) of the strings are not sent over the network anymore.
Everything is cached and synchronized.
This commit is contained in:
1 parent
f42d86ba11
commit
2f5d92f22a
7 files changed
+33
-26
No files matched your search
@@ -25,7 +25,7 @@ import net.minecraftforge.common.DimensionManager;
|
||||
public class DataDimension implements ISerializable {
|
||||
|
||||
public int dim;
|
||||
public String name;
|
||||
public CachedString name;
|
||||
public int players;
|
||||
public int forced;
|
||||
public int loaded;
|
||||
@@ -39,7 +39,7 @@ public class DataDimension implements ISerializable {
|
||||
WorldServer world = DimensionManager.getWorld(dim);
|
||||
|
||||
this.dim = dim;
|
||||
this.name = world.provider.getDimensionName();
|
||||
this.name = new CachedString(world.provider.getDimensionName());
|
||||
this.players = world.playerEntities.size();
|
||||
this.forced = world.getPersistentChunks().size();
|
||||
this.loaded = world.getChunkProvider().getLoadedChunkCount();
|
||||
@@ -75,7 +75,7 @@ public class DataDimension implements ISerializable {
|
||||
stream.writeInt(itemstacks);
|
||||
//stream.writeDouble(update);
|
||||
this.update.writeToStream(stream);
|
||||
Packet.writeString(name, stream);
|
||||
this.name.writeToStream(stream);
|
||||
}
|
||||
|
||||
public static DataDimension readFromStream(DataInputStream stream) throws IOException {
|
||||
@@ -90,7 +90,7 @@ public class DataDimension implements ISerializable {
|
||||
retVal.itemstacks = stream.readInt();
|
||||
//retVal.update = stream.readDouble();
|
||||
retVal.update = DataTiming.readFromStream(stream);
|
||||
retVal.name = Packet.readString(stream, 255);
|
||||
retVal.name = CachedString.readFromStream(stream);
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
@@ -20,14 +20,14 @@ public class DataEntity implements ISerializable, Comparable {
|
||||
|
||||
public int eid;
|
||||
public long npoints;
|
||||
public String name;
|
||||
public CachedString name;
|
||||
public CoordinatesBlock pos;
|
||||
public DataTiming update;
|
||||
|
||||
public DataEntity fill(Entity entity){
|
||||
|
||||
this.eid = entity.entityId;
|
||||
this.name = EntityManager.INSTANCE.getEntityName(entity, false);
|
||||
this.name = new CachedString(EntityManager.INSTANCE.getEntityName(entity, false));
|
||||
this.pos = new CoordinatesBlock(entity);
|
||||
|
||||
WeakHashMap<Entity, DescriptiveStatistics> data = ((ProfilerEntityUpdate)(ProfilerSection.ENTITY_UPDATETIME.getProfiler())).data;
|
||||
@@ -40,7 +40,7 @@ public class DataEntity implements ISerializable, Comparable {
|
||||
@Override
|
||||
public void writeToStream(DataOutputStream stream) throws IOException {
|
||||
stream.writeInt(this.eid);
|
||||
Packet.writeString(this.name, stream);
|
||||
this.name.writeToStream(stream);
|
||||
this.pos.writeToStream(stream);
|
||||
this.update.writeToStream(stream);
|
||||
stream.writeLong(this.npoints);
|
||||
@@ -49,7 +49,7 @@ public class DataEntity implements ISerializable, Comparable {
|
||||
public static DataEntity readFromStream(DataInputStream stream) throws IOException {
|
||||
DataEntity retVal = new DataEntity();
|
||||
retVal.eid = stream.readInt();
|
||||
retVal.name = Packet.readString(stream, 255);
|
||||
retVal.name = CachedString.readFromStream(stream);
|
||||
retVal.pos = CoordinatesBlock.readFromStream(stream);
|
||||
retVal.update = DataTiming.readFromStream(stream);
|
||||
retVal.npoints= stream.readLong();
|
||||
|
||||
@@ -15,7 +15,7 @@ public class DataEntityRender extends DataEntity {
|
||||
public DataEntityRender fill(Entity entity){
|
||||
|
||||
this.eid = entity.entityId;
|
||||
this.name = EntityManager.INSTANCE.getEntityName(entity, false);
|
||||
this.name = new CachedString(EntityManager.INSTANCE.getEntityName(entity, false));
|
||||
this.pos = new CoordinatesBlock(entity);
|
||||
|
||||
WeakHashMap<Entity, DescriptiveStatistics> data = ((ProfilerRenderEntity)(ProfilerSection.RENDER_ENTITY.getProfiler())).data;
|
||||
|
||||
@@ -12,8 +12,8 @@ import net.minecraft.network.packet.Packet;
|
||||
import mcp.mobius.opis.data.holders.ISerializable;
|
||||
|
||||
public class DataEvent implements ISerializable, Comparable {
|
||||
public String event;
|
||||
public String handler;
|
||||
public CachedString event;
|
||||
public CachedString handler;
|
||||
public DataTiming update;
|
||||
|
||||
public DataEvent fill(Cell<Class, Class, DescriptiveStatistics> cell){
|
||||
@@ -23,8 +23,8 @@ public class DataEvent implements ISerializable, Comparable {
|
||||
handlerName = splitHandler[2] + "." + splitHandler[3];
|
||||
} catch (Exception e){}
|
||||
|
||||
this.handler = handlerName;
|
||||
this.event = cell.getRowKey().getName().replace("net.minecraftforge.event.", "");
|
||||
this.handler = new CachedString(handlerName);
|
||||
this.event = new CachedString(cell.getRowKey().getName().replace("net.minecraftforge.event.", ""));
|
||||
|
||||
this.update = new DataTiming(cell.getValue().getGeometricMean());
|
||||
return this;
|
||||
@@ -32,15 +32,15 @@ public class DataEvent implements ISerializable, Comparable {
|
||||
|
||||
@Override
|
||||
public void writeToStream(DataOutputStream stream) throws IOException {
|
||||
Packet.writeString(this.event, stream);
|
||||
Packet.writeString(this.handler, stream);
|
||||
this.event.writeToStream(stream);
|
||||
this.handler.writeToStream(stream);
|
||||
this.update.writeToStream(stream);
|
||||
}
|
||||
|
||||
public static DataEvent readFromStream(DataInputStream stream) throws IOException {
|
||||
DataEvent retVal = new DataEvent();
|
||||
retVal.event = Packet.readString(stream, 255);
|
||||
retVal.handler = Packet.readString(stream, 255);
|
||||
retVal.event = CachedString.readFromStream(stream);
|
||||
retVal.handler = CachedString.readFromStream(stream);
|
||||
retVal.update = DataTiming.readFromStream(stream);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -12,28 +12,28 @@ import mcp.mobius.opis.data.profilers.ProfilerHandlerServer;
|
||||
import cpw.mods.fml.common.IScheduledTickHandler;
|
||||
|
||||
public class DataHandler implements ISerializable, Comparable {
|
||||
public String name;
|
||||
public DataTiming update;
|
||||
public CachedString name;
|
||||
public DataTiming update;
|
||||
|
||||
public DataHandler fill(IScheduledTickHandler ticker){
|
||||
double timingPre = ((ProfilerHandlerServer)(ProfilerSection.HANDLER_TICKSTART.getProfiler())).data.get(ticker).getGeometricMean();
|
||||
double timingPost = ((ProfilerHandlerServer)(ProfilerSection.HANDLER_TICKSTOP.getProfiler())).data.get(ticker).getGeometricMean();
|
||||
|
||||
this.update = new DataTiming(timingPre + timingPost);
|
||||
this.name = TickHandlerManager.getHandlerName(ticker);
|
||||
this.name = new CachedString(TickHandlerManager.getHandlerName(ticker));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(DataOutputStream stream) throws IOException {
|
||||
Packet.writeString(this.name, stream);
|
||||
this.name.writeToStream(stream);
|
||||
this.update.writeToStream(stream);
|
||||
}
|
||||
|
||||
public static DataHandler readFromStream(DataInputStream stream) throws IOException {
|
||||
DataHandler retVal = new DataHandler();
|
||||
retVal.name = Packet.readString(stream, 255);
|
||||
retVal.name = CachedString.readFromStream(stream);
|
||||
retVal.update = DataTiming.readFromStream(stream);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -47,15 +47,22 @@ public enum StringCache implements IMessageHandler {
|
||||
}
|
||||
|
||||
public void syncCache(Player player){
|
||||
// NEED TO AUTO SPLIT THE PACKET !
|
||||
PacketDispatcher.sendPacketToPlayer(NetDataList.create(Message.STATUS_STRINGUPD_FULL, this.toSend).packet, player);
|
||||
|
||||
int i = 0;
|
||||
while (i < this.toSend.size()){
|
||||
PacketDispatcher.sendPacketToPlayer(NetDataList.create(Message.STATUS_STRINGUPD_FULL, this.toSend.subList(i, Math.min(i + 50, this.toSend.size()))).packet, player);
|
||||
|
||||
i += 50;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleMessage(Message msg, NetDataRaw rawdata) {
|
||||
switch(msg){
|
||||
case STATUS_STRINGUPD:{
|
||||
modOpis.log.info("Received String Cache update");
|
||||
//modOpis.log.info("Received String Cache update");
|
||||
DataStringUpdate data = (DataStringUpdate)rawdata.value;
|
||||
this.cache.put(data.index, data.str);
|
||||
break;
|
||||
|
||||
@@ -243,7 +243,7 @@ public class OverlayEntityPerChunk implements IMwDataProvider, IMessageHandler {
|
||||
//String[] namelst = data.getName().split("\\.");
|
||||
//String name = namelst[namelst.length - 1];
|
||||
|
||||
String name = data.name;
|
||||
String name = data.name.toString();
|
||||
|
||||
table.addRow(data, name, String.format("[ %d %d %d ]", data.pos.x, data.pos.y, data.pos.z));
|
||||
nrows++;
|
||||
|
||||
Reference in new issue
Block a user