Compare commits

..

No commits in common. "b51e0ec2e07b169d5feebcbfd7ffd5c64db8eb5a" and "fb83b1089471fa0f6bf1dda9f10b21b9a58b4835" have entirely different histories.

11 changed files with 35 additions and 41 deletions

View File

@ -211,7 +211,7 @@ allprojects {
"-Xjvm-default=all", "-Xlambdas=indy", "-Xtype-enhancement-improvements-strict-mode",
"-Xmultifile-parts-inherit",
"-Xbackend-threads=0", "-Xno-param-assertions", "-Xno-call-assertions",
"-opt-in=kotlin.RequiresOptIn", "-Xassertions=jvm", "-progressive"
"-opt-in=kotlin.RequiresOptIn", "-Xextended-compiler-checks", "-Xassertions=jvm", "-progressive"
)
//languageVersion = (kotlinSplitVersion[0] + '.' + (kotlinSplitVersion[1].toShort() + 1).toString())
//apiVersion = "${kotlinSplitVersion[0]}.${kotlinSplitVersion[1]}"

View File

@ -4,7 +4,6 @@ import fr.username404.snowygui.gui.ColoredElement
import fr.username404.snowygui.gui.Element
import fr.username404.snowygui.gui.SnowyScreen
import fr.username404.snowygui.gui.elements.ClickBox
import net.minecraft.client.input.MouseButtonEvent
import org.lwjgl.glfw.GLFW
object ClickGui: SnowyScreen() {
@ -20,26 +19,26 @@ object ClickGui: SnowyScreen() {
private inline fun currentBoxContext(args: ClickBox.() -> Unit): Unit? = draggingBox?.run { boxContext { if (name.string == draggingBox) args() } }
private var offsetX: Double = 0.0;
private var offsetY: Double = 0.0;
override fun mouseClicked(event: MouseButtonEvent, isDoubleClick: Boolean): Boolean {
if (event.input() == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
clickBoxes.find { it.isWithinBounds(event.x, event.y) }?.let { draggingBox = it.name.string }
override fun mouseClicked(d: Double, e: Double, i: Int): Boolean {
if (i == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
clickBoxes.find { it.isWithinBounds(d, e) }?.let { draggingBox = it.name.string }
currentBoxContext {
offsetX = event.x - (x + width)
offsetY = event.y - (y + height)
offsetX = d - (x + width)
offsetY = e - (y + height)
}
}
buttonsContext { this.mouseClicked(event, isDoubleClick) }; return super.mouseClicked(event, isDoubleClick);
buttonsContext { this.mouseClicked(d, e, i) }; return super.mouseClicked(d, e, i);
}
override fun mouseReleased(event: MouseButtonEvent): Boolean { draggingBox = null; buttonsContext { this.mouseReleased(event) }; return false }
override fun mouseReleased(d: Double, e: Double, i: Int): Boolean { draggingBox = null; buttonsContext { this.mouseReleased(d, e, i) }; return false }
override fun mouseScrolled(d: Double, e: Double, f: Double, scrollY: Double): Boolean { boxContext { scroll(d, e, scrollY) }; return false }
override fun mouseDragged(event: MouseButtonEvent, mouseX: Double, mouseY: Double): Boolean {
if (event.input() == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
override fun mouseDragged(d: Double, e: Double, i: Int, f: Double, g: Double): Boolean {
if (i == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
currentBoxContext {
x = (event.x + offsetX).coerceIn(0.0..this@ClickGui.width - width.toDouble())
y = (event.y + offsetY).coerceIn(0.0..this@ClickGui.height - height.toDouble())
x = (d + offsetX).coerceIn(0.0..this@ClickGui.width - width.toDouble())
y = (e + offsetY).coerceIn(0.0..this@ClickGui.height - height.toDouble())
}
}
return super.mouseDragged(event, mouseX, mouseY)
return super.mouseDragged(d, e, i, f, g)
}
}

View File

@ -96,7 +96,7 @@ class ClickBox(
addVertex(x, y + height, 0.0F).colorEnd()
}
renderBufferWithPipeline(renderPipeline = RenderPipelines.LINES_TRANSLUCENT) {
renderBufferWithPipeline(renderPipeline = RenderPipelines.DEBUG_LINE_STRIP) {
colorShader()
addVertex(x + inclination, y + height, 0.0F).colorEnd(Colors.WHITE_LINES.hexValue)
addVertex(x + width, y + height, 0.0F).colorEnd(Colors.WHITE_LINES.hexValue)

View File

@ -10,7 +10,6 @@ import fr.username404.snowygui.utils.RenderingUtil.colorShader
import fr.username404.snowygui.utils.RenderingUtil.endDraw
import fr.username404.snowygui.utils.RenderingUtil.prepareDraw
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.input.MouseButtonEvent
import kotlin.reflect.full.findAnnotation
sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
@ -69,8 +68,8 @@ sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
}
private fun lightUp() { opacity += ButtonInfo.lightningFactor }
private fun lightDown() { opacity -= ButtonInfo.lightningFactor }
final override fun mouseClicked(event: MouseButtonEvent, isDoubleClick: Boolean): Boolean {
wasWithinBounds = isWithinBounds(event.x, event.y).also {
final override fun mouseClicked(d: Double, e: Double, i: Int): Boolean {
wasWithinBounds = isWithinBounds(d, e).also {
if (it) {
if (info.kind == Type.TOGGLE) {
toggled = !toggled
@ -80,7 +79,7 @@ sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
return false
}
final override fun mouseReleased(event: MouseButtonEvent): Boolean {
final override fun mouseReleased(d: Double, e: Double, i: Int): Boolean {
if (wasWithinBounds && (info.kind == Type.CLICK)) {
execAction()
lightDown()

View File

@ -3,7 +3,6 @@ package fr.username404.snowygui.gui.feature
import fr.username404.snowygui.gui.feature.ButtonInfo.Companion.Type
import kotlinx.serialization.Serializable
import net.minecraft.client.Minecraft
import net.minecraft.server.permissions.Permissions
/**
* @property command The command to execute
@ -18,7 +17,7 @@ data class Macro(
override fun execAction(): Unit = with(Minecraft.getInstance().player!!) {
connection.run {
command.let {
if (it.startsWith("say") && !this@with.permissions().hasPermission(Permissions.COMMANDS_GAMEMASTER)) {
if (it.startsWith("say") && !hasPermissions(2)) {
sendChat(it.drop(4))
} else sendCommand(it)
}

View File

@ -12,7 +12,6 @@ import org.lwjgl.glfw.GLFW.GLFW_KEY_Y
private typealias privateLambda = (() -> Unit)?
object AddKeyMaps {
private const val prefix = "snowy"
var category: KeyMapping.Category? = null; private set
@JvmOverloads
internal fun mkMap(
translationSuffix: String,
@ -20,9 +19,7 @@ object AddKeyMaps {
lambda: privateLambda = null
): Pair<KeyMapping, privateLambda> = KeyMapping(
"key.$prefix.$translationSuffix", InputConstants.Type.KEYSYM,
key, this.category ?: run {
this.category = KeyMapping.Category.register("category.$prefix.$category"); this.category
}!!
key, "category.$prefix.$category"
) to lambda
val list: MutableMap<KeyMapping, privateLambda> = with(Minecraft.getInstance()) {
mutableMapOf(

View File

@ -13,8 +13,6 @@ import fr.username404.snowygui.gui.feature.Colors
import fr.username404.snowygui.gui.hextoRGB
import net.minecraft.client.Minecraft
import net.minecraft.client.renderer.RenderPipelines
import org.joml.Matrix4f
import org.joml.Vector3f
import org.joml.Vector4f
import java.util.OptionalDouble
import java.util.OptionalInt
@ -47,11 +45,12 @@ object RenderingUtil {
val gpuSlice = RenderSystem.getDynamicUniforms().writeTransform(
RenderSystem.getModelViewMatrix(),
Vector4f(1F, 1F, 1F, 1F), // Alternative to old setShaderColor
Vector3f(),
Matrix4f()
RenderSystem.getModelOffset(),
RenderSystem.getTextureMatrix(),
RenderSystem.getShaderLineWidth()
)
fun renderBufferWithPipeline(
name: String = "Dynamic vertex buffer",
name: String? = "Dynamic vertex buffer",
renderPipeline: RenderPipeline,
renderTarget: RenderTarget = Minecraft.getInstance().mainRenderTarget,
uniformAndSamplerConsumer: ((RenderPass) -> Unit)? = null,

View File

@ -4,6 +4,4 @@ accessible field net/minecraft/client/OptionInstance value Ljava/lang/Object;
mutable field net/minecraft/client/OptionInstance value Ljava/lang/Object;
accessible field com/mojang/blaze3d/opengl/GlCommandEncoder inRenderPass Z
mutable field com/mojang/blaze3d/opengl/GlCommandEncoder inRenderPass Z
accessible method net/minecraft/client/KeyMapping$Category register (Ljava/lang/String;)Lnet/minecraft/client/KeyMapping$Category;
mutable field com/mojang/blaze3d/opengl/GlCommandEncoder inRenderPass Z

View File

@ -25,11 +25,14 @@ abstract class KeyMappings {
@Inject(method = "<init>*", at = @At("RETURN"))
private void onSettingsConstructed(Minecraft minecraft, File file, CallbackInfo ci) {
final var categoryList = KeysAccessor.getSortedCategoryList();
final var categoryMap = KeysAccessor.getSortedCategoryMap();
var newKeys = Lists.newArrayList(keyMappings);
for (KeyMapping key : keysToAdd) {
if (!categoryList.contains(key.getCategory()))
categoryList.add(key.getCategory());
if (!categoryMap.containsKey(key.getCategory())) {
Optional<Integer> biggest = categoryMap.values().stream().max(Integer::compareTo);
int biggestInt = biggest.orElse(0);
categoryMap.put(key.getCategory(), biggestInt + 1);
}
newKeys.remove(key);
newKeys.add(key);
}

View File

@ -4,10 +4,10 @@ import net.minecraft.client.KeyMapping;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.List;
import java.util.Map;
@Mixin(KeyMapping.Category.class)
@Mixin(KeyMapping.class)
public interface KeysAccessor {
@Accessor("SORT_ORDER")
static List<KeyMapping.Category> getSortedCategoryList() { throw new AssertionError(); }
@Accessor("CATEGORY_SORT_ORDER")
static Map<String, Integer> getSortedCategoryMap() { throw new AssertionError(); }
}

View File

@ -21,7 +21,7 @@ class FabricInit: Snowy(), ClientModInitializer {
EVENT.register(
object: HudRenderCallback, EventSnowy {
override val type: String = "HudRender"
override fun onHudRender(guiGraphics: GuiGraphics, tickCounter: DeltaTracker) = fire(guiGraphics)
override fun onHudRender(guiGraphics: GuiGraphics?, tickCounter: DeltaTracker?) = fire(guiGraphics)
}
)
}