Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler Warnings Clean up #168

Merged
merged 15 commits into from
Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Obsidian.API/Crafting/Builders/CuttingRecipeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ public IRecipe Build()
throw new InvalidOperationException("Recipe must atleast have 1 item as an ingredient");

return new CuttingRecipe
{
Name = this.Name ?? throw new NullReferenceException("Name must not be null"),
Type = CraftingType.Stonecutting,
Group = this.Group,
Ingredient = this.Ingredient ?? throw new NullReferenceException("Ingredient must not be null"),
Count = this.Count,
Result = this.Result != null ? new Ingredient { this.Result } : throw new NullReferenceException("Result is not set.")
};
(
this.Name ?? throw new NullReferenceException("Name must not be null"),
CraftingType.Stonecutting,
this.Group,
this.Result != null ? new Ingredient { this.Result } : throw new NullReferenceException("Result is not set."),
this.Ingredient ?? throw new NullReferenceException("Ingredient must not be null"),
this.Count
);
}
}
}
16 changes: 8 additions & 8 deletions Obsidian.API/Crafting/Builders/ShapedRecipeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ public IRecipe Build()
throw new InvalidOperationException("Keys cannot be empty.");

return new ShapedRecipe
{
Name = this.Name ?? throw new NullReferenceException("Recipe must have a name"),
Type = CraftingType.CraftingShaped,
Group = this.Group,
Pattern = new ReadOnlyCollection<string>(new List<string>(this.pattern)),
Result = this.Result != null ? new Ingredient { this.Result } : throw new NullReferenceException("Result is not set."),
Key = new ReadOnlyDictionary<char, Ingredient>(new Dictionary<char, Ingredient>(this.key))
};
(
this.Name ?? throw new NullReferenceException("Recipe must have a name"),
CraftingType.CraftingShaped,
this.Group,
this.Result != null ? new Ingredient { this.Result } : throw new NullReferenceException("Result is not set."),
new ReadOnlyCollection<string>(new List<string>(this.pattern)),
new ReadOnlyDictionary<char, Ingredient>(new Dictionary<char, Ingredient>(this.key))
);
}

public ShapedRecipeBuilder WithName(string name)
Expand Down
14 changes: 7 additions & 7 deletions Obsidian.API/Crafting/Builders/ShapelessRecipeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ public IRecipe Build()
throw new InvalidOperationException("Ingredients must be filled with atleast 1 item.");

return new ShapelessRecipe
{
Name = this.Name ?? throw new NullReferenceException("Recipe must have a name"),
Type = CraftingType.CraftingShapeless,
Group = this.Group,
Ingredients = new ReadOnlyCollection<Ingredient>(new List<Ingredient>(this.ingredients)),
Result = this.Result != null ? new Ingredient { this.Result } : throw new NullReferenceException("Result is not set.")
};
(
this.Name ?? throw new NullReferenceException("Recipe must have a name"),
CraftingType.CraftingShapeless,
this.Group,
this.Result != null ? new Ingredient { this.Result } : throw new NullReferenceException("Result is not set."),
new ReadOnlyCollection<Ingredient>(new List<Ingredient>(this.ingredients))
);
}

public ShapelessRecipeBuilder WithName(string name)
Expand Down
19 changes: 10 additions & 9 deletions Obsidian.API/Crafting/Builders/SmeltingRecipeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,23 @@ public IRecipe Build()
SmeltingType.Default => CraftingType.Smelting,
SmeltingType.Blasting => CraftingType.Blasting,
SmeltingType.Smoking => CraftingType.Smoking,
SmeltingType.CampfireCooking => CraftingType.CampfireCooking
SmeltingType.CampfireCooking => CraftingType.CampfireCooking,
_ => throw new NotImplementedException()
};

if (this.Ingredient.Count <= 0)
throw new InvalidOperationException("Recipe must atleast have 1 item as an ingredient");

return new SmeltingRecipe
{
Name = this.Name ?? throw new NullReferenceException("Recipe must have a name"),
Type = type,
(
this.Name ?? throw new NullReferenceException("Recipe must have a name"),
type,
Group = this.Group,
Ingredient = this.Ingredient,
Cookingtime = this.CookingTime,
Experience = this.Experience,
Result = this.Result != null ? new Ingredient { this.Result } : throw new NullReferenceException("Result is not set.")
};
this.Result != null ? new Ingredient { this.Result } : throw new NullReferenceException("Result is not set."),
this.Ingredient,
this.Experience,
this.CookingTime
);
}
}

