/// <summary> /// Intializes a new <see cref="LootPool"/> /// </summary> /// <param name="rolls">The amount of rolls to make (The amount of entries to use)</param> /// <param name="luckyRolls">The amount of extra rolls to take based on luck</param> /// <param name="conditions">All conditions have to be true for this pool to be used</param> /// <param name="entries">Entries in this pool</param> public LootPool(BaseEntry[] entries, MCRange rolls, BaseCondition[]?conditions = null, MCRange?luckyRolls = null) { Rolls = rolls; LuckyRolls = luckyRolls; Conditions = conditions; Entries = entries; }
/// <summary> /// Intializes a new <see cref="Attribute"/> /// </summary> /// <param name="type">The type of attribute</param> /// <param name="operation">The attribute operation to use</param> /// <param name="value">The value to use in the operation</param> /// <param name="slot">The slot the attribute effect works in</param> public Attribute(ID.AttributeType type, ID.AttributeOperation operation, MCRange value, ID.AttributeSlot slot) { Type = type; Operation = operation; Value = value; Slot = new ID.AttributeSlot[] { slot }; }
public void TestGetAsDataObject() { SharpCraft.Data.IConvertableToDataObject convertable1 = new MCRange(1, 2); SharpCraft.Data.IConvertableToDataObject convertable2 = new MCRange(null, 2); SharpCraft.Data.IConvertableToDataObject convertable3 = new MCRange(1, null); Assert.AreEqual("{max:2,min:1}", convertable1.GetAsDataObject(new object[] { "min", "max", ID.NBTTagType.TagInt }).GetDataString()); Assert.AreEqual("{max:2}", convertable2.GetAsDataObject(new object[] { "min", "max", ID.NBTTagType.TagInt }).GetDataString()); Assert.AreEqual("{min:1}", convertable3.GetAsDataObject(new object[] { "min", "max", ID.NBTTagType.TagInt }).GetDataString()); Assert.AreEqual("{max:2d,min:1d}", convertable1.GetAsDataObject(new object[] { "min", "max", ID.NBTTagType.TagDouble }).GetDataString()); Assert.AreEqual("{max:2s,min:1s}", convertable1.GetAsDataObject(new object[] { "min", "max", ID.NBTTagType.TagShort }).GetDataString()); Assert.AreEqual("{\"max\":2,\"min\":1}", convertable1.GetAsDataObject(new object[] { "min", "max", ID.NBTTagType.TagDouble, true }).GetDataString()); }
public void TestMcRange() { MCRange range = new MCRange(10.3, 50.77); Assert.AreEqual(10.3, range.Minimum, "Constructor didn't set minimum correctly"); Assert.AreEqual(50.77, range.Maximum, "Constructor didn't set maximum correctly"); range = new MCRange(5); Assert.AreEqual(5, range.Minimum, "Single constructor didn't set minimum correctly"); Assert.AreEqual(5, range.Maximum, "Single constructor didn't set maximum correctly"); range = new MCRange(null, 50.77); Assert.IsNull(range.Minimum, "Constructor didn't set minimum to null"); range = new MCRange(10.3, null); Assert.IsNull(range.Maximum, "Constructor didn't set maximum to null"); Assert.ThrowsException <ArgumentNullException>(() => new MCRange(null, null), "Min and max may not both be null"); Assert.ThrowsException <ArgumentException>(() => new MCRange(50, 10), "Max has be higher than min"); }
public void TestImplicitMCRange() { //setup MCRange range1 = 1..2; MCRange range2 = ^ 5..5; MCRange range3 = ^ 3; MCRange range4 = 1..; MCRange range5 = ..^ 1; //test Assert.AreEqual("1..2", range1.SelectorString(), "Range conversion doesn't work"); Assert.AreEqual("-5..5", range2.SelectorString(), "Range doesn't work correctly with negative numbers"); Assert.AreEqual("-3", range3.SelectorString(), "Index to range doesn't work correctly"); Assert.AreEqual("1..", range4.SelectorString(), "Range without end converted incorrectly"); Assert.AreEqual("..-1", range5.SelectorString(), "Range without beginning converted incorrectly"); Assert.AreEqual("1", ((MCRange)1).SelectorString(), "Double converted incorrectly"); Assert.ThrowsException <InvalidCastException>(() => (MCRange)(5..^ 5), "End might not be after start"); Assert.ThrowsException <InvalidCastException>(() => (MCRange)(..1), "Shouldn't be able to figure out range start."); Assert.ThrowsException <InvalidCastException>(() => (MCRange)(^ 1..), "Shouldn't be able to figure out range end"); }
/// <summary> /// Executes if the given score is in the given <see cref="MCRange"/> /// </summary> /// <param name="score">the score to check</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(ScoreValue score, MCRange range, bool want = true) { return(IfScore(score, score, range, want)); }
/// <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); }
/// <summary> /// Intializes a new <see cref="LootingChange"/> /// </summary> /// <param name="count">The amount of items in each stack</param> /// <param name="limit">The maximum amount of items this change can make. Setting to 0 = no limit.</param> public LootingChange(MCRange count, int limit = 0) : base("minecraft:limit_count") { Count = count; Limit = limit; }
/// <summary> /// Intializes a new <see cref="LimitCountChange"/> /// </summary> /// <param name="limit">The amount of items in each stack</param> public LimitCountChange(MCRange limit) : base("minecraft:limit_count") { Limit = limit; }
/// <summary> /// Intializes a new <see cref="DamageChange"/> /// </summary> /// <param name="damage">The amount of damage on the item. (0 = no durability, 1 = full)</param> public DamageChange(MCRange damage) : base("minecraft:set_damage") { Damage = damage; }
/// <summary> /// Intializes a new <see cref="BlockIntStateRange"/> for defining the range of the state /// </summary> /// <param name="min">the minimum the number can be</param> /// <param name="max">the maximum the number can be</param> public BlockIntStateRange(int min, int max) { IntRange = new MCRange(min, max); }
/// <summary> /// Intializes a new <see cref="BlockIntStateRange"/> for defining the range of the state /// </summary> /// <param name="intRange">the range the int can be in</param> public BlockIntStateRange(MCRange intRange) { IntRange = intRange; }
/// <summary> /// Intializes a new <see cref="EnchantRandomlyChange"/> /// </summary> public EnchantRandomlyChange(MCRange levels, bool treasure) : base("minecraft:enchant_with_levels") { Treasure = treasure; Levels = levels; }
/// <summary> /// Intializes a new <see cref="ExecuteIfScoreMatches"/> command /// </summary> /// <param name="selector">Selector selecting the thing to get a score from</param> /// <param name="objective">The <see cref="SharpCraft.Objective"/> to get the score for <see cref="Selector"/> from</param> /// <param name="range">The range the score should be inside</param> /// <param name="executeIf">True to use execute if and false to use execute unless the given thing is true</param> public ExecuteIfScoreMatches(BaseSelector selector, Objective objective, MCRange range, bool executeIf = true) : base(executeIf) { Selector = selector; Objective = objective; Range = range; }
/// <summary> /// Intializes a new <see cref="CountChange"/> /// </summary> /// <param name="count">The amount of items</param> public CountChange(MCRange count) : base("minecraft:set_count") { Count = count; }
/// <summary> /// Intializes a new <see cref="TimeCondition"/> /// </summary> /// <param name="modulo">the value of time to check for</param> /// <param name="time">The number to modulo the real time with</param> public TimeCondition(MCRange time, int?modulo) : base("minecraft:time_check") { Time = time; Modulo = modulo; }