Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
added mass storage probe info
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinsdar committed Nov 3, 2023
1 parent b2fcbe8 commit 257cb7a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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)));
}
}
}
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 257cb7a

Please sign in to comment.