Add helper method

This commit is contained in:
Raoul Van den Berge
2016-07-02 22:35:45 +02:00
parent a5e8f4c811
commit 92647151ac
4 changed files with 15 additions and 11 deletions

View File

@@ -25,9 +25,15 @@ public final class RefinedStorage {
public static final String ID = "refinedstorage"; public static final String ID = "refinedstorage";
public static final String VERSION = "0.8.4"; public static final String VERSION = "0.8.4";
public static final SimpleNetworkWrapper NETWORK = NetworkRegistry.INSTANCE.newSimpleChannel(ID); @SidedProxy(clientSide = "refinedstorage.proxy.ClientProxy", serverSide = "refinedstorage.proxy.ServerProxy")
public static CommonProxy PROXY;
public static final CreativeTabs TAB = new CreativeTabs(ID) { @Instance
public static RefinedStorage INSTANCE;
public final SimpleNetworkWrapper network = NetworkRegistry.INSTANCE.newSimpleChannel(ID);
public final CreativeTabs tab = new CreativeTabs(ID) {
@Override @Override
public ItemStack getIconItemStack() { public ItemStack getIconItemStack() {
return new ItemStack(RefinedStorageItems.STORAGE_DISK, 1, ItemStorageDisk.TYPE_1K); return new ItemStack(RefinedStorageItems.STORAGE_DISK, 1, ItemStorageDisk.TYPE_1K);
@@ -39,12 +45,6 @@ public final class RefinedStorage {
} }
}; };
@SidedProxy(clientSide = "refinedstorage.proxy.ClientProxy", serverSide = "refinedstorage.proxy.ServerProxy")
public static CommonProxy PROXY;
@Instance
public static RefinedStorage INSTANCE;
public List<ItemStack> items = new ArrayList<ItemStack>(); public List<ItemStack> items = new ArrayList<ItemStack>();
public int cableRfUsage; public int cableRfUsage;

View File

@@ -309,4 +309,8 @@ public final class RefinedStorageUtils {
public static ICraftingPattern getPatternFromNetwork(INetworkMaster network, ItemStack stack) { public static ICraftingPattern getPatternFromNetwork(INetworkMaster network, ItemStack stack) {
return network.getPattern(stack, CompareFlags.COMPARE_DAMAGE | CompareFlags.COMPARE_NBT); return network.getPattern(stack, CompareFlags.COMPARE_DAMAGE | CompareFlags.COMPARE_NBT);
} }
public static boolean hasPattern(INetworkMaster network, ItemStack stack) {
return RefinedStorageUtils.getPatternFromNetwork(network, stack) != null;
}
} }

View File

@@ -78,7 +78,7 @@ public class GroupedStorage implements IGroupedStorage {
otherStack.stackSize -= stack.stackSize; otherStack.stackSize -= stack.stackSize;
if (otherStack.stackSize == 0) { if (otherStack.stackSize == 0) {
if (RefinedStorageUtils.getPatternFromNetwork(network, otherStack) == null) { if (!RefinedStorageUtils.hasPattern(network, stack)) {
stacks.remove(otherStack.getItem(), otherStack); stacks.remove(otherStack.getItem(), otherStack);
} }
} }

View File

@@ -392,14 +392,14 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
@Override @Override
public void sendStorageToClient(EntityPlayerMP player) { public void sendStorageToClient(EntityPlayerMP player) {
RefinedStorage.NETWORK.sendTo(new MessageGridUpdate(this), player); RefinedStorage.INSTANCE.network.sendTo(new MessageGridUpdate(this), player);
} }
@Override @Override
public void sendStorageDeltaToClient(ItemStack stack, int delta) { public void sendStorageDeltaToClient(ItemStack stack, int delta) {
for (EntityPlayer player : worldObj.playerEntities) { for (EntityPlayer player : worldObj.playerEntities) {
if (isWatchingGrid(player)) { if (isWatchingGrid(player)) {
RefinedStorage.NETWORK.sendTo(new MessageGridDelta(stack, delta, RefinedStorageUtils.getPatternFromNetwork(this, stack) != null), (EntityPlayerMP) player); RefinedStorage.INSTANCE.network.sendTo(new MessageGridDelta(stack, delta, RefinedStorageUtils.hasPattern(this, stack)), (EntityPlayerMP) player);
} }
} }
} }