AmountHolder now contains a 3rd member (a data string, usually modname).

Added mod identification with a block param
Modified stuff to match MobiusCore.
This commit is contained in:
ProfMobius committed 2014-11-06 02:41:00 +01:00
1 parent a5e9667e4f
commit a2fcb77026
7 files changed
+43 -31

No files matched your search

+1 -1
View File
@@ -54,7 +54,7 @@ dependencies {
shade 'io.netty-opis:Netty-opis:4.0.23'
// shade 'io.netty:netty-all:4.0.23.Final'
// compile 'io.netty:netty-all:4.0.15.Final'
compile "mcp.mobius.mobiuscore:MobiusCore:1.3.0_dev3_1.7.10:dev"
compile "mcp.mobius.mobiuscore:MobiusCore:1.3.0_dev4_1.7.10:dev"
deployerJars "org.apache.maven.wagon:wagon-ssh:2.2"
}
@@ -14,25 +14,29 @@ import mcp.mobius.opis.network.PacketManager;
public class AmountHolder implements ISerializable {
public CachedString key = null;
public Integer value = 0;
public Integer value = 0;
public CachedString data = null;
public AmountHolder(String key, Integer value){
public AmountHolder(String key, Integer value, String data){
this.key = new CachedString(key);
this.value = value;
this.data = new CachedString(data);
}
public AmountHolder(CachedString key, Integer value){
public AmountHolder(CachedString key, Integer value, CachedString data){
this.key = key;
this.value = value;
this.data = data;
}
@Override
public void writeToStream(ByteArrayDataOutput stream){
this.key.writeToStream(stream);
stream.writeInt(this.value);
this.data.writeToStream(stream);
}
public static AmountHolder readFromStream(ByteArrayDataInput istream){
return new AmountHolder(CachedString.readFromStream(istream), istream.readInt());
return new AmountHolder(CachedString.readFromStream(istream), istream.readInt(), CachedString.readFromStream(istream));
}
}
@@ -135,7 +135,7 @@ public enum EntityManager {
Map<String, Integer> count = ((MonitoredEntityList)world.loadedEntityList).getCount();
for (String key : count.keySet())
if (count.get(key) > 0)
cumData.add(new AmountHolder(key, count.get(key)));
cumData.add(new AmountHolder(key, count.get(key), "Plop"));
}
return cumData;
}
@@ -8,6 +8,8 @@ import java.util.HashSet;
import java.util.Map;
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;
import com.google.common.collect.Table.Cell;
import mcp.mobius.mobiuscore.monitors.MonitoredEntityList;
import mcp.mobius.mobiuscore.monitors.MonitoredTileList;
@@ -22,6 +24,7 @@ import mcp.mobius.opis.data.holders.newtypes.DataTileEntity;
import mcp.mobius.opis.data.holders.newtypes.DataTiming;
import mcp.mobius.opis.data.holders.stats.StatsChunk;
import mcp.mobius.opis.data.profilers.ProfilerTileEntityUpdate;
import mcp.mobius.opis.helpers.ModIdentification;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
@@ -170,10 +173,26 @@ public enum TileEntityManager {
World world = DimensionManager.getWorld(dim);
if (world == null) continue;
Map<String, Integer> count = ((MonitoredTileList)world.loadedTileEntityList).getCount();
for (String key : count.keySet())
if (count.get(key) > 0)
cumData.add(new AmountHolder(key, count.get(key)));
Table<Block, Integer, Integer> count = ((MonitoredTileList)world.loadedTileEntityList).getCount();
Table<String, String, Integer> reducedCount = HashBasedTable.create();
for (Cell<Block, Integer, Integer> c : count.cellSet()){
if (c.getValue() > 0){
String stackName = ModIdentification.getStackName(c.getRowKey(), c.getColumnKey());
String modName = ModIdentification.getModStackName(c.getRowKey(), c.getColumnKey());
try{
reducedCount.put(stackName, modName, reducedCount.get(stackName, modName) + c.getValue());
} catch (Exception e){
reducedCount.put(stackName, modName, c.getValue());
}
}
}
for (Cell<String, String, Integer> c : reducedCount.cellSet()){
cumData.add(new AmountHolder(c.getRowKey(), c.getValue(), c.getColumnKey()));
}
}
return cumData;
}
@@ -140,15 +140,6 @@ public enum OpisServerTickHandler{
System.out.printf("[ %d ] %d %d\n", data.id, data.amount, data.size);
}
*/
for (int dim : DimensionManager.getIDs()){
World world = DimensionManager.getWorld(dim);
if (world == null) continue;
((MonitoredEntityList)(world.loadedEntityList)).printCount();
((MonitoredTileList)(world.loadedTileEntityList)).printCount();
}
modOpis.log.info("---");
}
profilerUpdateTickCounter++;
@@ -72,15 +72,7 @@ public class ModIdentification {
}
public static String getStackName(int id, int meta){
ItemStack is;
String name = String.format("te.%d.%d", id, meta);
try{
is = new ItemStack(Block.getBlockById(id), 1, meta);
name = is.getDisplayName();
} catch (Exception e) { }
return name;
return getStackName(Block.getBlockById(id), meta);
}
public static String getStackName(Block block, int meta){
@@ -96,14 +88,20 @@ public class ModIdentification {
}
public static String getModStackName(int id, int meta){
return getModStackName(Block.getBlockById(id), meta);
}
public static String getModStackName(Block block, int meta){
ItemStack is;
String modID = "<UNKNOWN>";
try{
is = new ItemStack(Block.getBlockById(id), 1, meta);
is = new ItemStack(block, 1, meta);
modID = nameFromStack(is);
} catch (Exception e) { }
return modID;
}
}
}
@@ -61,7 +61,7 @@ public class PanelAmountTileEnts extends JPanelMsgHandler implements ITabPanel{
for (Object o : rawdata.array){
AmountHolder entity = (AmountHolder)o;
model.addRow(new Object[] {entity.key, "Unknown", entity.value});
model.addRow(new Object[] {entity.key, entity.data, entity.value});
}
this.getTable().dataUpdated(row);