Skip to content

Commit 8f338b5

Browse files
committed
feat: upgrade to fabric 1.17.1
1 parent b02b3ba commit 8f338b5

13 files changed

Lines changed: 74 additions & 60 deletions

File tree

.github/workflows/Gradle CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
uses: actions/setup-java@v2
2424
with:
2525
distribution: 'temurin'
26-
java-version: 8
26+
java-version: 16
2727

2828
# Validate Gradle Wrapper
2929
- name: Gradle Wrapper Validation

build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
}
77

88
base {
9-
archivesName.set("${project.property("archivesBaseName")}-fabric-${project.property("minecraftVersion")}")
9+
archivesName.set("${project.property("archivesBaseName")}")
1010
}
1111

1212
version = project.property("modVersion") as String
@@ -25,14 +25,14 @@ dependencies {
2525
}
2626

2727
tasks {
28-
val javaVersion = JavaVersion.VERSION_1_8
28+
val javaVersion = JavaVersion.VERSION_16
2929

3030
withType<JavaCompile> {
3131
options.encoding = "UTF-8"
3232
sourceCompatibility = javaVersion.toString()
3333
targetCompatibility = javaVersion.toString()
3434
if (JavaVersion.current().isJava9Compatible) {
35-
options.release.set(8)
35+
options.release.set(javaVersion.toString().toInt())
3636
}
3737
}
3838

gradle.properties

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
kotlin.code.style = official
2-
org.gradle.jvmargs = -Xmx3G
3-
org.gradle.warning.mode = all
1+
kotlin.code.style=official
2+
org.gradle.jvmargs=-Xmx3G
3+
org.gradle.warning.mode=all
44
# Check these on https://fabricmc.net/develop/
5-
minecraftVersion = 1.16.5
6-
yarnMappings = 1.16.5+build.10
7-
loaderVersion = 0.13.3
5+
minecraftVersion=1.17.1
6+
yarnMappings=1.17.1+build.65
7+
loaderVersion=0.13.3
88
# Fabric API
9-
fabricVersion = 0.42.0+1.16
10-
loomVersion = 0.7-SNAPSHOT
9+
fabricVersion=0.46.1+1.17
10+
loomVersion=0.10-SNAPSHOT
1111
# Mod Properties
12-
modVersion = 1.4.0
13-
mavenGroup = io.github.samarium150
14-
archivesBaseName = structures_compass
12+
modVersion=1.17.1-1.4.0
13+
mavenGroup=io.github.samarium150
14+
archivesBaseName=structures_compass-fabric
1515
# Kotlin
16-
systemProp.kotlinVersion = 1.6.10
17-
fabricKotlinVersion = 1.7.1+kotlin.1.6.10
16+
systemProp.kotlinVersion=1.6.10
17+
fabricKotlinVersion=1.7.1+kotlin.1.6.10

src/main/kotlin/io/github/samarium150/minecraft/mod/structures_compass/client/gui/StructuresCompassScreen.kt

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,18 @@ class StructuresCompassScreen(private val itemStack: ItemStack) : Screen(
5454
private var selected: StructureFeature<*>? = null
5555

5656
private fun setup() {
57-
buttons.clear()
58-
startSearchButton = addButton(
57+
clearChildren()
58+
startSearchButton = addDrawableChild(
5959
TransparentButton(
6060
10,
6161
40,
6262
110,
6363
20,
6464
TranslatableText("${prefix}start_searching")
6565
) {
66-
selectionList.selected?.search()
66+
selectionList.selectedOrNull?.search()
6767
})
68-
sortByButton = addButton(
68+
sortByButton = addDrawableChild(
6969
TransparentButton(
7070
10,
7171
65,
@@ -77,24 +77,26 @@ class StructuresCompassScreen(private val itemStack: ItemStack) : Screen(
7777
sortByButton.message = TranslatableText("${prefix}sort_by").append(": ${sortingCategory.localizedName}")
7878
selectionList.refresh()
7979
})
80-
skipExistingChunksButton = addButton(TransparentButton(
80+
skipExistingChunksButton = addDrawableChild(TransparentButton(
8181
10, 90, 110, 20,
8282
TranslatableText("${prefix}skip_existing_chunks").append(": $skip")
8383
) {
8484
skip = !skip
8585
skipExistingChunksButton.message = TranslatableText("${prefix}skip_existing_chunks").append(": $skip")
8686
})
87-
addButton(TransparentButton(
87+
addDrawableChild(TransparentButton(
8888
10, height - 30, 110, 20,
8989
TranslatableText("gui.cancel")
9090
) {
91-
minecraftClient.currentScreen = null
91+
minecraftClient.setScreen(null)
9292
})
93-
searchTextField = addChild(TransparentTextField(
94-
textRenderer,
95-
130, 10, 140, 20,
96-
TranslatableText("${prefix}search")
97-
))
93+
searchTextField = addDrawableChild(
94+
TransparentTextField(
95+
textRenderer,
96+
130, 10, 140, 20,
97+
TranslatableText("${prefix}search")
98+
)
99+
)
98100
startSearchButton.active = false
99101
}
100102

@@ -155,7 +157,7 @@ class StructuresCompassScreen(private val itemStack: ItemStack) : Screen(
155157
selectionList.changeFocus(true)
156158
selectionList.restoreScrollAmount()
157159
}
158-
addChild(selectionList)
160+
addDrawableChild(selectionList)
159161
}
160162

161163
override fun tick() {

src/main/kotlin/io/github/samarium150/minecraft/mod/structures_compass/client/gui/widget/StructureSearchEntry.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import net.minecraft.client.sound.PositionedSoundInstance
2727
import net.minecraft.client.util.math.MatrixStack
2828
import net.minecraft.sound.SoundEvents
2929
import net.minecraft.text.LiteralText
30+
import net.minecraft.text.Text
3031
import net.minecraft.text.TranslatableText
3132
import net.minecraft.util.Identifier
3233
import net.minecraft.util.Util
@@ -49,7 +50,7 @@ class StructureSearchEntry(
4950

5051
override fun mouseClicked(mouseX: Double, mouseY: Double, button: Int): Boolean {
5152
return if (button == 0) {
52-
searchList.selected = this
53+
searchList.selectStructure(this)
5354
return if (Util.getMeasuringTimeMs() - lastClickTime < 250L) {
5455
search()
5556
true
@@ -94,7 +95,10 @@ class StructureSearchEntry(
9495
(y + 14 + client.textRenderer.fontHeight).toFloat(),
9596
0x808080
9697
)
97-
@Suppress("DEPRECATION")
98-
RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f)
98+
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f)
99+
}
100+
101+
override fun getNarration(): Text {
102+
return LiteralText(structure.getIdentifier()!!.getLocalizedStructureName())
99103
}
100104
}

src/main/kotlin/io/github/samarium150/minecraft/mod/structures_compass/client/gui/widget/StructureSearchList.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class StructureSearchList(
5454
}
5555

5656
override fun isSelectedEntry(slotIndex: Int): Boolean {
57-
return if (slotIndex >= 0 && slotIndex < children().size) children()[slotIndex].equals(selected) else false
57+
return if (slotIndex >= 0 && slotIndex < children().size) children()[slotIndex].equals(selectedOrNull) else false
5858
}
5959

6060
private fun getRowBottom(entryIndex: Int): Int {
@@ -100,8 +100,8 @@ class StructureSearchList(
100100
renderList(matrixStack, rowLeft, top + 4 - scrollAmount.toInt(), mouseX, mouseY, partialTicks)
101101
}
102102

103-
private fun selectStructure(entry: StructureSearchEntry?) {
104-
selected = entry
103+
fun selectStructure(entry: StructureSearchEntry?) {
104+
setSelected(entry)
105105
screen.selectStructure(entry)
106106
}
107107

@@ -122,7 +122,7 @@ class StructureSearchList(
122122
}
123123

124124
fun restoreScrollAmount() {
125-
if (selected != null) {
125+
if (selectedOrNull != null) {
126126
changeFocus(true)
127127
scrollAmount += itemHeight * 2
128128
}

src/main/kotlin/io/github/samarium150/minecraft/mod/structures_compass/client/gui/widget/TransparentTextField.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ class TransparentTextField(
173173
Rect(startX, startY, endX, endY).sanitize()
174174
val tessellator = Tessellator.getInstance()
175175
val buffer = tessellator.buffer
176-
@Suppress("DEPRECATION")
177-
RenderSystem.color4f(0.0f, 0.0f, 255.0f, 255.0f)
176+
RenderSystem.setShaderColor(0.0f, 0.0f, 255.0f, 255.0f)
178177
RenderSystem.disableTexture()
179178
RenderSystem.enableColorLogicOp()
180179
RenderSystem.logicOp(GlStateManager.LogicOp.OR_REVERSE)

src/main/kotlin/io/github/samarium150/minecraft/mod/structures_compass/client/item/StructuresCompassItemPredicate.kt

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import io.github.samarium150.minecraft.mod.structures_compass.util.getDimension
2020
import io.github.samarium150.minecraft.mod.structures_compass.util.getPos
2121
import net.fabricmc.api.EnvType
2222
import net.fabricmc.api.Environment
23-
import net.minecraft.client.item.ModelPredicateProvider
23+
import net.minecraft.client.item.UnclampedModelPredicateProvider
2424
import net.minecraft.client.world.ClientWorld
2525
import net.minecraft.entity.Entity
2626
import net.minecraft.entity.ItemEntity
@@ -33,7 +33,7 @@ import net.minecraft.util.math.MathHelper
3333
import net.minecraft.util.math.Vec3d
3434

3535
@Environment(EnvType.CLIENT)
36-
object StructuresCompassItemPredicate : ModelPredicateProvider {
36+
object StructuresCompassItemPredicate : UnclampedModelPredicateProvider {
3737

3838
data class AngleInterpolator(
3939
private var rotation: Double = 0.0,
@@ -74,7 +74,16 @@ object StructuresCompassItemPredicate : ModelPredicateProvider {
7474
return MathHelper.atan2(vector.z - entity.pos.z, vector.x - entity.pos.x)
7575
}
7676

77-
override fun call(stack: ItemStack?, clientWorld: ClientWorld?, livingEntity: LivingEntity?): Float {
77+
private fun scatter(seed: Int): Int {
78+
return seed * 1327217883
79+
}
80+
81+
override fun unclampedCall(
82+
stack: ItemStack?,
83+
clientWorld: ClientWorld?,
84+
livingEntity: LivingEntity?,
85+
seed: Int
86+
): Float {
7887
val entity: Entity = (livingEntity ?: stack?.holder) ?: return 0.0f
7988
val world: ClientWorld = clientWorld ?: entity.world as ClientWorld
8089
val pos = stack?.getPos()
@@ -85,13 +94,13 @@ object StructuresCompassItemPredicate : ModelPredicateProvider {
8594
} else if (entity is ItemFrameEntity) {
8695
getFrameRotation(entity)
8796
} else if (entity is ItemEntity) {
88-
(180.0f - entity.method_27314(0.5f) / 6.2831855f * 360.0f).toDouble()
97+
(180.0f - entity.getRotation(0.5f) / 6.2831855f * 360.0f).toDouble()
8998
} else livingEntity?.bodyYaw?.toDouble() ?: 0.0
9099
d1 = MathHelper.floorMod(d1 / 360.0, 1.0)
91100
val d2 = getAngle(Vec3d.ofCenter(pos), entity) / (2 * Math.PI)
92101
val d3 = if (flag) d2 + r1.update(world, 0.5 - (d1 - 0.25)) else 0.5 - (d1 - 0.25 - d2)
93102
return MathHelper.floorMod(d3, 1.0).toFloat()
94103
}
95-
return MathHelper.floorMod((r2.update(world, Math.random()) + stack.hashCode() / 2.14748365E9), 1.0).toFloat()
104+
return MathHelper.floorMod((r2.update(world, Math.random()) + scatter(seed) / 2.14748365E9), 1.0).toFloat()
96105
}
97106
}

src/main/kotlin/io/github/samarium150/minecraft/mod/structures_compass/client/util/RenderHelper.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import net.fabricmc.api.Environment
2727
import net.minecraft.client.font.TextRenderer
2828
import net.minecraft.client.render.BufferBuilder
2929
import net.minecraft.client.render.Tessellator
30+
import net.minecraft.client.render.VertexFormat.DrawMode
3031
import net.minecraft.client.render.VertexFormats
3132
import net.minecraft.client.util.math.MatrixStack
3233

@@ -58,7 +59,7 @@ fun TextRenderer.drawConfiguredStringOnHud(
5859

5960
@Environment(EnvType.CLIENT)
6061
fun BufferBuilder.update(startX: Int, startY: Int, endX: Int, endY: Int) {
61-
begin(7, VertexFormats.POSITION)
62+
begin(DrawMode.QUADS, VertexFormats.POSITION)
6263
vertex(startX.toDouble(), endY.toDouble(), 0.0).next()
6364
vertex(endX.toDouble(), endY.toDouble(), 0.0).next()
6465
vertex(endX.toDouble(), startY.toDouble(), 0.0).next()
@@ -86,8 +87,7 @@ fun drawRect(left: Int, top: Int, right: Int, bottom: Int, color: Int) {
8687
GlStateManager.SrcFactor.ONE,
8788
GlStateManager.DstFactor.ZERO
8889
)
89-
@Suppress("DEPRECATION")
90-
RenderSystem.color4f(red, green, blue, alpha)
90+
RenderSystem.setShaderColor(red, green, blue, alpha)
9191
buffer.update(sanitizedLeft, sanitizedTop, sanitizedRight, sanitizedBottom)
9292
tessellator.draw()
9393
RenderSystem.enableTexture()

src/main/kotlin/io/github/samarium150/minecraft/mod/structures_compass/network/packet/s2c/SyncPacket.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class SyncPacket(
6161
}
6262
StructuresCompassData.update(allowedStructures, structuresDimensionsMap)
6363
client.execute {
64-
client.openScreen(StructuresCompassScreen(itemStack))
64+
client.setScreen(StructuresCompassScreen(itemStack))
6565
}
6666
}
6767
}

0 commit comments

Comments
 (0)