Search in sources :

Example 16 with ItemRoutingInformation

use of logisticspipes.routing.ItemRoutingInformation in project LogisticsPipes by RS485.

the class ThermalDynamicsHooks method travelingItemToNBT.

public static void travelingItemToNBT(TravelingItem travelingItem, NBTTagCompound paramNBTTagCompound) {
    if (((ILPTravelingItemInfo) travelingItem).getLPRoutingInfoAddition() != null) {
        NBTTagCompound save = new NBTTagCompound();
        ((ItemRoutingInformation) ((ILPTravelingItemInfo) travelingItem).getLPRoutingInfoAddition()).writeToNBT(save);
        paramNBTTagCompound.setTag("LPRoutingInformation", save);
    }
}
Also used : ItemRoutingInformation(logisticspipes.routing.ItemRoutingInformation) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 17 with ItemRoutingInformation

use of logisticspipes.routing.ItemRoutingInformation in project LogisticsPipes by RS485.

the class ThermalDynamicsHooks method travelingItemNBTContructor.

public static void travelingItemNBTContructor(TravelingItem travelingItem, NBTTagCompound paramNBTTagCompound) {
    if (!paramNBTTagCompound.hasKey("LPRoutingInformation")) {
        return;
    }
    ((ILPTravelingItemInfo) travelingItem).setLPRoutingInfoAddition(new ItemRoutingInformation());
    ((ItemRoutingInformation) ((ILPTravelingItemInfo) travelingItem).getLPRoutingInfoAddition()).readFromNBT(paramNBTTagCompound.getCompoundTag("LPRoutingInformation"));
}
Also used : ItemRoutingInformation(logisticspipes.routing.ItemRoutingInformation)

Example 18 with ItemRoutingInformation

use of logisticspipes.routing.ItemRoutingInformation in project LogisticsPipes by RS485.

the class LogisticsEventListener method onItemStackToolTip.

@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onItemStackToolTip(ItemTooltipEvent event) {
    if (event.getItemStack().hasTagCompound()) {
        for (String key : event.getItemStack().getTagCompound().getKeySet()) {
            if (key.startsWith("logisticspipes:routingdata")) {
                ItemRoutingInformation info = ItemRoutingInformation.restoreFromNBT(event.getItemStack().getTagCompound().getCompoundTag(key));
                List<String> list = event.getToolTip();
                list.set(0, ChatColor.RED + "!!! " + ChatColor.WHITE + list.get(0) + ChatColor.RED + " !!!" + ChatColor.WHITE);
                list.add(1, TextUtil.translate("itemstackinfo.lprouteditem"));
                list.add(2, TextUtil.translate("itemstackinfo.lproutediteminfo"));
                list.add(3, TextUtil.translate("itemstackinfo.lprouteditemtype") + ": " + info.getItem().toString());
            }
        }
    }
}
Also used : ItemRoutingInformation(logisticspipes.routing.ItemRoutingInformation) TextComponentString(net.minecraft.util.text.TextComponentString) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 19 with ItemRoutingInformation

use of logisticspipes.routing.ItemRoutingInformation in project LogisticsPipes by RS485.

the class LogisticsEventListener method onEntitySpawn.

@SubscribeEvent
public void onEntitySpawn(EntityJoinWorldEvent event) {
    if (event != null && event.getEntity() instanceof EntityItem && event.getEntity().world != null && !event.getEntity().world.isRemote) {
        // Get ItemStack
        ItemStack stack = ((EntityItem) event.getEntity()).getItem();
        if (!stack.isEmpty() && stack.getItem() instanceof IItemAdvancedExistance && !((IItemAdvancedExistance) stack.getItem()).canExistInWorld(stack)) {
            event.setCanceled(true);
        }
        if (stack.hasTagCompound()) {
            for (String key : Objects.requireNonNull(stack.getTagCompound(), "nbt for stack must be non-null").getKeySet()) {
                if (key.startsWith("logisticspipes:routingdata")) {
                    ItemRoutingInformation info = ItemRoutingInformation.restoreFromNBT(stack.getTagCompound().getCompoundTag(key));
                    info.setItemTimedout();
                    ((EntityItem) event.getEntity()).setItem(info.getItem().getItem().makeNormalStack(stack.getCount()));
                    break;
                }
            }
        }
    }
}
Also used : IItemAdvancedExistance(logisticspipes.interfaces.IItemAdvancedExistance) ItemRoutingInformation(logisticspipes.routing.ItemRoutingInformation) TextComponentString(net.minecraft.util.text.TextComponentString) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 20 with ItemRoutingInformation

use of logisticspipes.routing.ItemRoutingInformation in project LogisticsPipes by RS485.

the class CoreRoutedPipe method addStatusInformation.

@Override
public void addStatusInformation(List<StatusEntry> status) {
    StatusEntry entry = new StatusEntry();
    entry.name = "Send Queue";
    entry.subEntry = new ArrayList<>();
    for (Triplet<IRoutedItem, EnumFacing, ItemSendMode> part : _sendQueue) {
        StatusEntry subEntry = new StatusEntry();
        subEntry.name = part.toString();
        entry.subEntry.add(subEntry);
    }
    status.add(entry);
    entry = new StatusEntry();
    entry.name = "In Transit To Me";
    entry.subEntry = new ArrayList<>();
    for (ItemRoutingInformation part : _inTransitToMe) {
        StatusEntry subEntry = new StatusEntry();
        subEntry.name = part.toString();
        entry.subEntry.add(subEntry);
    }
    status.add(entry);
}
Also used : IRoutedItem(logisticspipes.logisticspipes.IRoutedItem) ItemRoutingInformation(logisticspipes.routing.ItemRoutingInformation) EnumFacing(net.minecraft.util.EnumFacing) StatusEntry(logisticspipes.pipes.basic.debug.StatusEntry)

Aggregations

ItemRoutingInformation (logisticspipes.routing.ItemRoutingInformation)22 ItemStack (net.minecraft.item.ItemStack)7 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 ArrayList (java.util.ArrayList)4 IRoutedItem (logisticspipes.logisticspipes.IRoutedItem)4 LPTravelingItemServer (logisticspipes.transport.LPTravelingItem.LPTravelingItemServer)4 Triplet (logisticspipes.utils.tuples.Triplet)4 EnumFacing (net.minecraft.util.EnumFacing)4 ItemIdentifierStack (logisticspipes.utils.item.ItemIdentifierStack)3 ITransactor (logisticspipes.utils.transactor.ITransactor)3 LinkedList (java.util.LinkedList)2 List (java.util.List)2 TreeSet (java.util.TreeSet)2 IInventoryUtil (logisticspipes.interfaces.IInventoryUtil)2 Pair (logisticspipes.utils.tuples.Pair)2 TextComponentString (net.minecraft.util.text.TextComponentString)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 IFlowItems (buildcraft.api.transport.pipe.IFlowItems)1 Collection (java.util.Collection)1