Switched entity lookup off to new system
This commit is contained in:
@@ -114,7 +114,7 @@ import com.willfp.eco.internal.spigot.recipes.ShapedRecipeListener
|
||||
import com.willfp.eco.internal.spigot.recipes.listeners.ComplexInComplex
|
||||
import com.willfp.eco.internal.spigot.recipes.listeners.ComplexInEco
|
||||
import com.willfp.eco.internal.spigot.recipes.listeners.ComplexInVanilla
|
||||
import com.willfp.eco.lookup.LookupHelper
|
||||
import com.willfp.eco.core.lookup.LookupHelper
|
||||
import com.willfp.eco.util.BlockUtils
|
||||
import com.willfp.eco.util.NumberUtils
|
||||
import com.willfp.eco.util.ServerUtils
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.willfp.eco.internal.spigot.recipes.listeners
|
||||
|
||||
import com.willfp.eco.core.items.Items
|
||||
import com.willfp.eco.core.items.TestableItem
|
||||
import com.willfp.eco.core.recipe.Recipes
|
||||
import com.willfp.eco.core.recipe.parts.GroupedTestableItems
|
||||
import com.willfp.eco.core.recipe.parts.MaterialTestableItem
|
||||
import com.willfp.eco.core.recipe.parts.ModifiedTestableItem
|
||||
import com.willfp.eco.core.recipe.parts.TestableStack
|
||||
@@ -9,6 +11,7 @@ import com.willfp.eco.core.recipe.recipes.ShapedCraftingRecipe
|
||||
import com.willfp.eco.internal.spigot.recipes.GenericCraftEvent
|
||||
import com.willfp.eco.internal.spigot.recipes.RecipeListener
|
||||
import com.willfp.eco.internal.spigot.recipes.ShapedRecipeListener
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
class ComplexInEco : RecipeListener {
|
||||
override fun handle(event: GenericCraftEvent) {
|
||||
@@ -25,27 +28,40 @@ class ComplexInEco : RecipeListener {
|
||||
for (i in 0..8) {
|
||||
val itemStack = event.inventory.matrix[i]
|
||||
val part = craftingRecipe.parts[i]
|
||||
when (part) {
|
||||
is MaterialTestableItem -> {
|
||||
if (Items.isCustomItem(itemStack)) {
|
||||
event.deny()
|
||||
}
|
||||
}
|
||||
is ModifiedTestableItem -> {
|
||||
if (part.handle is MaterialTestableItem) {
|
||||
if (Items.isCustomItem(itemStack)) {
|
||||
event.deny()
|
||||
}
|
||||
}
|
||||
}
|
||||
is TestableStack -> {
|
||||
if (part.handle is MaterialTestableItem) {
|
||||
if (Items.isCustomItem(itemStack)) {
|
||||
event.deny()
|
||||
}
|
||||
}
|
||||
}
|
||||
if (part.isCustomWhenShouldNotBe(itemStack)) {
|
||||
event.deny()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun TestableItem.isCustomWhenShouldNotBe(itemStack: ItemStack): Boolean {
|
||||
when (this) {
|
||||
is MaterialTestableItem -> {
|
||||
if (Items.isCustomItem(itemStack)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
is ModifiedTestableItem -> {
|
||||
if (this.handle is MaterialTestableItem) {
|
||||
if (Items.isCustomItem(itemStack)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
is TestableStack -> {
|
||||
if (this.handle is MaterialTestableItem) {
|
||||
if (Items.isCustomItem(itemStack)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
is GroupedTestableItems -> {
|
||||
if (this.children.any { it.isCustomWhenShouldNotBe(itemStack) }) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user