fix: Weird tools for BP 7; feat: Options for jade; fix: tools for glass blocks in jade
This commit is contained in:
@@ -15,8 +15,9 @@ class CustomFakeBlockProvider(val registration: IWailaClientRegistration) : Jade
|
||||
accessor: Accessor<*>?,
|
||||
originalAccessor: Accessor<*>?
|
||||
): Accessor<*>? {
|
||||
if (!JadeIntegration.TConfig.blockDetection) return accessor
|
||||
if (accessor !is BlockAccessor) return accessor
|
||||
val customBlock = CurrentCustomBlockHolder.customBlocks[accessor.block]
|
||||
val customBlock = JadeIntegration.customBlocks[accessor.block]
|
||||
if (customBlock == null) return accessor
|
||||
return registration.blockAccessor()
|
||||
.from(accessor)
|
||||
@@ -25,6 +26,12 @@ class CustomFakeBlockProvider(val registration: IWailaClientRegistration) : Jade
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun hasCustomBlock(accessor: BlockAccessor): Boolean {
|
||||
return getCustomBlock(accessor) != null
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getCustomBlock(accessor: BlockAccessor): MiningRepoData.CustomMiningBlock? {
|
||||
if (!accessor.isFakeBlock) return null
|
||||
val item = accessor.fakeBlock
|
||||
|
||||
@@ -66,6 +66,7 @@ object CustomMiningHardnessProvider : IBlockComponentProvider {
|
||||
|
||||
@JvmStatic
|
||||
fun replaceBreakProgress(original: Float): Float {
|
||||
if (!JadeIntegration.TConfig.miningProgress) return original
|
||||
if (!isOnMiningIsland()) return original
|
||||
val pos = MC.interactionManager?.currentBreakingPos ?: return original
|
||||
val info = currentBreakingInfo
|
||||
|
||||
@@ -31,9 +31,8 @@ class DrillToolProvider : IBlockComponentProvider {
|
||||
p2: IPluginConfig?
|
||||
) {
|
||||
val customBlock = CustomFakeBlockProvider.getCustomBlock(accessor) ?: return
|
||||
if (customBlock.breakingPower <= 0) return
|
||||
val tool = RepoManager.miningData.getToolsThatCanBreak(customBlock.breakingPower).firstOrNull()
|
||||
?.asItemStack() ?: return
|
||||
?.asImmutableItemStack() ?: return
|
||||
tooltip.replace(JadeIds.MC_HARVEST_TOOL, UnaryOperator { elements ->
|
||||
elements.map { inner ->
|
||||
val lastItemIndex = inner.indexOfLast { it is ItemStackElement }
|
||||
|
||||
@@ -6,8 +6,15 @@ import moe.nea.firmament.repo.MiningRepoData
|
||||
import moe.nea.firmament.repo.RepoManager
|
||||
import moe.nea.firmament.util.ErrorUtil
|
||||
import net.minecraft.block.Block
|
||||
import moe.nea.firmament.events.ReloadRegistrationEvent
|
||||
import moe.nea.firmament.gui.config.ManagedConfig
|
||||
|
||||
object JadeIntegration {
|
||||
object TConfig : ManagedConfig("jade-integration", Category.INTEGRATIONS) {
|
||||
val miningProgress by toggle("progress") { true }
|
||||
val blockDetection by toggle("blocks") { true }
|
||||
}
|
||||
|
||||
object CurrentCustomBlockHolder {
|
||||
var customBlocks: Map<Block, MiningRepoData.CustomMiningBlock> = mapOf()
|
||||
|
||||
fun refreshBlockInfo() {
|
||||
@@ -31,6 +38,11 @@ object CurrentCustomBlockHolder {
|
||||
}.toMap()
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
fun onRepoReload(event: ReloadRegistrationEvent) {
|
||||
event.repo.registerReloadListener { refreshBlockInfo() }
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
fun onWorldSwap(event: SkyblockServerUpdateEvent) {
|
||||
refreshBlockInfo()
|
||||
@@ -0,0 +1,33 @@
|
||||
package moe.nea.firmament.mixins.compat.jade;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import moe.nea.firmament.compat.jade.CustomFakeBlockProvider;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import snownee.jade.addon.harvest.HarvestToolProvider;
|
||||
import snownee.jade.api.BlockAccessor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(HarvestToolProvider.class)
|
||||
public class EnforceToolDisplayForCustomBlocksInHarvestToolProvider {
|
||||
@ModifyExpressionValue(method = "getText", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;isToolRequired()Z"))
|
||||
private boolean overwriteRequiresTool(boolean original, @Local(argsOnly = true) BlockAccessor accessor) {
|
||||
if (CustomFakeBlockProvider.hasCustomBlock(accessor))
|
||||
return true;
|
||||
return original;
|
||||
}
|
||||
|
||||
private static final List<ItemStack> REPLACEABLE_TOOL = List.of(new ItemStack(Blocks.ENCHANTING_TABLE));
|
||||
|
||||
@ModifyExpressionValue(method = "getText", at = @At(value = "INVOKE", target = "Lcom/google/common/cache/Cache;get(Ljava/lang/Object;Ljava/util/concurrent/Callable;)Ljava/lang/Object;"))
|
||||
private Object overwriteAvailableTools(Object original, @Local(argsOnly = true) BlockAccessor accessor) {
|
||||
var orig = (List<ItemStack>) original;
|
||||
if (orig.isEmpty() && CustomFakeBlockProvider.hasCustomBlock(accessor))
|
||||
return REPLACEABLE_TOOL;
|
||||
return orig;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user