diff options
author | NotNite <hi@notnite.com> | 2024-02-15 22:09:15 -0500 |
---|---|---|
committer | NotNite <hi@notnite.com> | 2024-02-15 22:09:15 -0500 |
commit | 40c0e869ad1edd5524b409d50d8733003c4d0c31 (patch) | |
tree | 74af1fded8b56fad2a6243af12d2d676732b1002 /src/main/kotlin/com | |
parent | 4cbe83614ad0d035c1d0ce11385335cec63a0ed8 (diff) | |
download | gloppers-40c0e869ad1edd5524b409d50d8733003c4d0c31.tar.gz gloppers-40c0e869ad1edd5524b409d50d8733003c4d0c31.tar.bz2 gloppers-40c0e869ad1edd5524b409d50d8733003c4d0c31.zip |
1.0.2
Diffstat (limited to 'src/main/kotlin/com')
-rw-r--r-- | src/main/kotlin/com/notnite/gloppers/Gloppers.kt | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/src/main/kotlin/com/notnite/gloppers/Gloppers.kt b/src/main/kotlin/com/notnite/gloppers/Gloppers.kt deleted file mode 100644 index 95596c0..0000000 --- a/src/main/kotlin/com/notnite/gloppers/Gloppers.kt +++ /dev/null @@ -1,38 +0,0 @@ -package com.notnite.gloppers - -import net.minecraft.block.entity.HopperBlockEntity -import net.minecraft.inventory.Inventory -import net.minecraft.item.ItemStack - -object Gloppers { - private fun matchesGlob(glob: String, str: String): Boolean { - val regex = glob - .replace(".", "\\.") - .replace("*", ".*") - .replace("?", ".") - return str.matches(regex.toRegex()) - } - - fun canTransfer(to: Inventory, stack: ItemStack): Boolean { - if (to is HopperBlockEntity) { - val hopperName = to.name.copyContentOnly().string - val itemName = stack.registryEntry.key.get().value.path - - if (hopperName.startsWith("!")) { - val globs = hopperName.substring(1).split(",") - for (glob in globs) { - if (matchesGlob(glob, itemName)) { - // Glob matched, transfer - return true - } - } - - // No globs matched, so don't transfer - return false - } - } - - // Doesn't have a glob, so transfer - return true - } -} |