From c77d21507ad21b29a56502d37290c5f7380ca3d0 Mon Sep 17 00:00:00 2001 From: bdew Date: Sat, 22 Jul 2023 13:54:27 +0300 Subject: [PATCH] initial 1.20.1 port --- build.gradle | 13 ++----------- build.properties | 14 +++++++------- gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle | 14 ++++++++++++-- src/main/resources/META-INF/mods.toml | 8 ++++---- .../net/bdew/compacter/misc/CompacterCache.scala | 13 ++++--------- .../scala/net/bdew/compacter/misc/WidgetMode.scala | 12 ++++++------ .../net/bdew/compacter/registries/Blocks.scala | 5 +++-- 8 files changed, 39 insertions(+), 42 deletions(-) diff --git a/build.gradle b/build.gradle index 0f0c0c8..1bbc62a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,17 +1,8 @@ -buildscript { - repositories { - maven { url = 'https://maven.minecraftforge.net/' } - mavenCentral() - } - dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true - } -} - plugins { id 'scala' + id 'idea' id 'maven-publish' - id 'net.minecraftforge.gradle' version '5.1.+' + id 'net.minecraftforge.gradle' version '[6.0,6.2)' id 'org.parchmentmc.librarian.forgegradle' version '1.+' id "com.matthewprenger.cursegradle" version "1.4.0" id "com.modrinth.minotaur" version "2.+" diff --git a/build.properties b/build.properties index 05321a6..94c5955 100644 --- a/build.properties +++ b/build.properties @@ -1,10 +1,10 @@ mod.id=compacter -mod.version=1.10.0 +mod.version=1.11.0 curseforge.id=231549 modrinth.id=compacter -minecraft.version=1.19.3 -forge.version=44.1.5 -bdlib.version=1.26.0.4 -scala.version=2.13.10 -parchment.version=2022.12.18-1.19.3 -slp.version=2.13.10-build-15 \ No newline at end of file +minecraft.version=1.20.1 +forge.version=47.1.39 +bdlib.version=1.27.0.6 +scala.version=2.13.11 +parchment.version=2023.07.16-1.20.1 +slp.version=3.3.0-build-2 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8049c68..fae0804 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle index e793512..6df15a4 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,9 +1,19 @@ pluginManagement { repositories { gradlePluginPortal() - maven { url = 'https://maven.minecraftforge.net/' } - maven { url = 'https://maven.parchmentmc.org' } + maven { + name = 'MinecraftForge' + url = 'https://maven.minecraftforge.net/' + } + maven { + name = 'Parchment' + url = 'https://maven.parchmentmc.org' + } } } +plugins { + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0' +} + rootProject.name = 'compacter' \ No newline at end of file diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 4273f95..9403468 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -1,5 +1,5 @@ modLoader = "kotori_scala" -loaderVersion = "[2.13.10,2.14.0)" +loaderVersion = "[3.3.0,)" issueTrackerURL = "https://github.com/bdew-minecraft/compacter/issues" license = "MIT" @@ -20,21 +20,21 @@ This mods adds a single simple block - the Compacter. [[dependencies.compacter]] modId = "forge" mandatory = true -versionRange = "[44.1,)" +versionRange = "[47.1,)" ordering = "NONE" side = "BOTH" [[dependencies.compacter]] modId = "minecraft" mandatory = true -versionRange = "[1.19.3,)" +versionRange = "[1.20.1,)" ordering = "NONE" side = "BOTH" [[dependencies.compacter]] modId = "bdlib" mandatory = true -versionRange = "[1.26.0,)" +versionRange = "[1.27.0,)" ordering = "NONE" side = "BOTH" diff --git a/src/main/scala/net/bdew/compacter/misc/CompacterCache.scala b/src/main/scala/net/bdew/compacter/misc/CompacterCache.scala index dcda897..019f712 100644 --- a/src/main/scala/net/bdew/compacter/misc/CompacterCache.scala +++ b/src/main/scala/net/bdew/compacter/misc/CompacterCache.scala @@ -2,7 +2,7 @@ package net.bdew.compacter.misc import net.bdew.compacter.Compacter import net.minecraft.world.entity.player.Player -import net.minecraft.world.inventory.{AbstractContainerMenu, CraftingContainer} +import net.minecraft.world.inventory.{AbstractContainerMenu, CraftingContainer, TransientCraftingContainer} import net.minecraft.world.item.crafting.{CraftingRecipe, RecipeType} import net.minecraft.world.item.{Item, ItemStack} import net.minecraft.world.level.Level @@ -22,15 +22,10 @@ object ItemDef { object FakeContainer extends AbstractContainerMenu(null, 0) { override def stillValid(player: Player): Boolean = true - override def quickMoveStack(player : Player, slot : Int): ItemStack = ItemStack.EMPTY + override def quickMoveStack(player: Player, slot: Int): ItemStack = ItemStack.EMPTY } -class FakeInventory(cache: CompacterCache, stack: ItemStack) extends CraftingContainer(FakeContainer, cache.size, cache.size) { - override def getContainerSize: Int = cache.size * cache.size - - override def setChanged(): Unit = { - } - +class FakeInventory(cache: CompacterCache, stack: ItemStack) extends TransientCraftingContainer(FakeContainer, cache.size, cache.size) { override def getItem(slot: Int): ItemStack = { val x = slot % cache.size val y = slot / cache.size @@ -60,7 +55,7 @@ class CompacterCache(val size: Int) { val result = world.getRecipeManager .getRecipeFor[CraftingContainer, CraftingRecipe](RecipeType.CRAFTING, fakeInventory, world) - .map(recipe => recipe.assemble(fakeInventory)) + .map(recipe => recipe.assemble(fakeInventory, world.registryAccess)) .filter(!_.isEmpty) if (!result.isPresent) { diff --git a/src/main/scala/net/bdew/compacter/misc/WidgetMode.scala b/src/main/scala/net/bdew/compacter/misc/WidgetMode.scala index bc32788..918d047 100644 --- a/src/main/scala/net/bdew/compacter/misc/WidgetMode.scala +++ b/src/main/scala/net/bdew/compacter/misc/WidgetMode.scala @@ -1,12 +1,12 @@ package net.bdew.compacter.misc -import com.mojang.blaze3d.vertex.PoseStack import net.bdew.compacter.Textures import net.bdew.compacter.network.NetworkHandler import net.bdew.lib.data.DataSlotEnum import net.bdew.lib.gui._ import net.bdew.lib.gui.widgets.Widget import net.bdew.lib.{Client, Misc, Text} +import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.resources.sounds.SimpleSoundInstance import net.minecraft.network.chat.Component import net.minecraft.sounds.SoundEvents @@ -20,15 +20,15 @@ case class WidgetMode[T <: Enumeration](p: Point, ds: DataSlotEnum[T], pktConstr val values: Seq[T#Value] = ds.baseEnum.values.toList.sortBy(_.id) - override def drawBackground(m: PoseStack, mouse: Point): Unit = { + override def drawBackground(graphics: GuiGraphics, mouse: Point): Unit = { if (rect.contains(mouse)) - parent.drawTexture(m, rect, Textures.buttonHover) + parent.drawTexture(graphics, rect, Textures.buttonHover) else - parent.drawTexture(m, rect, Textures.buttonBase) + parent.drawTexture(graphics, rect, Textures.buttonBase) } - override def draw(m: PoseStack, mouse: Point, partial: Float): Unit = { - parent.drawTexture(m, iconRect, Textures.modeTextures(ds.value)) + override def draw(graphics: GuiGraphics, mouse: Point, partial: Float): Unit = { + parent.drawTexture(graphics, iconRect, Textures.modeTextures(ds.value)) } override def handleTooltip(p: Point, tip: mutable.ArrayBuffer[Component]): Unit = { diff --git a/src/main/scala/net/bdew/compacter/registries/Blocks.scala b/src/main/scala/net/bdew/compacter/registries/Blocks.scala index d054437..2c07e53 100644 --- a/src/main/scala/net/bdew/compacter/registries/Blocks.scala +++ b/src/main/scala/net/bdew/compacter/registries/Blocks.scala @@ -6,10 +6,11 @@ import net.bdew.lib.managers.BlockManager import net.minecraft.world.item.BlockItem import net.minecraft.world.level.block.SoundType import net.minecraft.world.level.block.state.BlockBehaviour.Properties -import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.MapColor object Blocks extends BlockManager(Items) { - def machineProps: Properties = props(Material.STONE) + def machineProps: Properties = props + .mapColor(MapColor.STONE) .sound(SoundType.STONE) .strength(2, 8)