Skip to content

Commit

Permalink
Fix #344 Add config to hide player skulls (on by default) to prevent lag
Browse files Browse the repository at this point in the history
  • Loading branch information
mezz committed Jul 6, 2016
1 parent 62c77cd commit f542e86
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/main/java/mezz/jei/ItemFilter.java
Expand Up @@ -24,6 +24,7 @@
import net.minecraft.client.renderer.RenderItem;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.item.Item;
import net.minecraft.item.ItemSkull;
import net.minecraft.item.ItemStack;

public class ItemFilter {
Expand Down Expand Up @@ -154,14 +155,6 @@ public boolean isItemStackHidden(@Nonnull ItemStack itemStack) {
return true;
}

return isItemStackHiddenByMissingModel(itemStack);
}

public Multiset<Item> getBrokenItems() {
return brokenItems;
}

private boolean isItemStackHiddenByMissingModel(@Nonnull ItemStack itemStack) {
Item item = itemStack.getItem();
if (brokenItems.contains(item)) {
return true;
Expand All @@ -180,12 +173,25 @@ private boolean isItemStackHiddenByMissingModel(@Nonnull ItemStack itemStack) {
}

if (Config.isHideMissingModelsEnabled()) {
return itemModel == null || itemModel == missingModel;
if (itemModel == null || itemModel == missingModel) {
return true;
}
}

if (Config.isHideLaggyModelsEnabled()) {
// Game freezes when loading player skulls, see https://bugs.mojang.com/browse/MC-65587
if (item instanceof ItemSkull && itemStack.getMetadata() == 3) {
return true;
}
}

return false;
}

public Multiset<Item> getBrokenItems() {
return brokenItems;
}

private boolean isItemHiddenByBlacklist(@Nonnull ItemStack itemStack) {
try {
if (!itemBlacklist.isItemBlacklisted(itemStack)) {
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/mezz/jei/config/Config.java
Expand Up @@ -37,6 +37,7 @@ public class Config {
private static boolean debugModeEnabled = false;
private static boolean debugItemEnabled = false;
private static boolean hideMissingModelsEnabled = true;
private static boolean hideLaggyModelsEnabled = true;
private static boolean deleteItemsInCheatModeEnabled = true;
private static boolean colorSearchEnabled = false;

Expand Down Expand Up @@ -106,6 +107,10 @@ public static boolean isHideMissingModelsEnabled() {
return hideMissingModelsEnabled;
}

public static boolean isHideLaggyModelsEnabled() {
return hideLaggyModelsEnabled;
}

public static boolean isColorSearchEnabled() {
return colorSearchEnabled;
}
Expand Down Expand Up @@ -288,6 +293,11 @@ private static boolean syncConfig() {
needsReload = true;
}

hideLaggyModelsEnabled = config.getBoolean(CATEGORY_ADVANCED, "hideLaggyModelsEnabled", hideLaggyModelsEnabled);
if (categoryAdvanced.get("hideLaggyModelsEnabled").hasChanged()) {
needsReload = true;
}

colorSearchEnabled = config.getBoolean(CATEGORY_ADVANCED, "colorSearchEnabled", colorSearchEnabled);
if (categoryAdvanced.get("colorSearchEnabled").hasChanged()) {
needsReload = true;
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/jei/lang/en_US.lang
Expand Up @@ -64,6 +64,8 @@ config.jei.advanced.itemBlacklist=Item Blacklist
config.jei.advanced.itemBlacklist.comment=List of items that should not be displayed in the item list. Format: modId[:name[:meta]]. Edit Mode will automatically add or remove entries here.
config.jei.advanced.hideMissingModelsEnabled=Hide Items with Missing Models
config.jei.advanced.hideMissingModelsEnabled.comment=Items with missing models will be hidden from the item list.
config.jei.advanced.hideLaggyModelsEnabled=Hide Items with Laggy Models
config.jei.advanced.hideLaggyModelsEnabled.comment=Items with models that cause a long delay will be hidden from the item list.
config.jei.advanced.colorSearchEnabled=Enable Color Search
config.jei.advanced.colorSearchEnabled.comment=Search items by color and show the searchable item colors on tooltips in the item list.
config.jei.advanced.debugModeEnabled=Debug Mode
Expand Down

0 comments on commit f542e86

Please sign in to comment.