diff --git a/core/src/io/anuke/mindustry/core/ContentLoader.java b/core/src/io/anuke/mindustry/core/ContentLoader.java index de3b1550e7..0f74193762 100644 --- a/core/src/io/anuke/mindustry/core/ContentLoader.java +++ b/core/src/io/anuke/mindustry/core/ContentLoader.java @@ -16,7 +16,6 @@ import io.anuke.mindustry.entities.effect.ItemDrop; import io.anuke.mindustry.entities.effect.Lightning; import io.anuke.mindustry.entities.effect.Puddle; import io.anuke.mindustry.entities.traits.TypeTrait; -import io.anuke.mindustry.entities.units.UnitType; import io.anuke.mindustry.game.Content; import io.anuke.mindustry.game.ContentList; import io.anuke.mindustry.game.MappableContent; @@ -204,9 +203,9 @@ public class ContentLoader{ return (T)temporaryMapper.get(type.ordinal()).get(id); } - if(id < 0){ //offset negative values by 256, as they are probably a product of byte overflow - id += 256; - } + //offset negative values by 256, as they are probably a product of byte overflow + if(id < 0) id += 256; + if(id >= contentMap[type.ordinal()].size || id < 0){ throw new RuntimeException("No " + type.name() + " with ID '" + id + "' found!"); } @@ -236,7 +235,7 @@ public class ContentLoader{ } public Array items(){ - return getBy(ContentType.block); + return getBy(ContentType.item); } public Item item(int id){ @@ -259,14 +258,6 @@ public class ContentLoader{ return (BulletType) getByID(ContentType.bullet, id); } - public Array units(){ - return getBy(ContentType.unit); - } - - public UnitType unit(int id){ - return (UnitType) getByID(ContentType.unit, id); - } - /** * Registers sync IDs for all types of sync entities. * Do not register units here! diff --git a/core/src/io/anuke/mindustry/core/Logic.java b/core/src/io/anuke/mindustry/core/Logic.java index 71fb6e5826..57dd7b1644 100644 --- a/core/src/io/anuke/mindustry/core/Logic.java +++ b/core/src/io/anuke/mindustry/core/Logic.java @@ -91,7 +91,7 @@ public class Logic extends Module{ //this never triggers in PvP; only for checking sector game-overs private void checkGameOver(){ - if(state.teams.get(defaultTeam).cores.size == 0 && !state.gameOver){ + if(!state.mode.isPvp && state.teams.get(defaultTeam).cores.size == 0 && !state.gameOver){ state.gameOver = true; Events.fire(new GameOverEvent()); } diff --git a/core/src/io/anuke/mindustry/entities/units/BaseUnit.java b/core/src/io/anuke/mindustry/entities/units/BaseUnit.java index 99b181679c..392cf90542 100644 --- a/core/src/io/anuke/mindustry/entities/units/BaseUnit.java +++ b/core/src/io/anuke/mindustry/entities/units/BaseUnit.java @@ -17,6 +17,7 @@ import io.anuke.mindustry.game.Team; import io.anuke.mindustry.gen.Call; import io.anuke.mindustry.graphics.Palette; import io.anuke.mindustry.net.Net; +import io.anuke.mindustry.type.ContentType; import io.anuke.mindustry.type.ItemStack; import io.anuke.mindustry.type.Weapon; import io.anuke.mindustry.world.Tile; @@ -385,7 +386,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{ this.isWave = stream.readBoolean(); this.spawner = stream.readInt(); - this.type = content.unit(type); + this.type = content.getByID(ContentType.unit, type); add(); } @@ -400,7 +401,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{ public void read(DataInput data, long time) throws IOException{ float lastx = x, lasty = y, lastrot = rotation; super.readSave(data); - this.type = content.unit(data.readByte()); + this.type = content.getByID(ContentType.unit, data.readByte()); this.spawner = data.readInt(); interpolator.read(lastx, lasty, x, y, time, rotation); diff --git a/core/src/io/anuke/mindustry/ui/fragments/DebugFragment.java b/core/src/io/anuke/mindustry/ui/fragments/DebugFragment.java index d5d4545a9d..ef2022f416 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/DebugFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/DebugFragment.java @@ -10,6 +10,7 @@ import io.anuke.mindustry.entities.units.BaseUnit; import io.anuke.mindustry.entities.units.UnitType; import io.anuke.mindustry.game.Team; import io.anuke.mindustry.net.Net; +import io.anuke.mindustry.type.ContentType; import io.anuke.mindustry.ui.dialogs.FloatingDialog; import io.anuke.mindustry.ui.dialogs.GenViewDialog; import io.anuke.ucore.core.Timers; @@ -149,7 +150,7 @@ public class DebugFragment extends Fragment{ t.row(); t.addButton("spawn", () -> { FloatingDialog dialog = new FloatingDialog("debug spawn"); - for(UnitType type : content.units()){ + for(UnitType type : content.getBy(ContentType.unit)){ dialog.content().addImageButton("white", 40, () -> { BaseUnit unit = type.create(player.getTeam()); unit.setWave();