Skip to content

Commit

Permalink
Get fabric working and add actions
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebemish committed Dec 13, 2023
1 parent d86e7dc commit fc6257a
Show file tree
Hide file tree
Showing 22 changed files with 758 additions and 20 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/build_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"jobs": {
"build": {
"runs-on": "ubuntu-22.04",
"steps": [
{
"name": "Setup Java",
"run": "echo \"JAVA_HOME=$JAVA_HOME_17_X64\" >> \"$GITHUB_ENV\""
},
{
"with": {
"fetch-depth": "0",
"persist-credentials": "false"
},
"name": "Checkout",
"uses": "actions/checkout@v4"
},
{
"with": {
"path": "**/.gradle/loom-cache",
"key": "${{ runner.os }}-gradle-${{ hashFiles('**/libs.versions.*', '**/*.gradle*', '**/gradle-wrapper.properties') }}",
"restore-keys": "${{ runner.os }}-gradle-"
},
"name": "Cache",
"uses": "actions/cache/restore@v3"
},
{
"with": {
"cache-read-only": true,
"gradle-home-cache-cleanup": true
},
"name": "Setup Gradle",
"uses": "gradle/gradle-build-action@v2"
},
{
"name": "Build",
"run": "./gradlew build",
"id": "build",
"env": {
"PR_NUMBER": "${{ github.event.pull_request.number }}"
}
},
{
"name": "Publish",
"run": "./gradlew publish",
"id": "publish",
"env": {
"PR_NUMBER": "${{ github.event.pull_request.number }}"
}
},
{
"with": {
"name": "artifacts",
"path": "build/repo"
},
"name": "Archive Publishable Artifacts",
"uses": "actions/upload-artifact@v3"
}
]
}
},
"name": "Build PR",
"concurrency": "ci-${{ github.ref }}",
"on": {
"pull_request": {

}
}
}
56 changes: 56 additions & 0 deletions .github/workflows/publish_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"jobs": {
"publish": {
"runs-on": "ubuntu-22.04",
"steps": [
{
"with": {
"repository": "lukebemish/artifact-sync",
"ref": "refs/heads/main",
"persist-credentials": false
},
"name": "Checkout Artifact Sync",
"uses": "actions/checkout@v4"
},
{
"run": "mkdir repo"
},
{
"with": {
"script": "const pull_requests = ${{ toJSON(github.event.workflow_run.pull_requests) }};\nif (!pull_requests.length) {\n return core.error(\"This workflow doesn't match any pull requests!\");\n}\nlet allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({\n owner: context.repo.owner,\n repo: context.repo.repo,\n run_id: context.payload.workflow_run.id,\n});\nlet matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {\n return artifact.name == \"artifacts\"\n})[0];\nlet download = await github.rest.actions.downloadArtifact({\n owner: context.repo.owner,\n repo: context.repo.repo,\n artifact_id: matchArtifact.id,\n archive_format: 'zip',\n});\nlet fs = require('fs');\nfs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/repo.zip`, Buffer.from(download.data));"
},
"name": "Download Artifacts",
"uses": "actions/github-script@v6"
},
{
"name": "Unpack Artifacts",
"run": "unzip repo.zip -d repo"
},
{
"name": "Publish Artifacts",
"run": "python3 run.py",
"env": {
"MAVEN_USER": "github",
"MAVEN_PASSWORD": "${{ secrets.PR_MAVEN_PASSWORD }}",
"MAVEN_URL": "https://maven.lukebemish.dev/pullrequests/",
"ALLOWED_VERSION": "*-pr${{ github.event.workflow_run.pull_requests[0].number }}",
"ALLOWED_PATHS": "dev/lukebemish/tempest/tempest-*"
}
}
],
"if": "${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}"
}
},
"name": "Publish PR",
"concurrency": "ci-${{ github.ref }}",
"on": {
"workflow_run": {
"workflows": [
"Build PR"
],
"types": [
"completed"
]
}
}
}
88 changes: 88 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
"jobs": {
"build": {
"runs-on": "ubuntu-22.04",
"permissions": {
"contents": "write"
},
"steps": [
{
"name": "Setup Java",
"run": "echo \"JAVA_HOME=$JAVA_HOME_17_X64\" >> \"$GITHUB_ENV\""
},
{
"with": {
"fetch-depth": "0"
},
"name": "Checkout",
"uses": "actions/checkout@v4"
},
{
"with": {
"path": "**/.gradle/loom-cache",
"key": "${{ runner.os }}-gradle-${{ hashFiles('**/libs.versions.*', '**/*.gradle*', '**/gradle-wrapper.properties') }}",
"restore-keys": "${{ runner.os }}-gradle-"
},
"name": "Cache",
"uses": "actions/cache@v3"
},
{
"with": {
"gradle-home-cache-cleanup": true
},
"name": "Setup Gradle",
"uses": "gradle/gradle-build-action@v2"
},
{
"uses": "fregante/setup-git-user@v2"
},
{
"name": "tagRelease",
"run": "./gradlew ",
"id": "tagrelease",
"env": {
"RELEASE_MAVEN_PASSWORD": "${{ secrets.RELEASE_MAVEN_PASSWORD }}",
"RELEASE_MAVEN_USER": "github",
"RELEASE_MAVEN_URL": "https://maven.lukebemish.dev/releases/",
"CURSEFORGE_KEY": "${{ secrets.CURSEFORGE_KEY }}",
"MODRINTH_KEY": "${{ secrets.MODRINTH_KEY }}"
}
},
{
"name": "Build",
"run": "./gradlew build",
"id": "build",
"env": {
"RELEASE_MAVEN_PASSWORD": "${{ secrets.RELEASE_MAVEN_PASSWORD }}",
"RELEASE_MAVEN_USER": "github",
"RELEASE_MAVEN_URL": "https://maven.lukebemish.dev/releases/",
"CURSEFORGE_KEY": "${{ secrets.CURSEFORGE_KEY }}",
"MODRINTH_KEY": "${{ secrets.MODRINTH_KEY }}"
}
},
{
"name": "Publish",
"run": "./gradlew publish modrinth curseforge",
"id": "publish",
"env": {
"RELEASE_MAVEN_PASSWORD": "${{ secrets.RELEASE_MAVEN_PASSWORD }}",
"RELEASE_MAVEN_USER": "github",
"RELEASE_MAVEN_URL": "https://maven.lukebemish.dev/releases/",
"CURSEFORGE_KEY": "${{ secrets.CURSEFORGE_KEY }}",
"MODRINTH_KEY": "${{ secrets.MODRINTH_KEY }}"
}
},
{
"run": "git push && git push --tags"
}
]
}
},
"name": "Release",
"concurrency": "ci-${{ github.ref }}",
"on": {
"workflow_dispatch": {

}
}
}
70 changes: 70 additions & 0 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"jobs": {
"build": {
"runs-on": "ubuntu-22.04",
"steps": [
{
"name": "Setup Java",
"run": "echo \"JAVA_HOME=$JAVA_HOME_17_X64\" >> \"$GITHUB_ENV\""
},
{
"with": {
"fetch-depth": "0",
"persist-credentials": "false"
},
"name": "Checkout",
"uses": "actions/checkout@v4"
},
{
"with": {
"path": "**/.gradle/loom-cache",
"key": "${{ runner.os }}-gradle-${{ hashFiles('**/libs.versions.*', '**/*.gradle*', '**/gradle-wrapper.properties') }}",
"restore-keys": "${{ runner.os }}-gradle-"
},
"name": "Cache",
"uses": "actions/cache/restore@v3"
},
{
"with": {
"cache-read-only": true,
"gradle-home-cache-cleanup": true
},
"name": "Setup Gradle",
"uses": "gradle/gradle-build-action@v2"
},
{
"name": "Build",
"run": "./gradlew build",
"id": "build",
"env": {
"SNAPSHOT_MAVEN_PASSWORD": "${{ secrets.SNAPSHOT_MAVEN_PASSWORD }}",
"SNAPSHOT_MAVEN_USER": "github",
"SNAPSHOT_MAVEN_URL": "https://maven.lukebemish.dev/snapshots/"
}
},
{
"name": "Publish",
"run": "./gradlew publish",
"id": "publish",
"env": {
"SNAPSHOT_MAVEN_PASSWORD": "${{ secrets.SNAPSHOT_MAVEN_PASSWORD }}",
"SNAPSHOT_MAVEN_USER": "github",
"SNAPSHOT_MAVEN_URL": "https://maven.lukebemish.dev/snapshots/"
}
}
]
}
},
"name": "Snapshot",
"concurrency": "ci-${{ github.ref }}",
"on": {
"workflow_dispatch": {

},
"push": {
"branches": [
"1.*"
]
}
}
}
4 changes: 4 additions & 0 deletions buildSrc/src/main/groovy/convention.shared.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ repositories {
name = 'BlameJared'
url = "https://maven.blamejared.com"
}
maven {
name = "Ladysnake Mods"
url = 'https://maven.ladysnake.org/releases'
}
}

