diff --git a/src/main/java/com/reider745/behavior/entities/formats/tags/components/attack/NearestAttackableTarget.java b/src/main/java/com/reider745/behavior/entities/formats/tags/components/attack/NearestAttackableTarget.java index 7522a2e9..96817aec 100644 --- a/src/main/java/com/reider745/behavior/entities/formats/tags/components/attack/NearestAttackableTarget.java +++ b/src/main/java/com/reider745/behavior/entities/formats/tags/components/attack/NearestAttackableTarget.java @@ -46,17 +46,19 @@ public class NearestAttackableTarget extends ComponentsTag implements IUpdateEnt public Filters(JSONObject json){ max_dist = json.getInt("max_dist"); - attack_interval = json.getInt("attack_interval"); + attack_interval = json.optInt("attack_interval", 40); - final JSONArray any_of = json.getJSONObject("filters").getJSONArray("any_of"); - for(int i = 0;i < any_of.length();i++){ - JSONObject condition = any_of.getJSONObject(i); + final JSONArray any_of = json.getJSONObject("filters").optJSONArray("any_of", null); + if(any_of != null){ + for(int i = 0;i < any_of.length();i++){ + JSONObject condition = any_of.getJSONObject(i); - switch (condition.getString("test")){ - case "is_family" -> - filters.add(new IsFamilyCondition(condition)); - default -> - throw new RuntimeException("Not support NearestAttackableTarget.Filters"); + switch (condition.getString("test")){ + case "is_family" -> + filters.add(new IsFamilyCondition(condition)); + default -> + throw new RuntimeException("Not support NearestAttackableTarget.Filters"); + } } } } diff --git a/src/main/java/com/reider745/behavior/entities/formats/tags/components/life/BreathableComponent.java b/src/main/java/com/reider745/behavior/entities/formats/tags/components/life/BreathableComponent.java index 3e6d01b3..5bf2ff51 100644 --- a/src/main/java/com/reider745/behavior/entities/formats/tags/components/life/BreathableComponent.java +++ b/src/main/java/com/reider745/behavior/entities/formats/tags/components/life/BreathableComponent.java @@ -21,7 +21,7 @@ public class BreathableComponent extends ComponentsTag implements IUpdateEntity if(json instanceof JSONObject jsonObject) { final BreathableComponent component = new BreathableComponent(); - component.totalSupply = jsonObject.getInt("total_supply"); + component.totalSupply = jsonObject.optInt("total_supply", jsonObject.optInt("totalSupply", 20)); component.suffocateTime = jsonObject.optInt("suffocate_time", 0); component.inhaleTime = jsonObject.optDouble("inhale_time", 2.0); component.generatesBubbles = jsonObject.optBoolean("generates_bubbles", false); diff --git a/src/main/java/com/reider745/behavior/recipes/RecipesShapedContent.java b/src/main/java/com/reider745/behavior/recipes/RecipesShapedContent.java index 30f6698e..fed08e2a 100644 --- a/src/main/java/com/reider745/behavior/recipes/RecipesShapedContent.java +++ b/src/main/java/com/reider745/behavior/recipes/RecipesShapedContent.java @@ -39,7 +39,7 @@ public class RecipesShapedContent extends BehaviorContent { } } - throw new RuntimeException("Not implemented yet"); + throw new RuntimeException("Not implemented yet: " + json); } @Override diff --git a/src/main/java/com/reider745/hooks/block/BlockPalette.java b/src/main/java/com/reider745/hooks/block/BlockPalette.java index cc11b09f..e686911c 100644 --- a/src/main/java/com/reider745/hooks/block/BlockPalette.java +++ b/src/main/java/com/reider745/hooks/block/BlockPalette.java @@ -21,7 +21,6 @@ import com.reider745.block.BlockStateStorage; import com.reider745.block.CustomBlock; import com.reider745.block.wall.BlockWall; import com.zhekasmirnov.horizon.runtime.logger.Logger; - import it.unimi.dsi.fastutil.Hash; import it.unimi.dsi.fastutil.ints.Int2IntMap; import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; @@ -218,7 +217,10 @@ public class BlockPalette { final JSONObject EMPTY = new JSONObject(); JSONObject blockMapping = EMPTY; try { - blockMapping = new JSONObject(Files.readString(new File("block_mapping.json").toPath())); + File file = new File("block_mapping.json"); + if(file.exists()) { + blockMapping = new JSONObject(Files.readString(file.toPath())); + } } catch (Exception ex) { Logger.warning("Malformed block state mappings: " + ex.getMessage()); }