Skip to content

Commit

Permalink
Packets refactor & 2 other changes (.net9 and 1.21.3) (#453)
Browse files Browse the repository at this point in the history
.NET9, Packets Refactor and 1.21.3
  • Loading branch information
Tides authored Nov 26, 2024
1 parent eb75516 commit dec1af4
Show file tree
Hide file tree
Showing 315 changed files with 47,619 additions and 42,715 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docfx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.0
dotnet-version: 9.0.0
- name: Install DocFX
run: dotnet tool update -g docfx
continue-on-error: true
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
include-prerelease: true
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release /p:DebugType=None
- name: Rename executables
working-directory: /home/runner/work/Obsidian/Obsidian/Obsidian.ConsoleApp/bin/Release/net8.0/
working-directory: /home/runner/work/Obsidian/Obsidian/Obsidian.ConsoleApp/bin/Release/net9.0/
run: |
mv Obsidian.ConsoleApp.dll ObsidianApp.dll
mv Obsidian.ConsoleApp.deps.json ObsidianApp.deps.json
Expand All @@ -33,7 +33,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: Obsidian-Nightly-Build
path: /home/runner/work/Obsidian/Obsidian/Obsidian.ConsoleApp/bin/Release/net8.0/
path: /home/runner/work/Obsidian/Obsidian/Obsidian.ConsoleApp/bin/Release/net9.0/
if: ${{ github.event_name == 'push' }} # Only upload artifacts on push, don't upload them for PRs
- name: Discord Webhook Action
uses: tsickert/[email protected]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/nuget-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
9
8
7
- name: Pack n Push
Expand Down
17 changes: 4 additions & 13 deletions Obsidian.API/Builders/BaseSoundEffectBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ public abstract class BaseSoundEffectBuilder : ISoundEffectBuilder, ISoundEffect
private const float MinPitch = 2.0f;
private const float MinVolume = 1.0f;

protected SoundId SoundId { get; init; }
protected string SoundLocation { get; init; }

Check warning on line 9 in Obsidian.API/Builders/BaseSoundEffectBuilder.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'SoundLocation' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

protected SoundCategory SoundCategory { get; init; }

protected string? SoundName { get; init; }

protected SoundPosition? SoundPosition { get; set; }

protected bool HasFixedRange { get; set; }

protected float Range { get; set; }
protected float? FixedRange { get; set; }

protected float Volume { get; set; } = .5f;

Expand All @@ -26,9 +24,9 @@ public abstract class BaseSoundEffectBuilder : ISoundEffectBuilder, ISoundEffect

protected int? EntityId { get; set; }

public virtual IRangedSoundEffectBuilder WithFixedRange()
public virtual IRangedSoundEffectBuilder WithFixedRange(float range)
{
this.HasFixedRange = true;
this.FixedRange = range;

return this;
}
Expand All @@ -41,13 +39,6 @@ public virtual ISoundEffectBaseBuilder WithPitch(float pitch)
return this;
}

public virtual ISoundEffectBaseBuilder WithRange(float range)
{
this.Range = range;

return this;
}

