diff --git a/common/build.gradle b/common/build.gradle index d61c4b6..53404b3 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -16,6 +16,7 @@ dependencies { transitive = false } implementation 'com.github.Carbon-Config-Project:CarbonConfigLib:1.0.0' + modCompileOnly("curse.maven:the-one-probe-fabric-581847:${project.top_fabric_file}") } architectury { diff --git a/common/src/main/java/io/github/gregtechintergalactical/gtcore/integration/top/MassStorageProvider.java b/common/src/main/java/io/github/gregtechintergalactical/gtcore/integration/top/MassStorageProvider.java new file mode 100644 index 0000000..e5850c3 --- /dev/null +++ b/common/src/main/java/io/github/gregtechintergalactical/gtcore/integration/top/MassStorageProvider.java @@ -0,0 +1,46 @@ +package io.github.gregtechintergalactical.gtcore.integration.top; + +import io.github.gregtechintergalactical.gtcore.GTCore; +import io.github.gregtechintergalactical.gtcore.blockentity.BlockEntityMassStorage; +import io.github.gregtechintergalactical.gtcore.data.SlotTypes; +import mcjty.theoneprobe.api.IProbeHitData; +import mcjty.theoneprobe.api.IProbeInfo; +import mcjty.theoneprobe.api.IProbeInfoProvider; +import mcjty.theoneprobe.api.ProbeMode; +import mcjty.theoneprobe.apiimpl.elements.ElementItemStack; +import mcjty.theoneprobe.apiimpl.elements.ElementVertical; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; + +import java.awt.*; + +public class MassStorageProvider implements IProbeInfoProvider { + @Override + public ResourceLocation getID() { + return new ResourceLocation(GTCore.ID, "mass_Storage"); + } + + @Override + public void addProbeInfo(ProbeMode probeMode, IProbeInfo iProbeInfo, Player player, Level level, BlockState blockState, IProbeHitData iProbeHitData) { + BlockEntity blockEntity = level.getBlockEntity(iProbeHitData.getPos()); + if (blockEntity instanceof BlockEntityMassStorage massStorage){ + var handler = massStorage.itemHandler.map(i -> i.getHandler(SlotTypes.UNLIMITED)).orElse(null); + if (handler != null){ + iProbeInfo.getElements().removeIf(iElement -> iElement instanceof ElementVertical); + ElementVertical vertical = new ElementVertical(); + ElementVertical elementVertical = new ElementVertical(iProbeInfo.defaultLayoutStyle().spacing(2).leftPadding(7).rightPadding(7)); + elementVertical.getStyle().borderColor(Color.CYAN.darker().getRGB()); + ItemStack stack = handler.getItem(0); + if (stack.getCount() > 0){ + elementVertical.element(new ElementItemStack(stack, iProbeInfo.defaultItemStyle())); + } + if (!elementVertical.getElements().isEmpty()) vertical.element(elementVertical); + vertical.element(new ElementVertical(iProbeInfo.defaultLayoutStyle().topPadding(4))); + } + } + } +} diff --git a/gradle.properties b/gradle.properties index 7fca163..37086db 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,6 +17,7 @@ rei_version=8.3.557 terraform_version_forge=3.1.5 terraform_version_fabric=3.1.0 mod_menu_version=3.1.0 +top_fabric_file=3877300 rhino_file=3187177 architectury_file=3208686