Merge branch 'master' of https://github.com/Anuken/Mindustry into 7.0-features
Conflicts: core/assets/icons/icons.properties core/assets/logicids.dat core/src/mindustry/ui/dialogs/PlanetDialog.java core/src/mindustry/world/blocks/distribution/ItemBridge.java core/src/mindustry/world/blocks/liquid/LiquidExtendingBridge.java core/src/mindustry/world/blocks/storage/StorageBlock.java gradle.properties
This commit is contained in:
@@ -35,6 +35,7 @@ public class ClassMap{
|
||||
classes.put("BulletType", mindustry.entities.bullet.BulletType.class);
|
||||
classes.put("ContinuousLaserBulletType", mindustry.entities.bullet.ContinuousLaserBulletType.class);
|
||||
classes.put("EmpBulletType", mindustry.entities.bullet.EmpBulletType.class);
|
||||
classes.put("FireBulletType", mindustry.entities.bullet.FireBulletType.class);
|
||||
classes.put("FlakBulletType", mindustry.entities.bullet.FlakBulletType.class);
|
||||
classes.put("LaserBoltBulletType", mindustry.entities.bullet.LaserBoltBulletType.class);
|
||||
classes.put("LaserBulletType", mindustry.entities.bullet.LaserBulletType.class);
|
||||
@@ -56,9 +57,6 @@ public class ClassMap{
|
||||
classes.put("Research", mindustry.game.Objectives.Research.class);
|
||||
classes.put("SectorComplete", mindustry.game.Objectives.SectorComplete.class);
|
||||
classes.put("AmmoType", mindustry.type.AmmoType.class);
|
||||
classes.put("AmmoTypes", mindustry.type.AmmoTypes.class);
|
||||
classes.put("ItemAmmoType", mindustry.type.AmmoTypes.ItemAmmoType.class);
|
||||
classes.put("PowerAmmoType", mindustry.type.AmmoTypes.PowerAmmoType.class);
|
||||
classes.put("Category", mindustry.type.Category.class);
|
||||
classes.put("ErrorContent", mindustry.type.ErrorContent.class);
|
||||
classes.put("Item", mindustry.type.Item.class);
|
||||
@@ -78,6 +76,8 @@ public class ClassMap{
|
||||
classes.put("Weapon", mindustry.type.Weapon.class);
|
||||
classes.put("Weather", mindustry.type.Weather.class);
|
||||
classes.put("WeatherEntry", mindustry.type.Weather.WeatherEntry.class);
|
||||
classes.put("ItemAmmoType", mindustry.type.ammo.ItemAmmoType.class);
|
||||
classes.put("PowerAmmoType", mindustry.type.ammo.PowerAmmoType.class);
|
||||
classes.put("PointDefenseWeapon", mindustry.type.weapons.PointDefenseWeapon.class);
|
||||
classes.put("RepairBeamWeapon", mindustry.type.weapons.RepairBeamWeapon.class);
|
||||
classes.put("HealBeamMount", mindustry.type.weapons.RepairBeamWeapon.HealBeamMount.class);
|
||||
@@ -145,7 +145,7 @@ public class ClassMap{
|
||||
classes.put("DuctBridge", mindustry.world.blocks.distribution.DuctBridge.class);
|
||||
classes.put("DuctBridgeBuild", mindustry.world.blocks.distribution.DuctBridge.DuctBridgeBuild.class);
|
||||
classes.put("DuctRouter", mindustry.world.blocks.distribution.DuctRouter.class);
|
||||
classes.put("DuctBuild", mindustry.world.blocks.distribution.DuctRouter.DuctBuild.class);
|
||||
classes.put("DuctRouterBuild", mindustry.world.blocks.distribution.DuctRouter.DuctRouterBuild.class);
|
||||
classes.put("ExtendingItemBridge", mindustry.world.blocks.distribution.ExtendingItemBridge.class);
|
||||
classes.put("ExtendingItemBridgeBuild", mindustry.world.blocks.distribution.ExtendingItemBridge.ExtendingItemBridgeBuild.class);
|
||||
classes.put("ItemBridge", mindustry.world.blocks.distribution.ItemBridge.class);
|
||||
@@ -330,8 +330,6 @@ public class ClassMap{
|
||||
classes.put("ReconstructorBuild", mindustry.world.blocks.units.Reconstructor.ReconstructorBuild.class);
|
||||
classes.put("RepairPoint", mindustry.world.blocks.units.RepairPoint.class);
|
||||
classes.put("RepairPointBuild", mindustry.world.blocks.units.RepairPoint.RepairPointBuild.class);
|
||||
classes.put("ResupplyPoint", mindustry.world.blocks.units.ResupplyPoint.class);
|
||||
classes.put("ResupplyPointBuild", mindustry.world.blocks.units.ResupplyPoint.ResupplyPointBuild.class);
|
||||
classes.put("UnitBlock", mindustry.world.blocks.units.UnitBlock.class);
|
||||
classes.put("UnitBuild", mindustry.world.blocks.units.UnitBlock.UnitBuild.class);
|
||||
classes.put("UnitFactory", mindustry.world.blocks.units.UnitFactory.class);
|
||||
|
||||
@@ -29,6 +29,7 @@ import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.mod.Mods.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.type.ammo.*;
|
||||
import mindustry.type.weather.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.units.*;
|
||||
@@ -95,6 +96,19 @@ public class ContentParser{
|
||||
readFields(result, data);
|
||||
return result;
|
||||
});
|
||||
put(AmmoType.class, (type, data) -> {
|
||||
//string -> item
|
||||
//if liquid ammo support is added, this should scan for liquids as well
|
||||
if(data.isString()) return find(ContentType.item, data.asString());
|
||||
//number -> power
|
||||
if(data.isNumber()) return new PowerAmmoType(data.asFloat());
|
||||
|
||||
var bc = resolve(data.getString("type", ""), ItemAmmoType.class);
|
||||
data.remove("type");
|
||||
AmmoType result = make(bc);
|
||||
readFields(result, data);
|
||||
return result;
|
||||
});
|
||||
put(DrawBlock.class, (type, data) -> {
|
||||
if(data.isString()){
|
||||
//try to instantiate
|
||||
@@ -746,7 +760,7 @@ public class ContentParser{
|
||||
/** Tries to resolve a class from the class type map. */
|
||||
<T> Class<T> resolve(String base, Class<T> def){
|
||||
//no base class specified
|
||||
if(base.isEmpty() && def != null) return def;
|
||||
if((base == null || base.isEmpty()) && def != null) return def;
|
||||
|
||||
//return mapped class if found in the global map
|
||||
var out = ClassMap.classes.get(!base.isEmpty() && Character.isLowerCase(base.charAt(0)) ? Strings.capitalize(base) : base);
|
||||
|
||||
@@ -626,7 +626,7 @@ public class Mods implements Loadable{
|
||||
try{
|
||||
//this binds the content but does not load it entirely
|
||||
Content loaded = parser.parse(l.mod, l.file.nameWithoutExtension(), l.file.readString("UTF-8"), l.file, l.type);
|
||||
Log.debug("[@] Loaded '@'.", l.mod.meta.name, (loaded instanceof UnlockableContent ? ((UnlockableContent)loaded).localizedName : loaded));
|
||||
Log.debug("[@] Loaded '@'.", l.mod.meta.name, (loaded instanceof UnlockableContent u ? u.localizedName : loaded));
|
||||
}catch(Throwable e){
|
||||
if(current != content.getLastAdded() && content.getLastAdded() != null){
|
||||
parser.markError(content.getLastAdded(), l.mod, l.file, e);
|
||||
@@ -723,7 +723,7 @@ public class Mods implements Loadable{
|
||||
|
||||
if(!metaf.exists()){
|
||||
Log.warn("Mod @ doesn't have a '[mod/plugin].[h]json' file, skipping.", sourceFile);
|
||||
throw new IllegalArgumentException("Invalid file: No mod.json found.");
|
||||
throw new ModLoadException("Invalid file: No mod.json found.");
|
||||
}
|
||||
|
||||
ModMeta meta = json.fromJson(ModMeta.class, Jval.read(metaf.readString()).toString(Jformat.plain));
|
||||
@@ -750,7 +750,7 @@ public class Mods implements Loadable{
|
||||
//unload
|
||||
mods.remove(other);
|
||||
}else{
|
||||
throw new IllegalArgumentException("A mod with the name '" + baseName + "' is already imported.");
|
||||
throw new ModLoadException("A mod with the name '" + baseName + "' is already imported.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -779,12 +779,23 @@ public class Mods implements Loadable{
|
||||
(meta.getMinMajor() >= 105 || headless)
|
||||
){
|
||||
if(ios){
|
||||
throw new IllegalArgumentException("Java class mods are not supported on iOS.");
|
||||
throw new ModLoadException("Java class mods are not supported on iOS.");
|
||||
}
|
||||
|
||||
loader = platform.loadJar(sourceFile, mainLoader);
|
||||
mainLoader.addChild(loader);
|
||||
Class<?> main = Class.forName(mainClass, true, loader);
|
||||
|
||||
//detect mods that incorrectly package mindustry in the jar
|
||||
if((main.getSuperclass().getName().equals("mindustry.mod.Plugin") || main.getSuperclass().getName().equals("mindustry.mod.Mod")) &&
|
||||
main.getSuperclass().getClassLoader() != Mod.class.getClassLoader()){
|
||||
throw new ModLoadException(
|
||||
"This mod/plugin has loaded Mindustry dependencies from its own class loader. " +
|
||||
"You are incorrectly including Mindustry dependencies in the mod JAR - " +
|
||||
"make sure Mindustry is declared as `compileOnly` in Gradle, and that the JAR is created with `runtimeClasspath`!"
|
||||
);
|
||||
}
|
||||
|
||||
metas.put(main, meta);
|
||||
mainMod = (Mod)main.getDeclaredConstructor().newInstance();
|
||||
}else{
|
||||
@@ -1017,6 +1028,12 @@ public class Mods implements Loadable{
|
||||
}
|
||||
}
|
||||
|
||||
public static class ModLoadException extends RuntimeException{
|
||||
public ModLoadException(String message){
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
public enum ModState{
|
||||
enabled,
|
||||
contentErrors,
|
||||
|
||||
Reference in New Issue
Block a user