using HarmonyLib; namespace Oxide.Plugins { [Info("IndustrialCustomSkinsFix", "Tangerine", "1.1.2")] [Description("Industrial Conveyor Custom Items & Skins Fix.")] class IndustrialCustomSkinsFix : RustPlugin { #region Variables private Harmony _harmony; #endregion #region OxideHooks void Init() { _harmony = new Harmony(Name + "Patch"); _harmony.PatchAll(); } void Unload() { _harmony.UnpatchAll(_harmony.Id); } #endregion #region Industrial Patch [HarmonyPatch(typeof(ItemContainer), nameof(ItemContainer.QuickIndustrialPreCheck))] public static class ItemContainer_QuickIndustrialPreCheck { [HarmonyPrefix] static bool Prefix(ItemContainer __instance, Item toTransfer, Vector2i range, out int foundSlot, ref bool __result) { int containerSize = range.y - range.x + 1; int count = __instance.itemList.Count; int itemsInRange = 0; foundSlot = -1; bool liquid = toTransfer.contents?.allowedContents == ItemContainer.ContentsType.Liquid; if (toTransfer.contents?.itemList.Count > 0 && liquid == false) { ItemContainer tc = toTransfer.contents; ItemContainer deport = toTransfer.parent; if (tc?.itemList.Count > 0) for (int i = tc.itemList.Count - 1; i >= 0; i--) { Item childItem = tc.itemList[i]; deport.GiveItem(childItem); } } for (int i = 0; i < count; ++i) { Item item = __instance.itemList[i]; int position = item.position; if (position < range.x || range.y < position) continue; ++itemsInRange; if (item.amount >= item.info.stackable || liquid && toTransfer.contents?.itemList.Count > 0) continue; if (item.info.itemid != toTransfer.info.itemid || toTransfer.IsBlueprint() && item.blueprintTarget != toTransfer.blueprintTarget) continue; if (item.skin != toTransfer.skin || item.name != toTransfer.name || item.text != toTransfer.text || (item.hasCondition && ((int)item?._condition != (int)toTransfer.maxCondition || (int)toTransfer?._condition != (int)item.maxCondition)) || item.contents?.itemList.Count > 0 || item.instanceData?.dataInt != toTransfer.instanceData?.dataInt || (item.contents?.capacity ?? 0) != (toTransfer.contents?.capacity ?? 0)) continue; foundSlot = position; __result = true; return false; } __result = itemsInRange < containerSize; return false; } } #endregion } }