Search in sources :

Example 1 with IClientInformationProvider

use of logisticspipes.interfaces.IClientInformationProvider in project LogisticsPipes by RS485.

the class ItemModuleInformationManager method saveInfotmation.

public static void saveInfotmation(ItemStack itemStack, LogisticsModule module) {
    if (module == null) {
        return;
    }
    NBTTagCompound nbt = new NBTTagCompound();
    module.writeToNBT(nbt);
    if (nbt.equals(new NBTTagCompound())) {
        return;
    }
    if (MainProxy.isClient()) {
        NBTTagList list = new NBTTagList();
        String info1 = "Please reopen the window";
        String info2 = "to see the information.";
        list.appendTag(new NBTTagString(info1));
        list.appendTag(new NBTTagString(info2));
        if (!itemStack.hasTagCompound()) {
            itemStack.setTagCompound(new NBTTagCompound());
        }
        NBTTagCompound stacktag = itemStack.getTagCompound();
        stacktag.setTag("informationList", list);
        stacktag.setDouble("Random-Stack-Prevent", new Random().nextDouble());
        return;
    }
    if (!itemStack.hasTagCompound()) {
        itemStack.setTagCompound(new NBTTagCompound());
    }
    NBTTagCompound stacktag = itemStack.getTagCompound();
    stacktag.setTag("moduleInformation", nbt);
    if (module instanceof IClientInformationProvider) {
        List<String> information = ((IClientInformationProvider) module).getClientInformation();
        if (information.size() > 0) {
            NBTTagList list = new NBTTagList();
            for (String info : information) {
                list.appendTag(new NBTTagString(info));
            }
            stacktag.setTag("informationList", list);
        }
    }
    stacktag.setDouble("Random-Stack-Prevent", new Random().nextDouble());
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) Random(java.util.Random) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagString(net.minecraft.nbt.NBTTagString) NBTTagString(net.minecraft.nbt.NBTTagString) IClientInformationProvider(logisticspipes.interfaces.IClientInformationProvider)

Example 2 with IClientInformationProvider

use of logisticspipes.interfaces.IClientInformationProvider in project LogisticsPipes by RS485.

the class ItemModuleInformationManager method saveInformation.

public static void saveInformation(@Nonnull ItemStack stack, LogisticsModule module) {
    if (module == null) {
        return;
    }
    NBTTagCompound nbt = new NBTTagCompound();
    module.writeToNBT(nbt);
    if (nbt.equals(new NBTTagCompound())) {
        return;
    }
    if (MainProxy.isClient()) {
        NBTTagList list = new NBTTagList();
        String info1 = "Please reopen the window";
        String info2 = "to see the information.";
        list.appendTag(new NBTTagString(info1));
        list.appendTag(new NBTTagString(info2));
        if (!stack.hasTagCompound()) {
            stack.setTagCompound(new NBTTagCompound());
        }
        NBTTagCompound tag = Objects.requireNonNull(stack.getTagCompound());
        tag.setTag("informationList", list);
        tag.setDouble("Random-Stack-Prevent", new Random().nextDouble());
        return;
    }
    if (!stack.hasTagCompound()) {
        stack.setTagCompound(new NBTTagCompound());
    }
    NBTTagCompound tag = Objects.requireNonNull(stack.getTagCompound());
    tag.setTag("moduleInformation", nbt);
    if (module instanceof IClientInformationProvider) {
        List<String> information = ((IClientInformationProvider) module).getClientInformation();
        if (information.size() > 0) {
            NBTTagList list = new NBTTagList();
            for (String info : information) {
                list.appendTag(new NBTTagString(info));
            }
            tag.setTag("informationList", list);
        }
    }
    tag.setDouble("Random-Stack-Prevent", new Random().nextDouble());
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) Random(java.util.Random) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagString(net.minecraft.nbt.NBTTagString) NBTTagString(net.minecraft.nbt.NBTTagString) IClientInformationProvider(logisticspipes.interfaces.IClientInformationProvider)

Aggregations

Random (java.util.Random)2 IClientInformationProvider (logisticspipes.interfaces.IClientInformationProvider)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 NBTTagList (net.minecraft.nbt.NBTTagList)2 NBTTagString (net.minecraft.nbt.NBTTagString)2