10 Commits
v1.5 ... v1.8

Author SHA1 Message Date
782d5e2b93 Change to Gitea Actions
All checks were successful
build-release / release (push) Successful in 1m9s
2025-06-25 14:23:40 +01:00
ce4a78454d dev: update for tML v2025.04.3.0 and MagicStorage v0.7.0.4 2025-06-25 14:23:36 +01:00
395bda3972 doc: update repo link in workshop description 2023-09-01 14:11:12 +01:00
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
d8c4649f92 ci: fix CI again 2023-02-04 13:13:29 +00:00
dd5f7256fc fix: Use new Locator property 2023-02-04 12:52:55 +00:00
5b1a55973b Revert "fix: work around magic storage locator sync bug"
This fix is now part of mainline Magic Storage
2023-02-04 12:47:38 +00:00
12 changed files with 133 additions and 196 deletions

View File

@ -0,0 +1,52 @@
name: "build-release"
run-name: "Build and Release MSVB"
on:
push:
tags:
- 'v*'
jobs:
release:
runs-on: arch-x86
container:
image: git.jackbondpreston.me/jack/msvb-build:latest
steps:
- name: Check out
uses: actions/checkout@v4
with:
path: MagicStorageVoidBag
- run: ls
- run: steamcmd "+login anonymous" "+workshop_download_item 1281930 2563309347" "+quit"
- run: wget https://github.com/tModLoader/tModLoader/releases/latest/download/tModLoader.zip
- run: unzip -q tModLoader.zip -d tModLoader
- run: rm tModLoader.zip
- run: ln -sf ${{ gitea.workspace }}/tModLoader/Libraries/Native/Linux/libSDL2-2.0.so.0 ${{ gitea.workspace }}/tModLoader/Libraries/Native/Linux/libSDL2.so
- run: >
echo "<Project ToolsVersion=\"14.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">
<Import Project=\"${{ gitea.workspace }}/tModLoader/tMLMod.targets\" />
</Project>" > tModLoader.targets
- run: |
wget https://github.com/steviegt6/fnb/archive/refs/tags/0.1.0.zip
unzip -q 0.1.0.zip -d TMLPatcher
dotnet build --configuration=Release TMLPatcher/fnb-0.1.0/src/
- run: |
rm -f ~/.steam/SteamApps/workshop/content/1281930/2563309347/workshop.json
YEAR=$(ls ~/.steam/SteamApps/workshop/content/1281930/2563309347/ | cut -c -4 | sort -nr | head -n 1)
VER=$(find ~/.steam/SteamApps/workshop/content/1281930/2563309347/ -type d -name "$YEAR.*" -printf "%f\n" | cut -c 6- | sort -nr | head -n 1)
cp ~/.steam/SteamApps/workshop/content/1281930/2563309347/$YEAR.$VER/MagicStorage.tmod ./
- run: dotnet TMLPatcher/fnb-0.1.0/src/Tomat.FNB/bin/Release/net8.0/fnb.dll tmod extract MagicStorage.tmod
- run: cp MagicStorage/MagicStorage.dll ${{ gitea.workspace }}
- run: rm -rf MagicStorageVoidBag/.git
- run: dotnet build -c Release MagicStorageVoidBag/MagicStorageVoidBag.sln || true
- run: cp MagicStorageVoidBag/bin/Release/net8.0/MagicStorageVoidBag.dll .
- run: mkdir release
- run: cp ~/.local/share/Terraria/tModLoader/Mods/MagicStorageVoidBag.tmod release/
- run: cp MagicStorageVoidBag.dll release/
- run: ls release
- name: Add Gitea Release
id: gitea-release
uses: https://gitea.com/actions/release-action@main
with:
files: |-
release/**
api_key: '${{secrets.RELEASE_TOKEN}}'

View File

@ -1,64 +0,0 @@
clone:
git:
image: woodpeckerci/plugin-git:latest
settings:
path: MagicStorageVoidBag
when:
event: tag
pipeline:
fetch-deps:
image: jackbondpreston/msvb-build-env
commands:
- steamcmd "+login anonymous" "+workshop_download_item 1281930 2563309347" "+quit"
- wget https://github.com/tModLoader/tModLoader/releases/latest/download/tModLoader.zip
- unzip -q tModLoader.zip -d tModLoader
- rm tModLoader.zip
- ln -sf $CI_WORKSPACE/tModLoader/Libraries/Native/Linux/libSDL2-2.0.so.0 $CI_WORKSPACE/tModLoader/Libraries/Native/Linux/libSDL2.so
- >
echo "<Project ToolsVersion=\"14.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">
<Import Project=\"$CI_WORKSPACE/tModLoader/tMLMod.targets\" />
</Project>" > tModLoader.targets
- |
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
VER=$(ls /root/.steam/steamapps/workshop/content/1281930/2563309347 | cut -c 6- | sort | head -n 1)
YEAR=$(ls /root/.steam/steamapps/workshop/content/1281930/2563309347 | cut -c -4 | sort | 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:
event: tag
build:
image: jackbondpreston/msvb-build-env
commands:
- |
echo "Shell: $SHELL"
echo "CI_WORKSPACE: $CI_WORKSPACE"
- cat tModLoader.targets
- cd $CI_WORKSPACE
- cd MagicStorageVoidBag
- rm -rf .git
- dotnet build -c Release || true
- cp bin/Release/net6.0/MagicStorageVoidBag.dll .
- cd $CI_WORKSPACE
- mkdir release
- cp ~/.local/share/Terraria/tModLoader/Mods/MagicStorageVoidBag.tmod release/
- cp MagicStorageVoidBag/MagicStorageVoidBag.dll release/
- ls release
when:
event: tag
gitea-release:
image: plugins/gitea-release
settings:
api_key:
from_secret: gitea-api-key
base_url: https://git.jackbondpreston.me
files: release/*
when:
event: tag

View File

@ -1,4 +1,5 @@
using MagicStorage;
using MagicStorage.Common.Systems;
using MagicStorage.Components;
using MagicStorageVoidBag.Items;
using System.Linq;
@ -12,7 +13,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();
@ -21,19 +22,19 @@ namespace MagicStorageVoidBag.Hooks {
var bag = (MSVoidBag)i.ModItem;
if (bag.location.X < 0 || bag.location.Y < 0) goto original;
if (bag.Location.X < 0 || bag.Location.Y < 0) goto original;
Tile tile = Main.tile[bag.location.X, bag.location.Y];
Tile tile = Main.tile[bag.Location.X, bag.Location.Y];
if (!tile.HasTile || tile.TileType != ModContent.TileType<StorageHeart>() || tile.TileFrameX != 0 || tile.TileFrameY != 0) goto original;
if (!TileEntity.ByPosition.TryGetValue(bag.location, out TileEntity te)) goto original;
if (!TileEntity.ByPosition.TryGetValue(bag.Location, out TileEntity te)) goto original;
if (te.type != ModContent.TileEntityType<TEStorageHeart>()) goto original;
TEStorageHeart heart = (TEStorageHeart)te;
heart.TryDeposit(returnItem);
heart.ResetCompactStage();
StorageGUI.needRefresh = true;
MagicUI.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;
@ -24,12 +24,12 @@ namespace MagicStorageVoidBag.Hooks {
var bag = (MSVoidBag)i.ModItem;
if (bag.location.X < 0 || bag.location.Y < 0) goto original;
if (bag.Location.X < 0 || bag.Location.Y < 0) goto original;
Tile tile = Main.tile[bag.location.X, bag.location.Y];
Tile tile = Main.tile[bag.Location.X, bag.Location.Y];
if (!tile.HasTile || tile.TileType != ModContent.TileType<StorageHeart>() || tile.TileFrameX != 0 || tile.TileFrameY != 0) goto original;
if (!TileEntity.ByPosition.TryGetValue(bag.location, out TileEntity te)) goto original;
if (!TileEntity.ByPosition.TryGetValue(bag.Location, out TileEntity te)) goto original;
if (te.type != ModContent.TileEntityType<TEStorageHeart>()) goto original;
if (Utility.HeartHasSpaceFor(newItem, (TEStorageHeart)te)) return true;

View File

@ -13,27 +13,35 @@ namespace MagicStorageVoidBag.ILPatches {
internal class PlayerUpdatePatch : ILPatch {
private static readonly log4net.ILog Logger = MagicStorageVoidBag.Instance.Logger;
public void Patch(ILContext il) {
if (il == null) {
Logger.Error("ILContext null!");
return;
try {
if (il == null) {
Logger.Error("ILContext null!");
return;
}
Logger.Debug("Patching Terraria.Player.Update IL...");
var c = new ILCursor(il);
var setterMethod = typeof(Player).GetProperty(nameof(Player.IsVoidVaultEnabled)).GetSetMethod();
if (!c.TryGotoNext(i => i.MatchCallOrCallvirt(setterMethod))) {
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), 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);
}
Logger.Debug("Patching Terraria.Player.Update IL...");
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! :(");
return;
}
c.Emit(OpCodes.Ldarg_0);
c.Emit(OpCodes.Ldc_I4, ModContent.ItemType<MSVoidBag>());
var hasItemMethod = typeof(Player).GetMethod(nameof(Player.HasItem));
c.Emit(OpCodes.Call, hasItemMethod);
c.Emit(OpCodes.Or);
Logger.Debug("...Complete!");
}
}
}

View File

@ -1,21 +1,15 @@
using MagicStorage.Items;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Terraria;
using Terraria.DataStructures;
using Terraria.GameContent.Creative;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
using Terraria.ModLoader.IO;
namespace MagicStorageVoidBag.Items {
[ExtendsFromMod("MagicStorage")]
public class MSVoidBag : PortableAccess {
[CloneByReference]
internal Dictionary<string, Point16> locationsByWorld = new();
public override void SetStaticDefaults() {
CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1;
@ -30,16 +24,13 @@ namespace MagicStorageVoidBag.Items {
Item.useAnimation = 28;
Item.useTime = 28;
Item.value = Item.sellPrice(gold: 10);
location = Point16.NegativeOne;
locationsByWorld[Main.worldName] = location;
}
public override void ModifyTooltips(List<TooltipLine> lines) {
bool isSet = location.X >= 0 && location.Y >= 0;
bool isSet = Location.X >= 0 && Location.Y >= 0;
for (int k = 0; k < lines.Count; k++)
if (isSet && lines[k].Mod == "Terraria" && lines[k].Name == "Tooltip1") {
lines[k].Text = Language.GetTextValue("Mods.MagicStorage.SetTo", location.X, location.Y);
lines[k].Text = Language.GetTextValue("Mods.MagicStorage.SetTo", Location.X, Location.Y);
} else if (!isSet && lines[k].Mod == "Terraria" && lines[k].Name == "Tooltip2") {
lines.RemoveAt(k);
k--;
@ -52,55 +43,5 @@ namespace MagicStorageVoidBag.Items {
recipe.AddIngredient(ItemID.VoidLens);
recipe.Register();
}
public override void UpdateInventory(Player player) {
if (!locationsByWorld.ContainsKey(Main.worldName) || location != locationsByWorld[Main.worldName]) {
locationsByWorld[Main.worldName] = location;
if (Main.netMode == NetmodeID.MultiplayerClient) {
int p = Array.IndexOf(Main.player, player);
int i = Array.IndexOf(player.inventory, Item);
if (p >= 0 && i >= 0) {
NetMessage.SendData(MessageID.SyncEquipment, -1, -1, null, p, i, player.inventory[i].prefix);
}
}
}
}
public override void SaveData(TagCompound tag) {
tag["X"] = location.X;
tag["Y"] = location.Y;
tag["version"] = SAVE_VERSION;
tag["locations"] = locationsByWorld
.Select(kvp => new TagCompound() {
["world"] = kvp.Key,
["X"] = kvp.Value.X,
["Y"] = kvp.Value.Y
})
.ToList();
}
public override void LoadData(TagCompound tag) {
if (tag.GetInt("version") < SAVE_VERSION || tag.GetList<TagCompound>("locations") is not List<TagCompound> locations) {
location = new Point16(tag.GetShort("X"), tag.GetShort("Y"));
locationsByWorld[Main.worldName] = location;
} else {
locationsByWorld = locations.ToDictionary(t => t.GetString("world"), t => new Point16(t.GetShort("X"), t.GetShort("Y")));
if (locationsByWorld.ContainsKey(Main.worldName)) {
location = locationsByWorld[Main.worldName];
}
}
}
public override void NetSend(BinaryWriter writer) {
writer.Write(location.X);
writer.Write(location.Y);
}
public override void NetReceive(BinaryReader reader) {
location = new Point16(reader.ReadInt16(), reader.ReadInt16());
locationsByWorld[Main.worldName] = location;
}
}
}

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

@ -10,18 +10,18 @@ namespace MagicStorageVoidBag {
// IL Patches
private PlayerUpdatePatch playerUpdatePatch = new();
public override void Load() {
IL.Terraria.Player.Update += playerUpdatePatch.Patch;
public override void Load() {
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,14 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<!-- Import tModLoader mod properties -->
<Import Project="../tModLoader.targets" />
<PropertyGroup>
<AssemblyName>MagicStorageVoidBag</AssemblyName>
<TargetFramework>net6.0</TargetFramework>
<PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="tModLoader.CodeAssist" Version="0.1.*" />
</ItemGroup>
<ItemGroup>
<Reference Include="MagicStorage">

View File

@ -1,16 +1,16 @@
{
"profiles": {
"Terraria": {
"commandName": "Executable",
"executablePath": "dotnet",
"commandLineArgs": "$(tMLPath)",
"workingDirectory": "$(tMLSteamPath)"
},
"TerrariaServer": {
"commandName": "Executable",
"executablePath": "dotnet",
"commandLineArgs": "$(tMLServerPath)",
"workingDirectory": "$(tMLSteamPath)"
}
}
{
"profiles": {
"Terraria": {
"commandName": "Executable",
"executablePath": "dotnet",
"commandLineArgs": "$(tMLPath)",
"workingDirectory": "$(tMLSteamPath)"
},
"TerrariaServer": {
"commandName": "Executable",
"executablePath": "dotnet",
"commandLineArgs": "$(tMLServerPath)",
"workingDirectory": "$(tMLSteamPath)"
}
}
}

View File

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

View File

@ -1,7 +1,7 @@
Adds an upgraded void bag that combines functionality of the Void Bag and Portable Remote Storage Access, by putting items into a magic storage system when your inventory is full (and allowing remote access as usual).
This item is crafted by combining a Void Bag with a Portable Remote Storage Access. To link it with your storage system, right click the Storage Heart with the bag equipped.
GitHub: https://github.com/jackbondpreston/MagicStorageVoidBag
Git: https://git.jackbondpreston.me/jack/MagicStorageVoidBag
Discord server if you need support/don't want to report bugs on GitHub: https://discord.gg/Z6V77mbtZQ
Thanks to the original MagicStorage mod for some code and of course the functionality of the original mod!