public virtual ISoundEffectBaseBuilder WithSeed(long seed)
{
this.Seed = seed;
Expand Down
4 changes: 1 addition & 3 deletions Obsidian.API/Builders/Interfaces/ISoundEffectBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ public interface ISoundEffectBuilder

public interface ISoundEffectBaseBuilder
{
public IRangedSoundEffectBuilder WithFixedRange();

public ISoundEffectBaseBuilder WithVolume(float volume);

public ISoundEffectBaseBuilder WithPitch(float pitch);
Expand All @@ -21,5 +19,5 @@ public interface ISoundEffectBaseBuilder

public interface IRangedSoundEffectBuilder
{
public ISoundEffectBaseBuilder WithRange(float range);
public IRangedSoundEffectBuilder WithFixedRange(float range);
}
22 changes: 4 additions & 18 deletions Obsidian.API/Builders/SoundEffectBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,40 +1,26 @@
using Obsidian.API.Builders.Interfaces;
using System.Diagnostics.CodeAnalysis;

namespace Obsidian.API.Builders;
public sealed class SoundEffectBuilder : BaseSoundEffectBuilder
{
internal SoundEffectBuilder() { }

public static ISoundEffectBuilder Create(SoundId soundId, SoundCategory soundCategory = SoundCategory.Master) => new SoundEffectBuilder
public static ISoundEffectBuilder Create(string soundLocation, SoundCategory soundCategory = SoundCategory.Master) => new SoundEffectBuilder
{
SoundId = soundId,
SoundLocation = soundLocation,
SoundCategory = soundCategory
};

public static ISoundEffectBuilder Create([NotNull] string soundName, SoundCategory soundCategory = SoundCategory.Master)
{
ArgumentException.ThrowIfNullOrEmpty(soundName);

return new SoundEffectBuilder
{
SoundName = soundName,
SoundId = SoundId.None,
SoundCategory = soundCategory
};
}

public override ISoundEffect Build() => new SoundEffect
{
SoundId = this.SoundId,
SoundId = this.SoundLocation,
SoundCategory = this.SoundCategory,
SoundPosition = this.SoundPosition,
Volume = this.Volume,
Pitch = this.Pitch,
Seed = this.Seed,
SoundName = this.SoundName,
HasFixedRange = this.HasFixedRange,
Range = this.Range,
FixedRange = this.FixedRange,
EntityId = this.EntityId
};
}
2 changes: 1 addition & 1 deletion Obsidian.API/Containers/BaseContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public abstract class BaseContainer : IEnumerable<ItemStack>

public InventoryType Type { get; }

public ChatMessage? Title { get; set; }
public ChatMessage Title { get; set; }

public Guid Uuid { get; } = Guid.NewGuid();

Expand Down
4 changes: 3 additions & 1 deletion Obsidian.API/Crafting/CraftingType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@ public enum CraftingType
Stonecutting,

SmithingTransform,
SmithingTrim
SmithingTrim,

CraftingTransmute
}
98 changes: 47 additions & 51 deletions Obsidian.API/Noise/DensityNoiseMapBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,67 +1,63 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using SharpNoise;
using SharpNoise;
using SharpNoise.Builders;
using SharpNoise.Models;
using System.Threading;

namespace Obsidian.API.Noise;

namespace Obsidian.WorldData.Generators.Overworld
/// <summary>
/// Builds a density noise map.
/// </summary>
/// <remarks>
/// This class builds a noise map by filling it with coherent-noise values
/// generated from the Y density of a noise cube.
/// </remarks>
public class DensityNoiseMapBuilder : NoiseMapBuilder
{
/// <summary>
/// Builds a density noise map.
/// </summary>
/// <remarks>
/// This class builds a noise map by filling it with coherent-noise values
/// generated from the Y density of a noise cube.
/// </remarks>
public class DensityNoiseMapBuilder : NoiseMapBuilder
public NoiseCube SourceNoiseCube { get; set; }

protected override void PrepareBuild()
{
public NoiseCube SourceNoiseCube { get; set; }
if (destWidth <= 0 ||
destHeight <= 0 ||
SourceNoiseCube == null ||
DestNoiseMap == null)
throw new InvalidOperationException("Builder isn't properly set up.");

protected override void PrepareBuild()
{
if (destWidth <= 0 ||
destHeight <= 0 ||
SourceNoiseCube == null ||
DestNoiseMap == null)
throw new InvalidOperationException("Builder isn't properly set up.");
DestNoiseMap.SetSize(destHeight, destWidth);
}

DestNoiseMap.SetSize(destHeight, destWidth);
}
protected override void BuildImpl(CancellationToken cancellationToken)
{
NoiseCube nc = SourceNoiseCube;

var xExtent = nc.Width;
var yExtent = nc.Height;
var zExtent = nc.Depth;
var xDelta = xExtent / destWidth;
var zDelta = zExtent / destHeight;

protected override void BuildImpl(CancellationToken cancellationToken)
var po = new ParallelOptions()
{
NoiseCube nc = SourceNoiseCube;
CancellationToken = cancellationToken,
};

var xExtent = nc.Width;
var yExtent = nc.Height;
var zExtent = nc.Depth;
var xDelta = xExtent / destWidth;
var zDelta = zExtent / destHeight;
Parallel.For(0, destHeight, po, z =>
{
double zCur = z * zDelta;

var po = new ParallelOptions()
{
CancellationToken = cancellationToken,
};
int x;
double xCur;

Parallel.For(0, destHeight, po, z =>
for (x = 0, xCur = 0; x < destWidth; x++, xCur += xDelta)
{
double zCur = z * zDelta;

int x;
double xCur;

for (x = 0, xCur = 0; x < destWidth; x++, xCur += xDelta)
float finalValue = 0;
for (int y = 0; y < yExtent; y++)
{
float finalValue = 0;
for (int y=0; y < yExtent; y++)
{
finalValue += (float)nc.GetValue((int)xCur, y, (int)zCur);
}
finalValue /= yExtent;
DestNoiseMap[x, z] = finalValue;
finalValue += (float)nc.GetValue((int)xCur, y, (int)zCur);
}
});
}
finalValue /= yExtent;
DestNoiseMap[x, z] = finalValue;
}
});
}
}
Loading

0 comments on commit dec1af4

Please sign in to comment.