mirror of
https://github.com/Artillex-Studios/AxMinions.git
synced 2024-11-21 11:25:50 +01:00
Some fixes to crafter
This commit is contained in:
parent
a6e40dc2ec
commit
ef60c97a11
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user