Expand Down
16 changes: 8 additions & 8 deletions Obsidian.API/Crafting/Builders/SmithingRecipeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ public IRecipe Build()
throw new InvalidOperationException("Sub ingredients must have atleast 1 item.");

return new SmithingRecipe
{
Name = this.Name ?? throw new NullReferenceException("Recipe must have a name"),
Type = CraftingType.Smithing,
Group = this.Group,
Base = this.Base,
Addition = this.Addition,
Result = this.Result != null ? new Ingredient { this.Result } : throw new NullReferenceException("Result is not set.")
};
(
this.Name ?? throw new NullReferenceException("Recipe must have a name"),
CraftingType.Smithing,
this.Group,
this.Base,
this.Addition,
this.Result != null ? new Ingredient { this.Result } : throw new NullReferenceException("Result is not set.")
);
}
}
}
10 changes: 10 additions & 0 deletions Obsidian.API/Crafting/CuttingRecipe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,15 @@ public sealed class CuttingRecipe : IRecipe
public Ingredient Ingredient { get; set; }

public int Count { get; set; }

public CuttingRecipe(string name, CraftingType type, string? group, Ingredient result, Ingredient ingredient, int count)
{
Name = name;
Type = type;
Group = group;
Result = result;
Ingredient = ingredient;
Count = count;
}
}
}
2 changes: 1 addition & 1 deletion Obsidian.API/Crafting/IRecipe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public interface IRecipe

public CraftingType Type { get; set; }

public string Group { get; set; }
public string? Group { get; set; }

public Ingredient Result { get; set; }
}
Expand Down
12 changes: 11 additions & 1 deletion Obsidian.API/Crafting/ShapedRecipe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,22 @@ public sealed class ShapedRecipe : IRecipe

public CraftingType Type { get; set; }

public string Group { get; set; }
public string? Group { get; set; }

public Ingredient Result { get; set; }

public IReadOnlyList<string> Pattern { get; set; }

public IReadOnlyDictionary<char, Ingredient> Key { get; set; }

public ShapedRecipe(string name, CraftingType type, string? group, Ingredient result, IReadOnlyList<string> pattern, IReadOnlyDictionary<char, Ingredient> key)
{
Name = name;
Type = type;
Group = group;
Result = result;
Pattern = pattern;
Key = key;
}
}
}
9 changes: 9 additions & 0 deletions Obsidian.API/Crafting/ShapelessRecipe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,14 @@ public sealed class ShapelessRecipe : IRecipe
public Ingredient Result { get; set; }

public IReadOnlyList<Ingredient> Ingredients { get; set; }

public ShapelessRecipe(string name, CraftingType type, string? group, Ingredient result, IReadOnlyList<Ingredient> ingredients)
{
Name = name;
Type = type;
Group = group;
Result = result;
Ingredients = ingredients;
}
}
}
11 changes: 11 additions & 0 deletions Obsidian.API/Crafting/SmeltingRecipe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,16 @@ public sealed class SmeltingRecipe : IRecipe
public float Experience { get; set; }

public int Cookingtime { get; set; }

public SmeltingRecipe(string name, CraftingType type, string? group, Ingredient result, Ingredient ingredient, float experience, int cookingTime)
{
Name = name;
Type = type;
Group = group;
Result = result;
Ingredient = ingredient;
Experience = experience;
Cookingtime = cookingTime;
}
}
}
10 changes: 10 additions & 0 deletions Obsidian.API/Crafting/SmithingRecipe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,15 @@ public sealed class SmithingRecipe : IRecipe
public Ingredient Base { get; set; }

public Ingredient Addition { get; set; }

public SmithingRecipe(string name, CraftingType type, string? group, Ingredient result, Ingredient @base, Ingredient addition)
{
Name = name;
Type = type;
Group = group;
Result = result;
Base = @base;
Addition = addition;
}
}
}
1 change: 1 addition & 0 deletions Obsidian.API/Events/BaseMinecraftEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class BaseMinecraftEventArgs : AsyncEventArgs

