feature: top ten synchronized java functuons

Signed-off-by: Pauline <git@ethanlibs.co>
This commit is contained in:
Pauline
2025-02-27 16:04:19 +01:00
committed by Linnea Gräf
parent d3930d3da3
commit af2a6d7a55
3 changed files with 42 additions and 5 deletions

View File

@@ -1,22 +1,29 @@
package moe.nea.firmament.compat.jade package moe.nea.firmament.compat.jade
import com.google.common.collect.Lists
import snownee.jade.addon.harvest.ToolHandler import snownee.jade.addon.harvest.ToolHandler
import net.minecraft.block.BlockState import net.minecraft.block.BlockState
import net.minecraft.item.Item
import net.minecraft.item.ItemStack import net.minecraft.item.ItemStack
import net.minecraft.util.Identifier import net.minecraft.util.Identifier
import net.minecraft.util.math.BlockPos import net.minecraft.util.math.BlockPos
import net.minecraft.world.World import net.minecraft.world.World
class DrillToolHandler : ToolHandler { class SimpleToolHandler(
private val uid: Identifier,
private val tools: MutableList<ItemStack>
) : ToolHandler {
constructor(uid: Identifier, tools: MutableList<Item>) : this(uid, Lists.transform(tools, Item::getDefaultStack))
override fun test(state: BlockState, world: World, pos: BlockPos): ItemStack { override fun test(state: BlockState, world: World, pos: BlockPos): ItemStack {
TODO("We need to override the existing tool handler tests because they use state.getHardness(world, pos) instead of using Breaking Power") TODO("We need to override the existing tool handler tests because they use state.getHardness(world, pos) instead of using Breaking Power")
} }
override fun getTools(): List<ItemStack> { override fun getTools(): List<ItemStack> {
TODO("Not yet implemented") return this.tools
} }
override fun getUid(): Identifier { override fun getUid(): Identifier {
TODO("Not yet implemented") return this.uid
} }
} }

View File

@@ -1,12 +1,38 @@
package moe.nea.firmament.compat.jade package moe.nea.firmament.compat.jade
import com.google.common.cache.Cache
import com.google.common.cache.CacheBuilder
import com.google.common.collect.ImmutableList
import com.google.common.collect.Maps
import java.util.concurrent.TimeUnit
import snownee.jade.addon.harvest.ToolHandler
import snownee.jade.api.BlockAccessor import snownee.jade.api.BlockAccessor
import snownee.jade.api.IBlockComponentProvider import snownee.jade.api.IBlockComponentProvider
import snownee.jade.api.ITooltip import snownee.jade.api.ITooltip
import snownee.jade.api.config.IPluginConfig import snownee.jade.api.config.IPluginConfig
import net.minecraft.block.Block
import net.minecraft.block.BlockState
import net.minecraft.item.ItemStack
import net.minecraft.resource.ResourceManager
import net.minecraft.resource.SynchronousResourceReloader
import net.minecraft.text.Text
import net.minecraft.util.Identifier import net.minecraft.util.Identifier
import net.minecraft.util.math.Vec2f
class DrillToolProvider : IBlockComponentProvider, SynchronousResourceReloader {
val resultCache: Cache<BlockState, ImmutableList<ItemStack>> = CacheBuilder.newBuilder().expireAfterAccess(5, TimeUnit.MINUTES).build()
val toolHandlers: MutableMap<Identifier, ToolHandler> = Maps.newLinkedHashMap()
private val shearableBlocks: MutableList<Block> = mutableListOf()
private val checkIcon: Text = Text.literal("")
private val xIcon: Text = Text.literal("")
private val itemSize = Vec2f(10f, 0f)
@Synchronized
fun registerHandler(handler: ToolHandler) {
toolHandlers.put(handler.uid, handler)
}
class DrillToolProvider : IBlockComponentProvider {
override fun appendTooltip(tooltip: ITooltip, accessor: BlockAccessor, config: IPluginConfig) { override fun appendTooltip(tooltip: ITooltip, accessor: BlockAccessor, config: IPluginConfig) {
TODO("Not yet implemented") TODO("Not yet implemented")
} }
@@ -14,4 +40,8 @@ class DrillToolProvider : IBlockComponentProvider {
override fun getUid(): Identifier { override fun getUid(): Identifier {
TODO("Not yet implemented") TODO("Not yet implemented")
} }
override fun reload(manager: ResourceManager) {
TODO("Not yet implemented")
}
} }

View File

@@ -28,7 +28,7 @@ class SkyblockProgressProvider : IClientExtensionProvider<ProgressView.Data, Pro
}) })
} }
override fun getUid(): Identifier? { override fun getUid(): Identifier {
return "progress".jadeId() return "progress".jadeId()
} }
} }