Skip to content

Commit

Permalink
Show detailed fluid amount tooltip for Fluid Drop and Packet item (#127)
Browse files Browse the repository at this point in the history
* Show detailed fluid amount tooltip for Fluid Drop and Packet item

* Guard against division by zero
  • Loading branch information
miozune authored May 8, 2023
1 parent 56cda9f commit f01cde7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.glodblock.github.nei;

import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.FluidStack;

import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidPacket;

import codechicken.nei.api.IStackStringifyHandler;

public class FCStackStringifyHandler implements IStackStringifyHandler {

@Override
public NBTTagCompound convertItemStackToNBT(ItemStack stack, boolean saveStackSize) {
return null;
}

@Override
public ItemStack convertNBTToItemStack(NBTTagCompound nbtTag) {
return null;
}

@Override
public FluidStack getFluid(ItemStack item) {
if (item.getItem() instanceof ItemFluidDrop) {
FluidStack fluid = ItemFluidDrop.getFluidStack(item);
fluid.amount /= Math.max(item.stackSize, 1);
return fluid;
} else if (item.getItem() instanceof ItemFluidPacket) {
return ItemFluidPacket.getFluidStack(item);
}
return null;
}
}
2 changes: 2 additions & 0 deletions src/main/java/com/glodblock/github/nei/NEI_FC_Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
import codechicken.nei.api.API;
import codechicken.nei.api.IConfigureNEI;

@SuppressWarnings("unused")
public class NEI_FC_Config implements IConfigureNEI {

@Override
public void loadConfig() {
API.registerNEIGuiHandler(new NEIGuiHandler());
API.addSearchProvider(new NEIItemFilter());
API.registerStackStringifyHandler(new FCStackStringifyHandler());

if (ModAndClassUtil.AVARITIA) {
API.registerGuiOverlay(GuiFluidPatternWireless.class, "extreme", null);
Expand Down

0 comments on commit f01cde7

Please sign in to comment.