Skip to content

Commit

Permalink
v1.1.0 Beta Fabric 1.19
Browse files Browse the repository at this point in the history
  • Loading branch information
eth0net authored Jul 26, 2022
2 parents e103540 + cd1f215 commit 266e7ac
Show file tree
Hide file tree
Showing 26 changed files with 214 additions and 74 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@ Enchant Menu adds a simple menu for modifying item enchantments.
- Select enchantments from the list of possible enchantments
- Select the level of enchantment from 1 to 10
- Supports custom enchantments

## Planned Features
- Toggle to surpass vanilla level limits
- Toggle to allow incompatible enchantments
- Toggle to allow treasure-only enchantments

## Planned Features
- Enchantment search box
- Configuration of menu features

## Gallery

![Item with enchantments](./assets/screenshots/item-with-enchantment.png)
![Custom enchantments](./assets/screenshots/custom-enchantments.png)
![Item with enchantments](./assets/screenshots/enchanted-locked.png)
![Incompatible enchantments unlocked](./assets/screenshots/incompatible-unlocked.png)
![Level limit unlocked](./assets/screenshots/level-unlocked.png)
![Treasure enchantments unlocked](./assets/screenshots/treasure-unlocked.png)

## Credit

Expand Down
Binary file added assets/enchant-menu.aseprite
Binary file not shown.
Binary file removed assets/menu.aseprite
Binary file not shown.
Binary file removed assets/screenshots/custom-enchantments.png
Binary file not shown.
Binary file added assets/screenshots/enchanted-locked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/incompatible-unlocked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/screenshots/item-with-enchantment.png
Binary file not shown.
Binary file added assets/screenshots/level-unlocked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshots/treasure-unlocked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ val modVersion: String by project
val modVersionName: String by project
val modVersionType: String by project

val changelogFile = project.file("changelogs/$modVersion.md")
val changelogText = if (changelogFile.exists()) changelogFile.readText() else "No changelog provided."

plugins {
id("fabric-loom")
val kotlinVersion: String by System.getProperties()
Expand Down Expand Up @@ -65,13 +68,14 @@ tasks {
projectId.set(base.archivesName)
versionName.set(modVersionName)
versionType.set(modVersionType)
changelog.set(project.file("changelogs/$modVersion.md").readText())
changelog.set(changelogText)
uploadFile.set(remapJar.get())
additionalFiles.set(listOf(remapSourcesJar.get()))
dependencies {
required.version(fabricVersionId)
required.version(fabricKotlinVersionId)
}
debugMode.set(true)
// syncBodyFrom.set(rootProject.file("README.md").toString())
}
}
16 changes: 16 additions & 0 deletions changelogs/1.1.0-beta+fabric-1.19.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Limit breaks enabled!

**Changed**:
- Bumped fabric-api `0.57.0+1.19` -> `0.58.0+1.19`
- Bumped fabric-language-kotlin `1.8.1+kotlin.1.7.0` -> `1.8.2+kotlin.1.7.10`
- Renamed increment/decrement identifiers to increment/decrement level
- Expanded enchantment list entries to Triple to include compatibility
- Reworked list texture for longer enchantment names

**Added**:
- Buttons and keybinds to toggle limit breaks
- Networking and state for limit breaks
- Incompatible, level, and treasure limit breaks
- New disabled and empty enchantment row textures

**Full Changelog**: https://github.com/eth0net/enchant-menu/commits/v1.1.0-alpha+fabric-1.19
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ minecraftVersion=1.19
yarnMappings=1.19+build.4
loaderVersion=0.14.8
# Fabric API
fabricVersion=0.57.0+1.19
fabricVersionId=Zp275COe
fabricVersion=0.58.0+1.19
fabricVersionId=3KmOcp6b
loomVersion=0.12-SNAPSHOT
# Kotlin
systemProp.kotlinVersion=1.7.0
fabricKotlinVersion=1.8.1+kotlin.1.7.0
fabricKotlinVersionId=D2Y5G2KO
fabricKotlinVersion=1.8.2+kotlin.1.7.10
fabricKotlinVersionId=5Aq3SFbi
# Mod Properties
mavenGroup=com.github.eth0net
modId=enchant-menu
modVersion=1.0.0+fabric-1.19
modVersionName=1.0.0 Fabric 1.19
modVersionType=release
modVersion=1.1.0-beta+fabric-1.19
modVersionName=1.1.0 Beta Fabric 1.19
modVersionType=beta
17 changes: 12 additions & 5 deletions src/main/kotlin/com/github/eth0net/enchantmenu/EnchantMenu.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.github.eth0net.enchantmenu

