Update to 1.20

- Remove some devenv mods that are not updated yet
 - Replace lib39 with fletchingtable for automixins
 - Use non kotlin entrypoints
 - Make use of DrawContext in a bunch of places
This commit is contained in:
nea
2023-06-08 00:11:46 +02:00
parent b65382a7b7
commit f98a1f5d53
14 changed files with 106 additions and 87 deletions

View File

@@ -5,6 +5,7 @@ import io.github.cottonmc.cotton.gui.client.ScreenDrawing
import io.github.cottonmc.cotton.gui.widget.WWidget
import io.github.cottonmc.cotton.gui.widget.data.Texture
import me.shedaniel.math.Color
import net.minecraft.client.gui.DrawContext
import net.minecraft.client.util.math.MatrixStack
import moe.nea.firmament.Firmament
@@ -27,7 +28,7 @@ open class WBar(
}
private fun drawSection(
matrices: MatrixStack,
context: DrawContext,
texture: Texture,
x: Int,
y: Int,
@@ -36,18 +37,18 @@ open class WBar(
sectionEnd: Double
) {
if (sectionEnd < progress && width == 4) {
ScreenDrawing.texturedRect(matrices, x, y, 4, 8, texture, fillColor.color)
ScreenDrawing.texturedRect(context, x, y, 4, 8, texture, fillColor.color)
return
}
if (sectionStart > progress && width == 4) {
ScreenDrawing.texturedRect(matrices, x, y, 4, 8, texture, emptyColor.color)
ScreenDrawing.texturedRect(context, x, y, 4, 8, texture, emptyColor.color)
return
}
val increasePerPixel = (sectionEnd - sectionStart / 4)
var valueAtPixel = sectionStart
for (i in (0 until width)) {
ScreenDrawing.texturedRect(
matrices, x + i, y, 1, 8,
context, x + i, y, 1, 8,
texture.image, texture.u1 + i / 64F, texture.v1, texture.u1 + (i + 1) / 64F, texture.v2,
if (valueAtPixel < progress) fillColor.color else emptyColor.color
)
@@ -55,11 +56,11 @@ open class WBar(
}
}
override fun paint(matrices: MatrixStack, x: Int, y: Int, mouseX: Int, mouseY: Int) {
override fun paint(context: DrawContext, x: Int, y: Int, mouseX: Int, mouseY: Int) {
var i = 0
while (i < width - 4) {
drawSection(
matrices,
context,
if (i == 0) left else middle,
x + i, y,
(width - (i + 4)).coerceAtMost(4),
@@ -67,7 +68,7 @@ open class WBar(
)
i += 4
}
drawSection(matrices, right, x + width - 4, y, 4, (width - 4) * total / width, total)
drawSection(context, right, x + width - 4, y, 4, (width - 4) * total / width, total)
RenderSystem.setShaderColor(1F, 1F, 1F, 1F)
}
}

View File

@@ -9,8 +9,8 @@ import io.github.cottonmc.cotton.gui.widget.WWidget
import io.github.cottonmc.cotton.gui.widget.data.Insets
import io.github.cottonmc.cotton.gui.widget.icon.Icon
import io.github.cottonmc.cotton.gui.widget.icon.ItemIcon
import net.minecraft.client.gui.DrawContext
import net.minecraft.client.item.TooltipContext
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.item.Items
import net.minecraft.text.Text
import moe.nea.firmament.gui.WTightScrollPanel
@@ -27,9 +27,9 @@ object PetsPage : ProfilePage {
for ((i, pet) in profileViewer.member.pets.withIndex()) {
val stack = SBItemStack(pet.itemId, PetData(pet.tier, pet.type.name, pet.exp)).asItemStack()
it.add(object : WItem(stack) {
override fun paint(matrices: MatrixStack?, x: Int, y: Int, mouseX: Int, mouseY: Int) {
BackgroundPainter.SLOT.paintBackground(matrices, x, y, this)
super.paint(matrices, x, y, mouseX, mouseY)
override fun paint(context: DrawContext?, x: Int, y: Int, mouseX: Int, mouseY: Int) {
BackgroundPainter.SLOT.paintBackground(context, x, y, this)
super.paint(context, x, y, mouseX, mouseY)
}
override fun addTooltip(tooltip: TooltipBuilder) {