pack enchantments

This commit is contained in:
Bixilon 2022-12-08 08:30:08 +01:00
parent f251769983
commit 2ba0ca96d3
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
6 changed files with 32 additions and 35 deletions

View File

@ -56,7 +56,7 @@ import de.bixilon.minosoft.data.registries.effects.DefaultStatusEffects
import de.bixilon.minosoft.data.registries.effects.attributes.DefaultStatusEffectAttributeNames
import de.bixilon.minosoft.data.registries.effects.attributes.DefaultStatusEffectAttributes
import de.bixilon.minosoft.data.registries.effects.attributes.EntityAttribute
import de.bixilon.minosoft.data.registries.enchantment.armor.SoulSpeedEnchantment
import de.bixilon.minosoft.data.registries.enchantment.armor.ArmorEnchantment
import de.bixilon.minosoft.data.registries.item.MinecraftItems
import de.bixilon.minosoft.data.registries.item.items.Item
import de.bixilon.minosoft.data.registries.shapes.AABB
@ -208,7 +208,7 @@ class LocalPlayerEntity(
}
val onSoulSpeedBlock = connection.tags[TagsS2CP.BLOCK_TAG_RESOURCE_LOCATION]?.get(SOUL_SPEED_BLOCKS).nullCast<Tag<Block>>()?.entries?.contains(connection.world[positionInfo.velocityPosition]?.block) ?: false
if (onSoulSpeedBlock && getEquipmentEnchant(connection.registries.enchantmentRegistry[SoulSpeedEnchantment]) > 0) {
if (onSoulSpeedBlock && getEquipmentEnchant(connection.registries.enchantmentRegistry[ArmorEnchantment.SoulSpeed]) > 0) {
// ToDo
return 1.0
}

View File

@ -13,9 +13,13 @@
package de.bixilon.minosoft.data.registries.enchantment
import de.bixilon.minosoft.data.registries.enchantment.armor.SoulSpeedEnchantment
import de.bixilon.minosoft.data.registries.enchantment.armor.ArmorEnchantment
import de.bixilon.minosoft.data.registries.enchantment.tool.MiningEnchantment
import de.bixilon.minosoft.data.registries.integrated.IntegratedRegistry
object IntegratedEnchantments : IntegratedRegistry<Enchantment>(
SoulSpeedEnchantment,
ArmorEnchantment.SoulSpeed,
MiningEnchantment.EfficiencyEnchantment,
)

View File

@ -17,8 +17,11 @@ import de.bixilon.minosoft.data.container.ArmorSlots
import de.bixilon.minosoft.data.container.EquipmentSlots
import de.bixilon.minosoft.data.container.stack.ItemStack
import de.bixilon.minosoft.data.entities.entities.Entity
import de.bixilon.minosoft.data.registries.CompanionResourceLocation
import de.bixilon.minosoft.data.registries.enchantment.Enchantment
import de.bixilon.minosoft.data.registries.enchantment.slots.SlotSpecificEnchantment
import de.bixilon.minosoft.data.registries.item.items.armor.ArmorItem
import de.bixilon.minosoft.util.KUtil.minecraft
interface ArmorEnchantment : SlotSpecificEnchantment {
val slots: Set<ArmorSlots>
@ -41,4 +44,10 @@ interface ArmorEnchantment : SlotSpecificEnchantment {
}
return armorSlot in this.slots
}
object SoulSpeed : Enchantment(), ArmorEnchantment, CompanionResourceLocation {
override val RESOURCE_LOCATION = minecraft("soul_speed")
override val slots: Set<ArmorSlots> = setOf(ArmorSlots.FEET)
}
}

View File

@ -1,24 +0,0 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.registries.enchantment.armor
import de.bixilon.minosoft.data.container.ArmorSlots
import de.bixilon.minosoft.data.registries.CompanionResourceLocation
import de.bixilon.minosoft.data.registries.enchantment.Enchantment
import de.bixilon.minosoft.util.KUtil.minecraft
object SoulSpeedEnchantment : Enchantment(), ArmorEnchantment, CompanionResourceLocation {
override val RESOURCE_LOCATION = minecraft("soul_speed")
override val slots: Set<ArmorSlots> = setOf(ArmorSlots.FEET)
}

