Show tooltip only for TR items. Kudos to Shedaniel (#2122)
This commit is contained in:
parent
fdc6f88dbc
commit
ed5478c8b7
2 changed files with 13 additions and 4 deletions
|
@ -74,7 +74,7 @@ group = 'TechReborn'
|
|||
dependencies {
|
||||
minecraft "com.mojang:minecraft:1.15.2"
|
||||
mappings "net.fabricmc:yarn:1.15.2+build.2:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:0.7.5+build.178"
|
||||
modImplementation "net.fabricmc:fabric-loader:0.8.4+build.198"
|
||||
|
||||
//Fabric api
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:0.4.29+build.290-1.15"
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
package techreborn.events;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import net.fabricmc.fabric.api.event.client.ItemTooltipCallback;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockEntityProvider;
|
||||
|
@ -53,10 +54,12 @@ import techreborn.utils.WIP;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class StackToolTipHandler implements ItemTooltipCallback {
|
||||
|
||||
private static ArrayList<Block> wipBlocks = new ArrayList<>();
|
||||
public static final Map<Item, Boolean> ITEM_ID = Maps.newHashMap();
|
||||
|
||||
public static void setup() {
|
||||
ItemTooltipCallback.EVENT.register(new StackToolTipHandler());
|
||||
|
@ -70,6 +73,8 @@ public class StackToolTipHandler implements ItemTooltipCallback {
|
|||
public void getTooltip(ItemStack stack, TooltipContext tooltipContext, List<Text> components) {
|
||||
Item item = stack.getItem();
|
||||
|
||||
if (!ITEM_ID.computeIfAbsent(item, this::isTRItem))
|
||||
return;
|
||||
|
||||
// Machine info and upgrades helper section
|
||||
Block block = Block.getBlockFromItem(item);
|
||||
|
@ -131,6 +136,10 @@ public class StackToolTipHandler implements ItemTooltipCallback {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isTRItem(Item item) {
|
||||
return Registry.ITEM.getId(item).getNamespace().equals("techreborn");
|
||||
}
|
||||
|
||||
public int percentage(int MaxValue, int CurrentValue) {
|
||||
if (CurrentValue == 0)
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue