3 Commits
v1.5 ... v1.6

Author SHA1 Message Date
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
5 changed files with 11 additions and 70 deletions

View File

@ -24,8 +24,8 @@ pipeline:
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)
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/

View File

@ -21,12 +21,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;
TEStorageHeart heart = (TEStorageHeart)te;

View File

@ -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

@ -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,6 +1,6 @@
displayName = MagicStorage Void Bag
author = jack
version = 1.5
version = 1.6
modReferences = MagicStorage
sortAfter = MagicStorage
includeSource = true