View File

@ -17,6 +17,9 @@ import de.bixilon.minosoft.data.registries.CompanionResourceLocation
import de.bixilon.minosoft.data.registries.enchantment.Enchantment
import de.bixilon.minosoft.util.KUtil.minecraft
object EfficiencyEnchantment : Enchantment(), ToolEnchantment, CompanionResourceLocation {
override val RESOURCE_LOCATION = minecraft("efficiency")
interface MiningEnchantment : ToolEnchantment {
object EfficiencyEnchantment : Enchantment(), ToolEnchantment, CompanionResourceLocation {
override val RESOURCE_LOCATION = minecraft("efficiency")
}
}

View File

@ -17,7 +17,6 @@ import de.bixilon.kotlinglm.pow
import de.bixilon.kotlinglm.vec3.Vec3i
import de.bixilon.kutil.collections.CollectionUtil.synchronizedMapOf
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
import de.bixilon.kutil.time.TimeUtil
import de.bixilon.kutil.time.TimeUtil.millis
import de.bixilon.minosoft.config.key.KeyActions
import de.bixilon.minosoft.config.key.KeyBinding
@ -27,7 +26,7 @@ import de.bixilon.minosoft.data.entities.entities.player.Hands
import de.bixilon.minosoft.data.registries.blocks.BlockState
import de.bixilon.minosoft.data.registries.effects.DefaultStatusEffects
import de.bixilon.minosoft.data.registries.enchantment.DefaultEnchantments
import de.bixilon.minosoft.data.registries.enchantment.tool.EfficiencyEnchantment
import de.bixilon.minosoft.data.registries.enchantment.tool.MiningEnchantment
import de.bixilon.minosoft.data.registries.fluid.DefaultFluids
import de.bixilon.minosoft.data.registries.item.items.tools.MiningToolItem
import de.bixilon.minosoft.data.registries.other.world.event.handlers.BlockDestroyedHandler
@ -193,7 +192,7 @@ class BreakInteractionHandler(
var speedMultiplier = breakItemInHand?.let { it.item.item.getMiningSpeedMultiplier(connection, target.blockState, it) } ?: 1.0f
if (isToolEffective) {
breakItemInHand?._enchanting?.enchantments?.get(EfficiencyEnchantment)?.let {
breakItemInHand?._enchanting?.enchantments?.get(MiningEnchantment.EfficiencyEnchantment)?.let {
speedMultiplier += it.pow(2) + 1.0f
}
}
@ -231,9 +230,11 @@ class BreakInteractionHandler(
damage > 1.0f -> {
breakProgress = 1.0
}
damage <= 0.0f -> {
breakProgress = 0.0
}
else -> {
val ticks = 1.0f / damage
val seconds = (ticks / ProtocolDefinition.TICKS_PER_SECOND)
@ -250,9 +251,11 @@ class BreakInteractionHandler(
}
fun init() {
renderWindow.inputHandler.registerCheckCallback(DESTROY_BLOCK_KEYBINDING to KeyBinding(
renderWindow.inputHandler.registerCheckCallback(
DESTROY_BLOCK_KEYBINDING to KeyBinding(
KeyActions.CHANGE to setOf(KeyCodes.MOUSE_BUTTON_LEFT),
))
)
)
connection.events.listen<LegacyBlockBreakAckEvent> {
when (it.actions) {
@ -266,6 +269,7 @@ class BreakInteractionHandler(
breakProgress = Double.NEGATIVE_INFINITY
}
}
PlayerActionC2SP.Actions.FINISHED_DIGGING -> {
if (legacyAcknowledgedBreakStarts[it.blockPosition] == null) {
// start was not acknowledged, undoing
@ -273,6 +277,7 @@ class BreakInteractionHandler(
}
legacyAcknowledgedBreakStarts.remove(it.blockPosition)
}
else -> Unit
}
}