/// <summary>
/// Constructs a new instance of the <see cref="BaseMinecraftEventArgs"/> class.
/// </summary>
/// <param name="server">The server that's handling this event.</param>
internal BaseMinecraftEventArgs(IServer server)
{
Expand Down
5 changes: 4 additions & 1 deletion Obsidian.API/Noise/BitShiftInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ public class BitShiftInput : Module
/// <summary>
/// ctor.
/// </summary>
public BitShiftInput() : base(1) { }
public BitShiftInput(Module source0) : base(1)
{
Source0 = source0;
}

/// <summary>
/// Retrieve noise value
Expand Down
4 changes: 2 additions & 2 deletions Obsidian.API/Noise/Blend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public class Blend : Module
/// <summary>
/// ctor.
/// </summary>
public Blend() : base(1)
public Blend(Module source0) : base(1)
{

Source0 = source0;
}

/// <summary>
Expand Down
9 changes: 4 additions & 5 deletions Obsidian.API/Noise/Blur.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public class Blur : Module
/// <summary>
/// ctor.
/// </summary>
public Blur() : base(1)
public Blur(Module source0) : base(1)
{

Source0 = source0;
}

/// <summary>
Expand All @@ -29,11 +29,10 @@ public override double GetValue(double x, double y, double z)
{
// Bitshift the source module by 1 one so we can
// "divide" each pixel into 4 quadrants
var shifted = new BitShiftInput
var shifted = new BitShiftInput(this.Source0)
{
Amount = 1,
Left = false,
Source0 = this.Source0
Left = false
};

var self = shifted.GetValue(x, y, z);
Expand Down
5 changes: 3 additions & 2 deletions Obsidian.API/Noise/FuncRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ public class FuncRunner : Module

public int Utility { get; set; } = 0;

public FuncRunner() : base(1)
public FuncRunner(Module source0, Func<Module, double, double, double, double> conditionFunction) : base(1)
{

Source0 = source0;
ConditionFunction = conditionFunction;
}

public override double GetValue(double x, double y, double z)
Expand Down
6 changes: 4 additions & 2 deletions Obsidian.API/Noise/FuncSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ public class FuncSelector : Module
/// <summary>
/// Ctor.
/// </summary>
public FuncSelector() : base(2)
public FuncSelector(Module source0, Module source1, Func<(double, double, double), int> conditionFunction) : base(2)
{

Source0 = source0;
Source1 = source1;
ConditionFunction = conditionFunction;
}

/// <summary>
Expand Down
9 changes: 4 additions & 5 deletions Obsidian.API/Noise/Interpolate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@ public class Interpolate : Module
{
public Module Source0 { get; set; }

public Interpolate() : base(1)
public Interpolate(Module source0) : base(1)
{

Source0 = source0;
}

public override double GetValue(double x, double y, double z)
{
// Bitshift the source module by 1 one so we can
// "divide" each pixel into 4 quadrants
var shifted = new BitShiftInput
var shifted = new BitShiftInput(this.Source0)
{
Amount = 1,
Left = false,
Source0 = this.Source0
Left = false
};

var center = shifted.GetValue(x, y, z);
Expand Down
4 changes: 2 additions & 2 deletions Obsidian.API/Noise/Polariaze.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ public class Polariaze : Module

public double Center { get; set; } = 0;

public Polariaze() : base(1)
public Polariaze(Module source0) : base(1)
{

Source0 = source0;
}

public override double GetValue(double x, double y, double z)
Expand Down
3 changes: 2 additions & 1 deletion Obsidian.API/Noise/TerrainSelect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ public class TerrainSelect : SharpNoise.Modules.Blend

public Module BiomeSelector { get; set; }

public TerrainSelect()
public TerrainSelect(Module biomeSelector)
{
Source1 = new Constant { ConstantValue = 0 };
BiomeSelector = biomeSelector;
}

public override double GetValue(double x, double y, double z)
Expand Down
5 changes: 3 additions & 2 deletions Obsidian.API/Noise/TransitionMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ public class TransitionMap : Module
/// <summary>
/// ctor.
/// </summary>
public TransitionMap() : base(1)
public TransitionMap(Module source0, int distance) : base (1)
{

Source0 = source0;
Distance = distance;
}

/// <summary>
Expand Down
5 changes: 3 additions & 2 deletions Obsidian.API/Noise/Zoom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ public class Zoom : Module

public double Amount { get; set; }

public Zoom() : base(1)
public Zoom(Module source0, double amount) : base(1)
{

Source0 = source0;
Amount = amount;
}

public override double GetValue(double x, double y, double z)
Expand Down
5 changes: 5 additions & 0 deletions Obsidian.API/Particles/ItemParticle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
{
public class ItemParticle : IParticle
{
public ItemParticle(ItemStack item)
{
Item = item;
}

public int Id => 36;

public ItemStack Item { get; set; }
Expand Down
Loading