mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-17 19:15:13 +00:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a845e6c3e5 | ||
|
|
4f3a0826fe | ||
|
|
6cd7697ca0 | ||
|
|
38dc14eca1 | ||
|
|
1fc824410b | ||
|
|
af6dba1269 | ||
|
|
2bf5a1cf9f |
No files matched your search
@@ -102,6 +102,7 @@ public class NEIModContainer extends DummyModContainer {
|
||||
gregTech5Loaded = Loader.isModLoaded("gregtech") && !Loader.isModLoaded("gregapi_post");
|
||||
gtnhLibLoaded = Loader.isModLoaded("gtnhlib");
|
||||
cubicChunksLoaded = Loader.isModLoaded("cubicchunks");
|
||||
ServerHandler.preInit();
|
||||
if (CommonUtils.isClient()) ClientHandler.preInit();
|
||||
asmDataTable = event.getAsmData();
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.minecraftforge.event.world.WorldEvent;
|
||||
|
||||
import codechicken.core.CommonUtils;
|
||||
import codechicken.lib.packet.PacketCustom;
|
||||
import codechicken.nei.item.ItemFluidDisplay;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerChangedDimensionEvent;
|
||||
@@ -18,6 +19,7 @@ import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerRespawnEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class ServerHandler {
|
||||
|
||||
@@ -31,6 +33,14 @@ public class ServerHandler {
|
||||
NEIActions.init();
|
||||
}
|
||||
|
||||
public static void preInit() {
|
||||
registerFluidDisplayItem();
|
||||
}
|
||||
|
||||
private static void registerFluidDisplayItem() {
|
||||
GameRegistry.registerItem(new ItemFluidDisplay(), "neiFluidDisplay");
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void tickEvent(TickEvent.WorldTickEvent event) {
|
||||
if (event.phase == Phase.START && !event.world.isRemote
|
||||
|
||||
@@ -146,14 +146,14 @@ public class API {
|
||||
* Hide an item from the item panel Damage values of OreDictionary.WILDCARD_VALUE and ItemStackMap.WILDCARD_TAG tags
|
||||
* function as wildcards for their respective variables
|
||||
*/
|
||||
public static void hideItem(ItemStack item) {
|
||||
public static synchronized void hideItem(ItemStack item) {
|
||||
if (!ItemInfo.hiddenItems.contains(item)) {
|
||||
ItemInfo.hiddenItems.add(item);
|
||||
LayoutManager.markItemsDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public static void hideItem(String rule) {
|
||||
public static synchronized void hideItem(String rule) {
|
||||
ItemFilter filter = ItemStackFilterParser.parse(rule);
|
||||
if (filter != null) {
|
||||
ItemInfo.hiddenItemsRules.filters.add(filter);
|
||||
|
||||
@@ -36,6 +36,7 @@ import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.RegistryNamespaced;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
import net.minecraftforge.common.IShearable;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
@@ -60,6 +61,7 @@ import codechicken.nei.config.HandlerDumper;
|
||||
import codechicken.nei.config.ItemPanelDumper;
|
||||
import codechicken.nei.config.RegistryDumper;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.item.FluidDisplayRenderer;
|
||||
import codechicken.nei.item.ItemFluidDisplay;
|
||||
import codechicken.nei.recipe.BrewingRecipeHandler;
|
||||
import codechicken.nei.recipe.RecipeItemInputHandler;
|
||||
@@ -134,7 +136,7 @@ public class ItemInfo {
|
||||
|
||||
public static void preInit() {
|
||||
addMobSpawnerItem();
|
||||
addFluidDisplayItem();
|
||||
setupFluidDisplayItemClient();
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
@@ -320,8 +322,9 @@ public class ItemInfo {
|
||||
GameDataManipulator.replaceItem(Block.getIdFromBlock(Blocks.mob_spawner), new ItemMobSpawner());
|
||||
}
|
||||
|
||||
private static void addFluidDisplayItem() {
|
||||
GameRegistry.registerItem(new ItemFluidDisplay(), "neiFluidDisplay");
|
||||
private static void setupFluidDisplayItemClient() {
|
||||
ItemFluidDisplay.INSTANCE.setCreativeTab(ItemFluidDisplay.tabFluids);
|
||||
MinecraftForgeClient.registerItemRenderer(ItemFluidDisplay.INSTANCE, new FluidDisplayRenderer());
|
||||
}
|
||||
|
||||
private static void addInfiniteHandlers() {
|
||||
|
||||
@@ -42,7 +42,7 @@ public class BookmarkItem {
|
||||
|
||||
this.groupId = groupId;
|
||||
this.stack = stack;
|
||||
this.factor = StackInfo.isFluidDisplayItem(stack) ? Math.min(144, nbTag.getInteger("Count")) : 1;
|
||||
this.factor = StackInfo.isFluidDisplayItem(stack) ? Math.max(nbTag.getInteger("Count"), 1) : 1;
|
||||
}
|
||||
|
||||
public Builder factor(long factor) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.item.ItemStack;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.api.IRecipeFilter;
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
|
||||
public class RecipeFilter implements IRecipeFilter {
|
||||
@@ -78,7 +79,7 @@ public class RecipeFilter implements IRecipeFilter {
|
||||
if (pStack == null) return false;
|
||||
|
||||
for (ItemStack stack : pStack.items) {
|
||||
if (this.filter.matches(stack)) {
|
||||
if (!ItemInfo.isHidden(stack) && this.filter.matches(stack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,20 @@ package codechicken.nei.item;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.nei.util.ReadableNumberConverter;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class FluidDisplayRenderer implements IItemRenderer {
|
||||
|
||||
@Override
|
||||
@@ -49,7 +52,8 @@ public class FluidDisplayRenderer implements IItemRenderer {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
|
||||
GL11.glColor4f(red, green, blue, 1F);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
OpenGlHelper
|
||||
.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
final Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
@@ -64,17 +68,17 @@ public class FluidDisplayRenderer implements IItemRenderer {
|
||||
}
|
||||
|
||||
private void renderAmountOverlay(ItemStack item, ItemFluidDisplay fluidDisplay) {
|
||||
final FluidStack fluidStack = fluidDisplay.getFluid(item);
|
||||
if (fluidStack == null || fluidStack.amount <= 0) {
|
||||
final long amount = fluidDisplay.getAmountLong(item);
|
||||
if (amount <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
String amountString = "";
|
||||
|
||||
if (fluidStack.amount < 10_000) {
|
||||
amountString = String.valueOf(fluidStack.amount) + "L";
|
||||
if (amount < 10_000) {
|
||||
amountString = String.valueOf(amount) + "L";
|
||||
} else {
|
||||
amountString = ReadableNumberConverter.INSTANCE.toWideReadableForm(fluidStack.amount) + "L";
|
||||
amountString = ReadableNumberConverter.INSTANCE.toWideReadableForm(amount) + "L";
|
||||
}
|
||||
|
||||
final FontRenderer fontRender = Minecraft.getMinecraft().fontRenderer;
|
||||
|
||||
@@ -10,7 +10,6 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -40,36 +39,32 @@ public class ItemFluidDisplay extends Item implements IFluidContainerItem {
|
||||
};
|
||||
|
||||
public ItemFluidDisplay() {
|
||||
setMaxStackSize(1);
|
||||
setUnlocalizedName("nei.fluidDisplay");
|
||||
setMaxStackSize(1);
|
||||
INSTANCE = this;
|
||||
|
||||
setCreativeTab(tabFluids);
|
||||
MinecraftForgeClient.registerItemRenderer(this, new FluidDisplayRenderer());
|
||||
}
|
||||
|
||||
public static ItemStack createStack(FluidStack fluidStack) {
|
||||
if (fluidStack == null || fluidStack.getFluid() == null) {
|
||||
return fluidStack == null ? null : createStack(fluidStack.getFluid(), fluidStack.amount);
|
||||
}
|
||||
|
||||
public static ItemStack createStack(Fluid fluid, long amount) {
|
||||
if (fluid == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int fluidId;
|
||||
|
||||
try {
|
||||
fluidId = FluidRegistry.getFluidID(fluidStack.getFluid());
|
||||
fluidId = FluidRegistry.getFluidID(fluid);
|
||||
} catch (Exception e) {
|
||||
NEIClientConfig.logger.error("Failed to get fluid id for: " + fluidStack.getFluid().getName(), e);
|
||||
NEIClientConfig.logger.error("Failed to get fluid id for: " + fluid.getName(), e);
|
||||
return null;
|
||||
}
|
||||
|
||||
final ItemStack stack = new ItemStack(INSTANCE, 1, fluidId);
|
||||
final NBTTagCompound nbtTag = new NBTTagCompound();
|
||||
|
||||
if (fluidStack.tag != null) {
|
||||
nbtTag.setTag("FluidTag", fluidStack.tag.copy());
|
||||
}
|
||||
|
||||
nbtTag.setInteger("neiFluidDisplayAmount", fluidStack.amount);
|
||||
nbtTag.setLong("neiFluidDisplayAmount", amount);
|
||||
stack.setTagCompound(nbtTag);
|
||||
return stack;
|
||||
}
|
||||
@@ -88,23 +83,25 @@ public class ItemFluidDisplay extends Item implements IFluidContainerItem {
|
||||
}
|
||||
|
||||
final NBTTagCompound nbTag = stack.getTagCompound();
|
||||
final FluidStack fluidStack = new FluidStack(fluid, nbTag.getInteger("neiFluidDisplayAmount"));
|
||||
|
||||
if (nbTag.hasKey("FluidTag")) {
|
||||
fluidStack.tag = nbTag.getCompoundTag("FluidTag");
|
||||
}
|
||||
final FluidStack fluidStack = new FluidStack(
|
||||
fluid,
|
||||
(int) Math.min(nbTag.getLong("neiFluidDisplayAmount"), Integer.MAX_VALUE));
|
||||
|
||||
return fluidStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity(ItemStack stack) {
|
||||
public long getAmountLong(ItemStack stack) {
|
||||
|
||||
if (stack == null || !(stack.getItem() instanceof ItemFluidDisplay) || !stack.hasTagCompound()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return stack.getTagCompound().getInteger("neiFluidDisplayAmount");
|
||||
return stack.getTagCompound().getLong("neiFluidDisplayAmount");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity(ItemStack stack) {
|
||||
return (int) Math.min(getAmountLong(stack), Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -180,7 +177,7 @@ public class ItemFluidDisplay extends Item implements IFluidContainerItem {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item aItem, CreativeTabs aTab, List<ItemStack> aList) {
|
||||
for (int i = 0, j = FluidRegistry.getMaxID(); i < j; i++) {
|
||||
for (int i = 0, j = FluidRegistry.getMaxID(); i <= j; i++) {
|
||||
final Fluid fluid = FluidRegistry.getFluid(i);
|
||||
if (fluid == null) {
|
||||
continue;
|
||||
|
||||
@@ -2,13 +2,17 @@ package codechicken.nei.recipe;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.client.gui.GuiRepair;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import codechicken.nei.ItemList;
|
||||
@@ -35,14 +39,17 @@ public class RepairRecipeHandler extends TemplateRecipeHandler {
|
||||
private static class ItemStackKey {
|
||||
|
||||
private final ItemStack stack;
|
||||
private final int hashCode;
|
||||
|
||||
public ItemStackKey(ItemStack stack) {
|
||||
this.stack = stack;
|
||||
this.hashCode = stack.isItemStackDamageable() ? stack.getItem().hashCode()
|
||||
: 31 * stack.getItem().hashCode() + stack.getItemDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return stack.getItem().hashCode();
|
||||
return this.hashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -104,22 +111,48 @@ public class RepairRecipeHandler extends TemplateRecipeHandler {
|
||||
reloadRepairRecipesTask.restart();
|
||||
}
|
||||
|
||||
private void buildCache() {
|
||||
final Map<ItemStackKey, RepairPair> recipes = new HashMap<>();
|
||||
private static final Set<Integer> knownBrokenItemTypes = ConcurrentHashMap.newKeySet();
|
||||
private static volatile List<ItemStack> uniqueMaterials;
|
||||
|
||||
for (ItemStack itemstack1 : ItemList.items) {
|
||||
recipes.computeIfAbsent(new ItemStackKey(itemstack1), key -> this.getRepairRecipe(key.stack));
|
||||
private void buildCache() {
|
||||
if (cachedRecipes != null) return;
|
||||
|
||||
uniqueMaterials = collectUniqueMaterials();
|
||||
|
||||
final Map<ItemStackKey, RepairPair> recipes = new ConcurrentHashMap<>();
|
||||
|
||||
try {
|
||||
ItemList.forkJoinPool.submit(
|
||||
() -> ItemList.items.parallelStream().forEach(
|
||||
itemstack1 -> recipes
|
||||
.computeIfAbsent(new ItemStackKey(itemstack1), key -> getRepairRecipe(key.stack))))
|
||||
.get();
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
NEIClientConfig.logger.error("Failed to build repair recipe cache", e);
|
||||
}
|
||||
|
||||
cachedRecipes = recipes.values().stream().filter(recipe -> recipe != null).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static List<ItemStack> collectUniqueMaterials() {
|
||||
final Map<Long, ItemStack> unique = new LinkedHashMap<>();
|
||||
for (ItemStack stack : ItemList.items) {
|
||||
final long key = ((long) Item.getIdFromItem(stack.getItem()) << 32) | (stack.getItemDamage() & 0xFFFFFFFFL);
|
||||
unique.putIfAbsent(key, stack);
|
||||
}
|
||||
return new ArrayList<>(unique.values());
|
||||
}
|
||||
|
||||
private RepairPair getRepairRecipe(ItemStack itemstack1) {
|
||||
if (!itemstack1.isItemStackDamageable()) return null;
|
||||
|
||||
final List<ItemStack> permutations = new ArrayList<>();
|
||||
final int itemId = Item.getIdFromItem(itemstack1.getItem());
|
||||
if (knownBrokenItemTypes.contains(itemId)) return null;
|
||||
|
||||
for (ItemStack itemstack2 : ItemList.items) {
|
||||
final List<ItemStack> permutations = new ArrayList<>();
|
||||
final List<ItemStack> candidates = uniqueMaterials != null ? uniqueMaterials : collectUniqueMaterials();
|
||||
|
||||
for (ItemStack itemstack2 : candidates) {
|
||||
try {
|
||||
if (itemstack1.getItem().getIsRepairable(itemstack1, itemstack2)) {
|
||||
final ItemStack right = itemstack2.copy();
|
||||
@@ -127,7 +160,8 @@ public class RepairRecipeHandler extends TemplateRecipeHandler {
|
||||
permutations.add(right);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Catch exceptions from mods that don't properly implement getIsRepairable
|
||||
knownBrokenItemTypes.add(itemId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,20 +74,18 @@ class SearchRecipeHandler<H extends IRecipeHandler> {
|
||||
}
|
||||
|
||||
List<Integer> filtered = null;
|
||||
final List<Integer> recipes = IntStream.range(0, filteredRecipes.size()).boxed()
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
final List<Integer> recipes = IntStream.range(0, filteredRecipes.size()).boxed().collect(Collectors.toList());
|
||||
|
||||
try {
|
||||
filtered = ItemList.forkJoinPool.submit(
|
||||
() -> recipes.parallelStream()
|
||||
.filter(recipe -> mathRecipe(this.original, filteredRecipes.get(recipe), filter))
|
||||
.collect(Collectors.toCollection(ArrayList::new)))
|
||||
.collect(Collectors.toList()))
|
||||
.get();
|
||||
|
||||
filtered.sort((a, b) -> a - b);
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
return filtered;
|
||||
|
||||
@@ -59,7 +59,7 @@ public class StackInfo {
|
||||
|
||||
if (nbtTag != null) {
|
||||
nbtTag = (NBTTagCompound) nbtTag.copy();
|
||||
nbtTag.setInteger("Count", (int) Math.max(Math.min(customCount, Integer.MAX_VALUE), 0));
|
||||
nbtTag.setLong("Count", Math.max(customCount, 0));
|
||||
return loadFromNBT(nbtTag);
|
||||
}
|
||||
|
||||
@@ -126,7 +126,15 @@ public class StackInfo {
|
||||
}
|
||||
|
||||
public static boolean equalItemAndNBT(ItemStack stackA, ItemStack stackB, boolean useNBT) {
|
||||
if (stackA == null || stackB == null || stackA.getItem() != stackB.getItem()) {
|
||||
if (stackA == null || stackB == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isFluidDisplayItem(stackA)) {
|
||||
return isFluidDisplayItem(stackB) && getFluid(stackA).isFluidEqual(getFluid(stackB));
|
||||
}
|
||||
|
||||
if (stackA.getItem() != stackB.getItem()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -142,6 +150,10 @@ public class StackInfo {
|
||||
}
|
||||
|
||||
public static synchronized FluidStack getFluid(ItemStack stack) {
|
||||
if (stack == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStackKey key = new ItemStackKey(stack);
|
||||
FluidStack fluid = fluidcache.get(key);
|
||||
|
||||
@@ -158,7 +170,8 @@ public class StackInfo {
|
||||
}
|
||||
|
||||
public static boolean isFluidContainer(ItemStack stack) {
|
||||
return stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack);
|
||||
return stack.getItem() instanceof IFluidContainerItem && !isFluidDisplayItem(stack)
|
||||
|| FluidContainerRegistry.isContainer(stack);
|
||||
}
|
||||
|
||||
public static String getItemStackGUID(ItemStack stack) {
|
||||
|
||||
@@ -45,7 +45,7 @@ public class DefaultStackStringifyHandler implements IStackStringifyHandler {
|
||||
final ItemStack stack = ItemStack.loadItemStackFromNBT(nbtTag);
|
||||
|
||||
if (stack != null) {
|
||||
stack.stackSize = nbtTag.getInteger("Count");
|
||||
stack.stackSize = (int) Math.min(nbtTag.getLong("Count"), Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
return stack;
|
||||
|
||||
+3
-12
@@ -31,13 +31,10 @@ public class FluidDisplayStackStringifyHandler implements IStackStringifyHandler
|
||||
return null;
|
||||
}
|
||||
|
||||
final long amount = ((ItemFluidDisplay) stack.getItem()).getAmountLong(stack);
|
||||
final NBTTagCompound nbTag = new NBTTagCompound();
|
||||
nbTag.setString(NBT_FLUID_NAME, fluidStack.getFluid().getName());
|
||||
nbTag.setInteger("Count", saveStackSize ? fluidStack.amount : 1);
|
||||
|
||||
if (fluidStack.tag != null) {
|
||||
nbTag.setTag("FluidTag", fluidStack.tag.copy());
|
||||
}
|
||||
nbTag.setLong("Count", saveStackSize ? amount : 1);
|
||||
|
||||
return nbTag;
|
||||
}
|
||||
@@ -55,13 +52,7 @@ public class FluidDisplayStackStringifyHandler implements IStackStringifyHandler
|
||||
return null;
|
||||
}
|
||||
|
||||
final FluidStack fluidStack = new FluidStack(fluid, nbtTag.getInteger("Count"));
|
||||
|
||||
if (nbtTag.hasKey("FluidTag")) {
|
||||
fluidStack.tag = nbtTag.getCompoundTag("FluidTag");
|
||||
}
|
||||
|
||||
return ItemFluidDisplay.createStack(fluidStack);
|
||||
return ItemFluidDisplay.createStack(fluid, nbtTag.getLong("Count"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -67,10 +67,9 @@ public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
|
||||
if (nbtTag.hasKey("gtFluidName")) {
|
||||
final String fluidName = nbtTag.getString("gtFluidName");
|
||||
final Fluid fluid = FluidRegistry.getFluid(fluidName);
|
||||
final int amount = nbtTag.getInteger("Count");
|
||||
|
||||
if (fluid != null) {
|
||||
return ItemFluidDisplay.createStack(new FluidStack(fluid, amount));
|
||||
return ItemFluidDisplay.createStack(fluid, nbtTag.getLong("Count"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,11 +97,7 @@ public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
|
||||
Fluid fluid = FluidRegistry.getFluid(nbtTag.getString("Fluid").toLowerCase());
|
||||
|
||||
if (fluid != null) {
|
||||
FluidStack fluidStack = new FluidStack(fluid, stack.stackSize);
|
||||
if (nbtTag.hasKey("FluidTag")) {
|
||||
fluidStack.tag = nbtTag.getCompoundTag("FluidTag");
|
||||
}
|
||||
return fluidStack;
|
||||
return new FluidStack(fluid, stack.stackSize);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
|
||||
@@ -4,8 +4,11 @@ import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
|
||||
public class IdentifierFilter implements ItemFilter {
|
||||
@@ -18,15 +21,33 @@ public class IdentifierFilter implements ItemFilter {
|
||||
|
||||
@Override
|
||||
public boolean matches(ItemStack stack) {
|
||||
final FluidStack fluidStack = StackInfo.isFluidDisplayItem(stack) ? StackInfo.getFluid(stack) : null;
|
||||
|
||||
if (fluidStack != null) {
|
||||
return this.pattern.matcher(getFluidStringIdentifier(fluidStack) + "\n" + getFluidIdentifier(fluidStack))
|
||||
.find();
|
||||
}
|
||||
|
||||
return this.pattern.matcher(getStringIdentifier(stack) + "\n" + getIdentifier(stack)).find();
|
||||
}
|
||||
|
||||
protected String getFluidIdentifier(FluidStack fluidStack) {
|
||||
return String.valueOf(FluidRegistry.getFluidID(fluidStack.getFluid()));
|
||||
}
|
||||
|
||||
protected String getFluidStringIdentifier(FluidStack fluidStack) {
|
||||
final String name = FluidRegistry.getDefaultFluidName(fluidStack.getFluid());
|
||||
|
||||
return name == null || name.isEmpty() ? "Unknown:Unknown" : name;
|
||||
}
|
||||
|
||||
protected String getIdentifier(ItemStack stack) {
|
||||
return Item.getIdFromItem(stack.getItem()) + ":" + stack.getItemDamage();
|
||||
}
|
||||
|
||||
protected String getStringIdentifier(ItemStack stack) {
|
||||
String name = GameData.getItemRegistry().getNameForObject(stack.getItem());
|
||||
final String name = GameData.getItemRegistry().getNameForObject(stack.getItem());
|
||||
|
||||
return name == null || name.isEmpty() ? "Unknown:Unknown" : name;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,11 +7,12 @@ import java.util.regex.Pattern;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.item.ItemFluidDisplay;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
@@ -41,9 +42,10 @@ public class ModNameFilter implements ItemFilter {
|
||||
}
|
||||
|
||||
protected static String getModId(ItemStack itemStack) {
|
||||
final FluidStack fluidStack = StackInfo.isFluidDisplayItem(itemStack) ? StackInfo.getFluid(itemStack) : null;
|
||||
|
||||
if (itemStack.getItem() instanceof ItemFluidDisplay fluidDisplay) {
|
||||
return getFluidModId(fluidDisplay, itemStack);
|
||||
if (fluidStack != null) {
|
||||
return getFluidModId(fluidStack.getFluid());
|
||||
}
|
||||
|
||||
if (!ItemInfo.itemOwners.containsKey(itemStack.getItem())) {
|
||||
@@ -59,8 +61,7 @@ public class ModNameFilter implements ItemFilter {
|
||||
return ItemInfo.itemOwners.get(itemStack.getItem());
|
||||
}
|
||||
|
||||
private static String getFluidModId(ItemFluidDisplay fluidDisplay, ItemStack itemStack) {
|
||||
final Fluid fluid = FluidRegistry.getFluid(itemStack.getItemDamage());
|
||||
private static String getFluidModId(Fluid fluid) {
|
||||
final String fluidName = FluidRegistry.getDefaultFluidName(fluid);
|
||||
|
||||
if (!fluidOwners.containsKey(fluidName)) {
|
||||
|
||||
Reference in new issue
Block a user