diff --git a/apps/amethyst/.credo.exs b/apps/amethyst/.credo.exs index 060eb8c..3335ccf 100644 --- a/apps/amethyst/.credo.exs +++ b/apps/amethyst/.credo.exs @@ -86,6 +86,8 @@ {Credo.Check.Readability.UnnecessaryAliasExpansion, []}, {Credo.Check.Readability.VariableNames, []}, {Credo.Check.Readability.WithSingleClause, []}, + {Credo.Check.Readability.BlockPipe, []}, + {Credo.Check.Readability.SinglePipe, []}, # ## Refactoring Opportunities @@ -106,6 +108,8 @@ {Credo.Check.Refactor.RejectReject, []}, {Credo.Check.Refactor.UnlessWithElse, []}, {Credo.Check.Refactor.WithClauses, []}, + {Credo.Check.Refactor.MapMap, []}, + {Credo.Check.Refactor.FilterReject, []}, # ## Warnings @@ -146,7 +150,6 @@ {Credo.Check.Design.DuplicatedCode, []}, {Credo.Check.Design.SkipTestWithoutComment, []}, {Credo.Check.Readability.AliasAs, []}, - {Credo.Check.Readability.BlockPipe, []}, {Credo.Check.Readability.ImplTrue, []}, {Credo.Check.Readability.MultiAlias, []}, {Credo.Check.Readability.NestedFunctionCalls, []}, @@ -154,16 +157,13 @@ {Credo.Check.Readability.OnePipePerLine, []}, {Credo.Check.Readability.SeparateAliasRequire, []}, {Credo.Check.Readability.SingleFunctionToBlockPipe, []}, - {Credo.Check.Readability.SinglePipe, []}, {Credo.Check.Readability.Specs, []}, {Credo.Check.Readability.StrictModuleLayout, []}, {Credo.Check.Readability.WithCustomTaggedTuple, []}, {Credo.Check.Refactor.ABCSize, []}, {Credo.Check.Refactor.AppendSingleItem, []}, {Credo.Check.Refactor.DoubleBooleanNegation, []}, - {Credo.Check.Refactor.FilterReject, []}, {Credo.Check.Refactor.IoPuts, []}, - {Credo.Check.Refactor.MapMap, []}, {Credo.Check.Refactor.ModuleDependencies, []}, {Credo.Check.Refactor.NegatedIsNil, []}, {Credo.Check.Refactor.PassAsyncInTestCases, []}, @@ -174,9 +174,8 @@ {Credo.Check.Warning.LeakyEnvironment, []}, {Credo.Check.Warning.MapGetUnsafePass, []}, {Credo.Check.Warning.MixEnv, []}, - {Credo.Check.Warning.UnsafeToAtom, []} - - # {Credo.Check.Refactor.MapInto, []}, + {Credo.Check.Warning.UnsafeToAtom, []}, + {Credo.Check.Refactor.MapInto, []}, # # Custom checks can be created using `mix credo.gen.check`. diff --git a/apps/amethyst/lib/states/configuration.ex b/apps/amethyst/lib/states/configuration.ex index 5c38294..50462ff 100644 --- a/apps/amethyst/lib/states/configuration.ex +++ b/apps/amethyst/lib/states/configuration.ex @@ -203,10 +203,10 @@ defmodule Amethyst.ConnectionState.Configuration do # https://gist.github.com/WinX64/ab8c7a8df797c273b32d3a3b66522906 minecraft:plains basic_biome = compound(%{ "effects" => compound(%{ - "sky_color" => int(7907327), - "water_fog_color" => int(329011), - "fog_color" => int(12638463), - "water_color" => int(4159204), + "sky_color" => int(7_907_327), + "water_fog_color" => int(329_011), + "fog_color" => int(12_638_463), + "water_color" => int(4_159_204), "mood_sound" => compound(%{ "tick_delay" => int(6000), "offset" => float(2.0), diff --git a/apps/amethyst/lib/states/macros.ex b/apps/amethyst/lib/states/macros.ex index d1644e4..c96abb9 100644 --- a/apps/amethyst/lib/states/macros.ex +++ b/apps/amethyst/lib/states/macros.ex @@ -15,6 +15,9 @@ # along with this program. If not, see . defmodule Amethyst.ConnectionState.Macros do + @moduledoc """ + Useful macros for defining packets. + """ require Logger defmacro defpacket_serverbound(name, id, version, signature, where \\ true) do quote do @@ -128,22 +131,22 @@ defmodule Amethyst.ConnectionState.Macros do def type_matches(value, :bool) when is_boolean(value), do: true def type_matches(value, :byte) when is_integer(value) and value in -128..127, do: true def type_matches(value, :ubyte) when is_integer(value) and value in 0..255, do: true - def type_matches(value, :short) when is_integer(value) and value in -32768..32767, do: true - def type_matches(value, :ushort) when is_integer(value) and value in 0..65535, do: true - def type_matches(value, :int) when is_integer(value) and value in -2147483648..2147483647, do: true - def type_matches(value, :long) when is_integer(value) and value in -9223372036854775808..9223372036854775807, do: true + def type_matches(value, :short) when is_integer(value) and value in -32_768..32_767, do: true + def type_matches(value, :ushort) when is_integer(value) and value in 0..65_535, do: true + def type_matches(value, :int) when is_integer(value) and value in -2_147_483_648..2_147_483_647, do: true + def type_matches(value, :long) when is_integer(value) and value in -9_223_372_036_854_775_808..9_223_372_036_854_775_807, do: true def type_matches(value, :float) when is_number(value), do: true def type_matches(value, :double) when is_number(value), do: true - def type_matches(value, :varint) when is_integer(value) and value in -2147483648..2147483647, do: true - def type_matches(value, :varlong) when is_integer(value) and value in -9223372036854775808..9223372036854775807, do: true + def type_matches(value, :varint) when is_integer(value) and value in -2_147_483_648..2_147_483_647, do: true + def type_matches(value, :varlong) when is_integer(value) and value in -9_223_372_036_854_775_808..9_223_372_036_854_775_807, do: true def type_matches(value, :uuid) when is_binary(value) and byte_size(value) == 36, do: true def type_matches(value, :string) when is_binary(value), do: true def type_matches(value, :raw) when is_binary(value), do: true def type_matches(value, :byte_array) when is_binary(value), do: true def type_matches({x, y, z}, :position) when - is_integer(x) and x in -33554432..33554431 and + is_integer(x) and x in -33_554_432..33_554_431 and is_integer(y) and y in -2048..2047 and - is_integer(z) and z in -33554432..33554431, do: true + is_integer(z) and z in -33_554_432..33_554_431, do: true def type_matches(value, :nbt), do: Amethyst.NBT.Write.check_type(value) def type_matches(value, :json) do case Jason.encode(value) do diff --git a/apps/example_game/lib/example/game.ex b/apps/example_game/lib/example/game.ex index d24d7e9..e727907 100644 --- a/apps/example_game/lib/example/game.ex +++ b/apps/example_game/lib/example/game.ex @@ -2,6 +2,10 @@ defmodule Example.Game do require Logger @behaviour Amethyst.Game + @moduledoc """ + Example game used for testing Amethyst. + """ + @impl true def instantiate(supervisor) do Logger.info("The supervisor for this game is at #{inspect(supervisor)}")