diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 70b4ec637d..f54f76b339 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -998,10 +998,12 @@ public class Blocks implements ContentList{ payloadConveyor = new PayloadConveyor("payload-conveyor"){{ requirements(Category.distribution, with(Items.graphite, 10, Items.copper, 20)); + canOverdrive = false; }}; payloadRouter = new PayloadRouter("payload-router"){{ requirements(Category.distribution, with(Items.graphite, 15, Items.copper, 20)); + canOverdrive = false; }}; //endregion diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index 19b22422a5..dc9e867c3f 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -1094,6 +1094,7 @@ public class UnitTypes implements ContentList{ hitsize = 0f; health = 1; rotateSpeed = 360f; + itemCapacity = 0; } @Override diff --git a/core/src/mindustry/core/ContentLoader.java b/core/src/mindustry/core/ContentLoader.java index 3a3fe0d2a3..0eacd5cec7 100644 --- a/core/src/mindustry/core/ContentLoader.java +++ b/core/src/mindustry/core/ContentLoader.java @@ -167,6 +167,10 @@ public class ContentLoader{ } public void handleContent(Content content){ + if(content instanceof Item && content.id > 127){ + throw new IllegalArgumentException("You may not have more than 127 different items total. Remove some mods."); + } + this.lastAdded = content; contentMap[content.getContentType().ordinal()].add(content); } diff --git a/core/src/mindustry/input/MobileInput.java b/core/src/mindustry/input/MobileInput.java index db6a008662..9aed8beadd 100644 --- a/core/src/mindustry/input/MobileInput.java +++ b/core/src/mindustry/input/MobileInput.java @@ -852,13 +852,7 @@ public class MobileInput extends InputHandler implements GestureListener{ //pathfind for ground units if(!flying && !type.canBoost && !(unit instanceof WaterMovec)){ - Tile on = unit.tileOn(); - if(on != null && !on.solid()){ - Tile to = pathfinder.getTargetTile(unit.tileOn(), unit.team, targetPos); - if(to != null){ - movement.set(to).sub(unit).setLength(speed); - } - } + movement.set(targetPos).sub(unit).limit(speed); } if(player.within(targetPos, attractDst)){ diff --git a/core/src/mindustry/mod/Mods.java b/core/src/mindustry/mod/Mods.java index 03e994d757..2a87330c82 100644 --- a/core/src/mindustry/mod/Mods.java +++ b/core/src/mindustry/mod/Mods.java @@ -588,59 +588,68 @@ public class Mods implements Loadable{ private LoadedMod loadMod(Fi sourceFile) throws Exception{ Time.mark(); - Fi zip = sourceFile.isDirectory() ? sourceFile : new ZipFi(sourceFile); - if(zip.list().length == 1 && zip.list()[0].isDirectory()){ - zip = zip.list()[0]; - } + ZipFi rootZip = null; - Fi metaf = zip.child("mod.json").exists() ? zip.child("mod.json") : zip.child("mod.hjson").exists() ? zip.child("mod.hjson") : zip.child("plugin.json"); - if(!metaf.exists()){ - Log.warn("Mod @ doesn't have a 'mod.json'/'mod.hjson'/'plugin.json' file, skipping.", sourceFile); - throw new IllegalArgumentException("Invalid file: No mod.json found."); - } - - ModMeta meta = json.fromJson(ModMeta.class, Jval.read(metaf.readString()).toString(Jformat.plain)); - meta.cleanup(); - String camelized = meta.name.replace(" ", ""); - String mainClass = meta.main == null ? camelized.toLowerCase() + "." + camelized + "Mod" : meta.main; - String baseName = meta.name.toLowerCase().replace(" ", "-"); - - if(mods.contains(m -> m.name.equals(baseName))){ - throw new IllegalArgumentException("A mod with the name '" + baseName + "' is already imported."); - } - - Mod mainMod; - - Fi mainFile = zip; - String[] path = (mainClass.replace('.', '/') + ".class").split("/"); - for(String str : path){ - if(!str.isEmpty()){ - mainFile = mainFile.child(str); - } - } - - //make sure the main class exists before loading it; if it doesn't just don't put it there - if(mainFile.exists()){ - //mobile versions don't support class mods - if(mobile){ - throw new IllegalArgumentException("Java class mods are not supported on mobile."); + try{ + Fi zip = sourceFile.isDirectory() ? sourceFile : (rootZip = new ZipFi(sourceFile)); + if(zip.list().length == 1 && zip.list()[0].isDirectory()){ + zip = zip.list()[0]; } - URLClassLoader classLoader = new URLClassLoader(new URL[]{sourceFile.file().toURI().toURL()}, ClassLoader.getSystemClassLoader()); - Class main = classLoader.loadClass(mainClass); - metas.put(main, meta); - mainMod = (Mod)main.getDeclaredConstructor().newInstance(); - }else{ - mainMod = null; - } + Fi metaf = zip.child("mod.json").exists() ? zip.child("mod.json") : zip.child("mod.hjson").exists() ? zip.child("mod.hjson") : zip.child("plugin.json"); + if(!metaf.exists()){ + Log.warn("Mod @ doesn't have a 'mod.json'/'mod.hjson'/'plugin.json' file, skipping.", sourceFile); + throw new IllegalArgumentException("Invalid file: No mod.json found."); + } - //all plugins are hidden implicitly - if(mainMod instanceof Plugin){ - meta.hidden = true; - } + ModMeta meta = json.fromJson(ModMeta.class, Jval.read(metaf.readString()).toString(Jformat.plain)); + meta.cleanup(); + String camelized = meta.name.replace(" ", ""); + String mainClass = meta.main == null ? camelized.toLowerCase() + "." + camelized + "Mod" : meta.main; + String baseName = meta.name.toLowerCase().replace(" ", "-"); - Log.info("Loaded mod '@' in @", meta.name, Time.elapsed()); - return new LoadedMod(sourceFile, zip, mainMod, meta); + if(mods.contains(m -> m.name.equals(baseName))){ + throw new IllegalArgumentException("A mod with the name '" + baseName + "' is already imported."); + } + + Mod mainMod; + + Fi mainFile = zip; + String[] path = (mainClass.replace('.', '/') + ".class").split("/"); + for(String str : path){ + if(!str.isEmpty()){ + mainFile = mainFile.child(str); + } + } + + //make sure the main class exists before loading it; if it doesn't just don't put it there + if(mainFile.exists()){ + //mobile versions don't support class mods + if(mobile){ + throw new IllegalArgumentException("Java class mods are not supported on mobile."); + } + + URLClassLoader classLoader = new URLClassLoader(new URL[]{sourceFile.file().toURI().toURL()}, ClassLoader.getSystemClassLoader()); + Class main = classLoader.loadClass(mainClass); + metas.put(main, meta); + mainMod = (Mod)main.getDeclaredConstructor().newInstance(); + }else{ + mainMod = null; + } + + //all plugins are hidden implicitly + if(mainMod instanceof Plugin){ + meta.hidden = true; + } + + Log.info("Loaded mod '@' in @", meta.name, Time.elapsed()); + return new LoadedMod(sourceFile, zip, mainMod, meta); + + }catch(Exception e){ + //delete root zip file so it can be closed on windows + if(rootZip != null) rootZip.delete(); + throw e; + } } /** Represents a mod's state. May be a jar file, folder or zip. */