Пример #1
0
 /// <summary>
 /// Executes if the <paramref name="mainSelector"/>'s score value is <paramref name="operation"/> than <paramref name="otherSelector"/>'s score value
 /// </summary>
 /// <param name="mainSelector">The first <see cref="BaseSelector"/></param>
 /// <param name="mainObject">The first <see cref="BaseSelector"/>'s <see cref="Objective"/></param>
 /// <param name="operation">The operation used to check the scores</param>
 /// <param name="otherSelector">The second <see cref="BaseSelector"/></param>
 /// <param name="otherObject">The second <see cref="BaseSelector"/>'s <see cref="Objective"/></param>
 /// <param name="want">false if it should execute when it's false</param>
 /// <returns>The function running the command</returns>
 public Function IfScore(BaseSelector mainSelector, Objective mainObject, ID.IfScoreOperation operation, BaseSelector otherSelector, Objective otherObject, bool want = true)
 {
     mainSelector.LimitSelector();
     otherSelector.LimitSelector();
     ForFunction.AddCommand(new ExecuteIfScoreRelative(mainSelector, mainObject, operation, otherSelector, otherObject, want));
     return(ForFunction);
 }
Пример #2
0
 /// <summary>
 /// Forces a player to spectate an entity. The player has to be in spectator mode. Leave both params empty to make the executing player stop spectating
 /// </summary>
 /// <param name="spectate">The entity to spectate</param>
 /// <param name="spectator">The spectating player</param>
 public void Spectate(BaseSelector spectate, BaseSelector spectator)
 {
     if (spectate is null)
     {
         ForFunction.AddCommand(new SpectateStopCommand());
     }
     else
     {
         spectate.LimitSelector();
         spectator.LimitSelector();
         ForFunction.AddCommand(new SpectateCommand(spectate, spectator));
     }
 }
Пример #3
0
 /// <summary>
 /// Copies data from a place to an entity at the data path's specified index
 /// </summary>
 /// <param name="toSelector">The entity to copy the data to</param>
 /// <param name="toDataPath">The data path to copy to</param>
 /// <param name="dataLocation">The place to copy the data from</param>
 /// <param name="index">the index to copy to</param>
 public void Copy(BaseSelector toSelector, string toDataPath, IDataLocation dataLocation, int index)
 {
     toSelector.LimitSelector();
     ForFunction.AddCommand(new DataModifyInsertLocationCommand(new EntityDataLocation(toSelector, toDataPath), index, dataLocation));
 }
Пример #4
0
 /// <summary>
 /// Copies data from a place to an entity
 /// </summary>
 /// <param name="toSelector">The entity to copy the data to</param>
 /// <param name="toDataPath">The data path to copy to</param>
 /// <param name="dataLocation">The place to copy the data from</param>
 /// <param name="modifierType">The way to add the data</param>
 public void Copy(BaseSelector toSelector, string toDataPath, ID.EntityDataModifierType modifierType, IDataLocation dataLocation)
 {
     toSelector.LimitSelector();
     ForFunction.AddCommand(new DataModifyWithLocationCommand(new EntityDataLocation(toSelector, toDataPath), modifierType, dataLocation));
 }
Пример #5
0
 /// <summary>
 /// Gets a numeric value from the selected entity's data at the given path
 /// </summary>
 /// <param name="selector">The <see cref="BaseSelector"/> to use</param>
 /// <param name="dataPath">The path to the data to get the number from</param>
 /// <param name="scale">The number to multiply the output number by</param>
 public void Get(BaseSelector selector, string dataPath, double scale = 1)
 {
     selector.LimitSelector();
     ForFunction.AddCommand(new DataGetCommand(new EntityDataLocation(selector, dataPath), scale));
 }
Пример #6
0
 /// <summary>
 /// Gives the loot which the selected entity would drop if killed to the selected players
 /// </summary>
 /// <param name="player">the <see cref="BaseSelector"/> to use</param>
 /// <param name="kill">the selector selecting the entity whose loot should be dropped</param>
 public void GiveItem(BaseSelector player, BaseSelector kill)
 {
     kill.LimitSelector();
     ForFunction.AddCommand(new LootCommand(new LootTargets.GiveTarget(player), new LootSources.KillSource(kill)));
 }
Пример #7
0
 /// <summary>
 /// Removes an attribute modifer from an entity
 /// </summary>
 /// <param name="selector">Selector which selects the entity to remove the modifier from</param>
 /// <param name="attribute">The attribute to remove the modifier from</param>
 /// <param name="uuid">The UUID of the modifier</param>
 public void RemoveModifier(BaseSelector selector, ID.AttributeType attribute, UUID uuid)
 {
     selector.LimitSelector();
     Function.AddCommand(new AttributeRemoveModifierCommand(selector, attribute, uuid));
 }
