Don't send when rebuilding
This commit is contained in:
@@ -15,6 +15,11 @@ public interface IGroupedStorage {
|
||||
*/
|
||||
void rebuild();
|
||||
|
||||
/**
|
||||
* @return If this storage is currently rebuilding
|
||||
*/
|
||||
boolean isRebuilding();
|
||||
|
||||
/**
|
||||
* Adds an item to the network. Will merge it with another item if it already exists.
|
||||
*
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.Collection;
|
||||
public class GroupedStorage implements IGroupedStorage {
|
||||
private INetworkMaster network;
|
||||
private Multimap<Item, ItemStack> stacks = ArrayListMultimap.create();
|
||||
private boolean rebuilding;
|
||||
|
||||
public GroupedStorage(INetworkMaster network) {
|
||||
this.network = network;
|
||||
@@ -22,6 +23,8 @@ public class GroupedStorage implements IGroupedStorage {
|
||||
|
||||
@Override
|
||||
public void rebuild() {
|
||||
this.rebuilding = true;
|
||||
|
||||
stacks.clear();
|
||||
|
||||
for (IStorage storage : network.getStorages()) {
|
||||
@@ -38,9 +41,16 @@ public class GroupedStorage implements IGroupedStorage {
|
||||
}
|
||||
}
|
||||
|
||||
this.rebuilding = false;
|
||||
|
||||
network.sendStorageToClient();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRebuilding() {
|
||||
return rebuilding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(ItemStack stack) {
|
||||
for (ItemStack otherStack : stacks.get(stack.getItem())) {
|
||||
|
||||
@@ -410,16 +410,20 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
|
||||
@Override
|
||||
public void sendStorageToClient() {
|
||||
for (EntityPlayer player : worldObj.playerEntities) {
|
||||
if (isWatchingGrid(player)) {
|
||||
sendStorageToClient((EntityPlayerMP) player);
|
||||
if (!storage.isRebuilding()) {
|
||||
for (EntityPlayer player : worldObj.playerEntities) {
|
||||
if (isWatchingGrid(player)) {
|
||||
sendStorageToClient((EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendStorageToClient(EntityPlayerMP player) {
|
||||
RefinedStorage.NETWORK.sendTo(new MessageGridItems(this), player);
|
||||
if (!storage.isRebuilding()) {
|
||||
RefinedStorage.NETWORK.sendTo(new MessageGridItems(this), player);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isWatchingGrid(EntityPlayer player) {
|
||||
|
||||
Reference in New Issue
Block a user