Update buildscript & apply automatic formatting rules

This commit is contained in:
Raven Szewczyk authored and Jason Mitchell committed 2022-06-27 10:23:18 -07:00
1 parent a7683b885d
commit f7a900e910
173 files changed
+4581 -5321

No files matched your search

+13 -19
View File
@@ -24,6 +24,9 @@ import codechicken.nei.recipe.IUsageHandler;
import codechicken.nei.recipe.RecipeCatalysts;
import codechicken.nei.recipe.RecipeInfo;
import codechicken.nei.recipe.StackInfo;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Slot;
@@ -31,17 +34,12 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Keyboard;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
* This is the main class that handles item property configuration.
* WARNING: DO NOT access this class until the world has been loaded
* These methods should be called from INEIConfig implementors
*/
public class API
{
public class API {
/**
* Register a new Crafting Recipe handler;
*
@@ -92,7 +90,8 @@ public class API
* {crafting, crafting2x2, smelting, fuel, brewing}
* @param positioner A Stack Repositioner for moving the items to the right place
*/
public static void registerGuiOverlay(Class<? extends GuiContainer> classz, String ident, IStackPositioner positioner) {
public static void registerGuiOverlay(
Class<? extends GuiContainer> classz, String ident, IStackPositioner positioner) {
RecipeInfo.registerGuiOverlay(classz, ident, positioner);
}
@@ -101,7 +100,8 @@ public class API
* @param handler The handler to register
* @param ident The recipe identification string
*/
public static void registerGuiOverlayHandler(Class<? extends GuiContainer> classz, IOverlayHandler handler, String ident) {
public static void registerGuiOverlayHandler(
Class<? extends GuiContainer> classz, IOverlayHandler handler, String ident) {
RecipeInfo.registerOverlayHandler(classz, handler, ident);
}
@@ -155,8 +155,7 @@ public class API
* Sets the item variants to appear in the item panel, overriding the default search pattern for a given item
*/
public static void setItemListEntries(Item item, Iterable<ItemStack> items) {
if(items == null)
items = Collections.emptyList();
if (items == null) items = Collections.emptyList();
ItemInfo.itemOverrides.replaceValues(item, items);
LayoutManager.markItemsDirty();
}
@@ -253,8 +252,7 @@ public class API
*/
public static void addSubset(String name, Iterable<ItemStack> items) {
ItemStackSet filter = new ItemStackSet();
for(ItemStack item : items)
filter.add(item);
for (ItemStack item : items) filter.add(item);
addSubset(new SubsetTag(name, filter));
}
@@ -290,8 +288,7 @@ public class API
LayoutManager.markItemsDirty();
}
public static void registerStackStringifyHandler(IStackStringifyHandler handler)
{
public static void registerStackStringifyHandler(IStackStringifyHandler handler) {
StackInfo.stackStringifyHandlers.add(handler);
}
@@ -356,11 +353,8 @@ public class API
}
@Deprecated
public static void addRecipeCatalyst(ItemStack stack, Class<? extends IRecipeHandler> handler) {
}
public static void addRecipeCatalyst(ItemStack stack, Class<? extends IRecipeHandler> handler) {}
@Deprecated
public static void addRecipeCatalyst(List<ItemStack> stacks, Class<? extends IRecipeHandler> handler) {
}
public static void addRecipeCatalyst(List<ItemStack> stacks, Class<? extends IRecipeHandler> handler) {}
}
@@ -2,43 +2,37 @@ package codechicken.nei.api;
import codechicken.nei.PositionedStack;
import codechicken.nei.guihook.GuiContainerManager;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.inventory.Slot;
import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
import java.util.List;
public class DefaultOverlayRenderer implements IRecipeOverlayRenderer
{
public DefaultOverlayRenderer(List<PositionedStack> ai, IStackPositioner positioner)
{
public class DefaultOverlayRenderer implements IRecipeOverlayRenderer {
public DefaultOverlayRenderer(List<PositionedStack> ai, IStackPositioner positioner) {
positioner = this.positioner = positioner;
ingreds = new ArrayList<>();
for(PositionedStack stack : ai)
ingreds.add(stack.copy());
for (PositionedStack stack : ai) ingreds.add(stack.copy());
ingreds = positioner.positionStacks(ingreds);
}
@Override
public void renderOverlay(GuiContainerManager gui, Slot slot)
{
public void renderOverlay(GuiContainerManager gui, Slot slot) {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(770, 1);
GL11.glColor4d(0.6, 0.6, 0.6, 0.7);
GuiContainerManager.setColouredItemRender(true);
for(PositionedStack stack : ingreds)
{
if(stack.relx == slot.xDisplayPosition && stack.rely == slot.yDisplayPosition)
for (PositionedStack stack : ingreds) {
if (stack.relx == slot.xDisplayPosition && stack.rely == slot.yDisplayPosition)
GuiContainerManager.drawItem(stack.relx, stack.rely, stack.item);
}
GuiContainerManager.setColouredItemRender(false);
GL11.glColor4f(1, 1, 1, 1);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_LIGHTING);
}
final IStackPositioner positioner;
ArrayList<PositionedStack> ingreds;
}
+8 -12
View File
@@ -5,18 +5,17 @@ import codechicken.nei.NEIChestGuiHandler;
import codechicken.nei.NEICreativeGuiHandler;
import codechicken.nei.NEIDummySlotHandler;
import codechicken.nei.NEIPotionGuiHandler;
import codechicken.nei.recipe.CheatItemHandler;
import codechicken.nei.recipe.FillFluidContainerHandler;
import codechicken.nei.recipe.GuiRecipeCatalyst;
import codechicken.nei.recipe.SearchInputDropHandler;
import codechicken.nei.recipe.FillFluidContainerHandler;
import codechicken.nei.recipe.CheatItemHandler;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.inventory.GuiContainerCreative;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.inventory.GuiContainerCreative;
public class GuiInfo {
public static final LinkedList<INEIGuiHandler> guiHandlers = new LinkedList<>();
@@ -25,7 +24,6 @@ public class GuiInfo {
public static Lock writeLock = guiHandlersLock.writeLock();
public static Lock readLock = guiHandlersLock.readLock();
public static void load() {
API.registerNEIGuiHandler(new NEICreativeGuiHandler());
API.registerNEIGuiHandler(new NEIChestGuiHandler());
@@ -51,11 +49,11 @@ public class GuiInfo {
return customSlotGuis.contains(gui.getClass());
}
public static boolean hideItemPanelSlot(GuiContainer gui, Rectangle4i rect)
{
public static boolean hideItemPanelSlot(GuiContainer gui, Rectangle4i rect) {
try {
readLock.lock();
if (guiHandlers.stream().anyMatch(handler -> handler.hideItemPanelSlot(gui, rect.x, rect.y, rect.w, rect.h))) {
if (guiHandlers.stream()
.anyMatch(handler -> handler.hideItemPanelSlot(gui, rect.x, rect.y, rect.w, rect.h))) {
return true;
}
} finally {
@@ -68,10 +66,8 @@ public class GuiInfo {
if ((new Rectangle4i(button.xPosition, button.yPosition, button.width, button.height)).intersects(rect)) {
return true;
}
}
return false;
}
}
@@ -4,10 +4,10 @@ package codechicken.nei.api;
* An nei configuration entry point should implement this class and have name "NEI<someting>Config"
* loadConfig will only be called when NEI is installed.
*/
public interface IConfigureNEI
{
public interface IConfigureNEI {
public void loadConfig();
public String getName();
public String getVersion();
}
@@ -3,8 +3,7 @@ package codechicken.nei.api;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiContainer;
public interface IGuiContainerOverlay
{
public interface IGuiContainerOverlay {
GuiContainer getFirstScreen();
default GuiScreen getFirstScreenGeneral() {
@@ -1,15 +1,19 @@
package codechicken.nei.api;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import java.util.List;
public interface IHighlightHandler
{
public interface IHighlightHandler {
public ItemStack identifyHighlight(World world, EntityPlayer player, MovingObjectPosition mop);
public List<String> handleTextData(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, List<String> currenttip, ItemInfo.Layout layout);
public List<String> handleTextData(
ItemStack itemStack,
World world,
EntityPlayer player,
MovingObjectPosition mop,
List<String> currenttip,
ItemInfo.Layout layout);
}
@@ -3,14 +3,16 @@ package codechicken.nei.api;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
public interface IInfiniteItemHandler
{
public interface IInfiniteItemHandler {
void onPickup(ItemStack heldItem);
void onPlaceInfinite(ItemStack heldItem);
boolean canHandleItem(ItemStack stack);
boolean isItemInfinite(ItemStack stack);
public void replenishInfiniteStack(InventoryPlayer inventory, int slotNo);
public ItemStack getInfiniteItem(ItemStack typeStack);
}
@@ -1,20 +1,17 @@
package codechicken.nei.api;
import codechicken.nei.VisiblityData;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import java.util.Collections;
import java.util.List;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
/**
* Lets you just override those things you want to
*/
public class INEIGuiAdapter implements INEIGuiHandler
{
public class INEIGuiAdapter implements INEIGuiHandler {
@Override
public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility)
{
public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility) {
return currentVisibility;
}
@@ -24,20 +21,17 @@ public class INEIGuiAdapter implements INEIGuiHandler
}
@Override
public List<TaggedInventoryArea> getInventoryAreas(GuiContainer gui)
{
public List<TaggedInventoryArea> getInventoryAreas(GuiContainer gui) {
return null;
}
@Override
public boolean handleDragNDrop(GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button)
{
public boolean handleDragNDrop(GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button) {
return false;
}
@Override
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h)
{
return false;
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) {
return false;
}
}
@@ -1,31 +1,29 @@
package codechicken.nei.api;
import codechicken.nei.VisiblityData;
import java.util.List;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import java.util.List;
/**
* If this is implemented on a gui, it will be automatically registered
*/
public interface INEIGuiHandler
{
public interface INEIGuiHandler {
public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility);
/**
* NEI will give the specified item to the InventoryRange returned if the player's inventory is full.
* Should not return null, just an empty list
*/
public Iterable<Integer> getItemSpawnSlots(GuiContainer gui, ItemStack item);
/**
* @return A list of TaggedInventoryAreas that will be used with the savestates.
*/
public List<TaggedInventoryArea> getInventoryAreas(GuiContainer gui);
/**
* Handles clicks while an itemstack has been dragged from the item panel. Use this to set configurable slots and the like.
* Handles clicks while an itemstack has been dragged from the item panel. Use this to set configurable slots and the like.
* Changes made to the stackSize of the dragged stack will be kept
* @param gui The current gui instance
* @param mousex The x position of the mouse
@@ -35,7 +33,7 @@ public interface INEIGuiHandler
* @return True if the drag n drop was handled. False to resume processing through other routes. The held stack will be deleted if draggedStack.stackSize == 0
*/
public boolean handleDragNDrop(GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button);
/**
* Used to prevent the item panel from drawing on top of other gui elements.
* This function will also be called with a 1x1 size rectangle on the mouse position for determining if the given coordinate should override item panel functions such as scrolling
@@ -1,6 +1,5 @@
package codechicken.nei.api;
public interface INEIModeHandler
{
public interface INEIModeHandler {
public boolean isModeValid(int mode);
}
@@ -3,7 +3,6 @@ package codechicken.nei.api;
import codechicken.nei.recipe.IRecipeHandler;
import net.minecraft.client.gui.inventory.GuiContainer;
public interface IOverlayHandler
{
public interface IOverlayHandler {
public void overlayRecipe(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, boolean shift);
}
@@ -3,7 +3,6 @@ package codechicken.nei.api;
import codechicken.nei.guihook.GuiContainerManager;
import net.minecraft.inventory.Slot;
public interface IRecipeOverlayRenderer
{
public interface IRecipeOverlayRenderer {
public void renderOverlay(GuiContainerManager gui, Slot slot);
}
@@ -1,14 +1,12 @@
package codechicken.nei.api;
import codechicken.nei.PositionedStack;
import java.util.ArrayList;
/**
* For repositioning recipes in overlay renderers.
*
*
*/
public interface IStackPositioner
{
public interface IStackPositioner {
public ArrayList<PositionedStack> positionStacks(ArrayList<PositionedStack> ai);
}
@@ -1,16 +1,14 @@
package codechicken.nei.api;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.FluidStack;
import net.minecraft.item.ItemStack;
public interface IStackStringifyHandler
{
public interface IStackStringifyHandler {
public NBTTagCompound convertItemStackToNBT(ItemStack stack, boolean saveStackSize);
public ItemStack convertNBTToItemStack(NBTTagCompound nbtTag);
public FluidStack getFluid(ItemStack stack);
}
}
@@ -2,15 +2,13 @@ package codechicken.nei.api;
import net.minecraft.item.ItemStack;
public interface ItemFilter
{
public interface ItemFilter {
/**
* Provides an item filter. May be called from any thread. Returned filter should only reference objects with immutable state.
*/
public static interface ItemFilterProvider
{
public static interface ItemFilterProvider {
public ItemFilter getFilter();
}
public boolean matches(ItemStack item);
}
}
+115 -130
View File
@@ -21,6 +21,13 @@ 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;
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;
@@ -52,22 +59,14 @@ import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.IShearable;
import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
/**
* 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, FOOTER
public class ItemInfo {
public static enum Layout {
HEADER,
BODY,
FOOTER
}
public static final ArrayListMultimap<Layout, IHighlightHandler> highlightHandlers = ArrayListMultimap.create();
@@ -85,33 +84,32 @@ public class ItemInfo
private static class ItemStackKey {
public final ItemStack stack;
public ItemStackKey(ItemStack stack) {
this.stack = stack;
}
@Override
public int hashCode() {
if(this.stack == null)
return 1;
if (this.stack == null) return 1;
int hashCode = 1;
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;
}
@Override
public boolean equals(Object o) {
if(o == this)
return true;
if(!(o instanceof ItemStackKey))
return false;
return ItemStack.areItemStacksEqual(this.stack, ((ItemStackKey)o).stack);
if (o == this) return true;
if (!(o instanceof ItemStackKey)) return false;
return ItemStack.areItemStacksEqual(this.stack, ((ItemStackKey) o).stack);
}
}
//lookup optimisation
// lookup optimisation
public static final ConcurrentHashMap<ItemStackKey, String> itemSearchNames = new ConcurrentHashMap<>();
public static boolean isHidden(ItemStack stack) {
@@ -164,7 +162,7 @@ public class ItemInfo
private static void populateSearchMap() {
/* Create a snapshot of the current keys in the cache */
HashSet<ItemStackKey> oldItems = new HashSet<>(itemSearchNames.keySet());
for(ItemStack stack : ItemList.items) {
for (ItemStack stack : ItemList.items) {
/* Populate each entry and remove it from the snapshot */
getSearchName(stack);
oldItems.remove(new ItemStackKey(stack));
@@ -177,21 +175,20 @@ public class ItemInfo
}
private static void addIDDumps() {
API.addOption(new RegistryDumper<Item>("tools.dump.item")
{
API.addOption(new RegistryDumper<Item>("tools.dump.item") {
@Override
public String[] header() {
return new String[]{"Name", "ID", "Has Block", "Mod", "Class"};
return new String[] {"Name", "ID", "Has Block", "Mod", "Class"};
}
@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()
return new String[] {
name,
Integer.toString(id),
Boolean.toString(Block.getBlockFromItem(item) != Blocks.air),
ItemInfo.itemOwners.get(item),
item.getClass().getCanonicalName()
};
}
@@ -200,21 +197,20 @@ public class ItemInfo
return Item.itemRegistry;
}
});
API.addOption(new RegistryDumper<Block>("tools.dump.block")
{
API.addOption(new RegistryDumper<Block>("tools.dump.block") {
@Override
public String[] header() {
return new String[]{"Name", "ID", "Has Item", "Mod", "Class"};
return new String[] {"Name", "ID", "Has Item", "Mod", "Class"};
}
@Override
public String[] dump(Block item, int id, String name) {
return new String[]{
name,
Integer.toString(id),
Boolean.toString(Item.getItemFromBlock(item) != null),
ItemInfo.itemOwners.get(item),
item.getClass().getCanonicalName()
return new String[] {
name,
Integer.toString(id),
Boolean.toString(Item.getItemFromBlock(item) != null),
ItemInfo.itemOwners.get(item),
item.getClass().getCanonicalName()
};
}
@@ -223,18 +219,15 @@ public class ItemInfo
return Block.blockRegistry;
}
});
API.addOption(new ArrayDumper<Potion>("tools.dump.potion")
{
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()
};
}
@@ -243,21 +236,20 @@ public class ItemInfo
return Potion.potionTypes;
}
});
API.addOption(new ArrayDumper<Enchantment>("tools.dump.enchantment")
{
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()
};
}
@@ -266,11 +258,20 @@ public class ItemInfo
return Enchantment.enchantmentsList;
}
});
API.addOption(new ArrayDumper<BiomeGenBase>("tools.dump.biome")
{
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
@@ -278,21 +279,20 @@ public class ItemInfo
BiomeDictionary.Type[] types = BiomeDictionary.getTypesForBiome(biome);
StringBuilder s_types = new StringBuilder();
for (BiomeDictionary.Type t : types) {
if (s_types.length() > 0)
s_types.append(", ");
if (s_types.length() > 0) s_types.append(", ");
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()
};
}
@@ -312,28 +312,26 @@ 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);
if (ident == null) {
NEIClientConfig.logger.error("Failed to find identifier for: " + item);
continue;
}
String modId = ident.modId;
itemOwners.put(item, modId);
ItemStackSet itemset = modSubsets.get(modId);
if(itemset == null)
modSubsets.put(modId, itemset = new ItemStackSet());
if (itemset == null) modSubsets.put(modId, itemset = new ItemStackSet());
itemset.with(item);
}
API.addSubset("Mod.Minecraft", modSubsets.remove("minecraft"));
for(Entry<String, ItemStackSet> entry : modSubsets.entrySet()) {
for (Entry<String, ItemStackSet> entry : modSubsets.entrySet()) {
ModContainer mc = FMLCommonHandler.instance().findContainerFor(entry.getKey());
if(mc == null)
NEIClientConfig.logger.error("Missing container for "+entry.getKey());
else
API.addSubset("Mod."+mc.getName(), entry.getValue());
if (mc == null) NEIClientConfig.logger.error("Missing container for " + entry.getKey());
else API.addSubset("Mod." + mc.getName(), entry.getValue());
}
}
@@ -392,40 +390,32 @@ public class ItemInfo
List<ItemStack> stackList = new LinkedList<>();
for (Item item : (Iterable<Item>) Item.itemRegistry) {
if (item == null)
continue;
if (item == null) continue;
for(CreativeTabs itemTab : item.getCreativeTabs()) {
for (CreativeTabs itemTab : item.getCreativeTabs()) {
if (itemTab != null) {
while (itemTab.getTabIndex() >= creativeTabRanges.size())
creativeTabRanges.add(null);
while (itemTab.getTabIndex() >= creativeTabRanges.size()) creativeTabRanges.add(null);
ItemStackSet set = creativeTabRanges.get(itemTab.getTabIndex());
if (set == null)
creativeTabRanges.set(itemTab.getTabIndex(), set = new ItemStackSet());
if (set == null) creativeTabRanges.set(itemTab.getTabIndex(), set = new ItemStackSet());
try {
stackList.clear();
item.getSubItems(item, itemTab, stackList);
for(ItemStack stack : stackList)
set.add(stack);
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);
}
}
}
if (item.isDamageable()) {
tools.with(item);
if (item instanceof ItemPickaxe)
picks.with(item);
else if (item instanceof ItemSpade)
shovels.with(item);
else if (item instanceof ItemAxe)
axes.with(item);
else if (item instanceof ItemHoe)
hoes.with(item);
else if (item instanceof ItemSword)
swords.with(item);
if (item instanceof ItemPickaxe) picks.with(item);
else if (item instanceof ItemSpade) shovels.with(item);
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:
@@ -441,19 +431,17 @@ public class ItemInfo
boots.with(item);
break;
}
else if (item == Items.arrow || item == Items.bow)
ranged.with(item);
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);
}
if (item instanceof ItemFood)
food.with(item);
if (item instanceof ItemFood) food.with(item);
try {
LinkedList<ItemStack> subItems = new LinkedList<>();
item.getSubItems(item, null, subItems);
for(ItemStack stack : subItems) {
for (ItemStack stack : subItems) {
if (item.isPotionIngredient(stack) && item.getPotionEffect(stack) != null) {
BrewingRecipeHandler.ingredients.add(stack);
potioningredients.add(stack);
@@ -461,7 +449,7 @@ public class ItemInfo
}
} catch (Exception e) {
NEIClientConfig.logger.error("Error loading brewing ingredients for: "+item, e);
NEIClientConfig.logger.error("Error loading brewing ingredients for: " + item, e);
}
}
API.addSubset("Items.Tools.Pickaxes", picks);
@@ -479,7 +467,7 @@ public class ItemInfo
API.addSubset("Items.Potions.Ingredients", potioningredients);
for (CreativeTabs tab : CreativeTabs.creativeTabArray) {
if(tab.getTabIndex() >= creativeTabRanges.size()) continue;
if (tab.getTabIndex() >= creativeTabRanges.size()) continue;
ItemStackSet set = creativeTabRanges.get(tab.getTabIndex());
if (set != null && !set.isEmpty())
API.addSubset("CreativeTabs." + I18n.format(tab.getTranslatedTabLabel()), set);
@@ -488,15 +476,14 @@ public class ItemInfo
BrewingRecipeHandler.searchPotions();
}
private static void addSpawnEggs()
{
private static void addSpawnEggs() {
addEntityEgg(EntitySnowman.class, 0xEEFFFF, 0xffa221);
addEntityEgg(EntityIronGolem.class, 0xC5C2C1, 0xffe1cc);
}
@SuppressWarnings("unchecked")
private static void addEntityEgg(Class<?> entity, int i, int j) {
int id = (Integer)EntityList.classToIDMapping.get(entity);
int id = (Integer) EntityList.classToIDMapping.get(entity);
EntityList.entityEggs.put(id, new EntityEggInfo(id, i, j));
}
@@ -509,34 +496,29 @@ public class ItemInfo
ArrayList<ItemStack> items = new ArrayList<>();
ArrayList<IHighlightHandler> handlers = new ArrayList<>();
if (highlightIdentifiers.containsKey(null))
handlers.addAll(highlightIdentifiers.get(null));
if (highlightIdentifiers.containsKey(mouseoverBlock))
handlers.addAll(highlightIdentifiers.get(mouseoverBlock));
if (highlightIdentifiers.containsKey(null)) handlers.addAll(highlightIdentifiers.get(null));
if (highlightIdentifiers.containsKey(mouseoverBlock)) handlers.addAll(highlightIdentifiers.get(mouseoverBlock));
for (IHighlightHandler ident : handlers) {
ItemStack item = ident.identifyHighlight(world, player, hit);
if (item != null)
items.add(item);
if (item != null) items.add(item);
}
if (items.size() > 0)
return items;
if (items.size() > 0) return items;
ItemStack pick = mouseoverBlock.getPickBlock(hit, world, x, y, z, player);
if (pick != null)
items.add(pick);
if (pick != null) items.add(pick);
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))
items.addAll(shearable.onSheared(new ItemStack(Items.shears), world, x, y, z, 0));
}
if (items.size() == 0)
items.add(0, new ItemStack(mouseoverBlock, 1, world.getBlockMetadata(x, y, z)));
if (items.size() == 0) items.add(0, new ItemStack(mouseoverBlock, 1, world.getBlockMetadata(x, y, z)));
return items;
}
@@ -546,7 +528,8 @@ public class ItemInfo
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())
@@ -557,8 +540,10 @@ public class ItemInfo
}
public static String getSearchName(ItemStack stack) {
return itemSearchNames.computeIfAbsent(new ItemStackKey(stack), key ->
EnumChatFormatting.getTextWithoutFormattingCodes(GuiContainerManager.concatenatedDisplayName(key.stack, true).toLowerCase())
);
return itemSearchNames.computeIfAbsent(
new ItemStackKey(stack),
key -> EnumChatFormatting.getTextWithoutFormattingCodes(
GuiContainerManager.concatenatedDisplayName(key.stack, true)
.toLowerCase()));
}
}
@@ -5,16 +5,18 @@ import codechicken.nei.VisiblityData;
import codechicken.nei.guihook.GuiContainerManager;
import net.minecraft.client.gui.inventory.GuiContainer;
public abstract class LayoutStyle
{
public abstract class LayoutStyle {
public abstract void init();
public abstract void reset();
public abstract void layout(GuiContainer gui, VisiblityData visibility);
public abstract String getName();
public void drawBackground(GuiContainerManager gui)
{
}
public void drawBackground(GuiContainerManager gui) {}
public abstract void drawButton(Button button, int mousex, int mousey);
public abstract void drawSubsetTag(String text, int x, int y, int w, int h, int state, boolean mouseover);
}
@@ -2,28 +2,24 @@ package codechicken.nei.api;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.config.OptionCycled;
import java.util.LinkedList;
import net.minecraft.world.World;
import java.util.LinkedList;
public class NEIInfo
{
public class NEIInfo {
public static final LinkedList<INEIModeHandler> modeHandlers = new LinkedList<>();
public static void load(World world) {
OptionCycled modeOption = (OptionCycled) NEIClientConfig.getOptionList().getOption("inventory.cheatmode");
modeOption.parent.synthesizeEnvironment(false);
if(!modeOption.optionValid(modeOption.value())) {
if (!modeOption.optionValid(modeOption.value())) {
modeOption.copyGlobals();
modeOption.cycle();
}
}
public static boolean isValidMode(int mode) {
for(INEIModeHandler handler : modeHandlers)
if(!handler.isModeValid(mode))
return false;
for (INEIModeHandler handler : modeHandlers) if (!handler.isModeValid(mode)) return false;
return true;
}
}
@@ -1,14 +1,12 @@
package codechicken.nei.api;
import java.util.HashSet;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import java.util.HashSet;
public class TaggedInventoryArea
{
public class TaggedInventoryArea {
public final HashSet<Integer> slots = new HashSet<>();
public final String tagName;
/**
@@ -19,30 +17,24 @@ public class TaggedInventoryArea
* Other inventories
*/
private final Container container;
public TaggedInventoryArea(InventoryPlayer invPlayer)
{
public TaggedInventoryArea(InventoryPlayer invPlayer) {
this("InventoryPlayer", 0, 39, null);
inventory = invPlayer;
}
public TaggedInventoryArea(String name, int first, int last, Container container)
{
public TaggedInventoryArea(String name, int first, int last, Container container) {
this.container = container;
tagName = name;
for(int i = first; i <= last; i++)
slots.add(i);
for (int i = first; i <= last; i++) slots.add(i);
}
public ItemStack getStackInSlot(int i)
{
if(inventory != null)
return inventory.getStackInSlot(i);
public ItemStack getStackInSlot(int i) {
if (inventory != null) return inventory.getStackInSlot(i);
return container.getSlot(i).getStack();
}
public boolean isContainer()
{
public boolean isContainer() {
return inventory == null;
}
}