Пример #8
0
 /// <summary>
 /// Sets the base value of an attribute
 /// </summary>
 /// <param name="selector">Selector which selects the entity to set the attribute base for</param>
 /// <param name="attribute">The attribute base to set</param>
 /// <param name="value">The value to set the base to</param>
 public void SetBase(BaseSelector selector, ID.AttributeType attribute, double value)
 {
     selector.LimitSelector();
     Function.AddCommand(new AttributeSetBaseCommand(selector, attribute, value));
 }
Пример #9
0
 /// <summary>
 /// Gets the selected entity's score and outputs it
 /// </summary>
 /// <param name="selector">the <see cref="BaseSelector"/> to use</param>
 /// <param name="objective">the <see cref="Objective"/> to take the score from</param>
 public void Get(BaseSelector selector, Objective objective)
 {
     selector.LimitSelector();
     ForFunction.AddCommand(new ScoreboardValueGetCommand(selector, objective));
 }
Пример #10
0
 /// <summary>
 /// Teleports the selected entities to the specified location facing another entity
 /// </summary>
 /// <param name="selector">The <see cref="BaseSelector"/> to use</param>
 /// <param name="tpTo">The location to teleport the entities to</param>
 /// <param name="facing">The selector the entities should look at</param>
 /// <param name="facingPart">The part of the entity to look at</param>
 public void Teleport(BaseSelector selector, Vector?tpTo, BaseSelector facing, ID.FacingAnchor facingPart = ID.FacingAnchor.feet)
 {
     facing.LimitSelector();
     ForFunction.AddCommand(new TeleportToFacingEntityCommand(tpTo ?? new Coords(), selector, facing, facingPart));
 }
Пример #11
0
 /// <summary>
 /// Executes if the given <see cref="BaseSelector"/>'s score is in the given <see cref="MCRange"/>
 /// </summary>
 /// <param name="selector">the <see cref="BaseSelector"/>'s score to check</param>
 /// <param name="scoreObject">the <see cref="Objective"/> to containing the score</param>
 /// <param name="range">the <see cref="MCRange"/> the score should be in</param>
 /// <param name="want">false if it should execute when it's false</param>
 /// <returns>The function running the command</returns>
 public Function IfScore(BaseSelector selector, Objective scoreObject, MCRange range, bool want = true)
 {
     selector.LimitSelector();
     ForFunction.AddCommand(new ExecuteIfScoreMatches(selector, scoreObject, range, want));
     return(ForFunction);
 }
Пример #12
0
 /// <summary>
 /// Executes if the <see cref="Entity"/> selected with <paramref name="dataPath"/> has the given datapath
 /// </summary>
 /// <param name="entitySelector">The <see cref="BaseSelector"/> which selects the entity</param>
 /// <param name="dataPath">The datapath the entity should contain</param>
 /// <param name="want">false if it should execute when it's false</param>
 /// <returns>The function running the command</returns>
 public Function IfData(BaseSelector entitySelector, string dataPath, bool want = true)
 {
     entitySelector.LimitSelector();
     ForFunction.AddCommand(new ExecuteIfData(new EntityDataLocation(entitySelector, dataPath), want));
     return(ForFunction);
 }
Пример #13
0
 /// <summary>
 /// Outputs the amount of points the selected player has
 /// </summary>
 /// <param name="player">the <see cref="BaseSelector"/> to use</param>
 public void PointsGet(BaseSelector player)
 {
     player.LimitSelector();
     ForFunction.AddCommand(new ExperienceGetCommand(player, false));
 }
Пример #14
0
 /// <summary>
 /// Outputs the amount of levels the selected player has
 /// </summary>
 /// <param name="player">the <see cref="BaseSelector"/> to use</param>
 public void LevelsGet(BaseSelector player)
 {
     player.LimitSelector();
     ForFunction.AddCommand(new ExperienceGetCommand(player, true));
 }
Пример #15
0
 /// <summary>
 /// Does math with a score and a number and saves the result in the entity's score
 /// </summary>
 /// <param name="mainSelector">The entity score to do math on (Result will be saved in here)</param>
 /// <param name="mainObjective">The <see cref="Objective"/> to get the value from to do math on</param>
 /// <param name="operationType">The operation to do between the numbers</param>
 /// <param name="number">The number to do math with</param>
 public void Operation(BaseSelector mainSelector, Objective mainObjective, ID.Operation operationType, int number)
 {
     mainSelector.LimitSelector();
     ForFunction.AddCommand(new ScoreboardOperationCommand(mainSelector, mainObjective, operationType, ForFunction.PackNamespace.Datapack.GetItems <SharpCraftFiles>().AddConstantNumber(number), ForFunction.PackNamespace.Datapack.GetItems <SharpCraftFiles>().ConstantObjective !));
 }
