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

更新:连锁挖矿,当矿石上方有指定方块时,不会触发连锁挖矿(避免刷矿) #379

Merged
merged 25 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ae2c63f
更新:简化代码,更新版本号
THEXN Aug 2, 2024
7edc251
添加插件:AutoReset 完全自动重置插件
THEXN Aug 2, 2024
afd1fc3
doc: PluginManager 自动更新插件
THEXN Aug 2, 2024
d9a8012
更新:白名单插件,优化config内容顺序,整理代码
THEXN Aug 2, 2024
a749e03
Update README.md
THEXN Aug 2, 2024
0275b4b
doc:修改AutoReset 完全自动重置插件的文档
THEXN Aug 2, 2024
d382a39
Merge branch 'master' of https://github.com/THEXN/TShockPlugin
THEXN Aug 2, 2024
53446c2
拉取
THEXN Aug 3, 2024
8bf7179
doc:文档名字
THEXN Aug 3, 2024
4e817e0
更新:Ezperm 便捷权限,优化代码,完善卸载函数
THEXN Aug 3, 2024
fe25cd2
更新:GenerateMap卸载函数完善
THEXN Aug 3, 2024
29d26eb
更新:完善GolfRewards 高尔夫奖励卸载函数
THEXN Aug 3, 2024
0d3e444
更新:完善InvincibilityPlugin 限时无敌的卸载函数
THEXN Aug 3, 2024
a2eae9d
更新:完善直到首字母为I的插件(除了ec和help插件)以外的卸载函数
THEXN Aug 3, 2024
058a1e9
更新:journeyUnlock 解锁旅途物品的卸载函数
THEXN Aug 3, 2024
27919fa
思考
THEXN Aug 3, 2024
98d22c5
Revert "更新:journeyUnlock 解锁旅途物品的卸载函数"
THEXN Aug 3, 2024
5b1ae70
修复:把恋恋插件加回来
THEXN Aug 3, 2024
769e9d5
Merge branch 'Controllerdestiny:master' into master
THEXN Aug 3, 2024
d1e305e
更新:journeyUnlock 解锁旅途物品的卸载函数
THEXN Aug 3, 2024
0f7a623
Merge branch 'master' of https://github.com/THEXN/TShockPlugin
THEXN Aug 3, 2024
f0a18e7
修复:少提交了
THEXN Aug 3, 2024
2ffd54a
Merge branch 'Controllerdestiny:master' into master
THEXN Aug 8, 2024
c2691a3
更新:连锁挖矿,当矿石上方有指定方块时,不会触发连锁挖矿(避免刷矿)
THEXN Aug 8, 2024
c682b96
Merge branch 'master' of https://github.com/THEXN/TShockPlugin
THEXN Aug 8, 2024
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
6 changes: 5 additions & 1 deletion VeinMiner/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public static void Load(ReloadEventArgs args = null)
//Item = new() { { 953, 1 }, { 2425, 5 } }
}
},
Tile = new() { 7, 166, 6, 167, 9, 168, 8, 169, 37, 22, 204, 56, 58, 107, 221, 108, 222, 111, 223, 211, 408, 123, 224, 404, 178, 63, 64, 65, 66, 67, 68 }
Tile = new() { 7, 166, 6, 167, 9, 168, 8, 169, 37, 22, 204, 56, 58, 107, 221, 108, 222, 111, 223, 211, 408, 123, 224, 404, 178, 63, 64, 65, 66, 67, 68 },
NotMine = new() { 21 ,26 ,88 }
}, Formatting.Indented));

VeinMiner.Config = JsonConvert.DeserializeObject<Config>(File.ReadAllText(Path.Combine(TShock.SavePath, "VeinMiner.json")));
Expand All @@ -48,6 +49,9 @@ public static void Load(ReloadEventArgs args = null)
[JsonProperty("矿石类型")]
public List<int> Tile { get; set; } = new();

[JsonProperty("当矿石上方有这些物品时,该处矿石不被挖掘")]
public List<int> NotMine { get; set; } = new();

[JsonProperty("兑换规则")]
public List<Exchange> Exchange { get; set; } = new();
}
Expand Down
3 changes: 2 additions & 1 deletion VeinMiner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
## 更新日志

```
暂无
v1.6.0.3
添加配置,当矿石上方有指定方块时,不会触发连锁挖矿(避免刷矿)
```

## 指令
Expand Down
104 changes: 61 additions & 43 deletions VeinMiner/VeinMiner.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using TerrariaApi.Server;
using TShockAPI;

