官方维基教程-7.0迁移指南
来自Mindustry中文wiki
7.0 迁移指南
方块
Block#expanded现在已被弃用,且无操作,使用Block#clipSize替代。这个字段会保留确保兼容性,但最后一定会删的。- 所有的
mindustry.world.meta.values.*类都已经用 lambda 覆盖了。请见于StatValues类。 方块熔炉已经从实验性功能包移出去,并且出现了重大变化。如果你在 Java 模组里用了这个类,建议你复制粘贴进去以便于保持使用旧版本。其他的实验性方块也可能随时被移出去。CacheLayer现在是一个可以重载方法的类,不是枚举。CacheLayer#add能被用来注册新的层。- 更多的字段,比如
variants和attributes是从Floor移动到Block。 Iconc以及相关的方法都被移除, 使用UnlockableContent.uiIcon/fullIcon.- 弃用了
Smelter和AttributeSmelter。 这些类具有硬编码的绘图功能。尽快改为GenericCrafter加上DrawSmelter。对于属性支持, 使用AttributeCrafter. Cultivator和Smelter,一样被弃用, 使用AttributeCrafter代替。ExtendingItemBridge和LiquidExtendingBridge合并到了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
aatlsbinary format. Update your Arc dependencies to read it. Core.nethas been removed, use the static methods inarc.util.Httpinstead.RidgedPerlinhas been renamed toRidged.SimplexandRidgedare now stateless; use static methods to generate noise now. The seed is a parameter.
Networking
Registratorfor packets has been moved toNet, and registration methods have been made public, for potential use in Java mods.InvokePackethas been removed, and replaced with generated packet classes that handle events directly.RemoteRead{Server, Client}have also been removed.Packetis now an abstract class, not an interface.
Misc
BulletType#despawnedis no longer called in many cases, use#removedif you need to listen to all removal eventsAttributeis now a standard class, not an enum. UseAttribute.addto register a new one.Vars.miningRangehas been moved toUnitType.- All fields in
Texare nowDrawable, notNinePatchDrawableorTextureRegionDrawable. Why? These fields are loaded from the atlas, which means mods that change UI sprites or an outdated atlas could previously cause aClassCastExceptioncrash.
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.
