PlotSellTool

基本信息

属性 值
类名 mytown.entities.tools.PlotSellTool
文件 src/main/java/mytown/entities/tools/PlotSellTool.java
行数 96
继承 extends myessentials.utils.Tool
启用版本 Minecraft 1.7.10

功能

地块出售工具。类注释 A tool which places signs that, when right clicked, sells the plots to that person. 手持工具点击地块,放置一张 SellSign 出售告示牌, 其他玩家右键该告示牌即完成购买。

字段

字段 初值 说明
price — 由构造器传入 int price
restricted false 是否仅限本镇居民购买
owner — 由构造器传入

构造器 PlotSellTool(Resident owner, int price)。 ⚠️ 构造器只接 price,不接 restricted —— restricted 初值恒为 false, 只能通过命令参数另行设置。

关键实现

onItemUse 按点击的面法线方向偏移,落在目标位置:

ForgeDirection direction = ForgeDirection.getOrientation(face);
bp = new BlockPos(bp.getX() + direction.offsetX, ...);

即告示牌放在所点击面的外侧。

实现要点

⚠️ 实际产生的注册内容是 MyTown:SellSign 告示牌类型 (见 SellSign)—— 这是全 mod 唯一的注册内容。

⚠️ 告示牌识别需要首行以 §1(EnumChatFormatting.DARK_BLUE)开头, 否则 isTileValid 返回 false。玩家手动造的普通告示牌不会被识别为出售牌。

⚠️ 本工具只在 CommandsEveryone 装载 (new PlotSellTool(res, price),行 598),助理 / 管理员层不提供。

⚠️ 交易结算走 EconomyProxy, 价格由 plot 所属城镇的经济配置决定,与 Bank 的城镇账本是两套。

相关条目