import com.github.eth0net.enchantmenu.network.channel.DecrementChannel
import com.github.eth0net.enchantmenu.network.channel.IncrementChannel
import com.github.eth0net.enchantmenu.network.channel.MenuChannel
import com.github.eth0net.enchantmenu.network.channel.*
import com.github.eth0net.enchantmenu.screen.EnchantMenuScreenHandler
import com.github.eth0net.enchantmenu.screen.EnchantMenuScreenHandlerFactory
import com.github.eth0net.enchantmenu.util.Identifier
Expand All @@ -24,12 +22,21 @@ object EnchantMenu : ModInitializer {
ServerPlayNetworking.registerGlobalReceiver(MenuChannel) { _, player, _, _, _ ->
player.openHandledScreen(EnchantMenuScreenHandlerFactory)
}
ServerPlayNetworking.registerGlobalReceiver(IncrementChannel) { _, player, _, _, _ ->
ServerPlayNetworking.registerGlobalReceiver(IncrementLevelChannel) { _, player, _, _, _ ->
(player.currentScreenHandler as? EnchantMenuScreenHandler)?.incrementLevel()
}
ServerPlayNetworking.registerGlobalReceiver(DecrementChannel) { _, player, _, _, _ ->
ServerPlayNetworking.registerGlobalReceiver(DecrementLevelChannel) { _, player, _, _, _ ->
(player.currentScreenHandler as? EnchantMenuScreenHandler)?.decrementLevel()
}
ServerPlayNetworking.registerGlobalReceiver(ToggleIncompatibleChannel) { _, player, _, _, _ ->
(player.currentScreenHandler as? EnchantMenuScreenHandler)?.toggleIncompatible()
}
ServerPlayNetworking.registerGlobalReceiver(ToggleLevelChannel) { _, player, _, _, _ ->
(player.currentScreenHandler as? EnchantMenuScreenHandler)?.toggleLevel()
}
ServerPlayNetworking.registerGlobalReceiver(ToggleTreasureChannel) { _, player, _, _, _ ->
(player.currentScreenHandler as? EnchantMenuScreenHandler)?.toggleTreasure()
}

Logger.info("EnchantMenu initialized.")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.github.eth0net.enchantmenu.client.gui.screen

import com.github.eth0net.enchantmenu.client.keybinding.DecrementKeyBinding
import com.github.eth0net.enchantmenu.client.keybinding.IncrementKeyBinding
import com.github.eth0net.enchantmenu.client.keybinding.MenuKeyBinding
import com.github.eth0net.enchantmenu.network.channel.DecrementChannel
import com.github.eth0net.enchantmenu.network.channel.IncrementChannel
import com.github.eth0net.enchantmenu.client.keybinding.*
import com.github.eth0net.enchantmenu.network.channel.*
import com.github.eth0net.enchantmenu.screen.EnchantMenuScreenHandler
import com.github.eth0net.enchantmenu.util.Identifier
import com.mojang.blaze3d.systems.RenderSystem
Expand All @@ -29,7 +26,7 @@ class EnchantMenuScreen(handler: EnchantMenuScreenHandler, playerInventory: Play
override fun getDisplayName() = Text.empty()
}, title) {

private val texture = Identifier("textures/menu.png")
private val texture = Identifier("textures/gui/enchant_menu.png")
private var stack = ItemStack.EMPTY
private var ticks = 0

Expand Down Expand Up @@ -62,12 +59,12 @@ class EnchantMenuScreen(handler: EnchantMenuScreenHandler, playerInventory: Play
override fun mouseClicked(mouseX: Double, mouseY: Double, button: Int): Boolean {
val x = (width - backgroundWidth) / 2
val y = (height - backgroundHeight) / 2
val clickX = mouseX.roundToInt() - (x + 51)
val clickX = mouseX.roundToInt() - (x + 44)

for (i in 0 until maxRows) {
val index = i + scrollOffset
val clickY = mouseY.roundToInt() - (y + 19 + 12 * i)
val inBounds = clickX in 0..133 && clickY in 0..11
val inBounds = clickX in 0..140 && clickY in 0..11
if (!inBounds || !handler.onButtonClick(client!!.player as PlayerEntity, index)) continue
client!!.interactionManager!!.clickButton(handler.syncId, index)
return true
Expand All @@ -83,8 +80,11 @@ class EnchantMenuScreen(handler: EnchantMenuScreenHandler, playerInventory: Play

override fun keyPressed(keyCode: Int, scanCode: Int, modifiers: Int): Boolean {
if (MenuKeyBinding.matchesKey(keyCode, scanCode)) close()
if (IncrementKeyBinding.matchesKey(keyCode, scanCode)) incrementLevel()
if (DecrementKeyBinding.matchesKey(keyCode, scanCode)) decrementLevel()
if (IncrementLevelKeyBinding.matchesKey(keyCode, scanCode)) onIncrementLevelClick()
if (DecrementLevelKeyBinding.matchesKey(keyCode, scanCode)) onDecrementLevelClick()
if (ToggleIncompatibleKeyBinding.matchesKey(keyCode, scanCode)) onToggleIncompatibleClick()
if (ToggleLevelKeyBinding.matchesKey(keyCode, scanCode)) onToggleLevelClick()
if (ToggleTreasureKeyBinding.matchesKey(keyCode, scanCode)) onToggleTreasureClick()
return super.keyPressed(keyCode, scanCode, modifiers)
}

Expand All @@ -102,53 +102,67 @@ class EnchantMenuScreen(handler: EnchantMenuScreenHandler, playerInventory: Play

// level text
val level = handler.level.toString()
textRenderer.drawTrimmed(Text.literal(level), x + 27 - level.length * 3, y + 21, level.length * 6, 0xFFFFFF)
textRenderer.drawTrimmed(Text.literal(level), x + 23 - level.length * 3, y + 21, level.length * 6, 0xFFFFFF)

// level change buttons
clearChildren()
if (handler.level < handler.maxLevel) addDrawableChild(TexturedButtonWidget(
x + 38, y + 18, 8, 13, 142, 166, texture
) { incrementLevel() })
x + 31, y + 18, 8, 13, 149, 166, texture
) { onIncrementLevelClick() })
if (handler.level > handler.minLevel) addDrawableChild(TexturedButtonWidget(
x + 7, y + 18, 8, 13, 134, 166, texture
) { decrementLevel() })
x + 6, y + 18, 8, 13, 141, 166, texture
) { onDecrementLevelClick() })

// scroll marker
if (canScroll) {
val scrollMarkerX = x + 185
val scrollMarkerY = y + 19 + (48 * (scrollOffset.toFloat() / maxScrollOffset)).toInt()
RenderSystem.setShaderTexture(0, texture)
drawTexture(matrices, scrollMarkerX, scrollMarkerY, 150, 166, 4, 12)
drawTexture(matrices, scrollMarkerX, scrollMarkerY, 141, 205, 4, 12)
}

// limit breaks
addDrawableChild(TexturedButtonWidget(
x + 152, y + 5, 11, 11, 168, if (handler.incompatibleUnlocked) 177 else 166, texture
) { onToggleIncompatibleClick() })
addDrawableChild(TexturedButtonWidget(
x + 165, y + 5, 11, 11, 179, if (handler.levelUnlocked) 177 else 166, texture
) { onToggleLevelClick() })
addDrawableChild(TexturedButtonWidget(
x + 178, y + 5, 11, 11, 190, if (handler.treasureUnlocked) 177 else 166, texture
) { onToggleTreasureClick() })

// enchantments list, from scroll offset to max rows
for (i in 0 until maxRows) {
val index = i + scrollOffset
if (index >= handler.enchantments.size) break

val xOffset = x + 51
val xOffset = x + 44
val yOffset = y + 19 + 12 * i

val (enchantment, currentLevel) = handler.enchantments[index]
val (enchantment, currentLevel, compatible) = handler.enchantments[index]
val hasEnchantment = currentLevel > 0
val text = enchantment.getName(if (hasEnchantment) currentLevel else handler.level)
var color = 6839882
var color = 0xFFFF80

RenderSystem.setShaderTexture(0, texture)

val hoverX = mouseX - xOffset
val hoverY = mouseY - yOffset
if (hoverX in 0 until 134 && hoverY in 0 until 12) {
drawTexture(matrices, xOffset, yOffset, 0, 202, 134, 12)
color = 0xFFFF80
if (!compatible && !handler.incompatibleUnlocked && !hasEnchantment) {
color = 37373737
drawTexture(matrices, xOffset, yOffset, 0, 178, 141, 12)
} else if (hoverX in 0 until 141 && hoverY in 0 until 12) {
drawTexture(matrices, xOffset, yOffset, 0, 202, 141, 12)
} else if (hasEnchantment) {
drawTexture(matrices, xOffset, yOffset, 0, 190, 134, 12)
color = 0xFFFF80
drawTexture(matrices, xOffset, yOffset, 0, 190, 141, 12)
} else {
drawTexture(matrices, xOffset, yOffset, 0, 166, 134, 12)
drawTexture(matrices, xOffset, yOffset, 0, 166, 141, 12)
color = 6839882
}

textRenderer.drawTrimmed(text, xOffset + 2, yOffset + 2, 130, color)
val overLimit = handler.level > enchantment.maxLevel && !handler.levelUnlocked
val lvl = if (hasEnchantment) currentLevel else if (overLimit) enchantment.maxLevel else handler.level
textRenderer.drawTrimmed(enchantment.getName(lvl), xOffset + 2, yOffset + 2, 137, color)
}
}

Expand All @@ -158,13 +172,28 @@ class EnchantMenuScreen(handler: EnchantMenuScreenHandler, playerInventory: Play
drawMouseoverTooltip(matrices, mouseX, mouseY)
}

private fun incrementLevel() {
private fun onIncrementLevelClick() {
handler.incrementLevel()
ClientPlayNetworking.send(IncrementChannel, PacketByteBufs.empty())
ClientPlayNetworking.send(IncrementLevelChannel, PacketByteBufs.empty())
}

private fun decrementLevel() {
private fun onDecrementLevelClick() {
handler.decrementLevel()
ClientPlayNetworking.send(DecrementChannel, PacketByteBufs.empty())
ClientPlayNetworking.send(DecrementLevelChannel, PacketByteBufs.empty())
}

private fun onToggleIncompatibleClick() {
handler.toggleIncompatible()
ClientPlayNetworking.send(ToggleIncompatibleChannel, PacketByteBufs.empty())
}

private fun onToggleLevelClick() {
handler.toggleLevel()
ClientPlayNetworking.send(ToggleLevelChannel, PacketByteBufs.empty())
}

private fun onToggleTreasureClick() {
handler.toggleTreasure()
ClientPlayNetworking.send(ToggleTreasureChannel, PacketByteBufs.empty())
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.github.eth0net.enchantmenu.client.keybinding

import com.github.eth0net.enchantmenu.client.keybinding.key.DecrementKey
import com.github.eth0net.enchantmenu.client.keybinding.key.DecrementLevelKey
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper
import net.minecraft.client.option.KeyBinding
import net.minecraft.client.util.InputUtil

internal val DecrementKeyBinding = KeyBindingHelper.registerKeyBinding(
internal val DecrementLevelKeyBinding = KeyBindingHelper.registerKeyBinding(
KeyBinding(
"key.enchant-menu.decrement", InputUtil.Type.KEYSYM, DecrementKey, "category.enchant-menu.general"
"key.enchant-menu.decrement_level", InputUtil.Type.KEYSYM, DecrementLevelKey, "category.enchant-menu.general"
)
)
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.github.eth0net.enchantmenu.client.keybinding

import com.github.eth0net.enchantmenu.client.keybinding.key.IncrementKey
import com.github.eth0net.enchantmenu.client.keybinding.key.IncrementLevelKey
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper
import net.minecraft.client.option.KeyBinding
import net.minecraft.client.util.InputUtil

internal val IncrementKeyBinding = KeyBindingHelper.registerKeyBinding(
internal val IncrementLevelKeyBinding = KeyBindingHelper.registerKeyBinding(
KeyBinding(
"key.enchant-menu.increment", InputUtil.Type.KEYSYM, IncrementKey, "category.enchant-menu.general"
"key.enchant-menu.increment_level", InputUtil.Type.KEYSYM, IncrementLevelKey, "category.enchant-menu.general"
)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.github.eth0net.enchantmenu.client.keybinding

import com.github.eth0net.enchantmenu.client.keybinding.key.ToggleIncompatibleKey
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper
import net.minecraft.client.option.KeyBinding
import net.minecraft.client.util.InputUtil

internal val ToggleIncompatibleKeyBinding = KeyBindingHelper.registerKeyBinding(
KeyBinding(
"key.enchant-menu.toggle_incompatible",
InputUtil.Type.KEYSYM,
ToggleIncompatibleKey,
"category.enchant-menu.general"
)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.github.eth0net.enchantmenu.client.keybinding

import com.github.eth0net.enchantmenu.client.keybinding.key.ToggleLevelKey
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper
import net.minecraft.client.option.KeyBinding
import net.minecraft.client.util.InputUtil

internal val ToggleLevelKeyBinding = KeyBindingHelper.registerKeyBinding(
KeyBinding(
"key.enchant-menu.toggle_level", InputUtil.Type.KEYSYM, ToggleLevelKey, "category.enchant-menu.general"
)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.github.eth0net.enchantmenu.client.keybinding

import com.github.eth0net.enchantmenu.client.keybinding.key.ToggleTreasureKey
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper
import net.minecraft.client.option.KeyBinding
import net.minecraft.client.util.InputUtil

internal val ToggleTreasureKeyBinding = KeyBindingHelper.registerKeyBinding(
KeyBinding(
"key.enchant-menu.toggle_treasure", InputUtil.Type.KEYSYM, ToggleTreasureKey, "category.enchant-menu.general"
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ package com.github.eth0net.enchantmenu.client.keybinding.key
import org.lwjgl.glfw.GLFW

internal const val MenuKey = GLFW.GLFW_KEY_X
internal const val IncrementKey = GLFW.GLFW_KEY_EQUAL
internal const val DecrementKey = GLFW.GLFW_KEY_MINUS
internal const val IncrementLevelKey = GLFW.GLFW_KEY_EQUAL
internal const val DecrementLevelKey = GLFW.GLFW_KEY_MINUS
internal const val ToggleIncompatibleKey = GLFW.GLFW_KEY_I
internal const val ToggleLevelKey = GLFW.GLFW_KEY_O
internal const val ToggleTreasureKey = GLFW.GLFW_KEY_P
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ package com.github.eth0net.enchantmenu.network.channel
import com.github.eth0net.enchantmenu.util.Identifier

internal val MenuChannel = Identifier("toggle_menu_channel")
internal val DecrementChannel = Identifier("decrement_channel")
internal val IncrementChannel = Identifier("increment_channel")
internal val DecrementLevelChannel = Identifier("decrement_level_channel")
internal val IncrementLevelChannel = Identifier("increment_level_channel")
internal val ToggleIncompatibleChannel = Identifier("toggle_incompatible_channel")
internal val ToggleLevelChannel = Identifier("toggle_level_channel")
internal val ToggleTreasureChannel = Identifier("toggle_treasure_channel")
Loading

0 comments on commit 266e7ac

Please sign in to comment.