官方维基教程-7.0迁移指南

来自Mindustry中文wiki
硫缺铅留言 | 贡献2026年2月1日 (日) 20:26的版本 (创建页面,内容为“<span id="迁移指南"></span> = 7.0 迁移指南 = == 方块 == * <code>Block#expanded</code> 现在已被弃用,且无操作,使用 <code>Block#clipSize</code>替代。这个字段会保留确保兼容性,但最后一定会删的。 * 所有的 <code>mindustry.world.meta.values.*</code> 类都已经用 lambda 覆盖了。请见于 <code>StatValues</code> 类。 * <code>方块熔炉</code> 已经从实验性功能包移出去,并且出现了重大…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

7.0 迁移指南

方块

  • Block#expanded 现在已被弃用,且无操作,使用 Block#clipSize替代。这个字段会保留确保兼容性,但最后一定会删的。
  • 所有的 mindustry.world.meta.values.* 类都已经用 lambda 覆盖了。请见于 StatValues 类。
  • 方块熔炉 已经从实验性功能包移出去,并且出现了重大变化。如果你在 Java 模组里用了这个类,建议你复制粘贴进去以便于保持使用旧版本。其他的实验性方块也可能随时被移出去。
  • CacheLayer 现在是一个可以重载方法的类,不是枚举。CacheLayer#add 能被用来注册新的层。
  • 更多的字段,比如 variantsattributes 是从 Floor 移动到 Block
  • Iconc 以及相关的方法都被移除, 使用 UnlockableContent.uiIcon/fullIcon.
  • 弃用了 SmelterAttributeSmelter 。 这些类具有硬编码的绘图功能。尽快改为 GenericCrafter 加上 DrawSmelter 。对于属性支持, 使用 AttributeCrafter.
  • CultivatorSmelter,一样被弃用, 使用AttributeCrafter 代替。
  • ExtendingItemBridgeLiquidExtendingBridge 合并到了 ItemBridge / LiquidBridge
  • PayloadAcceptor 是一个错误的包里面有误导性的词,使用PayloadBlock 代替。
  • 现在生成的图像 必须createIcons ;试图只用Core.atlas.addRegion 会失效。
  • LiquidModule#total() 被弃用,使用 currentAmount() 代替。

子弹

  • 任何使用单位弹药的mod代码现在都失效了。
  • ResupplyPoint 类被删除了。
  • AmmoType 由类变成了接口。
  • AmmoTypes 被删除了,用一个引用来代替。
  • 子弹类型的类移动到了mindustry.type.ammo 包。
  • ContentType.ammo 删了,作为子弹什么也不会做。

Arc

  • Pixmap的 API 完完全全变化了。 大多数方法都被禁用,颜色/混合/大小参数不再是 Pixmap 的状态机制。大多数与图像有关的方法现在是纯 Java 而不是 JNI + C。
  • SettingsDialog (Vars.ui.settings) 已经移入基础代码。 This technically doesn’t change the API; however, Java mods compiled with 6.0 source will try to access non-existent fields of a non-existent class, leading to crashes. Recompiling with v7 Mindustry/arc dependencies should be enough to fix this.这从技术上来讲并没有改变 API ,但是,6.0的Java模组
  • TextureAtlas now uses the smaller, faster aatls binary format. Update your Arc dependencies to read it.
  • Core.net has been removed, use the static methods in arc.util.Http instead.
  • RidgedPerlin has been renamed to Ridged.
  • Simplex and Ridged are now stateless; use static methods to generate noise now. The seed is a parameter.

Networking

  • Registrator for packets has been moved to Net, and registration methods have been made public, for potential use in Java mods.
  • InvokePacket has been removed, and replaced with generated packet classes that handle events directly.
  • RemoteRead{Server, Client} have also been removed.
  • Packet is now an abstract class, not an interface.

Misc

  • BulletType#despawned is no longer called in many cases, use #removed if you need to listen to all removal events
  • Attribute is now a standard class, not an enum. Use Attribute.add to register a new one.
  • Vars.miningRange has been moved to UnitType.
  • All fields in Tex are now Drawable, not NinePatchDrawable or TextureRegionDrawable. Why? These fields are loaded from the atlas, which means mods that change UI sprites or an outdated atlas could previously cause a ClassCastException crash.

Sprites

  • Outlines are now automatically generated for unit & weapon sprites. Leg regions are currently exempt.
  • All mod sprites are now automatically alpha-bled at load time when linear filtering is enabled - there is no need to do so manually.

More changes to come.

I will be introducing @Deprecated compatibility methods for most significant changes as needed. Ideally, most 6.0 java mods should still work with 7.0.