diff --git a/.github/workflows/curseforge.yml b/.github/workflows/curseforge.yml index 3ef48bd23..92bbd3bd7 100644 --- a/.github/workflows/curseforge.yml +++ b/.github/workflows/curseforge.yml @@ -14,17 +14,18 @@ jobs: if: "!contains(github.event.head_commit.message, 'ci skip')" steps: - uses: actions/checkout@v1 - - name: Set up JDK 11 + - name: Set up JDK 16 uses: actions/setup-java@v1 with: - java-version: 11 + java-version: 16 - name: Clean Gradle run: ./gradlew clean --refresh-dependencies --stacktrace env: danielshe_curse_api_key: ${{ secrets.CF_API_KEY }} BRANCH_NAME: ${{ github.ref }} + MAVEN_PASS: ${{ secrets.MAVEN_PASS }} - name: Upload to CurseForge and Maven - run: ./gradlew build publish releaseOnCf --stacktrace + run: ./gradlew build publish releaseOnCf publish --stacktrace env: danielshe_curse_api_key: ${{ secrets.CF_API_KEY }} BRANCH_NAME: ${{ github.ref }} diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index ae75043c1..e61f0bcf3 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -7,9 +7,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - - name: Set up JDK 11 + - name: Set up JDK 16 uses: actions/setup-java@v1 with: - java-version: 11 + java-version: 16 - name: Build with Gradle run: ./gradlew clean build --refresh-dependencies --stacktrace diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/server/DumpHandler.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/server/DumpHandler.java index 9db906ee3..6cc5dac6e 100644 --- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/server/DumpHandler.java +++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/server/DumpHandler.java @@ -34,7 +34,7 @@ public interface DumpHandler { static StackAccessor getOccupiedSlotWithRoomForStack(ItemStack stack, List inventoryStacks) { for (StackAccessor inventoryStack : inventoryStacks) { - if (canStackAddMore(inventoryStack.getItemStack(), stack)) { + if (canStackAddMore(inventoryStack.getItemStack(), stack) && inventoryStack.canPlace(stack)) { return inventoryStack; } } diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/server/GridCleanHandler.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/server/GridCleanHandler.java index 6eab52a53..fe83263c9 100644 --- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/server/GridCleanHandler.java +++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/server/GridCleanHandler.java @@ -38,6 +38,10 @@ static void returnSlotToPlayerInventory(Contai DumpHandler dumpHandler = context.getContainerInfo().getDumpHandler(); ItemStack stackToReturn = stackAccessor.getItemStack(); if (!stackToReturn.isEmpty()) { + if (!stackAccessor.allowModification(context.getPlayerEntity())) { + error("rei.rei.no.slot.in.inv"); + } + for (; stackToReturn.getCount() > 0; stackAccessor.takeStack(1)) { ItemStack stackToInsert = stackToReturn.copy(); stackToInsert.setCount(1); diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/server/SlotStackAccessor.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/server/SlotStackAccessor.java index fd3a47c84..216454cfc 100644 --- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/server/SlotStackAccessor.java +++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/server/SlotStackAccessor.java @@ -23,6 +23,7 @@ package me.shedaniel.rei.server; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; @@ -47,4 +48,14 @@ public void setItemStack(ItemStack stack) { public ItemStack takeStack(int amount) { return slot.remove(amount); } + + @Override + public boolean allowModification(Player player) { + return slot.mayPickup(player) && slot.mayPlace(getItemStack()); + } + + @Override + public boolean canPlace(ItemStack stack) { + return slot.mayPlace(stack); + } } diff --git a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/server/StackAccessor.java b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/server/StackAccessor.java index ba48579a0..d425b3121 100644 --- a/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/server/StackAccessor.java +++ b/RoughlyEnoughItems-api/src/main/java/me/shedaniel/rei/server/StackAccessor.java @@ -23,6 +23,7 @@ package me.shedaniel.rei.server; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; public interface StackAccessor { @@ -31,4 +32,12 @@ public interface StackAccessor { void setItemStack(ItemStack stack); ItemStack takeStack(int amount); + + default boolean allowModification(Player player) { + return true; + } + + default boolean canPlace(ItemStack stack) { + return true; + } } diff --git a/RoughlyEnoughItems-default-plugin/build.gradle b/RoughlyEnoughItems-default-plugin/build.gradle index 12375b694..afc96051b 100644 --- a/RoughlyEnoughItems-default-plugin/build.gradle +++ b/RoughlyEnoughItems-default-plugin/build.gradle @@ -5,5 +5,5 @@ loom { } dependencies { - compile project(path: ':RoughlyEnoughItems-api', configuration: 'dev') + compileOnly project(path: ':RoughlyEnoughItems-api', configuration: 'dev') } \ No newline at end of file diff --git a/RoughlyEnoughItems-runtime/build.gradle b/RoughlyEnoughItems-runtime/build.gradle index 870d044d0..7e31ac1a0 100644 --- a/RoughlyEnoughItems-runtime/build.gradle +++ b/RoughlyEnoughItems-runtime/build.gradle @@ -9,6 +9,6 @@ loom { } dependencies { - compile project(path: ':RoughlyEnoughItems-api', configuration: 'dev') + compileOnly project(path: ':RoughlyEnoughItems-api', configuration: 'dev') modCompileOnly("alexiil.mc.lib:libblockattributes-fluids:0.8.3-pre.3") } \ No newline at end of file diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/server/InputSlotCrafter.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/server/InputSlotCrafter.java index 9e51a158d..c26068f1d 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/server/InputSlotCrafter.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/server/InputSlotCrafter.java @@ -109,6 +109,10 @@ protected void fillInputSlot(StackAccessor slot, ItemStack toBeTakenStack) { } takenStack.setCount(1); + if (!slot.canPlace(takenStack)) { + return; + } + if (slot.getItemStack().isEmpty()) { slot.setItemStack(takenStack); } else { @@ -161,13 +165,22 @@ protected void returnInputs() { } public int method_7371(ItemStack itemStack) { + boolean rejectedModification = false; for (int i = 0; i < inventoryStacks.size(); i++) { ItemStack itemStack1 = this.inventoryStacks.get(i).getItemStack(); if (!itemStack1.isEmpty() && areItemsEqual(itemStack, itemStack1) && !itemStack1.isDamaged() && !itemStack1.isEnchanted() && !itemStack1.hasCustomHoverName()) { - return i; + if (!this.inventoryStacks.get(i).allowModification(player)) { + rejectedModification = true; + } else { + return i; + } } } + if (rejectedModification) { + throw new IllegalStateException("Unable to take item from inventory due to slot not allowing modification! Item requested: " + itemStack); + } + return -1; } diff --git a/build.gradle b/build.gradle index f01e01306..eb47cf5c3 100755 --- a/build.gradle +++ b/build.gradle @@ -1,9 +1,9 @@ plugins { - id("forgified-fabric-loom") version("0.6.66") apply false + id("dev.architectury.loom") version("0.9.0-SNAPSHOT") apply false id("maven-publish") id("java") id("java-library") - id("net.minecrell.licenser") version("0.4.1") + id("org.cadixdev.licenser") version("0.6.1") id("com.matthewprenger.cursegradle") version("1.4.0") } @@ -20,8 +20,8 @@ group = "me.shedaniel" allprojects { apply plugin: 'maven-publish' - apply plugin: 'forgified-fabric-loom' - apply plugin: 'net.minecrell.licenser' + apply plugin: 'dev.architectury.loom' + apply plugin: 'org.cadixdev.licenser' sourceCompatibility = targetCompatibility = 1.8 @@ -31,8 +31,12 @@ allprojects { } repositories { - maven { url "https://maven.shedaniel.me" } maven { url "https://maven.terraformersmc.com/releases" } + maven { url "https://maven.shedaniel.me/" } + } + + jar { + from "LICENSE" } processResources { @@ -163,7 +167,7 @@ task remapMavenJar(type: RemapJarTask, dependsOn: jar) { dependencies { subprojects.each { - compile project(path: ":${it.name}", configuration: "dev") + compileOnly project(path: ":${it.name}", configuration: "dev") include project(path: ":${it.name}", configuration: "remapped") } } diff --git a/gradle.properties b/gradle.properties index 4f65a6b4b..13f492e25 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ org.gradle.jvmargs=-Xmx3G -base_version=5.12 +base_version=5.12.1 supported_version=1.16.4/5 minecraft_version=1.16.5 fabricloader_version=0.12.12 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 18cd7f0cc..3bba85c78 100755 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-all.zip diff --git a/settings.gradle b/settings.gradle index 02cc0a9cf..e0f6fadc2 100755 --- a/settings.gradle +++ b/settings.gradle @@ -2,8 +2,8 @@ pluginManagement { repositories { maven { url "https://maven.shedaniel.me/" } maven { url "https://maven.fabricmc.net/" } - maven { url "https://files.minecraftforge.net/maven/" } gradlePluginPortal() + maven { url "https://files.minecraftforge.net/maven/" } } }