Some fixes to crafter

This commit is contained in:
TomTom 2024-06-25 12:12:44 +02:00
parent a6e40dc2ec
commit ef60c97a11
2 changed files with 20 additions and 4 deletions

View File

@ -155,6 +155,17 @@ class CrafterMinionType : MinionType("crafter", AxMinionsPlugin.INSTANCE.getReso
}
private fun canCraftShaped(recipe: ShapedRecipe, contents: HashMap<ItemStack, Int>): Boolean {
val frequencyMap = HashMap<Char, Int>()
for (s in recipe.shape) {
println("Line $s")
for (c in s.toCharArray()) {
println("Char $c")
frequencyMap[c] = frequencyMap.getOrDefault(c, 0)
}
}
println("Map $frequencyMap")
for (recipeChoice in recipe.choiceMap) {
if (recipeChoice.value == null) continue
if (recipeChoice.value.itemStack == null) continue
@ -169,7 +180,7 @@ class CrafterMinionType : MinionType("crafter", AxMinionsPlugin.INSTANCE.getReso
}
}
if (amount < recipeChoice.value.itemStack.amount) {
if (amount < frequencyMap[recipeChoice.key]!! * recipeChoice.value.itemStack.amount) {
return false
}
}

View File

@ -2,8 +2,6 @@ package com.artillexstudios.axminions.nms.v1_21_R1
import com.artillexstudios.axminions.api.minions.Minion
import com.artillexstudios.axminions.nms.NMSHandler
import java.util.UUID
import net.minecraft.core.BlockPos
import net.minecraft.world.entity.MobCategory
import org.bukkit.Location
import org.bukkit.block.Block
@ -14,6 +12,7 @@ import org.bukkit.craftbukkit.inventory.CraftItemStack
import org.bukkit.craftbukkit.util.CraftLocation
import org.bukkit.entity.Entity
import org.bukkit.inventory.ItemStack
import java.util.*
class NMSHandler : NMSHandler {
@ -39,6 +38,12 @@ class NMSHandler : NMSHandler {
override fun getExp(block: Block, itemStack: ItemStack): Int {
val craftBlock = block as CraftBlock
return craftBlock.nms.block.getExpDrop((block.state as CraftBlockState).handle, craftBlock.handle.minecraftWorld, CraftLocation.toBlockPosition(block.location), CraftItemStack.asNMSCopy(itemStack), true)
return craftBlock.nms.block.getExpDrop(
(block.state as CraftBlockState).handle,
craftBlock.handle.minecraftWorld,
CraftLocation.toBlockPosition(block.location),
CraftItemStack.asNMSCopy(itemStack),
true
)
}
}