mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-17 11:05:07 +00:00
[ci skip] spotlessApply with the new settings
This commit is contained in:
1 parent
f1dea5460a
commit
f106b5e766
172 files changed
+2552
-2088
No files matched your search
@@ -1,26 +1,5 @@
|
||||
package codechicken.nei.api;
|
||||
|
||||
import codechicken.core.featurehack.GameDataManipulator;
|
||||
import codechicken.nei.InfiniteStackSizeHandler;
|
||||
import codechicken.nei.InfiniteToolHandler;
|
||||
import codechicken.nei.ItemList;
|
||||
import codechicken.nei.ItemMobSpawner;
|
||||
import codechicken.nei.ItemStackMap;
|
||||
import codechicken.nei.ItemStackSet;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.PopupInputHandler;
|
||||
import codechicken.nei.config.ArrayDumper;
|
||||
import codechicken.nei.config.HandlerDumper;
|
||||
import codechicken.nei.config.ItemPanelDumper;
|
||||
import codechicken.nei.config.RegistryDumper;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.recipe.BrewingRecipeHandler;
|
||||
import codechicken.nei.recipe.RecipeItemInputHandler;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -28,6 +7,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
@@ -59,10 +39,35 @@ import net.minecraftforge.common.BiomeDictionary;
|
||||
import net.minecraftforge.common.IShearable;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import codechicken.core.featurehack.GameDataManipulator;
|
||||
import codechicken.nei.InfiniteStackSizeHandler;
|
||||
import codechicken.nei.InfiniteToolHandler;
|
||||
import codechicken.nei.ItemList;
|
||||
import codechicken.nei.ItemMobSpawner;
|
||||
import codechicken.nei.ItemStackMap;
|
||||
import codechicken.nei.ItemStackSet;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.PopupInputHandler;
|
||||
import codechicken.nei.config.ArrayDumper;
|
||||
import codechicken.nei.config.HandlerDumper;
|
||||
import codechicken.nei.config.ItemPanelDumper;
|
||||
import codechicken.nei.config.RegistryDumper;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.recipe.BrewingRecipeHandler;
|
||||
import codechicken.nei.recipe.RecipeItemInputHandler;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
|
||||
|
||||
/**
|
||||
* This is an internal class for storing information about items, to be accessed by the API
|
||||
*/
|
||||
public class ItemInfo {
|
||||
|
||||
public static enum Layout {
|
||||
HEADER,
|
||||
BODY,
|
||||
@@ -83,6 +88,7 @@ public class ItemInfo {
|
||||
public static final HashMap<Item, String> itemOwners = new HashMap<>();
|
||||
|
||||
private static class ItemStackKey {
|
||||
|
||||
public final ItemStack stack;
|
||||
|
||||
public ItemStackKey(ItemStack stack) {
|
||||
@@ -96,8 +102,7 @@ public class ItemInfo {
|
||||
hashCode = 31 * hashCode + stack.stackSize;
|
||||
hashCode = 31 * hashCode + Item.getIdFromItem(stack.getItem());
|
||||
hashCode = 31 * hashCode + stack.getItemDamage();
|
||||
hashCode = 31 * hashCode
|
||||
+ (!stack.hasTagCompound() ? 0 : stack.getTagCompound().hashCode());
|
||||
hashCode = 31 * hashCode + (!stack.hasTagCompound() ? 0 : stack.getTagCompound().hashCode());
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
@@ -129,8 +134,7 @@ public class ItemInfo {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Use field directly
|
||||
* @deprecated Use field directly
|
||||
*/
|
||||
@Deprecated
|
||||
public static List<ItemStack> getItemOverrides(Item item) {
|
||||
@@ -176,22 +180,18 @@ public class ItemInfo {
|
||||
|
||||
private static void addIDDumps() {
|
||||
API.addOption(new RegistryDumper<Item>("tools.dump.item") {
|
||||
|
||||
@Override
|
||||
public String[] header() {
|
||||
return new String[] {"Name", "ID", "Has Block", "Mod", "Class", "Display Name"};
|
||||
return new String[] { "Name", "ID", "Has Block", "Mod", "Class", "Display Name" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] dump(Item item, int id, String name) {
|
||||
return new String[] {
|
||||
name,
|
||||
Integer.toString(id),
|
||||
Boolean.toString(Block.getBlockFromItem(item) != Blocks.air),
|
||||
ItemInfo.itemOwners.get(item),
|
||||
item.getClass().getCanonicalName(),
|
||||
EnumChatFormatting.getTextWithoutFormattingCodes(
|
||||
GuiContainerManager.itemDisplayNameShort(new ItemStack(item)))
|
||||
};
|
||||
return new String[] { name, Integer.toString(id),
|
||||
Boolean.toString(Block.getBlockFromItem(item) != Blocks.air), ItemInfo.itemOwners.get(item),
|
||||
item.getClass().getCanonicalName(), EnumChatFormatting.getTextWithoutFormattingCodes(
|
||||
GuiContainerManager.itemDisplayNameShort(new ItemStack(item))) };
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -200,25 +200,19 @@ public class ItemInfo {
|
||||
}
|
||||
});
|
||||
API.addOption(new RegistryDumper<Block>("tools.dump.block") {
|
||||
|
||||
@Override
|
||||
public String[] header() {
|
||||
return new String[] {"Name", "ID", "Has Item", "Mod", "Class", "Display Name"};
|
||||
return new String[] { "Name", "ID", "Has Item", "Mod", "Class", "Display Name" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] dump(Block block, int id, String name) {
|
||||
final Item item = Item.getItemFromBlock(block);
|
||||
return new String[] {
|
||||
name,
|
||||
Integer.toString(id),
|
||||
Boolean.toString(item != null),
|
||||
ItemInfo.itemOwners.get(block),
|
||||
block.getClass().getCanonicalName(),
|
||||
item != null
|
||||
? EnumChatFormatting.getTextWithoutFormattingCodes(
|
||||
GuiContainerManager.itemDisplayNameShort(new ItemStack(item)))
|
||||
: "null"
|
||||
};
|
||||
return new String[] { name, Integer.toString(id), Boolean.toString(item != null),
|
||||
ItemInfo.itemOwners.get(block), block.getClass().getCanonicalName(),
|
||||
item != null ? EnumChatFormatting.getTextWithoutFormattingCodes(
|
||||
GuiContainerManager.itemDisplayNameShort(new ItemStack(item))) : "null" };
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -227,15 +221,14 @@ public class ItemInfo {
|
||||
}
|
||||
});
|
||||
API.addOption(new ArrayDumper<Potion>("tools.dump.potion") {
|
||||
|
||||
public String[] header() {
|
||||
return new String[] {"ID", "Unlocalised name", "Class"};
|
||||
return new String[] { "ID", "Unlocalised name", "Class" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] dump(Potion potion, int id) {
|
||||
return new String[] {
|
||||
Integer.toString(id), potion.getName(), potion.getClass().getCanonicalName()
|
||||
};
|
||||
return new String[] { Integer.toString(id), potion.getName(), potion.getClass().getCanonicalName() };
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -244,20 +237,16 @@ public class ItemInfo {
|
||||
}
|
||||
});
|
||||
API.addOption(new ArrayDumper<Enchantment>("tools.dump.enchantment") {
|
||||
|
||||
public String[] header() {
|
||||
return new String[] {"ID", "Unlocalised name", "Type", "Min Level", "Max Level", "Class"};
|
||||
return new String[] { "ID", "Unlocalised name", "Type", "Min Level", "Max Level", "Class" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] dump(Enchantment ench, int id) {
|
||||
return new String[] {
|
||||
Integer.toString(id),
|
||||
ench.getName(),
|
||||
ench.type.toString(),
|
||||
Integer.toString(ench.getMinLevel()),
|
||||
Integer.toString(ench.getMaxLevel()),
|
||||
ench.getClass().getCanonicalName()
|
||||
};
|
||||
return new String[] { Integer.toString(id), ench.getName(), ench.type.toString(),
|
||||
Integer.toString(ench.getMinLevel()), Integer.toString(ench.getMaxLevel()),
|
||||
ench.getClass().getCanonicalName() };
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -266,19 +255,11 @@ public class ItemInfo {
|
||||
}
|
||||
});
|
||||
API.addOption(new ArrayDumper<BiomeGenBase>("tools.dump.biome") {
|
||||
|
||||
@Override
|
||||
public String[] header() {
|
||||
return new String[] {
|
||||
"ID",
|
||||
"Name",
|
||||
"Temperature",
|
||||
"Rainfall",
|
||||
"Spawn Chance",
|
||||
"Root Height",
|
||||
"Height Variation",
|
||||
"Types",
|
||||
"Class"
|
||||
};
|
||||
return new String[] { "ID", "Name", "Temperature", "Rainfall", "Spawn Chance", "Root Height",
|
||||
"Height Variation", "Types", "Class" };
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -290,17 +271,11 @@ public class ItemInfo {
|
||||
s_types.append(t.name());
|
||||
}
|
||||
|
||||
return new String[] {
|
||||
Integer.toString(id),
|
||||
biome.biomeName,
|
||||
Float.toString(biome.getFloatTemperature(0, 0, 0)),
|
||||
Float.toString(biome.getFloatRainfall()),
|
||||
Float.toString(biome.getSpawningChance()),
|
||||
Float.toString(biome.rootHeight),
|
||||
Float.toString(biome.heightVariation),
|
||||
s_types.toString(),
|
||||
biome.getClass().getCanonicalName()
|
||||
};
|
||||
return new String[] { Integer.toString(id), biome.biomeName,
|
||||
Float.toString(biome.getFloatTemperature(0, 0, 0)), Float.toString(biome.getFloatRainfall()),
|
||||
Float.toString(biome.getSpawningChance()), Float.toString(biome.rootHeight),
|
||||
Float.toString(biome.heightVariation), s_types.toString(),
|
||||
biome.getClass().getCanonicalName() };
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -319,8 +294,7 @@ public class ItemInfo {
|
||||
UniqueIdentifier ident = null;
|
||||
try {
|
||||
ident = GameRegistry.findUniqueIdentifierFor(item);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
if (ident == null) {
|
||||
NEIClientConfig.logger.error("Failed to find identifier for: " + item);
|
||||
@@ -410,8 +384,8 @@ public class ItemInfo {
|
||||
item.getSubItems(item, itemTab, stackList);
|
||||
for (ItemStack stack : stackList) set.add(stack);
|
||||
} catch (Exception e) {
|
||||
NEIClientConfig.logger.error(
|
||||
"Error loading sub-items for: " + item + ". Tab: " + itemTab.getTabLabel(), e);
|
||||
NEIClientConfig.logger
|
||||
.error("Error loading sub-items for: " + item + ". Tab: " + itemTab.getTabLabel(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -423,21 +397,20 @@ public class ItemInfo {
|
||||
else if (item instanceof ItemAxe) axes.with(item);
|
||||
else if (item instanceof ItemHoe) hoes.with(item);
|
||||
else if (item instanceof ItemSword) swords.with(item);
|
||||
else if (item instanceof ItemArmor)
|
||||
switch (((ItemArmor) item).armorType) {
|
||||
case 0:
|
||||
helmets.with(item);
|
||||
break;
|
||||
case 1:
|
||||
chest.with(item);
|
||||
break;
|
||||
case 2:
|
||||
legs.with(item);
|
||||
break;
|
||||
case 3:
|
||||
boots.with(item);
|
||||
break;
|
||||
}
|
||||
else if (item instanceof ItemArmor) switch (((ItemArmor) item).armorType) {
|
||||
case 0:
|
||||
helmets.with(item);
|
||||
break;
|
||||
case 1:
|
||||
chest.with(item);
|
||||
break;
|
||||
case 2:
|
||||
legs.with(item);
|
||||
break;
|
||||
case 3:
|
||||
boots.with(item);
|
||||
break;
|
||||
}
|
||||
else if (item == Items.arrow || item == Items.bow) ranged.with(item);
|
||||
else if (item == Items.fishing_rod || item == Items.flint_and_steel || item == Items.shears)
|
||||
other.with(item);
|
||||
@@ -517,8 +490,7 @@ public class ItemInfo {
|
||||
|
||||
try {
|
||||
items.addAll(mouseoverBlock.getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), 0));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
if (mouseoverBlock instanceof IShearable) {
|
||||
IShearable shearable = (IShearable) mouseoverBlock;
|
||||
if (shearable.isShearable(new ItemStack(Items.shears), world, x, y, z))
|
||||
@@ -531,12 +503,11 @@ public class ItemInfo {
|
||||
}
|
||||
|
||||
public static void registerHighlightHandler(IHighlightHandler handler, ItemInfo.Layout... layouts) {
|
||||
for (ItemInfo.Layout layout : layouts)
|
||||
ItemInfo.highlightHandlers.get(layout).add(handler);
|
||||
for (ItemInfo.Layout layout : layouts) ItemInfo.highlightHandlers.get(layout).add(handler);
|
||||
}
|
||||
|
||||
public static List<String> getText(
|
||||
ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop) {
|
||||
public static List<String> getText(ItemStack itemStack, World world, EntityPlayer player,
|
||||
MovingObjectPosition mop) {
|
||||
List<String> retString = new ArrayList<>();
|
||||
|
||||
for (ItemInfo.Layout layout : ItemInfo.Layout.values())
|
||||
@@ -550,7 +521,6 @@ public class ItemInfo {
|
||||
return itemSearchNames.computeIfAbsent(
|
||||
new ItemStackKey(stack),
|
||||
key -> EnumChatFormatting.getTextWithoutFormattingCodes(
|
||||
GuiContainerManager.concatenatedDisplayName(key.stack, true)
|
||||
.toLowerCase()));
|
||||
GuiContainerManager.concatenatedDisplayName(key.stack, true).toLowerCase()));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user