├── resources
├── anchors
│ └── java.json
├── time_scalars
│ └── java.json
├── structure_mirrors
│ ├── bedrock.json
│ └── java.json
├── sorts
│ └── java.json
├── gamemodes
│ ├── java.json
│ ├── bedrock.json
│ └── java-test.json
├── operations
│ └── java.json
├── objective_criteria
│ └── bedrock.json
├── structure_rotations
│ ├── java.json
│ └── bedrock.json
├── scoreboard_slots
│ ├── bedrock.json
│ └── java.json
├── colours
│ └── java.json
├── item_slots
│ └── bedrock.json
├── mob_effects
│ └── java.json
├── enchantments
│ └── java.json
├── definitions-debug.json
├── data-debug.json
├── definitions.json
├── components
│ └── bedrock.json
└── item_components
│ └── bedrock.json
└── FunctionAnalyser
├── UserInterface
├── command_block.ico
├── ViewModels
│ ├── SortTypeViewModel.cs
│ ├── CommandVersionViewModel.cs
│ ├── CrashWindowViewModel.cs
│ └── UpdateWindowViewModel.cs
├── AssemblyInfo.cs
├── Views
│ └── CrashWindow.xaml.cs
├── UserInterface.csproj
└── UserInterface.csproj.user
├── Utilities
├── Utilities.csproj
├── EnumExtensions.cs
└── Generic.cs
├── AdvancedText
├── AdvancedText.csproj
└── ILogger.cs
├── CommandParser
├── Minecraft
│ ├── Nbt
│ │ ├── Tags
│ │ │ ├── INbtCollectionTag.cs
│ │ │ ├── INbtTag.cs
│ │ │ ├── StringNbtTag.cs
│ │ │ ├── IntegerNbtTag.cs
│ │ │ ├── LongNbtTag.cs
│ │ │ ├── FloatNbtTag.cs
│ │ │ ├── ShortNbtTag.cs
│ │ │ ├── DoubleNbtTag.cs
│ │ │ ├── ByteNbtTag.cs
│ │ │ ├── CompoundNbtTag.cs
│ │ │ ├── ByteArrayNbtTag.cs
│ │ │ ├── LongArrayNbtTag.cs
│ │ │ ├── IntegerArrayNbtTag.cs
│ │ │ └── ListNbtTag.cs
│ │ ├── Path
│ │ │ └── NbtPath.cs
│ │ └── NbtUtilities.cs
│ ├── Coordinates
│ │ ├── ICoordinates.cs
│ │ ├── Rotation.cs
│ │ ├── Angle.cs
│ │ ├── WorldCoordinate.cs
│ │ ├── WorldCoordinates.cs
│ │ └── LocalCoordinates.cs
│ └── GameType.cs
├── Arguments
│ ├── IArgument.cs
│ ├── BooleanArgument.cs
│ ├── NbtTagArgument.cs
│ ├── CompoundTagArgument.cs
│ ├── ResourceLocationArgument.cs
│ ├── ScoreboardSlotArgument.cs
│ ├── TeamArgument.cs
│ ├── ObjectiveCriterionArgument.cs
│ ├── RotationArgument.cs
│ ├── Vec2Argument.cs
│ ├── ColumnPosArgument.cs
│ ├── BiomeArgument.cs
│ ├── SoundArgument.cs
│ ├── RecipeArgument.cs
│ ├── BossbarArgument.cs
│ ├── StorageArgument.cs
│ ├── AttributeArgument.cs
│ ├── DimensionArgument.cs
│ ├── LootTableArgument.cs
│ ├── PredicateArgument.cs
│ ├── AdvancementArgument.cs
│ ├── ItemModifierArgument.cs
│ ├── Vec3Argument.cs
│ ├── BlockPosArgument.cs
│ ├── IntegerRangeArgument.cs
│ ├── ColourArgument.cs
│ ├── FloatRangeArgument.cs
│ ├── DoubleRangeArgument.cs
│ ├── AngleArgument.cs
│ ├── FunctionArgument.cs
│ ├── OperationArgument.cs
│ ├── MobEffectArgument.cs
│ ├── ItemArgument.cs
│ ├── BlockArgument.cs
│ ├── GamemodeArgument.cs
│ ├── ItemEnchantmentArgument.cs
│ ├── ItemSlotArgument.cs
│ ├── EntityAnchorArgument.cs
│ ├── UuidArgument.cs
│ ├── ComponentArgument.cs
│ ├── ItemComponentArgument.cs
│ ├── ObjectiveArgument.cs
│ ├── EntitySummonArgument.cs
│ ├── TimeArgument.cs
│ ├── SwizzleArgument.cs
│ ├── StructureMirrorArgument.cs
│ └── StructureRotationArgument.cs
├── Results
│ ├── Arguments
│ │ ├── Team.cs
│ │ ├── Anchor.cs
│ │ ├── Colour.cs
│ │ ├── ItemSlot.cs
│ │ ├── Objective.cs
│ │ ├── Operation.cs
│ │ ├── ScoreboardSlot.cs
│ │ ├── StructureMirror.cs
│ │ ├── Biome.cs
│ │ ├── Sound.cs
│ │ ├── StructureRotation.cs
│ │ ├── Recipe.cs
│ │ ├── Bossbar.cs
│ │ ├── Storage.cs
│ │ ├── MobEffect.cs
│ │ ├── Attribute.cs
│ │ ├── Dimension.cs
│ │ ├── LootTable.cs
│ │ ├── Predicate.cs
│ │ ├── Advancement.cs
│ │ ├── Enchantment.cs
│ │ ├── ItemModifier.cs
│ │ ├── Component.cs
│ │ ├── Time.cs
│ │ ├── ItemComponent.cs
│ │ ├── Function.cs
│ │ ├── ObjectiveCriterion.cs
│ │ ├── Message.cs
│ │ ├── Entity.cs
│ │ ├── Literal.cs
│ │ ├── ScoreHolder.cs
│ │ ├── Particle.cs
│ │ ├── Item.cs
│ │ ├── Range.cs
│ │ └── EntitySelector.cs
│ ├── ParseResults.cs
│ ├── CommandResults.cs
│ └── ReadResults.cs
├── Parsers
│ ├── JsonParser
│ │ ├── JsonArguments
│ │ │ ├── IJsonArgument.cs
│ │ │ ├── JsonNull.cs
│ │ │ ├── JsonNumber.cs
│ │ │ ├── JsonBoolean.cs
│ │ │ └── JsonString.cs
│ │ ├── JsonArgumentType.cs
│ │ └── JsonCharacterProvider.cs
│ ├── ComponentParser
│ │ └── ComponentArguments
│ │ │ ├── ComponentAny.cs
│ │ │ ├── ComponentRoot.cs
│ │ │ ├── ComponentNumber.cs
│ │ │ ├── ComponentString.cs
│ │ │ ├── ComponentRootObject.cs
│ │ │ ├── ComponentObject.cs
│ │ │ ├── ComponentUuid.cs
│ │ │ ├── ComponentArrayOrRoot.cs
│ │ │ └── ComponentResourceLocation.cs
│ └── ScoreboardSlotParser.cs
├── CommandParser.csproj
├── Collections
│ ├── BlockState.cs
│ ├── Sorts.cs
│ ├── Anchors.cs
│ ├── Colours.cs
│ ├── ItemSlots.cs
│ ├── Operations.cs
│ ├── StructureMirrors.cs
│ ├── StructureRotations.cs
│ ├── TimeScalars.cs
│ ├── Items.cs
│ ├── Entities.cs
│ ├── MobEffects.cs
│ ├── Enchantments.cs
│ ├── ScoreboardSlots.cs
│ ├── EntitySelectorOptions.cs
│ ├── Particles.cs
│ ├── Gamemodes.cs
│ ├── Blocks.cs
│ ├── Components.cs
│ └── ScoreboardSlot.cs
├── Providers
│ ├── NodeBuilder.cs
│ └── NumberProvider.cs
├── Tree
│ └── RootNode.cs
├── Context
│ ├── ParsedArgument.cs
│ └── Range.cs
├── Converters
│ ├── AbstractJsonConverter.cs
│ └── NodeContainerConverter.cs
├── DispatcherResources.cs
└── IStringReader.cs
├── ErrorCraft.FunctionAnalyser.UI.Avalonia
├── Assets
│ └── avalonia-logo.ico
├── Controls
│ ├── BorderedPanel.axaml.cs
│ └── BorderedPanel.axaml
├── ViewModels
│ ├── ViewModelBase.cs
│ └── MainWindowViewModel.cs
├── App.axaml
├── App.axaml.cs
├── ViewLocator.cs
├── Program.cs
└── Views
│ └── MainWindow.axaml
├── ErrorCraft.CommandParser
├── ErrorCraft.CommandParser.csproj
├── IStringReader.cs
└── StringReader.cs
├── FunctionAnalyser
├── Results
│ ├── IResult.cs
│ ├── SortType.cs
│ ├── Command.cs
│ ├── SimpleResult.cs
│ ├── SelectorCount.cs
│ └── SelectorResult.cs
├── Builders
│ ├── Collections
│ │ ├── IBuilder.cs
│ │ ├── GamemodesBuilder.cs
│ │ ├── CommandsBuilder.cs
│ │ ├── ItemsBuilder.cs
│ │ ├── SortsBuilder.cs
│ │ ├── AnchorsBuilder.cs
│ │ ├── ColoursBuilder.cs
│ │ ├── EntitiesBuilder.cs
│ │ ├── ItemSlotsBuilder.cs
│ │ ├── MobEffectsBuilder.cs
│ │ ├── OperationsBuilder.cs
│ │ ├── EnchantmentsBuilder.cs
│ │ ├── StructureMirrorsBuilder.cs
│ │ ├── BlocksBuilder.cs
│ │ ├── StructureRotationsBuilder.cs
│ │ ├── TimeScalarsBuilder.cs
│ │ ├── ParticlesBuilder.cs
│ │ ├── ScoreboardSlotsBuilder.cs
│ │ └── SelectorArgumentsBuilder.cs
│ ├── ResponseException.cs
│ └── Versions
│ │ └── VersionResources.cs
├── FunctionProgress.cs
├── VersionName.cs
├── FunctionOptions.cs
└── FunctionAnalyser.csproj
├── ProgramUpdater
├── Version.cs
├── ProgramUpdater.csproj
├── Assets.cs
└── Converters
│ └── TagNameConverter.cs
├── Tests
├── Tests.csproj
├── Tree
│ ├── ArgumentNodeTests.cs
│ └── LiteralNodeTests.cs
├── Arguments
│ ├── BiomeArgumentTests.cs
│ ├── SoundArgumentTests.cs
│ ├── RecipeArgumentTests.cs
│ ├── BossbarArgumentTests.cs
│ ├── StorageArgumentTests.cs
│ ├── FunctionArgumentTests.cs
│ ├── AttributeArgumentTests.cs
│ ├── DimensionArgumentTests.cs
│ ├── LootTableArgumentTests.cs
│ ├── PredicateArgumentTests.cs
│ ├── NbtTagArgumentTests.cs
│ ├── AdvancementArgumentTests.cs
│ ├── ItemModifierArgumentTests.cs
│ ├── ObjectiveArgumentTests.cs
│ ├── CompoundTagArgumentTests.cs
│ ├── ColourArgumentTests.cs
│ └── OperationArgumentTests.cs
└── Parsers
│ └── UuidParserTests.cs
└── ErrorCraft.CommandParser.Tests
├── ErrorCraft.CommandParser.Tests.csproj
└── StringReaderTests.cs
/resources/anchors/java.json:
--------------------------------------------------------------------------------
1 | {"values":["eyes","feet"]}
--------------------------------------------------------------------------------
/resources/time_scalars/java.json:
--------------------------------------------------------------------------------
1 | {"values":{"t":1,"s":20,"d":24000}}
--------------------------------------------------------------------------------
/resources/structure_mirrors/bedrock.json:
--------------------------------------------------------------------------------
1 | {"values":["none","x","xz","z"]}
--------------------------------------------------------------------------------
/resources/sorts/java.json:
--------------------------------------------------------------------------------
1 | {"values":["arbitrary","furthest","nearest","random"]}
--------------------------------------------------------------------------------
/resources/structure_mirrors/java.json:
--------------------------------------------------------------------------------
1 | {"values":["none","front_back","left_right"]}
--------------------------------------------------------------------------------
/resources/gamemodes/java.json:
--------------------------------------------------------------------------------
1 | {"values":["adventure","creative","spectator","survival"]}
--------------------------------------------------------------------------------
/resources/operations/java.json:
--------------------------------------------------------------------------------
1 | {"values":["=","+=","-=","*=","/=","%=","<",">","><"]}
--------------------------------------------------------------------------------
/resources/objective_criteria/bedrock.json:
--------------------------------------------------------------------------------
1 | {"normal":{"dummy":{}},"namespaced":{},"custom":[]}
--------------------------------------------------------------------------------
/resources/structure_rotations/java.json:
--------------------------------------------------------------------------------
1 | {"values":["none","clockwise_90","counterclockwise_90","180"]}
--------------------------------------------------------------------------------
/resources/structure_rotations/bedrock.json:
--------------------------------------------------------------------------------
1 | {"values":["0_degrees","90_degrees","180_degrees","270_degrees"]}
--------------------------------------------------------------------------------
/resources/gamemodes/bedrock.json:
--------------------------------------------------------------------------------
1 | {"values":["adventure","creative","spectator","survival","a","c","sp","s","0","1","2","3"]}
--------------------------------------------------------------------------------
/resources/scoreboard_slots/bedrock.json:
--------------------------------------------------------------------------------
1 | {
2 | "values": {
3 | "belowname": {},
4 | "list": {},
5 | "sidebar": {}
6 | }
7 | }
--------------------------------------------------------------------------------
/resources/gamemodes/java-test.json:
--------------------------------------------------------------------------------
1 | {"values":{"adventure":["adventure"],"creative":["creative"],"spectator":["spectator"],"survival":["survival"]}}
--------------------------------------------------------------------------------
/FunctionAnalyser/UserInterface/command_block.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErrorCraft/FunctionAnalyser/HEAD/FunctionAnalyser/UserInterface/command_block.ico
--------------------------------------------------------------------------------
/resources/scoreboard_slots/java.json:
--------------------------------------------------------------------------------
1 | {
2 | "values": {
3 | "belowName": {},
4 | "list": {},
5 | "sidebar": {"contents_optional":true,"slot_type":"colour"}
6 | }
7 | }
--------------------------------------------------------------------------------
/FunctionAnalyser/Utilities/Utilities.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/resources/colours/java.json:
--------------------------------------------------------------------------------
1 | {"values":["aqua","black","blue","dark_aqua","dark_blue","dark_gray","dark_green","dark_purple","dark_red","gold","gray","green","light_purple","red","reset","white","yellow"]}
--------------------------------------------------------------------------------
/FunctionAnalyser/AdvancedText/AdvancedText.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Minecraft/Nbt/Tags/INbtCollectionTag.cs:
--------------------------------------------------------------------------------
1 | namespace CommandParser.Minecraft.Nbt.Tags {
2 | public interface INbtCollectionTag : INbtTag {
3 | bool Add(INbtTag tag);
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/FunctionAnalyser/ErrorCraft.FunctionAnalyser.UI.Avalonia/Assets/avalonia-logo.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ErrorCraft/FunctionAnalyser/HEAD/FunctionAnalyser/ErrorCraft.FunctionAnalyser.UI.Avalonia/Assets/avalonia-logo.ico
--------------------------------------------------------------------------------
/FunctionAnalyser/ErrorCraft.CommandParser/ErrorCraft.CommandParser.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Minecraft/Nbt/Tags/INbtTag.cs:
--------------------------------------------------------------------------------
1 | namespace CommandParser.Minecraft.Nbt.Tags {
2 | public interface INbtTag {
3 | string ToSnbt();
4 | string GetName();
5 | sbyte GetId();
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/FunctionAnalyser/ErrorCraft.FunctionAnalyser.UI.Avalonia/Controls/BorderedPanel.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 |
3 | namespace ErrorCraft.FunctionAnalyser.UI.Avalonia.Controls;
4 |
5 | public class BorderedPanel : ItemsControl {
6 | }
7 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Minecraft/Coordinates/ICoordinates.cs:
--------------------------------------------------------------------------------
1 | namespace CommandParser.Minecraft.Coordinates {
2 | public interface ICoordinates {
3 | bool IsXRelative();
4 | bool IsYRelative();
5 | bool IsZRelative();
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/Results/IResult.cs:
--------------------------------------------------------------------------------
1 | using AdvancedText;
2 |
3 | namespace FunctionAnalyser.Results
4 | {
5 | public interface IResult
6 | {
7 | int GetTotal();
8 | TextComponent ToTextComponent();
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/FunctionAnalyser/ErrorCraft.CommandParser/IStringReader.cs:
--------------------------------------------------------------------------------
1 | namespace ErrorCraft.CommandParser {
2 | public interface IStringReader {
3 | string GetString();
4 | int GetCursor();
5 | bool CanRead();
6 | bool CanRead(int length);
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/Builders/Collections/IBuilder.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace FunctionAnalyser.Builders.Collections
4 | {
5 | public interface IBuilder
6 | {
7 | U Build(Dictionary resources);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/IArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Results;
2 |
3 | namespace CommandParser.Arguments
4 | {
5 | public interface IArgument
6 | {
7 | ReadResults Parse(IStringReader reader, DispatcherResources resources, out T result);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/FunctionAnalyser/ErrorCraft.FunctionAnalyser.UI.Avalonia/ViewModels/ViewModelBase.cs:
--------------------------------------------------------------------------------
1 | using ReactiveUI;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace ErrorCraft.FunctionAnalyser.UI.Avalonia.ViewModels;
7 | public class ViewModelBase : ReactiveObject {
8 | }
9 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/Team.cs:
--------------------------------------------------------------------------------
1 | namespace CommandParser.Results.Arguments
2 | {
3 | public class Team
4 | {
5 | public string Value { get; }
6 |
7 | public Team(string team)
8 | {
9 | Value = team;
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/Anchor.cs:
--------------------------------------------------------------------------------
1 | namespace CommandParser.Results.Arguments
2 | {
3 | public class Anchor
4 | {
5 | public string Value { get; }
6 |
7 | public Anchor(string anchor)
8 | {
9 | Value = anchor;
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/Colour.cs:
--------------------------------------------------------------------------------
1 | namespace CommandParser.Results.Arguments
2 | {
3 | public class Colour
4 | {
5 | public string Value { get; }
6 |
7 | public Colour(string colour)
8 | {
9 | Value = colour;
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/ItemSlot.cs:
--------------------------------------------------------------------------------
1 | namespace CommandParser.Results.Arguments
2 | {
3 | public class ItemSlot
4 | {
5 | public string Value { get; }
6 |
7 | public ItemSlot(string slot)
8 | {
9 | Value = slot;
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/Objective.cs:
--------------------------------------------------------------------------------
1 | namespace CommandParser.Results.Arguments
2 | {
3 | public class Objective
4 | {
5 | public string Name { get; }
6 |
7 | public Objective(string name)
8 | {
9 | Name = name;
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/FunctionProgress.cs:
--------------------------------------------------------------------------------
1 | namespace FunctionAnalyser
2 | {
3 | public class FunctionProgress
4 | {
5 | public double Completion { get; set; }
6 |
7 | public FunctionProgress()
8 | {
9 | Completion = 0.0d;
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/Operation.cs:
--------------------------------------------------------------------------------
1 | namespace CommandParser.Results.Arguments
2 | {
3 | public class Operation
4 | {
5 | public string Value { get; }
6 |
7 | public Operation(string operation)
8 | {
9 | Value = operation;
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/ScoreboardSlot.cs:
--------------------------------------------------------------------------------
1 | namespace CommandParser.Results.Arguments
2 | {
3 | public class ScoreboardSlot
4 | {
5 | public string Name { get; }
6 |
7 | public ScoreboardSlot(string name)
8 | {
9 | Name = name;
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/FunctionAnalyser/ErrorCraft.FunctionAnalyser.UI.Avalonia/ViewModels/MainWindowViewModel.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls.Documents;
2 |
3 | namespace ErrorCraft.FunctionAnalyser.UI.Avalonia.ViewModels;
4 |
5 | public class MainWindowViewModel : ViewModelBase {
6 | public InlineCollection Output { get; } = new InlineCollection();
7 | }
8 |
--------------------------------------------------------------------------------
/FunctionAnalyser/AdvancedText/ILogger.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace AdvancedText
4 | {
5 | public interface ILogger
6 | {
7 | void Log(TextComponent component);
8 | void Log(List component);
9 | void Clear();
10 | string GetFlatString();
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Parsers/JsonParser/JsonArguments/IJsonArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Results;
2 |
3 | namespace CommandParser.Parsers.JsonParser.JsonArguments
4 | {
5 | public interface IJsonArgument
6 | {
7 | string GetName();
8 | string AsJson();
9 | JsonArgumentType GetArgumentType();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/StructureMirror.cs:
--------------------------------------------------------------------------------
1 | namespace CommandParser.Results.Arguments
2 | {
3 | public class StructureMirror
4 | {
5 | public string Value { get; }
6 |
7 | public StructureMirror(string structureMirror)
8 | {
9 | Value = structureMirror;
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/resources/item_slots/bedrock.json:
--------------------------------------------------------------------------------
1 | {
2 | "values":[
3 | "slot.armor",
4 | "slot.armor.chest",
5 | "slot.armor.feet",
6 | "slot.armor.head",
7 | "slot.armor.legs",
8 | "slot.chest",
9 | "slot.enderchest",
10 | "slot.hotbar",
11 | "slot.inventory",
12 | "slot.saddle",
13 | "slot.weapon.mainhand",
14 | "slot.weapon.offhand"
15 | ]
16 | }
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/Biome.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 |
3 | namespace CommandParser.Results.Arguments
4 | {
5 | public class Biome
6 | {
7 | public ResourceLocation Value { get; }
8 |
9 | public Biome(ResourceLocation biome)
10 | {
11 | Value = biome;
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/Sound.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 |
3 | namespace CommandParser.Results.Arguments
4 | {
5 | public class Sound
6 | {
7 | public ResourceLocation Value { get; }
8 |
9 | public Sound(ResourceLocation sound)
10 | {
11 | Value = sound;
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/StructureRotation.cs:
--------------------------------------------------------------------------------
1 | namespace CommandParser.Results.Arguments
2 | {
3 | public class StructureRotation
4 | {
5 | public string Value { get; }
6 |
7 | public StructureRotation(string structureRotation)
8 | {
9 | Value = structureRotation;
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Minecraft/Nbt/Path/NbtPath.cs:
--------------------------------------------------------------------------------
1 | namespace CommandParser.Minecraft.Nbt.Path {
2 | public class NbtPath {
3 | private readonly string Path;
4 |
5 | public NbtPath(string path) {
6 | Path = path;
7 | }
8 |
9 | public string GetPath() {
10 | return Path;
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/Recipe.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 |
3 | namespace CommandParser.Results.Arguments
4 | {
5 | public class Recipe
6 | {
7 | public ResourceLocation Value { get; }
8 |
9 | public Recipe(ResourceLocation recipe)
10 | {
11 | Value = recipe;
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/Bossbar.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 |
3 | namespace CommandParser.Results.Arguments
4 | {
5 | public class Bossbar
6 | {
7 | public ResourceLocation Value { get; }
8 |
9 | public Bossbar(ResourceLocation bossbar)
10 | {
11 | Value = bossbar;
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/Storage.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 |
3 | namespace CommandParser.Results.Arguments
4 | {
5 | public class Storage
6 | {
7 | public ResourceLocation Value { get; }
8 |
9 | public Storage(ResourceLocation storage)
10 | {
11 | Value = storage;
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/MobEffect.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 |
3 | namespace CommandParser.Results.Arguments
4 | {
5 | public class MobEffect
6 | {
7 | public ResourceLocation Effect { get; }
8 |
9 | public MobEffect(ResourceLocation effect)
10 | {
11 | Effect = effect;
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/Attribute.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 |
3 | namespace CommandParser.Results.Arguments
4 | {
5 | public class Attribute
6 | {
7 | public ResourceLocation Value { get; }
8 |
9 | public Attribute(ResourceLocation attribute)
10 | {
11 | Value = attribute;
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/Dimension.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 |
3 | namespace CommandParser.Results.Arguments
4 | {
5 | public class Dimension
6 | {
7 | public ResourceLocation Value { get; }
8 |
9 | public Dimension(ResourceLocation dimension)
10 | {
11 | Value = dimension;
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/LootTable.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 |
3 | namespace CommandParser.Results.Arguments
4 | {
5 | public class LootTable
6 | {
7 | public ResourceLocation Value { get; }
8 |
9 | public LootTable(ResourceLocation lootTable)
10 | {
11 | Value = lootTable;
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/Predicate.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 |
3 | namespace CommandParser.Results.Arguments
4 | {
5 | public class Predicate
6 | {
7 | public ResourceLocation Value { get; }
8 |
9 | public Predicate(ResourceLocation predicate)
10 | {
11 | Value = predicate;
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/Advancement.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 |
3 | namespace CommandParser.Results.Arguments
4 | {
5 | public class Advancement
6 | {
7 | public ResourceLocation Value { get; }
8 |
9 | public Advancement(ResourceLocation advancement)
10 | {
11 | Value = advancement;
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/Enchantment.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 |
3 | namespace CommandParser.Results.Arguments
4 | {
5 | public class Enchantment
6 | {
7 | public ResourceLocation Value { get; }
8 |
9 | public Enchantment(ResourceLocation enchantment)
10 | {
11 | Value = enchantment;
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/ItemModifier.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 |
3 | namespace CommandParser.Results.Arguments
4 | {
5 | public class ItemModifier
6 | {
7 | public ResourceLocation Value { get; }
8 |
9 | public ItemModifier(ResourceLocation itemModifier)
10 | {
11 | Value = itemModifier;
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/Component.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Parsers.JsonParser.JsonArguments;
2 |
3 | namespace CommandParser.Results.Arguments
4 | {
5 | public class Component
6 | {
7 | public IJsonArgument Argument { get; }
8 |
9 | public Component(IJsonArgument argument)
10 | {
11 | Argument = argument;
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/BooleanArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Results;
2 |
3 | namespace CommandParser.Arguments
4 | {
5 | public class BooleanArgument : IArgument
6 | {
7 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out bool result)
8 | {
9 | return reader.ReadBoolean(out result);
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/Time.cs:
--------------------------------------------------------------------------------
1 | namespace CommandParser.Results.Arguments
2 | {
3 | public class Time
4 | {
5 | public int Value { get; }
6 |
7 | public Time(int time)
8 | {
9 | Value = time;
10 | }
11 |
12 | public override string ToString()
13 | {
14 | return Value.ToString();
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/ItemComponent.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Parsers.JsonParser.JsonArguments;
2 |
3 | namespace CommandParser.Results.Arguments
4 | {
5 | public class ItemComponent
6 | {
7 | public IJsonArgument Argument { get; }
8 |
9 | public ItemComponent(IJsonArgument argument)
10 | {
11 | Argument = argument;
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/VersionName.cs:
--------------------------------------------------------------------------------
1 | namespace FunctionAnalyser
2 | {
3 | public class VersionName
4 | {
5 | public string CommandName { get; }
6 | public string FancyName { get; }
7 |
8 | public VersionName(string commandName, string fancyName)
9 | {
10 | CommandName = commandName;
11 | FancyName = fancyName;
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/FunctionOptions.cs:
--------------------------------------------------------------------------------
1 | using FunctionAnalyser.Results;
2 |
3 | namespace FunctionAnalyser
4 | {
5 | public class FunctionOptions
6 | {
7 | public bool SkipFunctionOnError { get; init; }
8 | public bool ShowCommandErrors { get; init; }
9 | public bool ShowEmptyFunctions { get; init; }
10 | public SortType CommandSortType { get; init; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/Results/SortType.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 |
3 | namespace FunctionAnalyser.Results
4 | {
5 | public enum SortType
6 | {
7 | [Display(Name = "Times used")]
8 | TimesUsed = 0,
9 | [Display(Name = "Alphabetical")]
10 | Alphabetical = 1,
11 | [Display(Name = "Command length")]
12 | CommandLength = 2
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/CommandParser.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/resources/mob_effects/java.json:
--------------------------------------------------------------------------------
1 | {"values":["speed","slowness","haste","mining_fatigue","strength","instant_health","instant_damage","jump_boost","nausea","regeneration","resistance","fire_resistance","water_breathing","invisibility","blindness","night_vision","hunger","weakness","poison","wither","health_boost","absorption","saturation","glowing","levitation","luck","unluck","slow_falling","conduit_power","dolphins_grace","bad_omen","hero_of_the_village","darkness"]}
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/Function.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 |
3 | namespace CommandParser.Results.Arguments
4 | {
5 | public class Function
6 | {
7 | public ResourceLocation Location { get; }
8 | public bool IsTag { get; }
9 |
10 | public Function(ResourceLocation location, bool isTag)
11 | {
12 | Location = location;
13 | IsTag = isTag;
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/ObjectiveCriterion.cs:
--------------------------------------------------------------------------------
1 | namespace CommandParser.Results.Arguments
2 | {
3 | public class ObjectiveCriterion
4 | {
5 | public string Criterion { get; }
6 |
7 | public ObjectiveCriterion(string criterion)
8 | {
9 | Criterion = criterion;
10 | }
11 |
12 | public override string ToString()
13 | {
14 | return Criterion;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/FunctionAnalyser.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/NbtTagArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft.Nbt;
2 | using CommandParser.Minecraft.Nbt.Tags;
3 | using CommandParser.Results;
4 |
5 | namespace CommandParser.Arguments {
6 | public class NbtTagArgument : IArgument {
7 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out INbtTag result) {
8 | return new NbtParser(reader).ReadValue(out result);
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/Builders/ResponseException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Net.Http;
4 |
5 | namespace FunctionAnalyser.Builders
6 | {
7 | public class ResponseException : Exception
8 | {
9 | public ResponseException(string fileName, HttpResponseMessage response)
10 | : base($"{fileName}: {response.ReasonPhrase} ({((int)response.StatusCode).ToString(NumberFormatInfo.InvariantInfo)})") { }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/CompoundTagArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft.Nbt;
2 | using CommandParser.Minecraft.Nbt.Tags;
3 | using CommandParser.Results;
4 |
5 | namespace CommandParser.Arguments {
6 | public class CompoundTagArgument : IArgument {
7 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out INbtTag result) {
8 | return new NbtParser(reader).ReadCompound(out result);
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/ResourceLocationArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 |
4 | namespace CommandParser.Arguments
5 | {
6 | public class ResourceLocationArgument : IArgument
7 | {
8 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out ResourceLocation result)
9 | {
10 | return ResourceLocation.TryRead(reader, out result);
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/Message.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace CommandParser.Results.Arguments
4 | {
5 | public class Message
6 | {
7 | public string Text { get; }
8 | public Dictionary Selectors { get; }
9 |
10 | public Message(string text, Dictionary selectors)
11 | {
12 | Text = text;
13 | Selectors = selectors;
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/FunctionAnalyser/Utilities/EnumExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel.DataAnnotations;
3 | using static Utilities.Generic;
4 |
5 | namespace Utilities
6 | {
7 | public static class EnumExtensions
8 | {
9 | public static string GetDisplayName(this T value) where T : struct, Enum
10 | {
11 | DisplayAttribute displayAttribute = GetAttribute(value);
12 | return displayAttribute?.Name ?? value.ToString();
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/Entity.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 |
3 | namespace CommandParser.Results.Arguments
4 | {
5 | public class Entity
6 | {
7 | public ResourceLocation Value { get; }
8 | public bool IsTag { get; }
9 |
10 | public Entity(ResourceLocation value) : this(value, false) { }
11 |
12 | public Entity(ResourceLocation value, bool isTag)
13 | {
14 | Value = value;
15 | IsTag = isTag;
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Collections/BlockState.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace CommandParser.Collections
4 | {
5 | public class BlockState : Dictionary>
6 | {
7 | public bool ContainsProperty(string property)
8 | {
9 | return ContainsKey(property);
10 | }
11 |
12 | public bool PropertyContainsValue(string property, string value)
13 | {
14 | return this[property].Contains(value);
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/resources/enchantments/java.json:
--------------------------------------------------------------------------------
1 | {"values":["protection","fire_protection","feather_falling","blast_protection","projectile_protection","respiration","aqua_affinity","thorns","depth_strider","frost_walker","binding_curse","soul_speed","sharpness","smite","bane_of_arthropods","knockback","fire_aspect","looting","sweeping","efficiency","silk_touch","unbreaking","fortune","power","punch","flame","infinity","luck_of_the_sea","lure","loyalty","impaling","riptide","channeling","multishot","quick_charge","piercing","mending","vanishing_curse","swift_sneak"]}
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/ScoreboardSlotArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Parsers;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class ScoreboardSlotArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out ScoreboardSlot result)
10 | {
11 | return new ScoreboardSlotParser(reader, resources).Read(out result);
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/Results/Command.cs:
--------------------------------------------------------------------------------
1 | namespace FunctionAnalyser.Results
2 | {
3 | public class Command
4 | {
5 | public int Commands { get; set; }
6 | public int BehindExecute { get; set; }
7 |
8 | public static Command operator +(Command a, Command b)
9 | {
10 | return new Command()
11 | {
12 | Commands = a.Commands + b.Commands,
13 | BehindExecute = a.BehindExecute + b.BehindExecute
14 | };
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/TeamArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Results;
2 | using CommandParser.Results.Arguments;
3 |
4 | namespace CommandParser.Arguments
5 | {
6 | public class TeamArgument : IArgument
7 | {
8 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Team result)
9 | {
10 | ReadResults readResults = reader.ReadUnquotedString(out string team);
11 | result = new Team(team);
12 | return readResults;
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Minecraft/Coordinates/Rotation.cs:
--------------------------------------------------------------------------------
1 | namespace CommandParser.Minecraft.Coordinates {
2 | public class Rotation {
3 | public Angle YRotation { get; }
4 | public Angle XRotation { get; }
5 |
6 | public Rotation(Angle yRotation, Angle xRotation) {
7 | YRotation = yRotation;
8 | XRotation = xRotation;
9 | }
10 |
11 | public override string ToString() {
12 | return YRotation.ToString() + " " + XRotation.ToString();
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Collections/Sorts.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace CommandParser.Collections
4 | {
5 | public class Sorts
6 | {
7 | private readonly HashSet Values;
8 |
9 | public Sorts() : this(new HashSet()) { }
10 |
11 | public Sorts(HashSet values)
12 | {
13 | Values = values;
14 | }
15 |
16 | public bool Contains(string gamemode)
17 | {
18 | return Values.Contains(gamemode);
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Collections/Anchors.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace CommandParser.Collections
4 | {
5 | public class Anchors
6 | {
7 | private readonly HashSet Values;
8 |
9 | public Anchors() : this(new HashSet()) { }
10 |
11 | public Anchors(HashSet values)
12 | {
13 | Values = values;
14 | }
15 |
16 | public bool Contains(string anchor)
17 | {
18 | return Values.Contains(anchor);
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Collections/Colours.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace CommandParser.Collections
4 | {
5 | public class Colours
6 | {
7 | private readonly HashSet Values;
8 |
9 | public Colours() : this(new HashSet()) { }
10 |
11 | public Colours(HashSet values)
12 | {
13 | Values = values;
14 | }
15 |
16 | public bool Contains(string colour)
17 | {
18 | return Values.Contains(colour);
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/ObjectiveCriterionArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Parsers;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class ObjectiveCriterionArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out ObjectiveCriterion result)
10 | {
11 | return new ObjectiveCriterionParser(reader, resources).ByName(out result);
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Collections/ItemSlots.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace CommandParser.Collections
4 | {
5 | public class ItemSlots
6 | {
7 | private readonly HashSet Values;
8 |
9 | public ItemSlots() : this(new HashSet()) { }
10 |
11 | public ItemSlots(HashSet values)
12 | {
13 | Values = values;
14 | }
15 |
16 | public bool Contains(string slot)
17 | {
18 | return Values.Contains(slot);
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Collections/Operations.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace CommandParser.Collections
4 | {
5 | public class Operations
6 | {
7 | private readonly HashSet Values;
8 |
9 | public Operations() : this(new HashSet()) { }
10 |
11 | public Operations(HashSet values)
12 | {
13 | Values = values;
14 | }
15 |
16 | public bool Contains(string operation)
17 | {
18 | return Values.Contains(operation);
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Minecraft/GameType.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using Newtonsoft.Json.Converters;
3 | using System.Runtime.Serialization;
4 |
5 | namespace CommandParser.Minecraft {
6 | [JsonConverter(typeof(StringEnumConverter))]
7 | public enum GameType {
8 | [EnumMember(Value = "survival")]
9 | SURVIVAL = 0,
10 | [EnumMember(Value = "creative")]
11 | CREATIVE = 1,
12 | [EnumMember(Value = "adventure")]
13 | ADVENTURE = 2,
14 | [EnumMember(Value = "spectator")]
15 | SPECTATOR = 3
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/FunctionAnalyser/ErrorCraft.FunctionAnalyser.UI.Avalonia/App.axaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/FunctionAnalyser/UserInterface/ViewModels/SortTypeViewModel.cs:
--------------------------------------------------------------------------------
1 | using FunctionAnalyser.Results;
2 | using Utilities;
3 |
4 | namespace UserInterface.ViewModels
5 | {
6 | public class SortTypeViewModel
7 | {
8 | public SortType Value { get; }
9 | private readonly string DisplayName;
10 |
11 | public SortTypeViewModel(SortType value)
12 | {
13 | Value = value;
14 | DisplayName = value.GetDisplayName();
15 | }
16 |
17 | public override string ToString()
18 | {
19 | return DisplayName;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Collections/StructureMirrors.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace CommandParser.Collections
4 | {
5 | public class StructureMirrors
6 | {
7 | private readonly HashSet Values;
8 |
9 | public StructureMirrors() : this(new HashSet()) { }
10 |
11 | public StructureMirrors(HashSet values)
12 | {
13 | Values = values;
14 | }
15 |
16 | public bool Contains(string structureMirror)
17 | {
18 | return Values.Contains(structureMirror);
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Minecraft/Nbt/Tags/StringNbtTag.cs:
--------------------------------------------------------------------------------
1 | namespace CommandParser.Minecraft.Nbt.Tags {
2 | public class StringNbtTag : INbtTag {
3 | private readonly string Data;
4 |
5 | public StringNbtTag(string data) {
6 | Data = data;
7 | }
8 |
9 | public string GetName() {
10 | return "TAG_String";
11 | }
12 |
13 | public sbyte GetId() {
14 | return 8;
15 | }
16 |
17 | public string ToSnbt() {
18 | // Currently doesn't unescape
19 | return Data;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/ParseResults.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Context;
2 | using System.Collections.Generic;
3 |
4 | namespace CommandParser.Results
5 | {
6 | public class ParseResults
7 | {
8 | public CommandContext Context { get; }
9 | public IStringReader Reader { get; }
10 | public List Errors { get; }
11 |
12 | public ParseResults(CommandContext context, IStringReader reader, List errors)
13 | {
14 | Context = context;
15 | Reader = reader;
16 | Errors = errors;
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/RotationArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft.Coordinates;
2 | using CommandParser.Parsers.Coordinates;
3 | using CommandParser.Results;
4 | using Newtonsoft.Json;
5 |
6 | namespace CommandParser.Arguments {
7 | public class RotationArgument : IArgument {
8 | [JsonProperty("use_bedrock")]
9 | private readonly bool UseBedrock;
10 |
11 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Rotation result) {
12 | return new RotationParser(reader, UseBedrock).Parse(out result);
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Collections/StructureRotations.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace CommandParser.Collections
4 | {
5 | public class StructureRotations
6 | {
7 | private readonly HashSet Values;
8 |
9 | public StructureRotations() : this(new HashSet()) { }
10 |
11 | public StructureRotations(HashSet values)
12 | {
13 | Values = values;
14 | }
15 |
16 | public bool Contains(string structureRotation)
17 | {
18 | return Values.Contains(structureRotation);
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Collections/TimeScalars.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace CommandParser.Collections
4 | {
5 | public class TimeScalars
6 | {
7 | private readonly Dictionary Values;
8 |
9 | public TimeScalars() : this (new Dictionary()) { }
10 |
11 | public TimeScalars(Dictionary values)
12 | {
13 | Values = values;
14 | }
15 |
16 | public bool TryGetScalar(char input, out int scalar)
17 | {
18 | return Values.TryGetValue(input, out scalar);
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/CommandResults.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Context;
2 | using System.Collections.Generic;
3 |
4 | namespace CommandParser.Results
5 | {
6 | public class CommandResults
7 | {
8 | public bool Successful { get; }
9 | public CommandError Error { get; }
10 | public List Arguments { get; }
11 |
12 | public CommandResults(bool successful, CommandError error, List arguments)
13 | {
14 | Successful = successful;
15 | Error = error;
16 | Arguments = arguments;
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Collections/Items.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using System.Collections.Generic;
3 |
4 | namespace CommandParser.Collections
5 | {
6 | public class Items
7 | {
8 | private readonly HashSet Values;
9 |
10 | public Items() : this(new HashSet()) { }
11 |
12 | public Items(HashSet values)
13 | {
14 | Values = values;
15 | }
16 |
17 | public bool Contains(ResourceLocation item)
18 | {
19 | return item.IsDefaultNamespace() && Values.Contains(item.Path);
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/Vec2Argument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft.Coordinates;
2 | using CommandParser.Parsers.Coordinates;
3 | using CommandParser.Results;
4 | using Newtonsoft.Json;
5 |
6 | namespace CommandParser.Arguments {
7 | public class Vec2Argument : IArgument {
8 | [JsonProperty("use_bedrock")]
9 | private readonly bool UseBedrock;
10 |
11 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out ICoordinates result) {
12 | return new WorldCoordinatesParser(reader, UseBedrock).ParseDoubleFlat(out result);
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Collections/Entities.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using System.Collections.Generic;
3 |
4 | namespace CommandParser.Collections
5 | {
6 | public class Entities
7 | {
8 | private readonly HashSet Values;
9 |
10 | public Entities() : this(new HashSet()) { }
11 |
12 | public Entities(HashSet values)
13 | {
14 | Values = values;
15 | }
16 |
17 | public bool Contains(ResourceLocation entity)
18 | {
19 | return entity.IsDefaultNamespace() && Values.Contains(entity.Path);
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/Literal.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace CommandParser.Results.Arguments
4 | {
5 | public class Literal
6 | {
7 | public string Value { get; }
8 |
9 | public Literal(string literal)
10 | {
11 | Value = literal;
12 | }
13 |
14 | public override bool Equals(object obj)
15 | {
16 | return obj is Literal literal &&
17 | Value == literal.Value;
18 | }
19 |
20 | public override int GetHashCode()
21 | {
22 | return HashCode.Combine(Value);
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/Builders/Collections/GamemodesBuilder.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Collections;
2 | using CommandParser.Minecraft;
3 | using Newtonsoft.Json;
4 | using System.Collections.Generic;
5 |
6 | namespace FunctionAnalyser.Builders.Collections
7 | {
8 | public class GamemodesBuilder : IBuilder
9 | {
10 | [JsonProperty("values")]
11 | private readonly Dictionary> Values;
12 |
13 | public Gamemodes Build(Dictionary resources)
14 | {
15 | return new Gamemodes(Values);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/ColumnPosArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft.Coordinates;
2 | using CommandParser.Parsers.Coordinates;
3 | using CommandParser.Results;
4 | using Newtonsoft.Json;
5 |
6 | namespace CommandParser.Arguments {
7 | public class ColumnPosArgument : IArgument {
8 | [JsonProperty("use_bedrock")]
9 | private readonly bool UseBedrock;
10 |
11 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out ICoordinates result) {
12 | return new WorldCoordinatesParser(reader, UseBedrock).ParseIntegerFlat(out result);
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Collections/MobEffects.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using System.Collections.Generic;
3 |
4 | namespace CommandParser.Collections
5 | {
6 | public class MobEffects
7 | {
8 | private readonly HashSet Values;
9 |
10 | public MobEffects() : this(new HashSet()) { }
11 |
12 | public MobEffects(HashSet values)
13 | {
14 | Values = values;
15 | }
16 |
17 | public bool Contains(ResourceLocation effect)
18 | {
19 | return effect.IsDefaultNamespace() && Values.Contains(effect.Path);
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Minecraft/Coordinates/Angle.cs:
--------------------------------------------------------------------------------
1 | using System.Globalization;
2 |
3 | namespace CommandParser.Minecraft.Coordinates {
4 | public struct Angle {
5 | public float Value { get; }
6 | public bool IsRelative { get; }
7 |
8 | public Angle(float value, bool isRelative) {
9 | Value = value;
10 | IsRelative = isRelative;
11 | }
12 |
13 | public override string ToString() {
14 | string value = Value.ToString(NumberFormatInfo.InvariantInfo);
15 | if (IsRelative) return "~" + value;
16 | else return value;
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/resources/definitions-debug.json:
--------------------------------------------------------------------------------
1 | {
2 | "anchors": ["java"],
3 | "blocks": ["java"],
4 | "colours": ["java"],
5 | "commands": ["java","java-test"],
6 | "components": ["java"],
7 | "enchantments": ["java"],
8 | "entities": ["java"],
9 | "gamemodes": ["java-test"],
10 | "item_slots": ["java"],
11 | "items": ["java"],
12 | "mob_effects": ["java"],
13 | "objective_criteria": ["java"],
14 | "operations": ["java"],
15 | "particles": ["java"],
16 | "scoreboard_slots": ["java"],
17 | "selector_arguments": ["java"],
18 | "sorts": ["java"],
19 | "structure_mirrors": ["java"],
20 | "structure_rotations": ["java"],
21 | "time_scalars": ["java"]
22 | }
23 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Minecraft/Nbt/Tags/IntegerNbtTag.cs:
--------------------------------------------------------------------------------
1 | using static CommandParser.Minecraft.Nbt.NbtUtilities;
2 |
3 | namespace CommandParser.Minecraft.Nbt.Tags {
4 | public class IntegerNbtTag : INbtTag {
5 | private readonly int Data;
6 |
7 | public IntegerNbtTag(int data) {
8 | Data = data;
9 | }
10 |
11 | public string GetName() {
12 | return "TAG_Integer";
13 | }
14 |
15 | public sbyte GetId() {
16 | return 3;
17 | }
18 |
19 | public string ToSnbt() {
20 | return Data.ToString(NbtNumberFormatInfo);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Minecraft/Nbt/Tags/LongNbtTag.cs:
--------------------------------------------------------------------------------
1 | using static CommandParser.Minecraft.Nbt.NbtUtilities;
2 |
3 | namespace CommandParser.Minecraft.Nbt.Tags {
4 | public class LongNbtTag : INbtTag {
5 | private readonly long Data;
6 |
7 | public LongNbtTag(long data) {
8 | Data = data;
9 | }
10 |
11 | public string GetName() {
12 | return "TAG_Long";
13 | }
14 |
15 | public sbyte GetId() {
16 | return 4;
17 | }
18 |
19 | public string ToSnbt() {
20 | return Data.ToString(NbtNumberFormatInfo) + "L";
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Providers/NodeBuilder.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Arguments;
2 | using CommandParser.Tree;
3 |
4 | namespace CommandParser.Providers
5 | {
6 | public static class NodeBuilder
7 | {
8 | public static LiteralNode Literal(string literal, bool executable, string[] redirect)
9 | {
10 | return new LiteralNode(literal, executable, redirect);
11 | }
12 |
13 | public static ArgumentNode Argument(string name, IArgument type, bool executable, string[] redirect)
14 | {
15 | return new ArgumentNode(name, type, executable, redirect);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/FunctionAnalyser/ProgramUpdater/Version.cs:
--------------------------------------------------------------------------------
1 | using ProgramUpdater.Converters;
2 | using Newtonsoft.Json;
3 |
4 | namespace ProgramUpdater
5 | {
6 | public class Version
7 | {
8 | [JsonProperty("tag_name")]
9 | [JsonConverter(typeof(TagNameConverter))]
10 | private readonly System.Version VersionTag;
11 |
12 | [JsonProperty("assets")]
13 | private readonly Assets[] Assets;
14 |
15 | public System.Version GetVersionTag()
16 | {
17 | return VersionTag;
18 | }
19 |
20 | public Assets[] GetAssets()
21 | {
22 | return Assets;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Minecraft/Nbt/Tags/FloatNbtTag.cs:
--------------------------------------------------------------------------------
1 | using static CommandParser.Minecraft.Nbt.NbtUtilities;
2 |
3 | namespace CommandParser.Minecraft.Nbt.Tags {
4 | public class FloatNbtTag : INbtTag {
5 | private readonly float Data;
6 |
7 | public FloatNbtTag(float data) {
8 | Data = data;
9 | }
10 |
11 | public string GetName() {
12 | return "TAG_Float";
13 | }
14 |
15 | public sbyte GetId() {
16 | return 5;
17 | }
18 |
19 | public string ToSnbt() {
20 | return Data.ToString(NbtNumberFormatInfo) + "f";
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Minecraft/Nbt/Tags/ShortNbtTag.cs:
--------------------------------------------------------------------------------
1 | using static CommandParser.Minecraft.Nbt.NbtUtilities;
2 |
3 | namespace CommandParser.Minecraft.Nbt.Tags {
4 | public class ShortNbtTag : INbtTag {
5 | private readonly short Data;
6 |
7 | public ShortNbtTag(short data) {
8 | Data = data;
9 | }
10 |
11 | public string GetName() {
12 | return "TAG_Short";
13 | }
14 |
15 | public sbyte GetId() {
16 | return 2;
17 | }
18 |
19 | public string ToSnbt() {
20 | return Data.ToString(NbtNumberFormatInfo) + "s";
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/FunctionAnalyser/UserInterface/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly: ThemeInfo(
4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5 | //(used if a resource is not found in the page,
6 | // or application resource dictionaries)
7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8 | //(used if a resource is not found in the page,
9 | // app, or any theme specific resource dictionaries)
10 | )]
11 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/BiomeArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class BiomeArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Biome result)
10 | {
11 | result = default;
12 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation biome);
13 | if (readResults.Successful) result = new Biome(biome);
14 | return readResults;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/SoundArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class SoundArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Sound result)
10 | {
11 | result = default;
12 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation sound);
13 | if (readResults.Successful) result = new Sound(sound);
14 | return readResults;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Minecraft/Nbt/Tags/DoubleNbtTag.cs:
--------------------------------------------------------------------------------
1 | using static CommandParser.Minecraft.Nbt.NbtUtilities;
2 |
3 | namespace CommandParser.Minecraft.Nbt.Tags {
4 | public class DoubleNbtTag : INbtTag {
5 | private readonly double Data;
6 |
7 | public DoubleNbtTag(double data) {
8 | Data = data;
9 | }
10 |
11 | public string GetName() {
12 | return "TAG_Double";
13 | }
14 |
15 | public sbyte GetId() {
16 | return 6;
17 | }
18 |
19 | public string ToSnbt() {
20 | return Data.ToString(NbtNumberFormatInfo) + "d";
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/RecipeArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class RecipeArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Recipe result)
10 | {
11 | result = default;
12 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation recipe);
13 | if (readResults.Successful) result = new Recipe(recipe);
14 | return readResults;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Collections/Enchantments.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using System.Collections.Generic;
3 |
4 | namespace CommandParser.Collections
5 | {
6 | public class Enchantments
7 | {
8 | private readonly HashSet Values;
9 |
10 | public Enchantments() : this(new HashSet()) { }
11 |
12 | public Enchantments(HashSet values)
13 | {
14 | Values = values;
15 | }
16 |
17 | public bool Contains(ResourceLocation enchantment)
18 | {
19 | return enchantment.IsDefaultNamespace() && Values.Contains(enchantment.Path);
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Parsers/ComponentParser/ComponentArguments/ComponentAny.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Collections;
2 | using CommandParser.Parsers.JsonParser.JsonArguments;
3 | using CommandParser.Results;
4 |
5 | namespace CommandParser.Parsers.ComponentParser.ComponentArguments
6 | {
7 | public class ComponentAny : ComponentArgument
8 | {
9 | public override ReadResults Validate(JsonObject obj, string key, ComponentReader componentReader, Components components, IStringReader reader, int start, DispatcherResources resources)
10 | {
11 | return componentReader.ValidateContents(obj.GetChild(key), components);
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/FunctionAnalyser/ProgramUpdater/ProgramUpdater.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/BossbarArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class BossbarArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Bossbar result)
10 | {
11 | result = default;
12 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation bossbar);
13 | if (readResults.Successful) result = new Bossbar(bossbar);
14 | return readResults;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/StorageArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class StorageArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Storage result)
10 | {
11 | result = default;
12 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation storage);
13 | if (readResults.Successful) result = new Storage(storage);
14 | return readResults;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Minecraft/Coordinates/WorldCoordinate.cs:
--------------------------------------------------------------------------------
1 | using System.Globalization;
2 |
3 | namespace CommandParser.Minecraft.Coordinates {
4 | public struct WorldCoordinate {
5 | public double Value { get; }
6 | public bool IsRelative { get; }
7 |
8 | public WorldCoordinate(double value, bool isRelative) {
9 | Value = value;
10 | IsRelative = isRelative;
11 | }
12 |
13 | public override string ToString() {
14 | string value = Value.ToString(NumberFormatInfo.InvariantInfo);
15 | if (IsRelative) return "~" + value;
16 | else return value;
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Parsers/ComponentParser/ComponentArguments/ComponentRoot.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Collections;
2 | using CommandParser.Parsers.JsonParser.JsonArguments;
3 | using CommandParser.Results;
4 |
5 | namespace CommandParser.Parsers.ComponentParser.ComponentArguments
6 | {
7 | public class ComponentRoot : ComponentArgument
8 | {
9 | public override ReadResults Validate(JsonObject obj, string key, ComponentReader componentReader, Components components, IStringReader reader, int start, DispatcherResources resources)
10 | {
11 | return componentReader.ValidateFromRoot(obj.GetChild(key), components);
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Collections/ScoreboardSlots.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace CommandParser.Collections
4 | {
5 | public class ScoreboardSlots
6 | {
7 | private readonly Dictionary Values;
8 |
9 | public ScoreboardSlots() : this(new Dictionary()) { }
10 |
11 | public ScoreboardSlots(Dictionary values)
12 | {
13 | Values = values;
14 | }
15 |
16 | public bool TryGetSlot(string slot, out ScoreboardSlot result)
17 | {
18 | return Values.TryGetValue(slot, out result);
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Parsers/JsonParser/JsonArguments/JsonNull.cs:
--------------------------------------------------------------------------------
1 | namespace CommandParser.Parsers.JsonParser.JsonArguments
2 | {
3 | public class JsonNull : IJsonArgument
4 | {
5 | public const string NAME = "Null";
6 | public const string NULL = "null";
7 |
8 | public string AsJson()
9 | {
10 | return NULL;
11 | }
12 |
13 | public string GetName() => NAME;
14 |
15 | public JsonArgumentType GetArgumentType()
16 | {
17 | return JsonArgumentType.Null;
18 | }
19 |
20 | public override string ToString()
21 | {
22 | return NULL;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/FunctionAnalyser/Tests/Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 |
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/AttributeArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class AttributeArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Attribute result)
10 | {
11 | result = default;
12 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation attribute);
13 | if (readResults.Successful) result = new Attribute(attribute);
14 | return readResults;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/DimensionArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class DimensionArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Dimension result)
10 | {
11 | result = default;
12 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation dimension);
13 | if (readResults.Successful) result = new Dimension(dimension);
14 | return readResults;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/LootTableArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class LootTableArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out LootTable result)
10 | {
11 | result = default;
12 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation lootTable);
13 | if (readResults.Successful) result = new LootTable(lootTable);
14 | return readResults;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/PredicateArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class PredicateArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Predicate result)
10 | {
11 | result = default;
12 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation predicate);
13 | if (readResults.Successful) result = new Predicate(predicate);
14 | return readResults;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/ReadResults.cs:
--------------------------------------------------------------------------------
1 | namespace CommandParser.Results
2 | {
3 | public class ReadResults
4 | {
5 | public bool Successful { get; }
6 | public CommandError Error { get; }
7 |
8 | private ReadResults(bool successful, CommandError error)
9 | {
10 | Successful = successful;
11 | Error = error;
12 | }
13 |
14 | public static ReadResults Success()
15 | {
16 | return new ReadResults(true, null);
17 | }
18 |
19 | public static ReadResults Failure(CommandError error)
20 | {
21 | return new ReadResults(false, error);
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/AdvancementArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class AdvancementArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Advancement result)
10 | {
11 | result = default;
12 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation advancement);
13 | if (readResults.Successful) result = new Advancement(advancement);
14 | return readResults;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/ScoreHolder.cs:
--------------------------------------------------------------------------------
1 | namespace CommandParser.Results.Arguments
2 | {
3 | public class ScoreHolder
4 | {
5 | public string Name { get; }
6 | public EntitySelector Selector { get; }
7 |
8 | public ScoreHolder(string name, EntitySelector selector)
9 | {
10 | Name = name;
11 | Selector = selector;
12 | }
13 |
14 | public override string ToString()
15 | {
16 | if (Selector == null)
17 | {
18 | return Name;
19 | } else
20 | {
21 | return Selector.ToString();
22 | }
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/ItemModifierArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class ItemModifierArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out ItemModifier result)
10 | {
11 | result = default;
12 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation itemModifier);
13 | if (readResults.Successful) result = new ItemModifier(itemModifier);
14 | return readResults;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Collections/EntitySelectorOptions.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace CommandParser.Collections
4 | {
5 | public class EntitySelectorOptions
6 | {
7 | private readonly Dictionary Values;
8 |
9 | public EntitySelectorOptions() : this(new Dictionary()) { }
10 |
11 | public EntitySelectorOptions(Dictionary values)
12 | {
13 | Values = values;
14 | }
15 |
16 | public bool TryGet(string input, out EntitySelectorOption option)
17 | {
18 | return Values.TryGetValue(input, out option);
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/resources/data-debug.json:
--------------------------------------------------------------------------------
1 | {
2 | "java-test": {
3 | "name": "Java (Testing)",
4 | "resources": {
5 | "anchors": "java",
6 | "blocks": "java",
7 | "colours": "java",
8 | "commands": "java-test",
9 | "components": "java",
10 | "enchantments": "java",
11 | "entities": "java",
12 | "gamemodes": "java-test",
13 | "item_slots": "java",
14 | "items": "java",
15 | "mob_effects": "java",
16 | "objective_criteria": "java",
17 | "operations": "java",
18 | "particles": "java",
19 | "scoreboard_slots": "java",
20 | "selector_arguments": "java",
21 | "sorts": "java",
22 | "structure_mirrors": "java",
23 | "structure_rotations": "java",
24 | "time_scalars": "java"
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/FunctionAnalyser/ProgramUpdater/Assets.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 |
3 | namespace ProgramUpdater
4 | {
5 | public class Assets
6 | {
7 | [JsonProperty("name")]
8 | private readonly string Name;
9 |
10 | [JsonProperty("label")]
11 | private readonly string Label;
12 |
13 | [JsonProperty("browser_download_url")]
14 | private readonly string DownloadUrl;
15 |
16 | public string GetName()
17 | {
18 | return Name;
19 | }
20 |
21 | public string GetDownloadUrl()
22 | {
23 | return DownloadUrl;
24 | }
25 |
26 | public string GetLabel()
27 | {
28 | return Label;
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/resources/definitions.json:
--------------------------------------------------------------------------------
1 | {
2 | "anchors": ["java"],
3 | "blocks": ["java"],
4 | "colours": ["java"],
5 | "commands": ["java","bedrock"],
6 | "components": ["java","bedrock"],
7 | "enchantments": ["java"],
8 | "entities": ["java"],
9 | "gamemodes": ["java","bedrock"],
10 | "items": ["java"],
11 | "item_components": ["bedrock"],
12 | "item_slots": ["java","bedrock"],
13 | "mob_effects": ["java"],
14 | "objective_criteria": ["java","bedrock"],
15 | "operations": ["java"],
16 | "particles": ["java"],
17 | "scoreboard_slots": ["java","bedrock"],
18 | "selector_arguments": ["java","bedrock"],
19 | "sorts": ["java"],
20 | "time_scalars": ["java"],
21 | "structure_rotations": ["java","bedrock"],
22 | "structure_mirrors": ["java","bedrock"]
23 | }
24 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Tree/RootNode.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Context;
2 | using CommandParser.Results;
3 | using System;
4 |
5 | namespace CommandParser.Tree
6 | {
7 | public class RootNode : Node
8 | {
9 | public RootNode() : base(false, null) { }
10 |
11 | public override string GetName()
12 | {
13 | return "";
14 | }
15 |
16 | public override ReadResults Parse(IStringReader reader, CommandContext builder, DispatcherResources resources)
17 | {
18 | throw new NotImplementedException();
19 | }
20 |
21 | public void Merge(RootNode other)
22 | {
23 | foreach (Node child in other.Children.Values) AddChild(child);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/FunctionAnalyser/ErrorCraft.CommandParser.Tests/ErrorCraft.CommandParser.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 |
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/FunctionAnalyser/ErrorCraft.CommandParser/StringReader.cs:
--------------------------------------------------------------------------------
1 | namespace ErrorCraft.CommandParser {
2 | public class StringReader : IStringReader {
3 | private readonly string Command;
4 | private int Cursor;
5 |
6 | public StringReader(string command) {
7 | Command = command;
8 | Cursor = 0;
9 | }
10 |
11 | public string GetString() {
12 | return Command;
13 | }
14 |
15 | public int GetCursor() {
16 | return Cursor;
17 | }
18 |
19 | public bool CanRead() {
20 | return CanRead(1);
21 | }
22 |
23 | public bool CanRead(int length) {
24 | return Cursor + length <= Command.Length;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/FunctionAnalyser/ErrorCraft.CommandParser.Tests/StringReaderTests.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
2 |
3 | namespace ErrorCraft.CommandParser.Tests {
4 | [TestClass]
5 | public class StringReaderTests {
6 | [TestMethod]
7 | public void GetString_ReturnsCorrectValue() {
8 | StringReader stringReader = new StringReader("foo");
9 | string result = stringReader.GetString();
10 | Assert.AreEqual("foo", result);
11 | }
12 |
13 | [TestMethod]
14 | public void GetCursor_ReturnsCorrectValue() {
15 | StringReader stringReader = new StringReader("foo");
16 | int result = stringReader.GetCursor();
17 | Assert.AreEqual(0, result);
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/FunctionAnalyser/ErrorCraft.FunctionAnalyser.UI.Avalonia/App.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.Controls.ApplicationLifetimes;
3 | using Avalonia.Markup.Xaml;
4 | using ErrorCraft.FunctionAnalyser.UI.Avalonia.ViewModels;
5 | using ErrorCraft.FunctionAnalyser.UI.Avalonia.Views;
6 |
7 | namespace ErrorCraft.FunctionAnalyser.UI.Avalonia;
8 | public partial class App : Application {
9 | public override void Initialize() {
10 | AvaloniaXamlLoader.Load(this);
11 | }
12 |
13 | public override void OnFrameworkInitializationCompleted() {
14 | if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) {
15 | desktop.MainWindow = new MainWindow();
16 | }
17 |
18 | base.OnFrameworkInitializationCompleted();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/resources/components/bedrock.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": {
3 | "type": "object",
4 | "children": {
5 | "rawtext": {
6 | "type": "array",
7 | "array_contents": "object"
8 | }
9 | }
10 | },
11 | "primary": {
12 | "text": {
13 | "type": "string"
14 | },
15 | "translate": {
16 | "type": "string",
17 | "children": {
18 | "with": {
19 | "type": "array_or_root",
20 | "array_contents": "string",
21 | "may_be_empty": true,
22 | "optional": true
23 | }
24 | }
25 | },
26 | "score": {
27 | "type": "object",
28 | "children": {
29 | "name": {
30 | "type": "string"
31 | },
32 | "objective": {
33 | "type": "string"
34 | }
35 | }
36 | },
37 | "selector": {
38 | "type": "string"
39 | }
40 | },
41 | "optional": {}
42 | }
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Minecraft/Nbt/Tags/ByteNbtTag.cs:
--------------------------------------------------------------------------------
1 | using static CommandParser.Minecraft.Nbt.NbtUtilities;
2 |
3 | namespace CommandParser.Minecraft.Nbt.Tags {
4 | public class ByteNbtTag : INbtTag {
5 | public static readonly ByteNbtTag ZERO = new ByteNbtTag(0);
6 | public static readonly ByteNbtTag ONE = new ByteNbtTag(1);
7 |
8 | private readonly sbyte Data;
9 |
10 | public ByteNbtTag(sbyte data) {
11 | Data = data;
12 | }
13 |
14 | public string GetName() {
15 | return "TAG_Byte";
16 | }
17 |
18 | public sbyte GetId() {
19 | return 1;
20 | }
21 |
22 | public string ToSnbt() {
23 | return Data.ToString(NbtNumberFormatInfo) + "b";
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Providers/NumberProvider.cs:
--------------------------------------------------------------------------------
1 | using System.Globalization;
2 |
3 | namespace CommandParser.Providers
4 | {
5 | public static class NumberProvider
6 | {
7 | public static readonly NumberFormatInfo NumberFormatInfo = new NumberFormatInfo()
8 | {
9 | NumberDecimalSeparator = ".",
10 | PositiveInfinitySymbol = "Infinity",
11 | NegativeInfinitySymbol = "-Infinity",
12 | NegativeSign = "-",
13 | PositiveSign = "",
14 | NaNSymbol = "NaN"
15 | };
16 | public static readonly NumberStyles NumberStylesInteger = NumberStyles.AllowLeadingSign;
17 | public static readonly NumberStyles NumberStylesFloating = NumberStylesInteger | NumberStyles.AllowDecimalPoint;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/FunctionAnalyser/ErrorCraft.FunctionAnalyser.UI.Avalonia/ViewLocator.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Controls.Templates;
3 | using ErrorCraft.FunctionAnalyser.UI.Avalonia.ViewModels;
4 | using System;
5 |
6 | namespace ErrorCraft.FunctionAnalyser.UI.Avalonia;
7 | public class ViewLocator : IDataTemplate {
8 | public IControl Build(object data) {
9 | var name = data.GetType().FullName!.Replace("ViewModel", "View");
10 | var type = Type.GetType(name);
11 |
12 | if (type != null) {
13 | return (Control)Activator.CreateInstance(type)!;
14 | } else {
15 | return new TextBlock { Text = "Not Found: " + name };
16 | }
17 | }
18 |
19 | public bool Match(object data) {
20 | return data is ViewModelBase;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/Vec3Argument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft.Coordinates;
2 | using CommandParser.Parsers.Coordinates;
3 | using CommandParser.Results;
4 | using Newtonsoft.Json;
5 |
6 | namespace CommandParser.Arguments {
7 | public class Vec3Argument : IArgument {
8 | [JsonProperty("use_bedrock")]
9 | private readonly bool UseBedrock;
10 |
11 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out ICoordinates result) {
12 | if (reader.CanRead() && reader.Peek() == '^') {
13 | return new LocalCoordinatesParser(reader, UseBedrock).Parse(out result);
14 | }
15 | return new WorldCoordinatesParser(reader, UseBedrock).ParseDouble(out result);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/BlockPosArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft.Coordinates;
2 | using CommandParser.Parsers.Coordinates;
3 | using CommandParser.Results;
4 | using Newtonsoft.Json;
5 |
6 | namespace CommandParser.Arguments {
7 | public class BlockPosArgument : IArgument {
8 | [JsonProperty("use_bedrock")]
9 | private readonly bool UseBedrock;
10 |
11 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out ICoordinates result) {
12 | if (reader.CanRead() && reader.Peek() == '^') {
13 | return new LocalCoordinatesParser(reader, UseBedrock).Parse(out result);
14 | }
15 | return new WorldCoordinatesParser(reader, UseBedrock).ParseInteger(out result);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Parsers/JsonParser/JsonArgumentType.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using System.Runtime.Serialization;
3 |
4 | namespace CommandParser.Parsers.JsonParser
5 | {
6 | public enum JsonArgumentType
7 | {
8 | [EnumMember(Value = "null"), Display(Name = "Null")]
9 | Null = 1,
10 | [EnumMember(Value = "boolean"), Display(Name = "Boolean")]
11 | Boolean = 2,
12 | [EnumMember(Value = "number"), Display(Name = "Number")]
13 | Number = 3,
14 | [EnumMember(Value = "string"), Display(Name = "String")]
15 | String = 4,
16 | [EnumMember(Value = "object"), Display(Name = "Object")]
17 | Object = 5,
18 | [EnumMember(Value = "array"), Display(Name = "Array")]
19 | Array = 6
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Parsers/JsonParser/JsonArguments/JsonNumber.cs:
--------------------------------------------------------------------------------
1 | namespace CommandParser.Parsers.JsonParser.JsonArguments
2 | {
3 | public class JsonNumber : IJsonArgument
4 | {
5 | public const string NAME = "Number";
6 |
7 | private readonly string Number;
8 |
9 | public JsonNumber(string number)
10 | {
11 | Number = number;
12 | }
13 |
14 | public string AsJson()
15 | {
16 | return Number;
17 | }
18 |
19 | public string GetName() => NAME;
20 |
21 | public JsonArgumentType GetArgumentType()
22 | {
23 | return JsonArgumentType.Number;
24 | }
25 |
26 | public override string ToString()
27 | {
28 | return Number;
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/FunctionAnalyser/Utilities/Generic.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 |
4 | namespace Utilities
5 | {
6 | public static class Generic
7 | {
8 | public static string CombinePaths(string path1, string path2)
9 | {
10 | if (string.IsNullOrEmpty(path1)) return path2;
11 | else if (string.IsNullOrEmpty(path2)) return path1;
12 | else if (path1.EndsWith('/')) return path1 + path2;
13 | else return path1 + '/' + path2;
14 | }
15 |
16 | internal static TAttribute GetAttribute(TEnum value) where TEnum : struct, Enum where TAttribute : Attribute
17 | {
18 | FieldInfo field = typeof(TEnum).GetField(value.ToString());
19 | return field?.GetCustomAttribute();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/IntegerRangeArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Parsers;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 | using Newtonsoft.Json;
5 |
6 | namespace CommandParser.Arguments
7 | {
8 | public class IntegerRangeArgument : IArgument>
9 | {
10 | [JsonProperty("loopable")]
11 | private readonly bool Loopable;
12 |
13 | public IntegerRangeArgument(bool loopable = false)
14 | {
15 | Loopable = loopable;
16 | }
17 |
18 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Range result)
19 | {
20 | return new RangeParser(reader).Read(int.TryParse, CommandError.InvalidInteger, int.MinValue, int.MaxValue, Loopable, out result);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Context/ParsedArgument.cs:
--------------------------------------------------------------------------------
1 | namespace CommandParser.Context
2 | {
3 | public abstract class ParsedArgument
4 | {
5 | protected ParsedArgument() { }
6 | public abstract object GetResult();
7 | public abstract bool IsFromRoot();
8 | }
9 |
10 | public class ParsedArgument : ParsedArgument
11 | {
12 | private readonly T Result;
13 | private readonly bool FromRoot;
14 |
15 | public ParsedArgument(T result, bool fromRoot)
16 | {
17 | Result = result;
18 | FromRoot = fromRoot;
19 | }
20 |
21 | public override object GetResult()
22 | {
23 | return Result;
24 | }
25 |
26 | public override bool IsFromRoot()
27 | {
28 | return FromRoot;
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/ColourArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Results;
2 | using CommandParser.Results.Arguments;
3 |
4 | namespace CommandParser.Arguments
5 | {
6 | public class ColourArgument : IArgument
7 | {
8 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Colour result)
9 | {
10 | result = default;
11 | ReadResults readResults = reader.ReadUnquotedString(out string colour);
12 | if (!readResults.Successful) return readResults;
13 |
14 | if (!resources.Colours.Contains(colour))
15 | {
16 | return ReadResults.Failure(CommandError.UnknownColour(colour));
17 | }
18 |
19 | result = new Colour(colour);
20 | return ReadResults.Success();
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/resources/item_components/bedrock.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": {
3 | "type": "root_object"
4 | },
5 | "primary": {
6 | "can_place_on": {
7 | "type": "object",
8 | "key_resource_location": true,
9 | "children": {
10 | "blocks": {
11 | "type": "array",
12 | "array_contents": "string"
13 | }
14 | }
15 | },
16 | "can_destroy": {
17 | "type": "object",
18 | "key_resource_location": true,
19 | "children": {
20 | "blocks": {
21 | "type": "array",
22 | "array_contents": "string"
23 | }
24 | }
25 | },
26 | "item_lock": {
27 | "type": "object",
28 | "key_resource_location": true,
29 | "children": {
30 | "mode": {
31 | "type": "string"
32 | }
33 | }
34 | },
35 | "keep_on_death": {
36 | "type": "object",
37 | "key_resource_location": true
38 | }
39 | },
40 | "optional": {}
41 | }
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/FloatRangeArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Parsers;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 | using Newtonsoft.Json;
5 |
6 | namespace CommandParser.Arguments
7 | {
8 | public class FloatRangeArgument : IArgument>
9 | {
10 | [JsonProperty("loopable")]
11 | private readonly bool Loopable;
12 |
13 | public FloatRangeArgument(bool loopable = false)
14 | {
15 | Loopable = loopable;
16 | }
17 |
18 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Range result)
19 | {
20 | return new RangeParser(reader).Read(float.TryParse, CommandError.InvalidFloat, float.NegativeInfinity, float.PositiveInfinity, Loopable, out result);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/Builders/Versions/VersionResources.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 |
3 | namespace FunctionAnalyser.Builders.Versions
4 | {
5 | public class VersionResources
6 | {
7 | [JsonProperty("name")]
8 | private readonly string Name;
9 | [JsonProperty("resources")]
10 | private readonly VersionResourceKeys ResourceKeys;
11 | [JsonProperty("use_bedrock_string_reader")]
12 | private readonly bool UseBedrockStringReader;
13 |
14 | public string GetName()
15 | {
16 | return Name;
17 | }
18 |
19 | public VersionResourceKeys GetResourceKeys()
20 | {
21 | return ResourceKeys;
22 | }
23 |
24 | public bool GetUseBedrockStringReader()
25 | {
26 | return UseBedrockStringReader;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/DoubleRangeArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Parsers;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 | using Newtonsoft.Json;
5 |
6 | namespace CommandParser.Arguments
7 | {
8 | public class DoubleRangeArgument : IArgument>
9 | {
10 | [JsonProperty("loopable")]
11 | private readonly bool Loopable;
12 |
13 | public DoubleRangeArgument(bool loopable = false)
14 | {
15 | Loopable = loopable;
16 | }
17 |
18 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Range result)
19 | {
20 | return new RangeParser(reader).Read(double.TryParse, CommandError.InvalidDouble, double.NegativeInfinity, double.PositiveInfinity, Loopable, out result);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Parsers/JsonParser/JsonCharacterProvider.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Immutable;
2 |
3 | namespace CommandParser.Parsers.JsonParser
4 | {
5 | public static class JsonCharacterProvider
6 | {
7 | public const char OBJECT_OPEN_CHARACTER = '{';
8 | public const char OBJECT_CLOSE_CHARACTER = '}';
9 | public const char ARRAY_OPEN_CHARACTER = '[';
10 | public const char ARRAY_CLOSE_CHARACTER = ']';
11 | public const char NAME_VALUE_SEPARATOR = ':';
12 | public const char ARGUMENT_SEPARATOR = ',';
13 | public const char STRING_CHARACTER = '"';
14 | public static readonly ImmutableHashSet ESCAPABLE_CHARACTERS = ImmutableHashSet.Create('\'', '"', '\\', 'b', 'f', 'n', 'r', 't');
15 | public const char UNICODE_CHARACTER = 'u';
16 | public const char ESCAPE_CHARACTER = '\\';
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/AngleArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft.Coordinates;
2 | using CommandParser.Parsers.Coordinates;
3 | using CommandParser.Results;
4 |
5 | namespace CommandParser.Arguments {
6 | public class AngleArgument : IArgument {
7 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Angle result) {
8 | int start = reader.GetCursor();
9 | ReadResults readResults = new AngleParser(reader).Read(out result);
10 | if (!readResults.Successful) return readResults;
11 |
12 | if (float.IsNaN(result.Value) || float.IsInfinity(result.Value)) {
13 | reader.SetCursor(start);
14 | return ReadResults.Failure(CommandError.InvalidAngle().WithContext(reader));
15 | }
16 | return ReadResults.Success();
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/FunctionArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class FunctionArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Function result)
10 | {
11 | result = default;
12 | bool isTag = false;
13 | if (reader.CanRead() && reader.Peek() == '#')
14 | {
15 | reader.Skip();
16 | isTag = true;
17 | }
18 |
19 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation function);
20 | if (readResults.Successful) result = new Function(function, isTag);
21 | return readResults;
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/FunctionAnalyser/ErrorCraft.FunctionAnalyser.UI.Avalonia/Program.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.Controls.ApplicationLifetimes;
3 | using Avalonia.ReactiveUI;
4 | using System;
5 |
6 | namespace ErrorCraft.FunctionAnalyser.UI.Avalonia;
7 | internal class Program {
8 | // Initialization code. Don't use any Avalonia, third-party APIs or any
9 | // SynchronizationContext-reliant code before AppMain is called: things aren't initialized
10 | // yet and stuff might break.
11 | [STAThread]
12 | public static void Main(string[] args) => BuildAvaloniaApp()
13 | .StartWithClassicDesktopLifetime(args);
14 |
15 | // Avalonia configuration, don't remove; also used by visual designer.
16 | public static AppBuilder BuildAvaloniaApp()
17 | => AppBuilder.Configure()
18 | .UsePlatformDetect()
19 | .LogToTrace()
20 | .UseReactiveUI();
21 | }
22 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/Results/SimpleResult.cs:
--------------------------------------------------------------------------------
1 | using AdvancedText;
2 |
3 | namespace FunctionAnalyser.Results
4 | {
5 | public class SimpleResult : IResult
6 | {
7 | private int Total;
8 |
9 | public SimpleResult() : this(0) { }
10 |
11 | private SimpleResult(int total)
12 | {
13 | Total = total;
14 | }
15 |
16 | public void Increase()
17 | {
18 | Total++;
19 | }
20 |
21 | public int GetTotal()
22 | {
23 | return Total;
24 | }
25 |
26 | public TextComponent ToTextComponent()
27 | {
28 | return new TextComponent(Total.ToString());
29 | }
30 |
31 | public static SimpleResult operator +(SimpleResult a, SimpleResult b)
32 | {
33 | return new SimpleResult(a.Total + b.Total);
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/FunctionAnalyser/Tests/Tree/ArgumentNodeTests.cs:
--------------------------------------------------------------------------------
1 | using CommandParser;
2 | using CommandParser.Arguments;
3 | using CommandParser.Context;
4 | using CommandParser.Tree;
5 | using Microsoft.VisualStudio.TestTools.UnitTesting;
6 | using static CommandParser.Providers.NodeBuilder;
7 |
8 | namespace Tests.Tree
9 | {
10 | [TestClass]
11 | public class ArgumentNodeTests
12 | {
13 | [TestMethod]
14 | public void ArgumentNode_ShouldParse()
15 | {
16 | // Arrange
17 | Node node = Argument("foo", new IntegerArgument(), true, null);
18 | IStringReader reader = new StringReader("123 456");
19 | CommandContext context = new CommandContext(0);
20 |
21 | // Act
22 | node.Parse(reader, context);
23 |
24 | // Assert
25 | Assert.AreEqual(context.Results[0].GetResult(), 123);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Collections/Particles.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Tree;
3 | using System.Collections.Generic;
4 |
5 | namespace CommandParser.Collections
6 | {
7 | public class Particles
8 | {
9 | private readonly Dictionary Values;
10 |
11 | public Particles() : this(new Dictionary()) { }
12 |
13 | public Particles(Dictionary values)
14 | {
15 | Values = values;
16 | }
17 |
18 | public bool TryGetNodes(ResourceLocation item, out Dictionary nodes)
19 | {
20 | nodes = default;
21 | if (!item.IsDefaultNamespace() || !Values.TryGetValue(item.Path, out RootNode root)) return false;
22 | nodes = root.Children ?? new Dictionary();
23 | return true;
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/Particle.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Context;
2 | using CommandParser.Minecraft;
3 | using System.Collections.Generic;
4 |
5 | namespace CommandParser.Results.Arguments
6 | {
7 | public class Particle
8 | {
9 | public ResourceLocation Name { get; }
10 | public Dictionary Arguments { get; }
11 |
12 | public Particle(ResourceLocation name, Dictionary arguments)
13 | {
14 | Name = name;
15 | Arguments = arguments;
16 | }
17 |
18 | public override string ToString()
19 | {
20 | string s = Name.ToString();
21 |
22 | foreach (ParsedArgument argument in Arguments.Values)
23 | {
24 | s += $" {argument.GetResult()}";
25 | }
26 |
27 | return s;
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/OperationArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Results;
2 | using CommandParser.Results.Arguments;
3 |
4 | namespace CommandParser.Arguments
5 | {
6 | public class OperationArgument : IArgument
7 | {
8 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Operation result)
9 | {
10 | result = default;
11 | int start = reader.GetCursor();
12 | while (!reader.AtEndOfArgument()) reader.Skip();
13 | string operation = reader.GetString()[start..reader.GetCursor()];
14 |
15 | if (!resources.Operations.Contains(operation))
16 | {
17 | return ReadResults.Failure(CommandError.InvalidOperation());
18 | }
19 |
20 | result = new Operation(operation);
21 | return ReadResults.Success();
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/MobEffectArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class MobEffectArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out MobEffect result)
10 | {
11 | result = default;
12 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation mobEffect);
13 | if (!readResults.Successful) return readResults;
14 | if (!resources.MobEffects.Contains(mobEffect))
15 | {
16 | return ReadResults.Failure(CommandError.UnknownEffect(mobEffect));
17 | }
18 | result = new MobEffect(mobEffect);
19 | return ReadResults.Success();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/Item.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Minecraft.Nbt.Tags;
3 | using System.Text;
4 |
5 | namespace CommandParser.Results.Arguments {
6 | public class Item {
7 | public ResourceLocation Resource { get; }
8 | public INbtTag Nbt { get; }
9 | public bool IsTag { get; }
10 |
11 | public Item(ResourceLocation item, INbtTag nbt, bool isTag) {
12 | Resource = item;
13 | Nbt = nbt;
14 | IsTag = isTag;
15 | }
16 |
17 | public override string ToString() {
18 | StringBuilder stringBuilder = new StringBuilder();
19 | if (IsTag) stringBuilder.Append('#');
20 | stringBuilder.Append(Resource.ToString());
21 | if (Nbt != null) stringBuilder.Append(Nbt.ToSnbt());
22 | return stringBuilder.ToString();
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/ItemArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Parsers;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 | using Newtonsoft.Json;
5 |
6 | namespace CommandParser.Arguments
7 | {
8 | public class ItemArgument : IArgument-
9 | {
10 | [JsonProperty("for_testing")]
11 | private readonly bool ForTesting;
12 |
13 | [JsonProperty("use_bedrock")]
14 | private readonly bool UseBedrock;
15 |
16 | public ItemArgument(bool forTesting = false, bool useBedrock = false)
17 | {
18 | ForTesting = forTesting;
19 | UseBedrock = useBedrock;
20 | }
21 |
22 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Item result)
23 | {
24 | return new ItemParser(reader, resources, ForTesting, UseBedrock).Parse(out result);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/FunctionAnalyser/UserInterface/Views/CrashWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Windows;
4 | using UserInterface.ViewModels;
5 |
6 | namespace UserInterface
7 | {
8 | public partial class CrashWindow : Window
9 | {
10 | private readonly CrashWindowViewModel Model;
11 |
12 | public CrashWindow(Exception exception, string crashReportFile)
13 | {
14 | InitializeComponent();
15 | DataContext = Model = new CrashWindowViewModel(exception, crashReportFile);
16 | }
17 |
18 | private void ViewReport(object sender, RoutedEventArgs e)
19 | {
20 | new Process() { StartInfo = new ProcessStartInfo(Model.CrashReportFile) { UseShellExecute = true } }.Start();
21 | }
22 |
23 | private void CloseWindow(object sender, RoutedEventArgs e)
24 | {
25 | Close();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/BlockArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Parsers;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 | using Newtonsoft.Json;
5 |
6 | namespace CommandParser.Arguments
7 | {
8 | public class BlockArgument : IArgument
9 | {
10 | [JsonProperty("for_testing")]
11 | private readonly bool ForTesting;
12 |
13 | [JsonProperty("use_bedrock")]
14 | private readonly bool UseBedrock;
15 |
16 | public BlockArgument(bool forTesting = false, bool useBedrock = false)
17 | {
18 | ForTesting = forTesting;
19 | UseBedrock = useBedrock;
20 | }
21 |
22 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Block result)
23 | {
24 | return new BlockParser(reader, ForTesting, resources, UseBedrock).Parse(out result);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/Results/SelectorCount.cs:
--------------------------------------------------------------------------------
1 | namespace FunctionAnalyser.Results
2 | {
3 | public class SelectorCount
4 | {
5 | public int NearestPlayer { get; set; }
6 | public int AllPlayers { get; set; }
7 | public int RandomPlayer { get; set; }
8 | public int AllEntities { get; set; }
9 | public int CurrentEntity { get; set; }
10 |
11 | public static SelectorCount operator +(SelectorCount a, SelectorCount b)
12 | {
13 | return new SelectorCount()
14 | {
15 | NearestPlayer = a.NearestPlayer + b.NearestPlayer,
16 | AllPlayers = a.AllPlayers + b.AllPlayers,
17 | RandomPlayer = a.RandomPlayer + b.RandomPlayer,
18 | AllEntities = a.AllEntities + b.AllEntities,
19 | CurrentEntity = a.CurrentEntity + b.CurrentEntity
20 | };
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/GamemodeArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 |
4 | namespace CommandParser.Arguments
5 | {
6 | public class GamemodeArgument : IArgument
7 | {
8 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out GameType result)
9 | {
10 | result = default;
11 | int start = reader.GetCursor();
12 | ReadResults readResults = reader.ReadUnquotedString(out string gamemode);
13 | if (!readResults.Successful) return readResults;
14 | if (!resources.Gamemodes.TryGet(gamemode, out result))
15 | {
16 | reader.SetCursor(start);
17 | return ReadResults.Failure(CommandError.UnknownGamemode(gamemode).WithContext(reader));
18 | }
19 |
20 | return ReadResults.Success();
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/FunctionAnalyser/Tests/Tree/LiteralNodeTests.cs:
--------------------------------------------------------------------------------
1 | using CommandParser;
2 | using CommandParser.Arguments;
3 | using CommandParser.Context;
4 | using CommandParser.Results.Arguments;
5 | using CommandParser.Tree;
6 | using Microsoft.VisualStudio.TestTools.UnitTesting;
7 | using static CommandParser.Providers.NodeBuilder;
8 |
9 | namespace Tests.Tree
10 | {
11 | [TestClass]
12 | public class LiteralNodeTests
13 | {
14 | [TestMethod]
15 | public void LiteralNode_ShouldParse()
16 | {
17 | // Arrange
18 | Node node = Literal("foo", true, null);
19 | IStringReader reader = new StringReader("foo");
20 | CommandContext context = new CommandContext(0);
21 |
22 | // Act
23 | node.Parse(reader, context);
24 |
25 | // Assert
26 | Assert.AreEqual(context.Results[0].GetResult(), new Literal("foo"));
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Minecraft/Coordinates/WorldCoordinates.cs:
--------------------------------------------------------------------------------
1 | namespace CommandParser.Minecraft.Coordinates {
2 | public class WorldCoordinates : ICoordinates {
3 | public WorldCoordinate X { get; }
4 | public WorldCoordinate Y { get; }
5 | public WorldCoordinate Z { get; }
6 |
7 | public WorldCoordinates(WorldCoordinate x, WorldCoordinate y, WorldCoordinate z) {
8 | X = x;
9 | Y = y;
10 | Z = z;
11 | }
12 |
13 | public bool IsXRelative() {
14 | return X.IsRelative;
15 | }
16 |
17 | public bool IsYRelative() {
18 | return Y.IsRelative;
19 | }
20 |
21 | public bool IsZRelative() {
22 | return Z.IsRelative;
23 | }
24 |
25 | public override string ToString() {
26 | return X.ToString() + " " + Y.ToString() + " " + Z.ToString();
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/Builders/Collections/CommandsBuilder.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Tree;
2 | using Newtonsoft.Json;
3 | using System.Collections.Generic;
4 |
5 | namespace FunctionAnalyser.Builders.Collections
6 | {
7 | public class CommandsBuilder: IBuilder
8 | {
9 | [JsonProperty("parent")]
10 | private readonly string Parent;
11 | [JsonProperty("root")]
12 | private readonly RootNode Root;
13 |
14 | public RootNode Build(Dictionary resources)
15 | {
16 | RootNode all = new RootNode();
17 | all.Merge(Root);
18 |
19 | CommandsBuilder builder = this;
20 | while (builder.Parent != null)
21 | {
22 | builder = resources[builder.Parent];
23 | all.Merge(builder.Root);
24 | }
25 | return all;
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/Builders/Collections/ItemsBuilder.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Collections;
2 | using Newtonsoft.Json;
3 | using System.Collections.Generic;
4 |
5 | namespace FunctionAnalyser.Builders.Collections
6 | {
7 | public class ItemsBuilder : IBuilder
8 | {
9 | [JsonProperty("parent")]
10 | private readonly string Parent;
11 | [JsonProperty("values")]
12 | private readonly HashSet Values;
13 |
14 | public Items Build(Dictionary resources)
15 | {
16 | HashSet all = new HashSet(Values);
17 | ItemsBuilder builder = this;
18 | while (builder.Parent != null)
19 | {
20 | builder = resources[builder.Parent];
21 | foreach (string s in builder.Values) all.Add(s);
22 | }
23 | return new Items(all);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/Builders/Collections/SortsBuilder.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Collections;
2 | using Newtonsoft.Json;
3 | using System.Collections.Generic;
4 |
5 | namespace FunctionAnalyser.Builders.Collections
6 | {
7 | public class SortsBuilder : IBuilder
8 | {
9 | [JsonProperty("parent")]
10 | private readonly string Parent;
11 | [JsonProperty("values")]
12 | private readonly HashSet Values;
13 |
14 | public Sorts Build(Dictionary resources)
15 | {
16 | HashSet all = new HashSet(Values);
17 | SortsBuilder builder = this;
18 | while (builder.Parent != null)
19 | {
20 | builder = resources[builder.Parent];
21 | foreach (string s in builder.Values) all.Add(s);
22 | }
23 | return new Sorts(all);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/ItemEnchantmentArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class ItemEnchantmentArgument : IArgument
8 | {
9 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Enchantment result)
10 | {
11 | result = default;
12 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation enchantment);
13 | if (!readResults.Successful) return readResults;
14 | if (!resources.Enchantments.Contains(enchantment))
15 | {
16 | return ReadResults.Failure(CommandError.UnknownEnchantment(enchantment));
17 | }
18 | result = new Enchantment(enchantment);
19 | return ReadResults.Success();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Parsers/JsonParser/JsonArguments/JsonBoolean.cs:
--------------------------------------------------------------------------------
1 | namespace CommandParser.Parsers.JsonParser.JsonArguments
2 | {
3 | public class JsonBoolean : IJsonArgument
4 | {
5 | public const string NAME = "Boolean";
6 | public const string TRUE = "true";
7 | public const string FALSE = "false";
8 |
9 | private readonly bool Boolean;
10 |
11 | public JsonBoolean(bool boolean)
12 | {
13 | Boolean = boolean;
14 | }
15 |
16 | public string AsJson()
17 | {
18 | return Boolean ? TRUE : FALSE;
19 | }
20 |
21 | public string GetName() => NAME;
22 |
23 | public JsonArgumentType GetArgumentType()
24 | {
25 | return JsonArgumentType.Boolean;
26 | }
27 |
28 | public override string ToString()
29 | {
30 | return Boolean ? TRUE : FALSE;
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/Builders/Collections/AnchorsBuilder.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Collections;
2 | using Newtonsoft.Json;
3 | using System.Collections.Generic;
4 |
5 | namespace FunctionAnalyser.Builders.Collections
6 | {
7 | public class AnchorsBuilder : IBuilder
8 | {
9 | [JsonProperty("parent")]
10 | private readonly string Parent;
11 | [JsonProperty("values")]
12 | private readonly HashSet Values;
13 |
14 | public Anchors Build(Dictionary resources)
15 | {
16 | HashSet all = new HashSet(Values);
17 | AnchorsBuilder builder = this;
18 | while (builder.Parent != null)
19 | {
20 | builder = resources[builder.Parent];
21 | foreach (string s in builder.Values) all.Add(s);
22 | }
23 | return new Anchors(all);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/Builders/Collections/ColoursBuilder.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Collections;
2 | using Newtonsoft.Json;
3 | using System.Collections.Generic;
4 |
5 | namespace FunctionAnalyser.Builders.Collections
6 | {
7 | public class ColoursBuilder : IBuilder
8 | {
9 | [JsonProperty("parent")]
10 | private readonly string Parent;
11 | [JsonProperty("values")]
12 | private readonly HashSet Values;
13 |
14 | public Colours Build(Dictionary resources)
15 | {
16 | HashSet all = new HashSet(Values);
17 | ColoursBuilder builder = this;
18 | while (builder.Parent != null)
19 | {
20 | builder = resources[builder.Parent];
21 | foreach (string s in builder.Values) all.Add(s);
22 | }
23 | return new Colours(all);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/Builders/Collections/EntitiesBuilder.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Collections;
2 | using Newtonsoft.Json;
3 | using System.Collections.Generic;
4 |
5 | namespace FunctionAnalyser.Builders.Collections
6 | {
7 | public class EntitiesBuilder : IBuilder
8 | {
9 | [JsonProperty("parent")]
10 | private readonly string Parent;
11 | [JsonProperty("values")]
12 | private readonly HashSet Values;
13 |
14 | public Entities Build(Dictionary resources)
15 | {
16 | HashSet all = new HashSet(Values);
17 | EntitiesBuilder builder = this;
18 | while (builder.Parent != null)
19 | {
20 | builder = resources[builder.Parent];
21 | foreach (string s in builder.Values) all.Add(s);
22 | }
23 | return new Entities(all);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/ItemSlotArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Results;
2 | using CommandParser.Results.Arguments;
3 |
4 | namespace CommandParser.Arguments
5 | {
6 | public class ItemSlotArgument : IArgument
7 | {
8 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out ItemSlot result)
9 | {
10 | result = default;
11 | int start = reader.GetCursor();
12 | ReadResults readResults = reader.ReadUnquotedString(out string slot);
13 |
14 | if (!readResults.Successful) return readResults;
15 | if (!resources.ItemSlots.Contains(slot))
16 | {
17 | reader.SetCursor(start);
18 | return ReadResults.Failure(CommandError.UnknownSlot(slot).WithContext(reader));
19 | }
20 | result = new Results.Arguments.ItemSlot(slot);
21 | return ReadResults.Success();
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Converters/AbstractJsonConverter.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using Newtonsoft.Json.Linq;
3 | using System;
4 |
5 | namespace CommandParser.Converters
6 | {
7 | public abstract class AbstractJsonConverter : JsonConverter
8 | {
9 | protected abstract T Create(JObject jObject, JsonSerializer serializer);
10 |
11 | public override bool CanConvert(Type objectType)
12 | {
13 | return typeof(T).IsAssignableFrom(objectType);
14 | }
15 |
16 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
17 | {
18 | JObject jObject = JObject.Load(reader);
19 | return Create(jObject, serializer);
20 | }
21 |
22 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
23 | {
24 | throw new NotImplementedException();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/EntityAnchorArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Results;
2 | using CommandParser.Results.Arguments;
3 |
4 | namespace CommandParser.Arguments
5 | {
6 | public class EntityAnchorArgument : IArgument
7 | {
8 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Anchor result)
9 | {
10 | result = default;
11 | int start = reader.GetCursor();
12 | ReadResults readResults = reader.ReadUnquotedString(out string anchor);
13 | if (!readResults.Successful) return readResults;
14 |
15 | if (!resources.Anchors.Contains(anchor))
16 | {
17 | reader.SetCursor(start);
18 | return ReadResults.Failure(CommandError.InvalidEntityAnchor(anchor).WithContext(reader));
19 | }
20 |
21 | result = new Anchor(anchor);
22 | return ReadResults.Success();
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/Builders/Collections/ItemSlotsBuilder.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Collections;
2 | using Newtonsoft.Json;
3 | using System.Collections.Generic;
4 |
5 | namespace FunctionAnalyser.Builders.Collections
6 | {
7 | public class ItemSlotsBuilder : IBuilder
8 | {
9 | [JsonProperty("parent")]
10 | private readonly string Parent;
11 | [JsonProperty("values")]
12 | private readonly HashSet Values;
13 |
14 | public ItemSlots Build(Dictionary resources)
15 | {
16 | HashSet all = new HashSet(Values);
17 | ItemSlotsBuilder builder = this;
18 | while (builder.Parent != null)
19 | {
20 | builder = resources[builder.Parent];
21 | foreach (string s in builder.Values) all.Add(s);
22 | }
23 | return new ItemSlots(all);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/Builders/Collections/MobEffectsBuilder.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Collections;
2 | using Newtonsoft.Json;
3 | using System.Collections.Generic;
4 |
5 | namespace FunctionAnalyser.Builders.Collections
6 | {
7 | public class MobEffectsBuilder : IBuilder
8 | {
9 | [JsonProperty("parent")]
10 | private readonly string Parent;
11 | [JsonProperty("values")]
12 | private readonly HashSet Values;
13 |
14 | public MobEffects Build(Dictionary resources)
15 | {
16 | HashSet all = new HashSet(Values);
17 | MobEffectsBuilder builder = this;
18 | while (builder.Parent != null)
19 | {
20 | builder = resources[builder.Parent];
21 | foreach (string s in builder.Values) all.Add(s);
22 | }
23 | return new MobEffects(all);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/Builders/Collections/OperationsBuilder.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Collections;
2 | using Newtonsoft.Json;
3 | using System.Collections.Generic;
4 |
5 | namespace FunctionAnalyser.Builders.Collections
6 | {
7 | public class OperationsBuilder : IBuilder
8 | {
9 | [JsonProperty("parent")]
10 | private readonly string Parent;
11 | [JsonProperty("values")]
12 | private readonly HashSet Values;
13 |
14 | public Operations Build(Dictionary resources)
15 | {
16 | HashSet all = new HashSet(Values);
17 | OperationsBuilder builder = this;
18 | while (builder.Parent != null)
19 | {
20 | builder = resources[builder.Parent];
21 | foreach (string s in builder.Values) all.Add(s);
22 | }
23 | return new Operations(all);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Collections/Gamemodes.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using System.Collections.Generic;
3 |
4 | namespace CommandParser.Collections
5 | {
6 | public class Gamemodes
7 | {
8 | private readonly Dictionary> Values;
9 |
10 | public Gamemodes() : this(new Dictionary>()) { }
11 |
12 | public Gamemodes(Dictionary> values)
13 | {
14 | Values = values;
15 | }
16 |
17 | public bool TryGet(string gamemode, out GameType result)
18 | {
19 | foreach (KeyValuePair> pair in Values)
20 | {
21 | if (pair.Value.Contains(gamemode))
22 | {
23 | result = pair.Key;
24 | return true;
25 | }
26 | }
27 | result = default;
28 | return false;
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Minecraft/Nbt/Tags/CompoundNbtTag.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Text;
3 |
4 | namespace CommandParser.Minecraft.Nbt.Tags {
5 | public class CompoundNbtTag : INbtTag {
6 | private readonly Dictionary Data;
7 |
8 | public CompoundNbtTag() {
9 | Data = new Dictionary();
10 | }
11 |
12 | public string ToSnbt() {
13 | StringBuilder stringBuilder = new StringBuilder("{");
14 | stringBuilder.Append(NbtUtilities.Join(", ", Data, n => n.Key + ": " + n.Value.ToSnbt()));
15 | return stringBuilder.Append('}').ToString();
16 | }
17 |
18 | public string GetName() {
19 | return "TAG_Compound";
20 | }
21 |
22 | public sbyte GetId() {
23 | return 10;
24 | }
25 |
26 | public void Add(string key, INbtTag value) {
27 | Data[key] = value;
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Parsers/ComponentParser/ComponentArguments/ComponentNumber.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Collections;
2 | using CommandParser.Parsers.JsonParser;
3 | using CommandParser.Parsers.JsonParser.JsonArguments;
4 | using CommandParser.Results;
5 |
6 | namespace CommandParser.Parsers.ComponentParser.ComponentArguments
7 | {
8 | public class ComponentNumber : ComponentArgument
9 | {
10 | public override ReadResults Validate(JsonObject obj, string key, ComponentReader componentReader, Components components, IStringReader reader, int start, DispatcherResources resources)
11 | {
12 | if (obj.GetChild(key) is not JsonNumber)
13 | {
14 | reader.SetCursor(start);
15 | return ReadResults.Failure(ComponentCommandError.InvalidComponent(key, JsonArgumentType.Number, obj.GetChild(key).GetArgumentType()).WithContext(reader));
16 | }
17 | return ReadResults.Success();
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/Builders/Collections/EnchantmentsBuilder.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Collections;
2 | using Newtonsoft.Json;
3 | using System.Collections.Generic;
4 |
5 | namespace FunctionAnalyser.Builders.Collections
6 | {
7 | public class EnchantmentsBuilder : IBuilder
8 | {
9 | [JsonProperty("parent")]
10 | private readonly string Parent;
11 | [JsonProperty("values")]
12 | private readonly HashSet Values;
13 |
14 | public Enchantments Build(Dictionary resources)
15 | {
16 | HashSet all = new HashSet(Values);
17 | EnchantmentsBuilder builder = this;
18 | while (builder.Parent != null)
19 | {
20 | builder = resources[builder.Parent];
21 | foreach (string s in builder.Values) all.Add(s);
22 | }
23 | return new Enchantments(all);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/FunctionAnalyser/ProgramUpdater/Converters/TagNameConverter.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using Newtonsoft.Json.Linq;
3 | using System;
4 |
5 | namespace ProgramUpdater.Converters
6 | {
7 | public class TagNameConverter : JsonConverter
8 | {
9 | public override bool CanConvert(Type objectType)
10 | {
11 | return typeof(string) == objectType;
12 | }
13 |
14 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
15 | {
16 | string tagName = JToken.Load(reader).ToObject().Replace("v", null);
17 | return System.Version.TryParse(tagName, out System.Version actualTagName) ? actualTagName : null;
18 | }
19 |
20 | public override bool CanWrite => false;
21 |
22 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
23 | {
24 | throw new NotImplementedException();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/UuidArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Results;
2 | using Utilities;
3 |
4 | namespace CommandParser.Arguments {
5 | public class UuidArgument : IArgument {
6 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out UUID result) {
7 | int start = reader.GetCursor();
8 | while (reader.CanRead() && IsUuidPart(reader.Peek())) {
9 | reader.Skip();
10 | }
11 | string uuid = reader.GetString()[start..reader.GetCursor()];
12 | if (!UUID.TryParse(uuid, out result)) {
13 | return ReadResults.Failure(CommandError.InvalidUuid());
14 | }
15 | return ReadResults.Success();
16 | }
17 |
18 | private static bool IsUuidPart(char c) {
19 | return c >= '0' && c <= '9' ||
20 | c >= 'a' && c <= 'f' ||
21 | c >= 'A' && c <= 'F' ||
22 | c == '-';
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/Range.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace CommandParser.Results.Arguments
5 | {
6 | public class Range where T : struct, IComparable
7 | {
8 | public T Minimum { get; }
9 | public T Maximum { get; }
10 |
11 | public Range(T minimum, T maximum)
12 | {
13 | Minimum = minimum;
14 | Maximum = maximum;
15 | }
16 |
17 | public override string ToString()
18 | {
19 | return $"{Minimum}..{Maximum}";
20 | }
21 |
22 | public override bool Equals(object obj)
23 | {
24 | return obj is Range range &&
25 | EqualityComparer.Default.Equals(Minimum, range.Minimum) &&
26 | EqualityComparer.Default.Equals(Maximum, range.Maximum);
27 | }
28 |
29 | public override int GetHashCode()
30 | {
31 | return HashCode.Combine(Minimum, Maximum);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/Builders/Collections/StructureMirrorsBuilder.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Collections;
2 | using Newtonsoft.Json;
3 | using System.Collections.Generic;
4 |
5 | namespace FunctionAnalyser.Builders.Collections
6 | {
7 | public class StructureMirrorsBuilder : IBuilder
8 | {
9 | [JsonProperty("parent")]
10 | private readonly string Parent;
11 | [JsonProperty("values")]
12 | private readonly HashSet Values;
13 |
14 | public StructureMirrors Build(Dictionary resources)
15 | {
16 | HashSet all = new HashSet(Values);
17 | StructureMirrorsBuilder builder = this;
18 | while (builder.Parent != null)
19 | {
20 | builder = resources[builder.Parent];
21 | foreach (string s in builder.Values) all.Add(s);
22 | }
23 | return new StructureMirrors(all);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Parsers/ComponentParser/ComponentArguments/ComponentString.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Collections;
2 | using CommandParser.Parsers.JsonParser;
3 | using CommandParser.Parsers.JsonParser.JsonArguments;
4 | using CommandParser.Results;
5 |
6 | namespace CommandParser.Parsers.ComponentParser.ComponentArguments
7 | {
8 | public class ComponentString : ComponentArgument
9 | {
10 | public override ReadResults Validate(JsonObject obj, string key, ComponentReader componentReader, Components components, IStringReader reader, int start, DispatcherResources resources)
11 | {
12 | if (!IsText(obj.GetChild(key)))
13 | {
14 | reader.SetCursor(start);
15 | return ReadResults.Failure(ComponentCommandError.InvalidComponent(key, JsonArgumentType.String, obj.GetChild(key).GetArgumentType()).WithContext(reader));
16 | }
17 | return ValidateChildren(obj, key, componentReader, components, reader, start, resources);
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Parsers/ComponentParser/ComponentArguments/ComponentRootObject.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Collections;
2 | using CommandParser.Parsers.JsonParser;
3 | using CommandParser.Parsers.JsonParser.JsonArguments;
4 | using CommandParser.Results;
5 |
6 | namespace CommandParser.Parsers.ComponentParser.ComponentArguments
7 | {
8 | public class ComponentRootObject : ComponentArgument
9 | {
10 | public override ReadResults Validate(JsonObject obj, string key, ComponentReader componentReader, Components components, IStringReader reader, int start, DispatcherResources resources)
11 | {
12 | if (obj.GetChild(key) is not JsonObject actualObject)
13 | {
14 | reader.SetCursor(start);
15 | return ReadResults.Failure(ComponentCommandError.InvalidComponent(key, JsonArgumentType.Object, obj.GetChild(key).GetArgumentType()).WithContext(reader));
16 | }
17 | return componentReader.ValidateObject(actualObject, components);
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Minecraft/Coordinates/LocalCoordinates.cs:
--------------------------------------------------------------------------------
1 | using System.Globalization;
2 |
3 | namespace CommandParser.Minecraft.Coordinates {
4 | public class LocalCoordinates : ICoordinates {
5 | public double Left { get; }
6 | public double Up { get; }
7 | public double Forwards { get; }
8 |
9 | public LocalCoordinates(double left, double up, double forwards) {
10 | Left = left;
11 | Up = up;
12 | Forwards = forwards;
13 | }
14 |
15 | public bool IsXRelative() {
16 | return true;
17 | }
18 |
19 | public bool IsYRelative() {
20 | return true;
21 | }
22 |
23 | public bool IsZRelative() {
24 | return true;
25 | }
26 |
27 | public override string ToString() {
28 | return "^" + Left.ToString(NumberFormatInfo.InvariantInfo) + " ^" + Up.ToString(NumberFormatInfo.InvariantInfo) + " ^" + Forwards.ToString(NumberFormatInfo.InvariantInfo);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/Builders/Collections/BlocksBuilder.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Collections;
2 | using Newtonsoft.Json;
3 | using System.Collections.Generic;
4 |
5 | namespace FunctionAnalyser.Builders.Collections
6 | {
7 | public class BlocksBuilder : IBuilder
8 | {
9 | [JsonProperty("parent")]
10 | private readonly string Parent;
11 | [JsonProperty("values")]
12 | private readonly Dictionary Values;
13 |
14 | public Blocks Build(Dictionary resources)
15 | {
16 | Dictionary all = new Dictionary(Values);
17 | BlocksBuilder builder = this;
18 | while (builder.Parent != null)
19 | {
20 | builder = resources[builder.Parent];
21 | foreach (KeyValuePair pair in builder.Values) all.Add(pair.Key, pair.Value);
22 | }
23 | return new Blocks(all);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/Builders/Collections/StructureRotationsBuilder.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Collections;
2 | using Newtonsoft.Json;
3 | using System.Collections.Generic;
4 |
5 | namespace FunctionAnalyser.Builders.Collections
6 | {
7 | public class StructureRotationsBuilder : IBuilder
8 | {
9 | [JsonProperty("parent")]
10 | private readonly string Parent;
11 | [JsonProperty("values")]
12 | private readonly HashSet Values;
13 |
14 | public StructureRotations Build(Dictionary resources)
15 | {
16 | HashSet all = new HashSet(Values);
17 | StructureRotationsBuilder builder = this;
18 | while (builder.Parent != null)
19 | {
20 | builder = resources[builder.Parent];
21 | foreach (string s in builder.Values) all.Add(s);
22 | }
23 | return new StructureRotations(all);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/Builders/Collections/TimeScalarsBuilder.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Collections;
2 | using Newtonsoft.Json;
3 | using System.Collections.Generic;
4 |
5 | namespace FunctionAnalyser.Builders.Collections
6 | {
7 | public class TimeScalarsBuilder : IBuilder
8 | {
9 | [JsonProperty("parent")]
10 | private readonly string Parent;
11 | [JsonProperty("values")]
12 | private readonly Dictionary Values;
13 |
14 | public TimeScalars Build(Dictionary resources)
15 | {
16 | Dictionary all = new Dictionary(Values);
17 | TimeScalarsBuilder builder = this;
18 | while (builder.Parent != null)
19 | {
20 | builder = resources[builder.Parent];
21 | foreach (KeyValuePair pair in builder.Values) all.Add(pair.Key, pair.Value);
22 | }
23 | return new TimeScalars(all);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Parsers/JsonParser/JsonArguments/JsonString.cs:
--------------------------------------------------------------------------------
1 | using static CommandParser.Parsers.JsonParser.JsonCharacterProvider;
2 |
3 | namespace CommandParser.Parsers.JsonParser.JsonArguments
4 | {
5 | public class JsonString : IJsonArgument
6 | {
7 | public const string NAME = "String";
8 |
9 | private readonly string String;
10 |
11 | public JsonString(string s)
12 | {
13 | String = s;
14 | }
15 |
16 | public string AsJson()
17 | {
18 | return $"{STRING_CHARACTER}{String}{STRING_CHARACTER}";
19 | }
20 |
21 | public string GetName() => NAME;
22 |
23 | public JsonArgumentType GetArgumentType()
24 | {
25 | return JsonArgumentType.String;
26 | }
27 |
28 | public static implicit operator string(JsonString s)
29 | {
30 | return s.String;
31 | }
32 |
33 | public override string ToString()
34 | {
35 | return String;
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Collections/Blocks.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using System.Collections.Generic;
3 |
4 | namespace CommandParser.Collections
5 | {
6 | public class Blocks
7 | {
8 | private readonly Dictionary Values;
9 |
10 | public Blocks() : this(new Dictionary()) { }
11 |
12 | public Blocks(Dictionary values)
13 | {
14 | Values = values;
15 | }
16 |
17 | public bool ContainsBlock(ResourceLocation item)
18 | {
19 | return item.IsDefaultNamespace() && Values.ContainsKey(item.Path);
20 | }
21 |
22 | public bool ContainsProperty(ResourceLocation item, string property)
23 | {
24 | return Values[item.Path].ContainsProperty(property);
25 | }
26 |
27 | public bool PropertyContainsValue(ResourceLocation item, string property, string value)
28 | {
29 | return Values[item.Path].PropertyContainsValue(property, value);
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Parsers/ComponentParser/ComponentArguments/ComponentObject.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Collections;
2 | using CommandParser.Parsers.JsonParser;
3 | using CommandParser.Parsers.JsonParser.JsonArguments;
4 | using CommandParser.Results;
5 |
6 | namespace CommandParser.Parsers.ComponentParser.ComponentArguments
7 | {
8 | public class ComponentObject : ComponentArgument
9 | {
10 | public override ReadResults Validate(JsonObject obj, string key, ComponentReader componentReader, Components components, IStringReader reader, int start, DispatcherResources resources)
11 | {
12 | if (obj.GetChild(key) is not JsonObject actualObject)
13 | {
14 | reader.SetCursor(start);
15 | return ReadResults.Failure(ComponentCommandError.InvalidComponent(key, JsonArgumentType.Object, obj.GetChild(key).GetArgumentType()).WithContext(reader));
16 | }
17 | return ValidateChildren(actualObject, key, componentReader, components, reader, start, resources);
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/ComponentArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Parsers.ComponentParser;
2 | using CommandParser.Parsers.JsonParser;
3 | using CommandParser.Parsers.JsonParser.JsonArguments;
4 | using CommandParser.Results;
5 | using CommandParser.Results.Arguments;
6 |
7 | namespace CommandParser.Arguments
8 | {
9 | public class ComponentArgument : IArgument
10 | {
11 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Component result)
12 | {
13 | result = default;
14 | if (!reader.CanRead()) return ReadResults.Failure(CommandError.IncorrectArgument().WithContext(reader));
15 | int start = reader.GetCursor();
16 |
17 | ReadResults readResults = new JsonReader(reader).ReadAny(out IJsonArgument json);
18 | if (!readResults.Successful) return readResults;
19 | result = new Component(json);
20 | return new ComponentReader(reader, start, resources).ValidateFromRoot(json, resources.Components);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Minecraft/Nbt/Tags/ByteArrayNbtTag.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Text;
3 |
4 | namespace CommandParser.Minecraft.Nbt.Tags {
5 | public class ByteArrayNbtTag : INbtCollectionTag {
6 | private readonly List Data;
7 |
8 | public ByteArrayNbtTag() {
9 | Data = new List();
10 | }
11 |
12 | public string GetName() {
13 | return "TAG_Byte_Array";
14 | }
15 |
16 | public string ToSnbt() {
17 | StringBuilder stringBuilder = new StringBuilder("[B;");
18 | stringBuilder.Append(NbtUtilities.Join(", ", Data, n => n.ToSnbt()));
19 | return stringBuilder.Append(']').ToString();
20 | }
21 |
22 | public sbyte GetId() {
23 | return 7;
24 | }
25 |
26 | public bool Add(INbtTag tag) {
27 | if (tag is ByteNbtTag b) {
28 | Data.Add(b);
29 | return true;
30 | }
31 | return false;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Minecraft/Nbt/Tags/LongArrayNbtTag.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Text;
3 |
4 | namespace CommandParser.Minecraft.Nbt.Tags {
5 | public class LongArrayNbtTag : INbtCollectionTag {
6 | private readonly List Data;
7 |
8 | public LongArrayNbtTag() {
9 | Data = new List();
10 | }
11 |
12 | public string GetName() {
13 | return "TAG_Long_Array";
14 | }
15 |
16 | public string ToSnbt() {
17 | StringBuilder stringBuilder = new StringBuilder("[L;");
18 | stringBuilder.Append(NbtUtilities.Join(", ", Data, n => n.ToSnbt()));
19 | return stringBuilder.Append(']').ToString();
20 | }
21 |
22 | public sbyte GetId() {
23 | return 12;
24 | }
25 |
26 | public bool Add(INbtTag tag) {
27 | if (tag is LongNbtTag l) {
28 | Data.Add(l);
29 | return true;
30 | }
31 | return false;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/Builders/Collections/ParticlesBuilder.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Collections;
2 | using CommandParser.Tree;
3 | using Newtonsoft.Json;
4 | using System.Collections.Generic;
5 |
6 | namespace FunctionAnalyser.Builders.Collections
7 | {
8 | public class ParticlesBuilder : IBuilder
9 | {
10 | [JsonProperty("parent")]
11 | private readonly string Parent;
12 | [JsonProperty("values")]
13 | private readonly Dictionary Values;
14 |
15 | public Particles Build(Dictionary resources)
16 | {
17 | Dictionary all = new Dictionary(Values);
18 | ParticlesBuilder builder = this;
19 | while (builder.Parent != null)
20 | {
21 | builder = resources[builder.Parent];
22 | foreach (KeyValuePair pair in builder.Values) all.Add(pair.Key, pair.Value);
23 | }
24 | return new Particles(all);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/ItemComponentArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Parsers.ComponentParser;
2 | using CommandParser.Parsers.JsonParser;
3 | using CommandParser.Parsers.JsonParser.JsonArguments;
4 | using CommandParser.Results;
5 | using CommandParser.Results.Arguments;
6 |
7 | namespace CommandParser.Arguments
8 | {
9 | public class ItemComponentArgument : IArgument
10 | {
11 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out ItemComponent result)
12 | {
13 | result = default;
14 | if (!reader.CanRead()) return ReadResults.Failure(CommandError.IncorrectArgument().WithContext(reader));
15 | int start = reader.GetCursor();
16 |
17 | ReadResults readResults = new JsonReader(reader).ReadAny(out IJsonArgument json);
18 | if (!readResults.Successful) return readResults;
19 | result = new ItemComponent(json);
20 | return new ComponentReader(reader, start, resources).ValidateFromRoot(json, resources.ItemComponents);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Minecraft/Nbt/Tags/IntegerArrayNbtTag.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Text;
3 |
4 | namespace CommandParser.Minecraft.Nbt.Tags {
5 | public class IntegerArrayNbtTag : INbtCollectionTag {
6 | private readonly List Data;
7 |
8 | public IntegerArrayNbtTag() {
9 | Data = new List();
10 | }
11 |
12 | public string GetName() {
13 | return "TAG_Integer_Array";
14 | }
15 |
16 | public string ToSnbt() {
17 | StringBuilder stringBuilder = new StringBuilder("[I;");
18 | stringBuilder.Append(NbtUtilities.Join(", ", Data, n => n.ToSnbt()));
19 | return stringBuilder.Append(']').ToString();
20 | }
21 |
22 | public sbyte GetId() {
23 | return 11;
24 | }
25 |
26 | public bool Add(INbtTag tag) {
27 | if (tag is IntegerNbtTag i) {
28 | Data.Add(i);
29 | return true;
30 | }
31 | return false;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Results/Arguments/EntitySelector.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Context;
2 | using System.Collections.Generic;
3 |
4 | namespace CommandParser.Results.Arguments
5 | {
6 | public enum SelectorType
7 | {
8 | None = 0,
9 | NearestPlayer = 1,
10 | AllPlayers = 2,
11 | RandomPlayer = 3,
12 | AllEntities = 4,
13 | Self = 5
14 | }
15 |
16 | public class EntitySelector
17 | {
18 | public EntitySelector(bool includesEntities, int maxResults, bool isSelf, SelectorType selectorType, List arguments)
19 | {
20 | IncludesEntities = includesEntities;
21 | MaxResults = maxResults;
22 | IsSelf = isSelf;
23 | SelectorType = selectorType;
24 | Arguments = arguments;
25 | }
26 |
27 | public bool IncludesEntities { get; }
28 | public int MaxResults { get; }
29 | public bool IsSelf { get; }
30 | public SelectorType SelectorType { get; }
31 | public List Arguments { get; }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/ObjectiveArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Results;
2 | using CommandParser.Results.Arguments;
3 | using Newtonsoft.Json;
4 |
5 | namespace CommandParser.Arguments
6 | {
7 | public class ObjectiveArgument : IArgument
8 | {
9 | [JsonProperty("use_bedrock")]
10 | private readonly bool UseBedrock;
11 |
12 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Objective result)
13 | {
14 | result = default;
15 | ReadResults readResults;
16 | string objective;
17 |
18 | if (UseBedrock) readResults = reader.ReadString(out objective);
19 | else readResults = reader.ReadUnquotedString(out objective);
20 |
21 | if (!readResults.Successful) return readResults;
22 | if (objective.Length > 16)
23 | {
24 | return ReadResults.Failure(CommandError.ObjectiveNameTooLong());
25 | }
26 | result = new Objective(objective);
27 | return ReadResults.Success();
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/Builders/Collections/ScoreboardSlotsBuilder.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Collections;
2 | using Newtonsoft.Json;
3 | using System.Collections.Generic;
4 |
5 | namespace FunctionAnalyser.Builders.Collections
6 | {
7 | public class ScoreboardSlotsBuilder : IBuilder
8 | {
9 | [JsonProperty("parent")]
10 | private readonly string Parent;
11 | [JsonProperty("values")]
12 | private readonly Dictionary Values;
13 |
14 | public ScoreboardSlots Build(Dictionary resources)
15 | {
16 | Dictionary all = new Dictionary(Values);
17 | ScoreboardSlotsBuilder builder = this;
18 | while (builder.Parent != null)
19 | {
20 | builder = resources[builder.Parent];
21 | foreach (KeyValuePair pair in builder.Values) all.Add(pair.Key, pair.Value);
22 | }
23 | return new ScoreboardSlots(all);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Minecraft/Nbt/Tags/ListNbtTag.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Text;
3 |
4 | namespace CommandParser.Minecraft.Nbt.Tags {
5 | public class ListNbtTag : INbtCollectionTag {
6 | private readonly List Data;
7 | private sbyte? Type;
8 |
9 | public ListNbtTag() {
10 | Data = new List();
11 | Type = null;
12 | }
13 |
14 | public string GetName() {
15 | return "TAG_List";
16 | }
17 |
18 | public string ToSnbt() {
19 | StringBuilder stringBuilder = new StringBuilder("[");
20 | stringBuilder.Append(NbtUtilities.Join(", ", Data, n => n.ToSnbt()));
21 | return stringBuilder.Append(']').ToString();
22 | }
23 |
24 | public sbyte GetId() {
25 | return 9;
26 | }
27 |
28 | public bool Add(INbtTag tag) {
29 | sbyte id = tag.GetId();
30 | if (Type == null) Type = id;
31 | else if (Type != id) return false;
32 |
33 | Data.Add(tag);
34 | return true;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Context/Range.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace CommandParser.Context
4 | {
5 | public struct Range
6 | {
7 | public int Start { get; }
8 | public int End { get; }
9 |
10 | public Range(int start, int end)
11 | {
12 | Start = start;
13 | End = end;
14 | }
15 |
16 | public bool IsEmpty()
17 | {
18 | return Start == End;
19 | }
20 |
21 | public static Range At(int start)
22 | {
23 | return new Range(start, start);
24 | }
25 |
26 | public static Range Encompassing(Range left, Range right)
27 | {
28 | return new Range(Math.Min(left.Start, right.Start), Math.Max(left.End, right.End));
29 | }
30 |
31 | public override bool Equals(object obj)
32 | {
33 | return obj is Range range &&
34 | Start == range.Start &&
35 | End == range.End;
36 | }
37 |
38 | public override int GetHashCode()
39 | {
40 | return HashCode.Combine(Start, End);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/FunctionAnalyser/UserInterface/UserInterface.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net6.0-windows
6 | true
7 | 1.2.0.0
8 | 1.2.0.0
9 | command_block.ico
10 | ErrorCraft
11 | Function Analyser
12 | A tool that analyses your functions and generates a report that includes details about them.
13 | Function Analyser
14 | Function Analyser
15 | 1.2.0
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/FunctionAnalyser/UserInterface/UserInterface.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | <_LastSelectedProfileId>C:\Users\Ramon\source\repos\FunctionAnalyser\FunctionAnalyser\UserInterface\Properties\PublishProfiles\FolderProfile.pubxml
5 |
6 |
7 |
8 | Designer
9 |
10 |
11 |
12 |
13 | Code
14 |
15 |
16 | Code
17 |
18 |
19 |
20 |
21 | Designer
22 |
23 |
24 | Designer
25 |
26 |
27 | Designer
28 |
29 |
30 |
--------------------------------------------------------------------------------
/FunctionAnalyser/ErrorCraft.FunctionAnalyser.UI.Avalonia/Controls/BorderedPanel.axaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
30 |
31 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Parsers/ComponentParser/ComponentArguments/ComponentUuid.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Collections;
2 | using CommandParser.Parsers.JsonParser;
3 | using CommandParser.Parsers.JsonParser.JsonArguments;
4 | using CommandParser.Results;
5 | using Utilities;
6 |
7 | namespace CommandParser.Parsers.ComponentParser.ComponentArguments {
8 | public class ComponentUuid : ComponentArgument {
9 | public override ReadResults Validate(JsonObject obj, string key, ComponentReader componentReader, Components components, IStringReader reader, int start, DispatcherResources resources) {
10 | if (!IsText(obj.GetChild(key))) {
11 | reader.SetCursor(start);
12 | return ReadResults.Failure(ComponentCommandError.InvalidComponent(key, JsonArgumentType.String, obj.GetChild(key).GetArgumentType()).WithContext(reader));
13 | }
14 | if (!UUID.TryParse(obj.GetChild(key).ToString(), out _)) {
15 | reader.SetCursor(start);
16 | return ReadResults.Failure(CommandError.InvalidUuid().WithContext(reader));
17 | }
18 | return ReadResults.Success();
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/FunctionAnalyser/FunctionAnalyser/Builders/Collections/SelectorArgumentsBuilder.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Collections;
2 | using Newtonsoft.Json;
3 | using System.Collections.Generic;
4 |
5 | namespace FunctionAnalyser.Builders.Collections
6 | {
7 | public class SelectorArgumentsBuilder : IBuilder
8 | {
9 | [JsonProperty("parent")]
10 | private readonly string Parent;
11 | [JsonProperty("values")]
12 | private readonly Dictionary Values;
13 |
14 | public EntitySelectorOptions Build(Dictionary resources)
15 | {
16 | Dictionary all = new Dictionary(Values);
17 | SelectorArgumentsBuilder builder = this;
18 | while (builder.Parent != null)
19 | {
20 | builder = resources[builder.Parent];
21 | foreach (KeyValuePair pair in builder.Values) all.Add(pair.Key, pair.Value);
22 | }
23 | return new EntitySelectorOptions(all);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Parsers/ComponentParser/ComponentArguments/ComponentArrayOrRoot.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Collections;
2 | using CommandParser.Parsers.JsonParser.JsonArguments;
3 | using CommandParser.Results;
4 |
5 | namespace CommandParser.Parsers.ComponentParser.ComponentArguments
6 | {
7 | public class ComponentArrayOrRoot : ComponentArgument
8 | {
9 | public override ReadResults Validate(JsonObject obj, string key, ComponentReader componentReader, Components components, IStringReader reader, int start, DispatcherResources resources)
10 | {
11 | ComponentArray componentArray = new ComponentArray();
12 | int end = reader.GetCursor();
13 | ReadResults readResults = componentArray.Validate(obj, key, componentReader, components, reader, start, resources);
14 |
15 | if (!readResults.Successful)
16 | {
17 | reader.SetCursor(end);
18 | ComponentRoot componentRoot = new ComponentRoot();
19 | return componentRoot.Validate(obj, key, componentReader, components, reader, start, resources);
20 | }
21 |
22 | return ReadResults.Success();
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/EntitySummonArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Minecraft;
2 | using CommandParser.Results;
3 | using CommandParser.Results.Arguments;
4 | using Newtonsoft.Json;
5 |
6 | namespace CommandParser.Arguments
7 | {
8 | public class EntitySummonArgument : IArgument
9 | {
10 | [JsonProperty("use_bedrock")]
11 | private readonly bool UseBedrock;
12 |
13 | public ReadResults Parse(IStringReader reader, DispatcherResources resources, out Entity result)
14 | {
15 | result = default;
16 | ReadResults readResults = ResourceLocation.TryRead(reader, out ResourceLocation entity);
17 | if (!readResults.Successful) return readResults;
18 |
19 | // Temporary
20 | if (UseBedrock)
21 | {
22 | result = new Entity(entity);
23 | return ReadResults.Success();
24 | }
25 |
26 | if (!resources.Entities.Contains(entity))
27 | {
28 | return ReadResults.Failure(CommandError.UnknownEntity(entity));
29 | }
30 | result = new Entity(entity);
31 | return ReadResults.Success();
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/FunctionAnalyser/Tests/Arguments/BiomeArgumentTests.cs:
--------------------------------------------------------------------------------
1 | using CommandParser;
2 | using CommandParser.Arguments;
3 | using CommandParser.Results;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | namespace Tests.Arguments
7 | {
8 | [TestClass]
9 | public class BiomeArgumentTests
10 | {
11 | [TestMethod]
12 | public void BiomeArgument_ParseShouldSucceed()
13 | {
14 | // Arrange
15 | BiomeArgument argument = new BiomeArgument();
16 | IStringReader reader = new StringReader("foo:bar");
17 |
18 | // Act
19 | ReadResults readResults = argument.Parse(reader, out _);
20 |
21 | // Assert
22 | Assert.IsTrue(readResults.Successful);
23 | }
24 |
25 | [TestMethod]
26 | public void BiomeArgument_ParseShouldFail()
27 | {
28 | // Arrange
29 | BiomeArgument argument = new BiomeArgument();
30 | IStringReader reader = new StringReader("foo::bar");
31 |
32 | // Act
33 | ReadResults readResults = argument.Parse(reader, out _);
34 |
35 | // Assert
36 | Assert.IsFalse(readResults.Successful);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/FunctionAnalyser/Tests/Arguments/SoundArgumentTests.cs:
--------------------------------------------------------------------------------
1 | using CommandParser;
2 | using CommandParser.Arguments;
3 | using CommandParser.Results;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | namespace Tests.Arguments
7 | {
8 | [TestClass]
9 | public class SoundArgumentTests
10 | {
11 | [TestMethod]
12 | public void SoundArgument_ParseShouldSucceed()
13 | {
14 | // Arrange
15 | SoundArgument argument = new SoundArgument();
16 | IStringReader reader = new StringReader("foo:bar");
17 |
18 | // Act
19 | ReadResults readResults = argument.Parse(reader, out _);
20 |
21 | // Assert
22 | Assert.IsTrue(readResults.Successful);
23 | }
24 |
25 | [TestMethod]
26 | public void SoundArgument_ParseShouldFail()
27 | {
28 | // Arrange
29 | SoundArgument argument = new SoundArgument();
30 | IStringReader reader = new StringReader("foo::bar");
31 |
32 | // Act
33 | ReadResults readResults = argument.Parse(reader, out _);
34 |
35 | // Assert
36 | Assert.IsFalse(readResults.Successful);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/FunctionAnalyser/Tests/Arguments/RecipeArgumentTests.cs:
--------------------------------------------------------------------------------
1 | using CommandParser;
2 | using CommandParser.Arguments;
3 | using CommandParser.Results;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | namespace Tests.Arguments
7 | {
8 | [TestClass]
9 | public class RecipeArgumentTests
10 | {
11 | [TestMethod]
12 | public void RecipeArgument_ParseShouldSucceed()
13 | {
14 | // Arrange
15 | RecipeArgument argument = new RecipeArgument();
16 | IStringReader reader = new StringReader("foo:bar");
17 |
18 | // Act
19 | ReadResults readResults = argument.Parse(reader, out _);
20 |
21 | // Assert
22 | Assert.IsTrue(readResults.Successful);
23 | }
24 |
25 | [TestMethod]
26 | public void RecipeArgument_ParseShouldFail()
27 | {
28 | // Arrange
29 | RecipeArgument argument = new RecipeArgument();
30 | IStringReader reader = new StringReader("foo::bar");
31 |
32 | // Act
33 | ReadResults readResults = argument.Parse(reader, out _);
34 |
35 | // Assert
36 | Assert.IsFalse(readResults.Successful);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/FunctionAnalyser/Tests/Arguments/BossbarArgumentTests.cs:
--------------------------------------------------------------------------------
1 | using CommandParser;
2 | using CommandParser.Arguments;
3 | using CommandParser.Results;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | namespace Tests.Arguments
7 | {
8 | [TestClass]
9 | public class BossbarArgumentTests
10 | {
11 | [TestMethod]
12 | public void BossbarArgument_ParseShouldSucceed()
13 | {
14 | // Arrange
15 | BossbarArgument argument = new BossbarArgument();
16 | IStringReader reader = new StringReader("foo:bar");
17 |
18 | // Act
19 | ReadResults readResults = argument.Parse(reader, out _);
20 |
21 | // Assert
22 | Assert.IsTrue(readResults.Successful);
23 | }
24 |
25 | [TestMethod]
26 | public void BossbarArgument_ParseShouldFail()
27 | {
28 | // Arrange
29 | BossbarArgument argument = new BossbarArgument();
30 | IStringReader reader = new StringReader("foo::bar");
31 |
32 | // Act
33 | ReadResults readResults = argument.Parse(reader, out _);
34 |
35 | // Assert
36 | Assert.IsFalse(readResults.Successful);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/FunctionAnalyser/Tests/Arguments/StorageArgumentTests.cs:
--------------------------------------------------------------------------------
1 | using CommandParser;
2 | using CommandParser.Arguments;
3 | using CommandParser.Results;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | namespace Tests.Arguments
7 | {
8 | [TestClass]
9 | public class StorageArgumentTests
10 | {
11 | [TestMethod]
12 | public void StorageArgument_ParseShouldSucceed()
13 | {
14 | // Arrange
15 | StorageArgument argument = new StorageArgument();
16 | IStringReader reader = new StringReader("foo:bar");
17 |
18 | // Act
19 | ReadResults readResults = argument.Parse(reader, out _);
20 |
21 | // Assert
22 | Assert.IsTrue(readResults.Successful);
23 | }
24 |
25 | [TestMethod]
26 | public void StorageArgument_ParseShouldFail()
27 | {
28 | // Arrange
29 | StorageArgument argument = new StorageArgument();
30 | IStringReader reader = new StringReader("foo::bar");
31 |
32 | // Act
33 | ReadResults readResults = argument.Parse(reader, out _);
34 |
35 | // Assert
36 | Assert.IsFalse(readResults.Successful);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/FunctionAnalyser/CommandParser/Arguments/TimeArgument.cs:
--------------------------------------------------------------------------------
1 | using CommandParser.Results;
2 | using CommandParser.Results.Arguments;
3 |
4 | namespace CommandParser.Arguments
5 | {
6 | public class TimeArgument : IArgument