Compare commits

..

4 Commits
v1.6 ... main

Author SHA1 Message Date
a3473a002d
ci: fix ci 2023-08-17 18:16:45 +01:00
48b51324fb
v1.7 for 1.4.4 2023-08-17 17:53:02 +01:00
0c6328b39d
dev: more 1.4.4 fixes, fix CRLF -> LF 2023-08-17 17:44:55 +01:00
278a0d9278
dev: tmodporter changes 2023-08-17 16:37:16 +01:00
8 changed files with 73 additions and 63 deletions

View File

@ -23,10 +23,10 @@ pipeline:
wget https://github.com/steviegt6/tml-patcher/releases/latest/download/TML.Patcher.zip
unzip -q TML.Patcher.zip -d TMLPatcher
- |
rm -f /root/.steam/steamapps/workshop/content/1281930/2563309347/workshop.json
YEAR=$(ls /root/.steam/steamapps/workshop/content/1281930/2563309347 | cut -c -4 | sort -nr | head -n 1)
VER=$(find /root/.steam/steamapps/workshop/content/1281930/2563309347/ -type d -name "$YEAR.*" -printf "%f\n" | cut -c 6- | sort -nr | head -n 1)
cp /root/.steam/steamapps/workshop/content/1281930/2563309347/$YEAR.$VER/MagicStorage.tmod ./
rm -f /root/.steam/SteamApps/workshop/content/1281930/2563309347/workshop.json
YEAR=$(ls /root/.steam/SteamApps/workshop/content/1281930/2563309347 | cut -c -4 | sort -nr | head -n 1)
VER=$(find /root/.steam/SteamApps/workshop/content/1281930/2563309347/ -type d -name "$YEAR.*" -printf "%f\n" | cut -c 6- | sort -nr | head -n 1)
cp /root/.steam/SteamApps/workshop/content/1281930/2563309347/$YEAR.$VER/MagicStorage.tmod ./
- dotnet TMLPatcher/TML.Patcher.dll extract MagicStorage.tmod
- cp MagicStorage/MagicStorage.dll $CI_WORKSPACE/
when:

View File

@ -12,7 +12,7 @@ using Terraria.ModLoader;
namespace MagicStorageVoidBag.Hooks {
internal class GetItemVoidVaultHook {
private static readonly log4net.ILog Logger = MagicStorageVoidBag.Instance.Logger;
public static bool Hook(On.Terraria.Player.orig_GetItem_VoidVault orig, Player player, int plr, Item[] inventory, Item newItem, GetItemSettings settings, Item returnItem) {
public static bool Hook(Terraria.On_Player.orig_GetItem_VoidVault orig, Player player, int plr, Item[] inventory, Item newItem, GetItemSettings settings, Item returnItem) {
var i = player.inventory.FirstOrDefault(i => i.type == ModContent.ItemType<MSVoidBag>(), null);
newItem = newItem.Clone();
@ -33,7 +33,7 @@ namespace MagicStorageVoidBag.Hooks {
heart.TryDeposit(returnItem);
heart.ResetCompactStage();
StorageGUI.needRefresh = true;
StorageGUI.SetRefresh();
if (returnItem.stack != newItem.stack) {
if (newItem.IsACoin) {

View File

@ -16,7 +16,7 @@ namespace MagicStorageVoidBag.Hooks {
private static readonly log4net.ILog Logger = MagicStorageVoidBag.Instance.Logger;
// Despite the constant negative press cofveve
public static bool Hook(On.Terraria.Player.orig_ItemSpaceForCofveve orig, Player player, Item newItem) {
public static bool Hook(Terraria.On_Player.orig_ItemSpaceForCofveve orig, Player player, Item newItem) {
var i = player.inventory.FirstOrDefault(i => i.type == ModContent.ItemType<MSVoidBag>(), null);
if (i == null) goto original;

View File

@ -13,6 +13,7 @@ namespace MagicStorageVoidBag.ILPatches {
internal class PlayerUpdatePatch : ILPatch {
private static readonly log4net.ILog Logger = MagicStorageVoidBag.Instance.Logger;
public void Patch(ILContext il) {
try {
if (il == null) {
Logger.Error("ILContext null!");
return;
@ -23,17 +24,24 @@ namespace MagicStorageVoidBag.ILPatches {
var c = new ILCursor(il);
var setterMethod = typeof(Player).GetProperty(nameof(Player.IsVoidVaultEnabled)).GetSetMethod();
if (!c.TryGotoNext(i => i.MatchCallOrCallvirt(setterMethod))) {
Logger.Warn("Failed to go to next call or callvirt! :(");
Logger.Error("Failed to go to next call or callvirt! :(");
return;
}
c.Emit(OpCodes.Ldarg_0);
c.Emit(OpCodes.Ldc_I4, ModContent.ItemType<MSVoidBag>());
var hasItemMethod = typeof(Player).GetMethod(nameof(Player.HasItem));
var hasItemMethod = typeof(Player).GetMethod(nameof(Player.HasItem), new[] { typeof(int) });
if (hasItemMethod == null) {
Logger.Error("Failed to reflect Player.HasItem(int)! :(");
return;
}
c.Emit(OpCodes.Call, hasItemMethod);
c.Emit(OpCodes.Or);
Logger.Debug("...Complete!");
} catch (Exception e) {
throw new ILPatchFailureException(MagicStorageVoidBag.Instance, il, e);
}
}
}
}

View File

@ -1,15 +1,17 @@
Mods: {
Mods: {
MagicStorageVoidBag: {
ItemName: {
MSVoidBag: Magic Void Bag
}
ItemTooltip: {
MSVoidBag:
ItemName.MSVoidBag: Magic Void Bag
ItemTooltip.MSVoidBag:
'''
<right> Storage Heart to store location
Currently not set to any location
'''
}
}
Items: {
MSVoidBag: {
DisplayName: M S Void Bag
Tooltip: ""
}
}
}
}

View File

@ -11,17 +11,17 @@ namespace MagicStorageVoidBag {
private PlayerUpdatePatch playerUpdatePatch = new();
public override void Load() {
IL.Terraria.Player.Update += playerUpdatePatch.Patch;
Terraria.IL_Player.Update += playerUpdatePatch.Patch;
On.Terraria.Player.GetItem_VoidVault += GetItemVoidVaultHook.Hook;
On.Terraria.Player.ItemSpaceForCofveve += ItemSpaceForCofveveHook.Hook;
Terraria.On_Player.GetItem_VoidVault += GetItemVoidVaultHook.Hook;
Terraria.On_Player.ItemSpaceForCofveve += ItemSpaceForCofveveHook.Hook;
}
public override void Unload() {
IL.Terraria.Player.Update -= playerUpdatePatch.Patch;
Terraria.IL_Player.Update -= playerUpdatePatch.Patch;
On.Terraria.Player.GetItem_VoidVault -= GetItemVoidVaultHook.Hook;
On.Terraria.Player.ItemSpaceForCofveve -= ItemSpaceForCofveveHook.Hook;
Terraria.On_Player.GetItem_VoidVault -= GetItemVoidVaultHook.Hook;
Terraria.On_Player.ItemSpaceForCofveve -= ItemSpaceForCofveveHook.Hook;
base.Unload();
}

View File

@ -1,7 +1,7 @@
displayName = MagicStorage Void Bag
author = jack
version = 1.6
version = 1.7
modReferences = MagicStorage
sortAfter = MagicStorage
includeSource = true
homepage = https://github.com/jackbondpreston/MagicStorageVoidBag
homepage = https://git.jackbondpreston.me/jack/MagicStorageVoidBag