Lightweight client count update message. Seems to fix WAILA update issues.

This commit is contained in:
Justin Aquadro committed 2014-11-07 00:16:55 -05:00
1 parent 83935f004b
commit e68db00642
3 files changed
+24 -1

No files matched your search

@@ -5,6 +5,7 @@ import com.jaquadro.minecraft.storagedrawers.config.ConfigManager;
import com.jaquadro.minecraft.storagedrawers.config.OreDictRegistry;
import com.jaquadro.minecraft.storagedrawers.core.*;
import com.jaquadro.minecraft.storagedrawers.network.BlockClickMessage;
import com.jaquadro.minecraft.storagedrawers.network.CountUpdateMessage;
import cpw.mods.fml.client.event.ConfigChangedEvent;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
@@ -51,6 +52,7 @@ public class StorageDrawers
network = NetworkRegistry.INSTANCE.newSimpleChannel(MOD_ID);
network.registerMessage(BlockClickMessage.Handler.class, BlockClickMessage.class, 0, Side.SERVER);
network.registerMessage(CountUpdateMessage.Handler.class, CountUpdateMessage.class, 1, Side.CLIENT);
compRegistry = new CompTierRegistry();
oreDictRegistry = new OreDictRegistry();
@@ -229,6 +229,8 @@ public class TileEntityCompDrawers extends TileEntityDrawersBase implements ISto
pooledCount = count;
}
@Override
public void markDirty () {
for (int i = 0; i < 3; i++) {
@@ -3,6 +3,9 @@ package com.jaquadro.minecraft.storagedrawers.block.tile;
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
import com.jaquadro.minecraft.storagedrawers.config.ConfigManager;
import com.jaquadro.minecraft.storagedrawers.inventory.InventoryStack;
import com.jaquadro.minecraft.storagedrawers.network.CountUpdateMessage;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.Item;
@@ -124,6 +127,9 @@ public class TileEntityDrawers extends TileEntityDrawersBase implements IStorage
inventoryStacks[slot] = null;
}
if (!worldObj.isRemote)
syncClientCount(slot);
return stack;
}
@@ -169,6 +175,9 @@ public class TileEntityDrawers extends TileEntityDrawersBase implements IStorage
data[slot].count += countAdded;
stack.stackSize -= countAdded;
if (!worldObj.isRemote)
syncClientCount(slot);
return countAdded;
}
@@ -233,7 +242,17 @@ public class TileEntityDrawers extends TileEntityDrawersBase implements IStorage
@Override
public void clientUpdateCount (int slot, int count) {
data[slot].count = count;
if (data[slot].count != count) {
data[slot].count = count;
getWorldObj().func_147479_m(xCoord, yCoord, zCoord); // markBlockForRenderUpdate
}
}
protected void syncClientCount (int slot) {
IMessage message = new CountUpdateMessage(xCoord, yCoord, zCoord, slot, data[slot].count);
NetworkRegistry.TargetPoint targetPoint = new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 500);
StorageDrawers.network.sendToAllAround(message, targetPoint);
}
@Override