Expand All @@ -9,7 +10,7 @@ namespace VeinMiner
public class VeinMiner : TerrariaPlugin
{
public override string Name => "VeinMiner";
public override Version Version => new Version(1, 6, 0, 2);
public override Version Version => new Version(1, 6, 0, 3);
public override string Author => "Megghy|YSpoof|Maxthegreat99|肝帝熙恩";
public override string Description => "VeinMiner by Megghy 适用于 TShock 5.2 支持!";

Expand Down Expand Up @@ -84,47 +85,72 @@ void Mine(TSPlayer plr, int x, int y, int type)
var list = GetVein(new(), x, y, type).Result;
var count = list.Count;
var item = Utils.GetItemFromTile(x, y);
if (Config.Exchange.Where(e => e.Type == type && count >= e.MinSize).ToList() is { Count: > 0 } exchangeList)
exchangeList.ForEach(e =>
var mineableList = new List<Point>();

// 过滤出可挖的矿石坐标
foreach (var point in list)
{
if (point.Y > 0 && Config.NotMine.Contains(Main.tile[point.X, point.Y - 1].type))
{
if (e.Item.Count <= plr.GetBlankSlot())
continue;
}

mineableList.Add(point);
}

var mineCount = mineableList.Count;
if (mineCount > 0)
{
list = mineableList;

if (Config.Exchange.Where(e => e.Type == type && mineCount >= e.MinSize).ToList() is { Count: > 0 } exchangeList)
exchangeList.ForEach(e =>
{
e.Item.ForEach(ex => plr.GiveItem(ex.Key, ex.Value));
if (e.OnlyGiveItem)
KillTileAndSend(list, true);
if (e.Item.Count <= plr.GetBlankSlot())
{
e.Item.ForEach(ex => plr.GiveItem(ex.Key, ex.Value));
if (e.OnlyGiveItem)
KillTileAndSend(list, true);
else
GiveItem();
plr.SendMessage($"[c/95CFA6:<VeinMiner>] 挖掘了 [c/95CFA6: {mineCount} {(item.type == 0 ? "未知" : item.Name)}].", Color.White);
return;
}
else
GiveItem();
plr.SendMessage($"[c/95CFA6:<VeinMiner>] 挖掘了 [c/95CFA6: {count} {(item.type == 0 ? "未知" : item.Name)}].", Color.White);
return;
}
else
{
plr.SendInfoMessage($"[c/95CFA6:<VeinMiner>] 背包已满,还需空位:[c/95CFA6:{e.Item.Count}] .");
plr.SendTileSquareCentered(x, y, 1);
return;
}
});
else
GiveItem();
void GiveItem()
{
if (Config.PutInInventory)
{
plr.SendInfoMessage($"[c/95CFA6:<VeinMiner>] 背包已满,还需空位:[c/95CFA6:{e.Item.Count}] .");
plr.SendTileSquareCentered(x, y, 1);
return;
}
});
else
GiveItem();

void GiveItem()
{
if (plr.IsSpaceEnough(item.netID, count))
if (Config.PutInInventory)
{
plr.GiveItem(item.netID, count);
KillTileAndSend(list, true);
if (plr.IsSpaceEnough(item.netID, mineCount))
{
plr.GiveItem(item.netID, mineCount);
KillTileAndSend(list, true);
}
else
{
WorldGen.KillTile(x, y);
plr.SendInfoMessage($"[c/95CFA6:<VeinMiner>] 背包已满,需额外空位:[c/95CFA6:{mineCount}] 以放入 [c/95CFA6:{item.Name}] .");
}
}
else
{
WorldGen.KillTile(x, y);
plr.SendInfoMessage($"[c/95CFA6:<VeinMiner>] 背包已满,需额外空位:[c/95CFA6:{count}] 以放入 [c/95CFA6:{item.Name}] .");
}
KillTileAndSend(list, false);

if (plr.GetData<VMStatus>("VeinMiner").EnableBroadcast && Config.Broadcast && mineCount > 1)
plr.SendMessage($"[c/95CFA6:<VeinMiner>] 正在挖掘 [c/95CFA6:{mineCount} {(item.type == 0 ? "未知" : item.Name)}].", Color.White);
}
else
KillTileAndSend(list, false);
if (plr.GetData<VMStatus>("VeinMiner").EnableBroadcast && Config.Broadcast && count > 1)
plr.SendMessage($"[c/95CFA6:<VeinMiner>] 正在挖掘 [c/95CFA6:{count} {(item.type == 0 ? "未知" : item.Name)}].", Color.White);
}
else if (count > 0)
{
plr.SendMessage($"[c/95CFA6:<VeinMiner>] 无法挖取矿石,可能是因为矿石上方有不可破坏的物体.", Color.White);
}
}

Expand All @@ -134,20 +160,12 @@ public static void KillTileAndSend(List<Point> list, bool noItem)
{
if (!list.Any())
return;
/*var minX = list[0].X;
var minY = list[0].Y;
var maxX = minX;
var maxY = minY;*/

list.ForEach(p =>
{
/*if (p.X < minX) minX = p.X;
if (p.X > maxX) maxX = p.X;
if (p.Y < minY) minY = p.Y;
if (p.Y > maxY) maxY = p.Y;*/
WorldGen.KillTile(p.X, p.Y, false, false, noItem);
NetMessage.SendData(17, -1, -1, null, 4, p.X, p.Y, false.GetHashCode());
});
//NetMessage.SendTileSquare(-1, minX, minY, maxX - minX + 1, maxY - minY + 1, Terraria.ID.TileChangeType.None);
});
}

Expand Down
Loading