mirror of
https://github.com/GTNewHorizons/Opis.git
synced 2026-11-19 03:49:24 +00:00
Added a kill all stacks command to the purge buttons.
Added confirmation windows for purge commands. Display itemstacks instead of total entities.
This commit is contained in:
1 parent
a882d27186
commit
8469bd29bf
6 files changed
+49
-6
No files matched your search
@@ -12,6 +12,7 @@ import mcp.mobius.mobiuscore.profiler.ProfilerSection;
|
||||
import mcp.mobius.opis.data.holders.ISerializable;
|
||||
import mcp.mobius.opis.data.profilers.ProfilerDimTick;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.monster.EntityMob;
|
||||
import net.minecraft.entity.passive.EntityAnimal;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
@@ -31,6 +32,7 @@ public class DataDimension implements ISerializable {
|
||||
public int entities;
|
||||
public int mobs;
|
||||
public int neutral;
|
||||
public int itemstacks;
|
||||
public DataTiming update;
|
||||
|
||||
public DataDimension fill(int dim){
|
||||
@@ -54,6 +56,8 @@ public class DataDimension implements ISerializable {
|
||||
this.mobs += 1;
|
||||
if (entity instanceof EntityAnimal)
|
||||
this.neutral += 1;
|
||||
if (entity instanceof EntityItem)
|
||||
this.itemstacks += 1;
|
||||
}
|
||||
|
||||
return this;
|
||||
@@ -68,6 +72,7 @@ public class DataDimension implements ISerializable {
|
||||
stream.writeInt(entities);
|
||||
stream.writeInt(mobs);
|
||||
stream.writeInt(neutral);
|
||||
stream.writeInt(itemstacks);
|
||||
//stream.writeDouble(update);
|
||||
this.update.writeToStream(stream);
|
||||
Packet.writeString(name, stream);
|
||||
@@ -82,6 +87,7 @@ public class DataDimension implements ISerializable {
|
||||
retVal.entities= stream.readInt();
|
||||
retVal.mobs = stream.readInt();
|
||||
retVal.neutral = stream.readInt();
|
||||
retVal.itemstacks = stream.readInt();
|
||||
//retVal.update = stream.readDouble();
|
||||
retVal.update = DataTiming.readFromStream(stream);
|
||||
retVal.name = Packet.readString(stream, 255);
|
||||
|
||||
@@ -325,4 +325,19 @@ public enum EntityManager {
|
||||
}
|
||||
return killedEnts;
|
||||
}
|
||||
|
||||
public int killAllStacks(int dim){
|
||||
WorldServer world = DimensionManager.getWorld(dim);
|
||||
if (world == null) return -1;
|
||||
|
||||
int killedEnts = 0;
|
||||
|
||||
for (Entity entity : (ArrayList<Entity>)world.loadedEntityList){
|
||||
if (entity instanceof EntityItem){
|
||||
entity.setDead();
|
||||
killedEnts += 1;
|
||||
}
|
||||
}
|
||||
return killedEnts;
|
||||
}
|
||||
}
|
||||
@@ -193,6 +193,15 @@ public class ServerMessageHandler {
|
||||
EntityManager.INSTANCE.killAllHostiles(((SerialInt)param1).value);
|
||||
}
|
||||
|
||||
else if(maintype == Message.COMMAND_KILL_STACKS_ALL){
|
||||
for (int dim : DimensionManager.getIDs())
|
||||
EntityManager.INSTANCE.killAllStacks(dim);
|
||||
}
|
||||
|
||||
else if(maintype == Message.COMMAND_KILL_STACKS_DIM){
|
||||
EntityManager.INSTANCE.killAllStacks(((SerialInt)param1).value);
|
||||
}
|
||||
|
||||
else if(maintype == Message.COMMAND_PURGE_CHUNKS_ALL){
|
||||
for (int dim : DimensionManager.getIDs())
|
||||
ChunkManager.INSTANCE.purgeChunks(dim);
|
||||
|
||||
@@ -59,6 +59,8 @@ public enum Message {
|
||||
COMMAND_KILL_HOSTILES_ALL(PRIVILEGED), // This will kill all hostile in all the dimensions
|
||||
COMMAND_PURGE_CHUNKS_DIM(PRIVILEGED), // This will purge the chunks in the dim given as argument
|
||||
COMMAND_PURGE_CHUNKS_ALL(PRIVILEGED), // This will purge the chunks in all dimensions
|
||||
COMMAND_KILL_STACKS_DIM(PRIVILEGED), // This will kill all stacks in the dim given as argument
|
||||
COMMAND_KILL_STACKS_ALL(PRIVILEGED), // This will kill all stacks in all the dimensions
|
||||
|
||||
OVERLAY_CHUNK_ENTITIES,
|
||||
OVERLAY_CHUNK_TIMING,
|
||||
|
||||
@@ -3,6 +3,8 @@ package mcp.mobius.opis.swing.actions;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
import mcp.mobius.opis.api.TabPanelRegistrar;
|
||||
import mcp.mobius.opis.data.holders.basetypes.SerialInt;
|
||||
@@ -19,17 +21,26 @@ public class ActionDimensions implements ActionListener {
|
||||
PanelDimensions panel = (PanelDimensions)TabPanelRegistrar.INSTANCE.getTab("opis.dimensions");
|
||||
|
||||
if (e.getSource() == panel.getBtnPurgeAll()){
|
||||
PacketDispatcher.sendPacketToServer(Packet_ReqData.create(Message.COMMAND_KILL_HOSTILES_ALL));
|
||||
PacketDispatcher.sendPacketToServer(Packet_ReqData.create(Message.COMMAND_PURGE_CHUNKS_ALL));
|
||||
if (JOptionPane.showConfirmDialog (null, "Do you want to kill all hostiles in game ?","Warning", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
|
||||
PacketDispatcher.sendPacketToServer(Packet_ReqData.create(Message.COMMAND_KILL_HOSTILES_ALL));
|
||||
if (JOptionPane.showConfirmDialog (null, "Do you want to remove all the dropped items ?","Warning", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
|
||||
PacketDispatcher.sendPacketToServer(Packet_ReqData.create(Message.COMMAND_KILL_STACKS_ALL));
|
||||
if (JOptionPane.showConfirmDialog (null, "Do you want to purge chunks ?","Warning", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
|
||||
PacketDispatcher.sendPacketToServer(Packet_ReqData.create(Message.COMMAND_PURGE_CHUNKS_ALL));
|
||||
|
||||
} else {
|
||||
JTableStats table = panel.getTable();
|
||||
if (table == null || table.getSelectedRow() == -1) return;
|
||||
int indexData = table.convertRowIndexToModel(table.getSelectedRow());
|
||||
DataDimension data = (DataDimension)table.getTableData().get(indexData);
|
||||
|
||||
if (JOptionPane.showConfirmDialog (null, "Do you want to kill all hostiles ?","Warning", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
|
||||
PacketDispatcher.sendPacketToServer(Packet_ReqData.create(Message.COMMAND_KILL_HOSTILES_DIM, new SerialInt(data.dim)));
|
||||
if (JOptionPane.showConfirmDialog (null, "Do you want to remove all the dropped items ?","Warning", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
|
||||
PacketDispatcher.sendPacketToServer(Packet_ReqData.create(Message.COMMAND_KILL_STACKS_DIM, new SerialInt(data.dim)));
|
||||
if (JOptionPane.showConfirmDialog (null, "Do you want to purge chunks ?","Warning", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
|
||||
PacketDispatcher.sendPacketToServer(Packet_ReqData.create(Message.COMMAND_PURGE_CHUNKS_DIM, new SerialInt(data.dim)));
|
||||
|
||||
PacketDispatcher.sendPacketToServer(Packet_ReqData.create(Message.COMMAND_KILL_HOSTILES_DIM, new SerialInt(data.dim)));
|
||||
PacketDispatcher.sendPacketToServer(Packet_ReqData.create(Message.COMMAND_PURGE_CHUNKS_DIM, new SerialInt(data.dim)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class PanelDimensions extends JPanelMsgHandler implements IMessageHandler
|
||||
// {null, null, null, null, null, null, null, null, null},
|
||||
},
|
||||
new String[] {
|
||||
"Dim", "Name", "Players", "Forced chunks", "Loaded chunks", "Monsters", "Animals", "Entities", "Update time", "Purge"
|
||||
"Dim", "Name", "Players", "Forced chunks", "Loaded chunks", "Monsters", "Animals", "Stacks", "Update time", "Purge"
|
||||
// "Dim", "Name", "Players", "Forced chunks", "Loaded chunks", "Monsters", "Animals", "Entities", "Purge"
|
||||
}
|
||||
) {
|
||||
@@ -104,7 +104,7 @@ public class PanelDimensions extends JPanelMsgHandler implements IMessageHandler
|
||||
data.loaded,
|
||||
data.mobs,
|
||||
data.neutral,
|
||||
data.entities,
|
||||
data.itemstacks,
|
||||
data.update,
|
||||
"Purge"
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user