Skip to content

Commit

Permalink
Merge branch '1.21.x' into client-handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
Tides committed Nov 27, 2024
2 parents de7c497 + e0c3050 commit 032aebb
Show file tree
Hide file tree
Showing 313 changed files with 47,456 additions and 42,674 deletions.
68 changes: 21 additions & 47 deletions .github/workflows/docfx.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,28 @@
name: .NET Docs
name: Update Docs

on:
release:
types:
- published
workflow_dispatch:
push:
branches:
- 1.*
branches: [1.*]
paths:
- 'Obsidian.Docs/**'
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
permissions:
contents: write
- "**/*.cs"
- "**/*.csproj"
- ".github/workflows/docfx.yml"
jobs:
build:
update-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.0
- name: Install DocFX
run: dotnet tool update -g docfx
continue-on-error: true
- name: Build Obsidian
run: dotnet build
- name: Build documentation
run: docfx Obsidian.Docs/docfx.json
- name: Upload GitHub Pages artifact
uses: actions/upload-pages-artifact@v1
with:
# Path of the directory containing the static assets.
path: ./Obsidian.Docs/_site/ # default is _site/
deploy:
# Add a dependency to the build job
needs: build
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
- name: Trigger Workflow in Another Repository
run: |
# Set the required variables
repo_owner="ObsidianMC"
repo_name="Documentation"
event_type="trigger-workflow"
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.WORKFLOW_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$repo_owner/$repo_name/dispatches \
-d "{\"event_type\": \"$event_type\",\"client_payload\":{\"unit\":false,\"integration\":true}}"
14 changes: 11 additions & 3 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@ name: .NET Build
on:
push:
branches: [ 1.* ]
paths:
- "**/*.cs"
- "**/*.csproj"
- ".github/workflows/dotnet.yml"
pull_request:
branches: [ 1.* ]
paths:
- "**/*.cs"
- "**/*.csproj"
- ".github/workflows/dotnet.yml"

jobs:
build:
Expand All @@ -17,14 +25,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 +41,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
13 changes: 9 additions & 4 deletions .github/workflows/nuget-push.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
name: Nuget

on:
workflow_dispatch:
push:
branches: [ "1.*" ]
branches: ["1.*"]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]

tags: ["v*.*.*"]
# don't publish when we change workflow files
paths-ignore:
- ".github/workflows/*.yml"

env:
DOTNET_NOLOGO: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1
Expand All @@ -26,11 +30,12 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
9
8
7
- name: Pack n Push
run: |
cd Obsidian.API
dotnet build -c Release -p:Version=1.0.0-${{ github.run_number }}-${{ github.sha }}
dotnet pack -c Release -o build -p:Version=1.0.0-nightly-${{ github.run_number }}
dotnet nuget push "build/*" --skip-duplicate -k ${{ secrets.NUGET_ORG_API_KEY }} -s https://api.nuget.org/v3/index.json
dotnet nuget push "build/*" --skip-duplicate -k ${{ secrets.NUGET_ORG_API_KEY }} -s https://api.nuget.org/v3/index.json
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; }

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 032aebb

Please sign in to comment.