configurations {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public static void recieveWeatherUpdate(UpdateWeatherChunk msg) {
var level = Minecraft.getInstance().level;
msg.apply(Objects.requireNonNull(level), pos -> {
Minecraft.getInstance().levelRenderer.setBlocksDirty(
pos.getX(), pos.getY(), pos.getZ(),
pos.getX(), pos.getY(), pos.getZ()
pos.getX(), pos.getY(), pos.getZ(),
pos.getX(), pos.getY(), pos.getZ()
);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class WeatherChunkData {
private final LevelChunk chunk;

private final Int2IntMap updateQueue = new Int2IntOpenHashMap();
private boolean dirty = false;
private boolean networkingDirty = false;

private float[] precipitation = new float[] {-0.5f, -0.5f, -0.5f, -0.5f};
private float[] temperature = new float[] {0.5f, 0.5f, 0.5f, 0.5f};
Expand All @@ -50,14 +50,28 @@ public class WeatherChunkData {

private boolean initialized;

public WeatherChunkData(LevelChunk chunk) {
private final @Nullable Runnable setDirtyCallback;

public WeatherChunkData(LevelChunk chunk, @Nullable Runnable setDirtyCallback) {
this.chunk = chunk;
this.setDirtyCallback = setDirtyCallback;
}

public WeatherChunkData(LevelChunk chunk) {
this(chunk, null);
}

void update(int pos, int data) {
protected void update(int pos, int data) {
synchronized (updateQueue) {
updateQueue.put(pos, data);
dirty = true;
markDirty();
}
}

private void markDirty() {
networkingDirty = true;
if (setDirtyCallback != null) {
setDirtyCallback.run();
}
}

Expand All @@ -75,7 +89,7 @@ public List<BlockPos> icedInSection(SectionPos pos) {
}

public void update() {
if (this.dirty) {
if (this.networkingDirty) {
int[] posData;
int[] weatherData;
synchronized (updateQueue) {
Expand All @@ -88,7 +102,7 @@ public void update() {
i++;
}
updateQueue.clear();
this.dirty = false;
this.networkingDirty = false;
}
var packet = new UpdateWeatherChunk(LevelIdMap.CURRENT.id(chunk.getLevel().dimension()), chunk.getPos(), posData, weatherData, precipitation, temperature, windX, windZ, thunder);
UpdateWeatherChunk.Sender.SENDER.send(packet, chunk);
Expand Down Expand Up @@ -240,7 +254,7 @@ public void tick(ServerLevel level, WeatherMapData.Built weatherMap) {
windZ[i] = weatherMap.windZ().query(x+XS[i], z+ZS[i], gameTime);
thunder[i] = Mth.clamp(weatherMap.thunder().query(x+XS[i], z+ZS[i], gameTime), -1, 1);
}
this.dirty = true;
this.markDirty();
}

BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos();
Expand Down
Loading

0 comments on commit fc6257a

Please sign in to comment.