Skip to content

Commit

Permalink
Merge branch 'mc/1.20.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHillcox committed Dec 28, 2023
2 parents e9d9876 + 8b4f40e commit ef7b89f
Show file tree
Hide file tree
Showing 13 changed files with 184 additions and 195 deletions.
23 changes: 15 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@ on:

jobs:
build:
if: |
!contains(github.event.head_commit.message, '[ciskip]')
uses: nanite/workflows/.github/workflows/base-java.yml@v1
with:
use-snapshots: true
gradle-tasks: build publish
secrets:
saps-token: ${{ secrets.SAPS_TOKEN }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
cache-read-only: false
gradle-home-cache-cleanup: true
- name: Build & Publish to Github Maven
run: ./gradlew build --no-daemon
27 changes: 8 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,19 @@ on:
jobs:
build:
runs-on: ubuntu-latest
if: |
!contains(github.event.head_commit.message, '[ciskip]')
steps:
- uses: actions/checkout@v3
- name: Set up JDK
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '17'
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: build
- name: Publish to Maven & Curseforge
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Build & Publish
run: ./gradlew build publish publishMods --no-daemon
env:
SAPS_TOKEN: ${{ secrets.SAPS_TOKEN }}
CURSEFORGE_KEY: ${{ secrets.CURSEFORGE_KEY }}
with:
arguments: publish curseforgePublish
- name: Release to Github
uses: "softprops/action-gh-release@v1"
with:
body_path: "./CHANGELOG.md"
prerelease: false
files: |
./+(forge|fabric)/build/libs/*+@(mc+([0-9]).+([0-9]).+([0-9])).jar
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CURSE_TOKEN: ${{ secrets.CURSEFORGE_KEY }}
6 changes: 2 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Accelerated Decay Changelog

## [1.0.0]
## [3.0.1]

### Changed

- Updated to 1.19.2
- Improved multi-threading safety and performance thanks to [(#7)](https://github.com/ErrorMikey/AcceleratedDecay/pull/7) [BumbleTree](https://github.com/BumbleTree)
96 changes: 87 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "0.12.0-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.3-SNAPSHOT" apply false
id "me.modmuss50.mod-publish-plugin" version "0.3.5"
}

architectury {
Expand All @@ -9,6 +10,7 @@ architectury {

subprojects {
apply plugin: "dev.architectury.loom"
apply plugin: "maven-publish"

loom {
silentMojangMappingsLicense()
Expand All @@ -21,24 +23,31 @@ subprojects {
// The following line declares the yarn mappings you may select this one as well.
// mappings "net.fabricmc:yarn:1.18.2+build.4:v2"
}

publishing {
repositories {
if (providers.environmentVariable("SAPS_TOKEN").isPresent()) {
maven {
url "https://maven.saps.dev/${providers.environmentVariable("SNAPSHOT").map { "snapshots" }.getOrElse("releases")}"
credentials {
username = "errormikey"
password = "${providers.environmentVariable("SAPS_TOKEN").get()}"
}
}
}
}
}
}

allprojects {
apply plugin: "java"
apply plugin: "architectury-plugin"
apply plugin: "maven-publish"

ext.ENV = System.getenv()
ext.SNAPSHOT = ENV.SNAPSHOT != null && (ENV.SNAPSHOT == "true" || ENV.SNAPSHOT == true)
ext.MAVEN_URL = "https://maven.saps.dev/${SNAPSHOT ? "snapshots" : "releases"}"
ext.MAVEN_VERSION = rootProject.version + (SNAPSHOT ? "-SNAPSHOT" : "")

archivesBaseName = rootProject.archives_base_name
version = "${rootProject.mod_version}+mc${rootProject.minecraft_version}"
group = rootProject.maven_group

repositories {
}

tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
Expand All @@ -50,4 +59,73 @@ allprojects {
}
}

task curseforgePublish
publishMods {
dryRun = providers.environmentVariable("CURSE_TOKEN").getOrNull() == null
changelog = file("./CHANGELOG.md").text
version = "${mod_version}"
type = STABLE

def fabricOptions = publishOptions {
file = project.provider { project(":fabric").tasks.remapJar }.flatMap { it.archiveFile }
displayName = "${project.name} Fabric ${mod_version}+mc${minecraft_version}"
modLoaders.add("fabric")
}

def forgeOptions = publishOptions {
file = project.provider { project(":forge").tasks.remapJar }.flatMap { it.archiveFile }
displayName = "${project.name} Forge ${mod_version}+mc${minecraft_version}"
modLoaders.add("neoforge")
}

def curseForgeOptions = curseforgeOptions {
accessToken = providers.environmentVariable("CURSE_TOKEN")
projectId = "${curseforge_id}"
minecraftVersions.add("${minecraft_version}")
}

def modrinthOptions = modrinthOptions {
accessToken = providers.environmentVariable("MODRINTH_TOKEN")
projectId = "${modrinth_id}"
minecraftVersions.add("${minecraft_version}")
}

curseforge("curseforgeFabric") {
from(curseForgeOptions, fabricOptions)
requires {
slug = "architectury-api"
slug = "fabric-api"
}
}

curseforge("curseforgeForge") {
from(curseForgeOptions, forgeOptions)
requires {
slug = "architectury-api"
}
}

modrinth("modrinthFabric") {
from(modrinthOptions, fabricOptions)
requires {
slug = "architectury-api"
slug = "fabric-api"
}
}

modrinth("modrinthForge") {
from(modrinthOptions, forgeOptions)
requires {
slug = "architectury-api"
}
}

github {
file = project.provider { project(":forge").tasks.remapJar }.flatMap { it.archiveFile }
additionalFiles.from project.provider { project(":fabric").tasks.remapJar }.flatMap { it.archiveFile }

repository = "${project.github_repo}"
accessToken = providers.environmentVariable("GITHUB_TOKEN")
commitish = providers.environmentVariable("GITHUB_SHA").orElse("dryRun")
tagName = providers.environmentVariable("GITHUB_REF_NAME").orElse("dryRun")
}
}
20 changes: 0 additions & 20 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,11 @@ dependencies {
modApi "dev.architectury:architectury:${rootProject.architectury_version}"
}

if (ENV.SAPS_TOKEN) {
println("Saps token available")
} else {
println("No saps token 😭")
}

publishing {
publications {
mavenCommon(MavenPublication) {
artifactId = "${rootProject.archivesBaseName}-${project.name}"
from components.java

version = MAVEN_VERSION
}
}

repositories {
if (ENV.SAPS_TOKEN) {
maven {
url MAVEN_URL
credentials {
username = "errormikey"
password = "${ENV.SAPS_TOKEN}"
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,56 +25,50 @@
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.Iterator;

public class AcceleratedDecay {
public static final String MOD_ID = "accelerateddecay";

private static final List<TimedDimBlockPos> timeBasedScanLocations = new ArrayList<>();
private static final ConcurrentHashMap<TimedDimBlockPos, Boolean> timeBasedScanLocations = new ConcurrentHashMap<>();

public static void init() {
BlockEvent.BREAK.register(AcceleratedDecay::breakHandler);
TickEvent.SERVER_LEVEL_POST.register(AcceleratedDecay::levelTick);
}

private static void levelTick(ServerLevel serverLevel) {
if (timeBasedScanLocations.isEmpty()) {
return;
}

Instant now = Instant.now();
List<TimedDimBlockPos> locations = timeBasedScanLocations.stream()
.filter(e -> !e.checkAfter.isAfter(now) && serverLevel.dimension().equals(e.dim))
.toList();

if (locations.isEmpty()) {
return;
}
for (Iterator<TimedDimBlockPos> iterator = timeBasedScanLocations.keySet().iterator(); iterator.hasNext(); ) {
TimedDimBlockPos location = iterator.next();
if (!location.checkAfter.isAfter(now) && serverLevel.dimension().equals(location.dim)) {
if (location.player == null || !location.player.isAlive()) {
iterator.remove();
continue;
}

for (TimedDimBlockPos location : locations) {
if (location.player == null || !location.player.isAlive()) {
continue;
}
Set<BlockPos> yeetLeaves = seekLeaves(serverLevel, location.pos);

Set<BlockPos> yeetLeaves = seekLeaves(serverLevel, location.pos);
boolean isFirst = true;
for (BlockPos yeetLeaf : yeetLeaves) {
BlockState blockState = serverLevel.getBlockState(yeetLeaf);
if (!blockState.is(BlockTags.LEAVES)) {
continue;
}

boolean isFirst = true;
for (BlockPos yeetLeaf : yeetLeaves) {
BlockState blockState = serverLevel.getBlockState(yeetLeaf);
if (!blockState.is(BlockTags.LEAVES)) {
continue;
}
EventResult eventResult = BlockEvent.BREAK.invoker().breakBlock(serverLevel, yeetLeaf, blockState, location.player, null);
if (eventResult.isFalse()) {
continue;
}

// Allow events to block us
EventResult eventResult = BlockEvent.BREAK.invoker().breakBlock(serverLevel, yeetLeaf, blockState, location.player, null);
if (eventResult.isFalse()) {
continue;
destroyBlockWithOptionalSoundAndParticles(serverLevel, yeetLeaf, true, 512, location.player, isFirst);
isFirst = false;
}

destroyBlockWithOptionalSoundAndParticles(serverLevel, yeetLeaf, true, 512, location.player, isFirst);
isFirst = false;
iterator.remove();
}

timeBasedScanLocations.remove(location);
}
}

Expand All @@ -83,7 +77,7 @@ private static EventResult breakHandler(Level level, BlockPos blockPos, BlockSta
return EventResult.pass();
}

timeBasedScanLocations.add(new TimedDimBlockPos(Instant.now().plus(1, ChronoUnit.SECONDS), blockPos, level.dimension(), player));
timeBasedScanLocations.put(new TimedDimBlockPos(Instant.now().plus(1, ChronoUnit.SECONDS), blockPos, level.dimension(), player), Boolean.TRUE);
return EventResult.pass();
}

Expand Down Expand Up @@ -131,10 +125,8 @@ public static void destroyBlockWithOptionalSoundAndParticles(Level level, BlockP
Block.dropResources(blockState, level, blockPos, blockEntity, player, ItemStack.EMPTY);
}

boolean bl2 = level.setBlock(blockPos, fluidState.createLegacyBlock(), 3, i);
if (bl2) {
level.gameEvent(player, GameEvent.BLOCK_DESTROY, blockPos);
}
level.setBlock(blockPos, fluidState.createLegacyBlock(), 3, i);
level.gameEvent(player, GameEvent.BLOCK_DESTROY, blockPos);
}

record TimedDimBlockPos(
Expand Down
Loading

0 comments on commit ef7b89f

Please sign in to comment.