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 {
|
dependencies {
|
||||||
minecraft "com.mojang:minecraft:1.15.2"
|
minecraft "com.mojang:minecraft:1.15.2"
|
||||||
mappings "net.fabricmc:yarn:1.15.2+build.2:v2"
|
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
|
//Fabric api
|
||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:0.4.29+build.290-1.15"
|
modImplementation "net.fabricmc.fabric-api:fabric-api:0.4.29+build.290-1.15"
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
package techreborn.events;
|
package techreborn.events;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
import net.fabricmc.fabric.api.event.client.ItemTooltipCallback;
|
import net.fabricmc.fabric.api.event.client.ItemTooltipCallback;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockEntityProvider;
|
import net.minecraft.block.BlockEntityProvider;
|
||||||
|
@ -53,10 +54,12 @@ import techreborn.utils.WIP;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class StackToolTipHandler implements ItemTooltipCallback {
|
public class StackToolTipHandler implements ItemTooltipCallback {
|
||||||
|
|
||||||
private static ArrayList<Block> wipBlocks = new ArrayList<>();
|
private static ArrayList<Block> wipBlocks = new ArrayList<>();
|
||||||
|
public static final Map<Item, Boolean> ITEM_ID = Maps.newHashMap();
|
||||||
|
|
||||||
public static void setup() {
|
public static void setup() {
|
||||||
ItemTooltipCallback.EVENT.register(new StackToolTipHandler());
|
ItemTooltipCallback.EVENT.register(new StackToolTipHandler());
|
||||||
|
@ -69,8 +72,10 @@ public class StackToolTipHandler implements ItemTooltipCallback {
|
||||||
@Override
|
@Override
|
||||||
public void getTooltip(ItemStack stack, TooltipContext tooltipContext, List<Text> components) {
|
public void getTooltip(ItemStack stack, TooltipContext tooltipContext, List<Text> components) {
|
||||||
Item item = stack.getItem();
|
Item item = stack.getItem();
|
||||||
|
|
||||||
|
if (!ITEM_ID.computeIfAbsent(item, this::isTRItem))
|
||||||
|
return;
|
||||||
|
|
||||||
// Machine info and upgrades helper section
|
// Machine info and upgrades helper section
|
||||||
Block block = Block.getBlockFromItem(item);
|
Block block = Block.getBlockFromItem(item);
|
||||||
|
|
||||||
|
@ -130,7 +135,11 @@ 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) {
|
public int percentage(int MaxValue, int CurrentValue) {
|
||||||
if (CurrentValue == 0)
|
if (CurrentValue == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue