Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: CraftFromContainers AddOre and AddFuel #112

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions CraftFromContainers/BepInExPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ static bool Prefix(Fireplace __instance, Humanoid user, bool hold, ref bool __re
inventory.RemoveItem(__instance.m_fuelItem.m_itemData.m_shared.m_name, amount);
typeof(Inventory).GetMethod("Changed", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(inventory, new object[] { });
for (int i = 0; i < amount; i++)
___m_nview.InvokeRPC("AddFuel", new object[] { });
___m_nview.InvokeRPC("RPC_AddFuel", new object[] { });

user.Message(MessageHud.MessageType.Center, Localization.instance.Localize("$msg_fireadding", new string[]{__instance.m_fuelItem.m_itemData.m_shared.m_name}), 0, null);

Expand Down Expand Up @@ -308,7 +308,7 @@ static bool Prefix(Fireplace __instance, Humanoid user, bool hold, ref bool __re
user.Message(MessageHud.MessageType.Center, Localization.instance.Localize("$msg_fireadding", new string[]{__instance.m_fuelItem.m_itemData.m_shared.m_name}), 0, null);

for(int i = 0; i < amount; i++)
___m_nview.InvokeRPC("AddFuel", new object[] { });
___m_nview.InvokeRPC("RPC_AddFuel", new object[] { });

__result = false;

Expand Down Expand Up @@ -353,7 +353,7 @@ static bool Prefix(CookingStation __instance, ref bool __result, Humanoid user,
typeof(Container).GetMethod("Save", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(c, new object[] { });
//typeof(Inventory).GetMethod("Changed", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(c.GetInventory(), new object[] { });
user.Message(MessageHud.MessageType.Center, "$msg_added " + __instance.m_fuelItem.m_itemData.m_shared.m_name, 0, null);
___m_nview.InvokeRPC("AddFuel", Array.Empty<object>());
___m_nview.InvokeRPC("RPC_AddFuel", Array.Empty<object>());
__result = true;
return false;
}
Expand Down Expand Up @@ -481,7 +481,7 @@ static bool Prefix(Smelter __instance, Humanoid user, ItemDrop.ItemData item, ZN
//typeof(Inventory).GetMethod("Changed", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(inventory, new object[] { });

for (int i = 0; i < amount; i++)
___m_nview.InvokeRPC("AddOre", new object[] { newItem.m_dropPrefab.name });
___m_nview.InvokeRPC("RPC_AddOre", new object[] { newItem.m_dropPrefab.name });

user.Message(MessageHud.MessageType.TopLeft, $"$msg_added {amount} {name}", 0, null);
if (Traverse.Create(__instance).Method("GetQueueSize").GetValue<int>() >= __instance.m_maxOre)
Expand Down Expand Up @@ -513,7 +513,7 @@ static bool Prefix(Smelter __instance, Humanoid user, ItemDrop.ItemData item, ZN
//typeof(Inventory).GetMethod("Changed", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(c.GetInventory(), new object[] { });

for (int i = 0; i < amount; i++)
___m_nview.InvokeRPC("AddOre", new object[] { newItem.m_dropPrefab.name });
___m_nview.InvokeRPC("RPC_AddOre", new object[] { newItem.m_dropPrefab.name });

user.Message(MessageHud.MessageType.TopLeft, $"$msg_added {amount} {name}", 0, null);

Expand Down Expand Up @@ -568,7 +568,7 @@ static bool Prefix(Smelter __instance, ref bool __result, ZNetView ___m_nview, H
inventory.RemoveItem(__instance.m_fuelItem.m_itemData.m_shared.m_name, amount);
//typeof(Inventory).GetMethod("Changed", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(inventory, new object[] { });
for (int i = 0; i < amount; i++)
___m_nview.InvokeRPC("AddFuel", new object[] { });
___m_nview.InvokeRPC("RPC_AddFuel", new object[] { });

added += amount;

Expand Down