fix plank tests

This commit is contained in:
Moritz Zwerger 2024-10-29 23:12:07 +01:00
parent 5011828949
commit ad72c013df
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
4 changed files with 29 additions and 10 deletions

View File

@ -31,6 +31,7 @@ import de.bixilon.minosoft.data.registries.blocks.state.BlockState
import de.bixilon.minosoft.data.registries.blocks.types.building.WoolBlock
import de.bixilon.minosoft.data.registries.blocks.types.building.stone.StoneBlock
import de.bixilon.minosoft.data.registries.blocks.types.pvp.CobwebBlock
import de.bixilon.minosoft.data.registries.blocks.types.wood.Oak
import de.bixilon.minosoft.data.registries.effects.mining.MiningEffect
import de.bixilon.minosoft.data.registries.enchantment.armor.ArmorEnchantment
import de.bixilon.minosoft.data.registries.enchantment.tool.MiningEnchantment
@ -164,35 +165,35 @@ class BreakHandlerTest {
fun nothingPlanks() {
breakBlock(MinecraftBlocks.OAK_PLANKS, ticks = 62)!!.assert(productivity = BlockBreakProductivity.INEFFECTIVE)
breakBlock(Oak.Planks.identifier, ticks = 62)!!.assert(productivity = BlockBreakProductivity.INEFFECTIVE)
}
fun pickaxePlanks() {
breakBlock(MinecraftBlocks.OAK_PLANKS, WoodenTool.WoodenPickaxe, ticks = 62)!!.assert(productivity = BlockBreakProductivity.INEFFECTIVE)
breakBlock(Oak.Planks.identifier, WoodenTool.WoodenPickaxe, ticks = 62)!!.assert(productivity = BlockBreakProductivity.INEFFECTIVE)
}
fun woodenAxePlanks() {
breakBlock(MinecraftBlocks.OAK_PLANKS, WoodenTool.WoodenAxe, ticks = 31)!!.assert(productivity = BlockBreakProductivity.EFFECTIVE)
breakBlock(Oak.Planks.identifier, WoodenTool.WoodenAxe, ticks = 31)!!.assert(productivity = BlockBreakProductivity.EFFECTIVE)
}
fun stoneAxePlanks() {
breakBlock(MinecraftBlocks.OAK_PLANKS, StoneTool.StoneAxe, ticks = 16)!!.assert(productivity = BlockBreakProductivity.EFFECTIVE)
breakBlock(Oak.Planks.identifier, StoneTool.StoneAxe, ticks = 16)!!.assert(productivity = BlockBreakProductivity.EFFECTIVE)
}
fun ironAxePlanks() {
breakBlock(MinecraftBlocks.OAK_PLANKS, IronTool.IronAxe, ticks = 11)!!.assert(productivity = BlockBreakProductivity.EFFECTIVE)
breakBlock(Oak.Planks.identifier, IronTool.IronAxe, ticks = 11)!!.assert(productivity = BlockBreakProductivity.EFFECTIVE)
}
fun diamondAxePlanks() {
breakBlock(MinecraftBlocks.OAK_PLANKS, DiamondTool.DiamondAxe, ticks = 9)!!.assert(productivity = BlockBreakProductivity.EFFECTIVE)
breakBlock(Oak.Planks.identifier, DiamondTool.DiamondAxe, ticks = 9)!!.assert(productivity = BlockBreakProductivity.EFFECTIVE)
}
fun netheriteAxePlanks() {
breakBlock(MinecraftBlocks.OAK_PLANKS, NetheriteTool.NetheriteAxe, ticks = 8)!!.assert(productivity = BlockBreakProductivity.EFFECTIVE)
breakBlock(Oak.Planks.identifier, NetheriteTool.NetheriteAxe, ticks = 8)!!.assert(productivity = BlockBreakProductivity.EFFECTIVE)
}
fun goldenAxePlanks() {
breakBlock(MinecraftBlocks.OAK_PLANKS, GoldenTool.GoldenAxe, ticks = 6)!!.assert(productivity = BlockBreakProductivity.EFFECTIVE)
breakBlock(Oak.Planks.identifier, GoldenTool.GoldenAxe, ticks = 6)!!.assert(productivity = BlockBreakProductivity.EFFECTIVE)
}
fun nothingEndStone() {

View File

@ -23,9 +23,10 @@ import de.bixilon.minosoft.data.registries.blocks.types.properties.shape.special
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
import de.bixilon.minosoft.data.registries.item.items.Item
import de.bixilon.minosoft.data.registries.item.items.tool.axe.AxeRequirement
import de.bixilon.minosoft.data.registries.item.items.tool.properties.requirement.HandBreakable
import de.bixilon.minosoft.protocol.versions.Version
abstract class PlanksBlock(identifier: ResourceLocation, settings: BlockSettings) : Block(identifier, settings), FullOpaqueBlock, BlockStateBuilder, AxeRequirement, BlockWithItem<Item> {
abstract class PlanksBlock(identifier: ResourceLocation, settings: BlockSettings) : Block(identifier, settings), FullOpaqueBlock, BlockStateBuilder, AxeRequirement, HandBreakable, BlockWithItem<Item> {
override val hardness get() = 2.0f
override val item: Item = this::item.inject(identifier)

View File

@ -0,0 +1,16 @@
/*
* Minosoft
* Copyright (C) 2020-2024 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.item.items.tool.properties.requirement
interface HandBreakable

View File

@ -23,6 +23,7 @@ import de.bixilon.minosoft.data.registries.enchantment.armor.ArmorEnchantment
import de.bixilon.minosoft.data.registries.enchantment.tool.MiningEnchantment
import de.bixilon.minosoft.data.registries.fluid.fluids.WaterFluid
import de.bixilon.minosoft.data.registries.item.items.tool.MiningTool
import de.bixilon.minosoft.data.registries.item.items.tool.properties.requirement.HandBreakable
import de.bixilon.minosoft.data.registries.item.items.tool.properties.requirement.ToolRequirement
import de.bixilon.minosoft.input.interaction.breaking.BreakHandler
import de.bixilon.minosoft.protocol.packets.c2s.play.entity.player.PlayerActionC2SP
@ -63,7 +64,7 @@ class SurvivalDigger(
var speed = 1.0f
var toolSpeed = 1.0f
val block = target.state.block
val toolRequired = if (block is PixLyzerBlock) block.requiresTool else block is ToolRequirement
val toolRequired = if (block is PixLyzerBlock) block.requiresTool else (block is ToolRequirement && block !is HandBreakable)
var isBestTool = !toolRequired
if (stack != null && stack.item.item is MiningTool) {