Пример #16
0
 /// <summary>
 /// Does math with two scores and saves the result in one of the entities' score
 /// </summary>
 /// <param name="mainSelector">The first entity (The result will be stored in this entity's score)</param>
 /// <param name="mainObjective">The first entity's <see cref="Objective"/> (The result will be stored in here)</param>
 /// <param name="operationType">The operation to do between the numbers</param>
 /// <param name="otherSelector">The other entity</param>
 /// <param name="otherObjective">The other entity's <see cref="Objective"/></param>
 public void Operation(BaseSelector mainSelector, Objective mainObjective, ID.Operation operationType, BaseSelector otherSelector, Objective otherObjective)
 {
     mainSelector.LimitSelector();
     otherSelector.LimitSelector();
     ForFunction.AddCommand(new ScoreboardOperationCommand(mainSelector, mainObjective, operationType, otherSelector, otherObjective));
 }
Пример #17
0
 /// <summary>
 /// Teleports the selected entities to another entity
 /// </summary>
 /// <param name="selector">The <see cref="BaseSelector"/> to use</param>
 /// <param name="toSelector">The entity to teleport to</param>
 public void Teleport(BaseSelector selector, BaseSelector toSelector)
 {
     toSelector.LimitSelector();
     ForFunction.AddCommand(new TeleportToEntityCommand(selector, toSelector));
 }
Пример #18
0
 /// <summary>
 /// Gets the base value of an attribute
 /// </summary>
 /// <param name="selector">Selector which selects the entity to get the attribute base for</param>
 /// <param name="attribute">The attribute base to get</param>
 /// <param name="scale">A value to multiply the attribute base with before outputting</param>
 public void GetBase(BaseSelector selector, ID.AttributeType attribute, double scale = 1)
 {
     selector.LimitSelector();
     Function.AddCommand(new AttributeGetBaseCommand(selector, attribute, scale));
 }
Пример #19
0
 /// <summary>
 /// Adds the data from <paramref name="newEntity"/> to the selected entity
 /// </summary>
 /// <param name="selector">The <see cref="BaseSelector"/> to use</param>
 /// <param name="newEntity">the new data to add to the entity</param>
 public void Change(BaseSelector selector, Data.SimpleDataHolder newEntity)
 {
     selector.LimitSelector();
     ForFunction.AddCommand(new DataMergeEntityCommand(selector, newEntity));
 }
Пример #20
0
 /// <summary>
 /// Adds an attribute modifer to an entity
 /// </summary>
 /// <param name="selector">Selector which selects the entity to add the modifier to</param>
 /// <param name="attribute">The attribute to add the modifier to</param>
 /// <param name="uuid">The UUID of the modifier</param>
 /// <param name="name">The name of the modifier</param>
 /// <param name="value">The value of the modifier</param>
 /// <param name="operation">The modifier's operation</param>
 public void AddModifier(BaseSelector selector, ID.AttributeType attribute, UUID uuid, string name, double value, ID.AttributeOperation operation)
 {
     selector.LimitSelector();
     Function.AddCommand(new AttributeAddModifierCommand(selector, attribute, uuid, name, value, operation));
 }
Пример #21
0
 /// <summary>
 /// Adds the <paramref name="copyData"/> to the entity's data at the specified data path
 /// </summary>
 /// <param name="toSelector">The entity to copy to</param>
 /// <param name="toDataPath">The data path to copy to</param>
 /// <param name="copyData">The data to insert</param>
 /// <param name="modifierType">The way to add the data</param>
 public void Change(BaseSelector toSelector, string toDataPath, ID.EntityDataModifierType modifierType, Data.SimpleDataHolder copyData)
 {
     toSelector.LimitSelector();
     ForFunction.AddCommand(new DataModifyWithDataCommand(new EntityDataLocation(toSelector, toDataPath), modifierType, copyData));
 }
Пример #22
0
 /// <summary>
 /// Gets an attribute modifer from an entity
 /// </summary>
 /// <param name="selector">Selector which selects the entity to get the modifier from</param>
 /// <param name="attribute">The attribute to get the modifier from</param>
 /// <param name="uuid">The UUID of the modifier</param>
 /// <param name="scale">A value to multiply the attribute modifier with before outputting</param>
 public void GetModifier(BaseSelector selector, ID.AttributeType attribute, UUID uuid, double scale)
 {
     selector.LimitSelector();
     Function.AddCommand(new AttributeGetModifierCommand(selector, attribute, uuid, scale));
 }
Пример #23
0
 /// <summary>
 /// Adds the <paramref name="copyData"/> to the entity's data at the specified data path at the specified index of the array
 /// </summary>
 /// <param name="toSelector">The entity to copy to</param>
 /// <param name="toDataPath">The data path to copy to</param>
 /// <param name="copyData">The data to insert</param>
 /// <param name="index">the index to insert the data at</param>
 public void Change(BaseSelector toSelector, string toDataPath, int index, Data.SimpleDataHolder copyData)
 {
     toSelector.LimitSelector();
     ForFunction.AddCommand(new DataModifyInsertDataCommand(new EntityDataLocation(toSelector, toDataPath), index, copyData));
 }