Don't send when rebuilding
This commit is contained in:
@@ -15,6 +15,11 @@ public interface IGroupedStorage {
|
|||||||
*/
|
*/
|
||||||
void rebuild();
|
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.
|
* 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 {
|
public class GroupedStorage implements IGroupedStorage {
|
||||||
private INetworkMaster network;
|
private INetworkMaster network;
|
||||||
private Multimap<Item, ItemStack> stacks = ArrayListMultimap.create();
|
private Multimap<Item, ItemStack> stacks = ArrayListMultimap.create();
|
||||||
|
private boolean rebuilding;
|
||||||
|
|
||||||
public GroupedStorage(INetworkMaster network) {
|
public GroupedStorage(INetworkMaster network) {
|
||||||
this.network = network;
|
this.network = network;
|
||||||
@@ -22,6 +23,8 @@ public class GroupedStorage implements IGroupedStorage {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void rebuild() {
|
public void rebuild() {
|
||||||
|
this.rebuilding = true;
|
||||||
|
|
||||||
stacks.clear();
|
stacks.clear();
|
||||||
|
|
||||||
for (IStorage storage : network.getStorages()) {
|
for (IStorage storage : network.getStorages()) {
|
||||||
@@ -38,9 +41,16 @@ public class GroupedStorage implements IGroupedStorage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.rebuilding = false;
|
||||||
|
|
||||||
network.sendStorageToClient();
|
network.sendStorageToClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isRebuilding() {
|
||||||
|
return rebuilding;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(ItemStack stack) {
|
public void add(ItemStack stack) {
|
||||||
for (ItemStack otherStack : stacks.get(stack.getItem())) {
|
for (ItemStack otherStack : stacks.get(stack.getItem())) {
|
||||||
|
|||||||
@@ -410,16 +410,20 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendStorageToClient() {
|
public void sendStorageToClient() {
|
||||||
for (EntityPlayer player : worldObj.playerEntities) {
|
if (!storage.isRebuilding()) {
|
||||||
if (isWatchingGrid(player)) {
|
for (EntityPlayer player : worldObj.playerEntities) {
|
||||||
sendStorageToClient((EntityPlayerMP) player);
|
if (isWatchingGrid(player)) {
|
||||||
|
sendStorageToClient((EntityPlayerMP) player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendStorageToClient(EntityPlayerMP player) {
|
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) {
|
private boolean isWatchingGrid(EntityPlayer player) {
|
||||||
|
|||||||
Reference in New Issue
Block a user