mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 08:48:34 +01:00
Fixed a bug with a concurrentModificationException sometimes spamming the console when looking at recipes in NEI
Closes https://github.com/Ellpeck/ActuallyAdditions/issues/13
This commit is contained in:
parent
c409afe159
commit
f0a17025c7
1 changed files with 27 additions and 29 deletions
|
@ -48,40 +48,38 @@ public class TooltipEvent{
|
||||||
if(screen != null && !(screen instanceof GuiBooklet) && screen instanceof GuiContainer){
|
if(screen != null && !(screen instanceof GuiBooklet) && screen instanceof GuiContainer){
|
||||||
GuiContainer gui = (GuiContainer)screen;
|
GuiContainer gui = (GuiContainer)screen;
|
||||||
if(gui.inventorySlots != null && gui.inventorySlots.inventorySlots != null && !gui.inventorySlots.inventorySlots.isEmpty()){
|
if(gui.inventorySlots != null && gui.inventorySlots.inventorySlots != null && !gui.inventorySlots.inventorySlots.isEmpty()){
|
||||||
for(Object o : gui.inventorySlots.inventorySlots){
|
for(int i = 0; i < gui.inventorySlots.inventorySlots.size(); i++){
|
||||||
if(o instanceof Slot){
|
Slot slot = gui.inventorySlots.getSlot(i);
|
||||||
Slot slot = (Slot)o;
|
|
||||||
|
|
||||||
int guiLeft = ReflectionHelper.getPrivateValue(GuiContainer.class, gui, 4);
|
int guiLeft = ReflectionHelper.getPrivateValue(GuiContainer.class, gui, 4);
|
||||||
int guiTop = ReflectionHelper.getPrivateValue(GuiContainer.class, gui, 5);
|
int guiTop = ReflectionHelper.getPrivateValue(GuiContainer.class, gui, 5);
|
||||||
int mouseX = Mouse.getEventX()*gui.width/Minecraft.getMinecraft().displayWidth-guiLeft;
|
int mouseX = Mouse.getEventX()*gui.width/Minecraft.getMinecraft().displayWidth-guiLeft;
|
||||||
int mouseY = gui.height-Mouse.getEventY()*gui.height/Minecraft.getMinecraft().displayHeight-1-guiTop;
|
int mouseY = gui.height-Mouse.getEventY()*gui.height/Minecraft.getMinecraft().displayHeight-1-guiTop;
|
||||||
|
|
||||||
if(mouseX >= slot.xDisplayPosition-1 && mouseY >= slot.yDisplayPosition-1 && mouseX <= slot.xDisplayPosition+16 && mouseY <= slot.yDisplayPosition+16){
|
if(mouseX >= slot.xDisplayPosition-1 && mouseY >= slot.yDisplayPosition-1 && mouseX <= slot.xDisplayPosition+16 && mouseY <= slot.yDisplayPosition+16){
|
||||||
ItemStack stack = slot.getStack();
|
ItemStack stack = slot.getStack();
|
||||||
if(stack != null){
|
if(stack != null){
|
||||||
for(BookletPage page : InitBooklet.pagesWithItemStackData){
|
for(BookletPage page : InitBooklet.pagesWithItemStackData){
|
||||||
if(page.getItemStackForPage() != null && page.getItemStackForPage().isItemEqual(stack)){
|
if(page.getItemStackForPage() != null && page.getItemStackForPage().isItemEqual(stack)){
|
||||||
int keyCode = KeyBinds.keybindOpenBooklet.getKeyCode();
|
int keyCode = KeyBinds.keybindOpenBooklet.getKeyCode();
|
||||||
if(!ConfigBoolValues.NEED_BOOKLET_FOR_KEYBIND_INFO.isEnabled() || Minecraft.getMinecraft().thePlayer.inventory.hasItem(InitItems.itemLexicon)){
|
if(!ConfigBoolValues.NEED_BOOKLET_FOR_KEYBIND_INFO.isEnabled() || Minecraft.getMinecraft().thePlayer.inventory.hasItem(InitItems.itemLexicon)){
|
||||||
if(ConfigBoolValues.SHOW_NEED_BOOKLET_FOR_KEYBIND_INFO.isEnabled()){
|
if(ConfigBoolValues.SHOW_NEED_BOOKLET_FOR_KEYBIND_INFO.isEnabled()){
|
||||||
event.toolTip.add(EnumChatFormatting.GOLD+StringUtil.localizeFormatted("booklet."+ModUtil.MOD_ID_LOWER+".keyToSeeRecipe", keyCode > 0 && keyCode < Keyboard.KEYBOARD_SIZE ? "'"+Keyboard.getKeyName(keyCode)+"'" : "[NONE]"));
|
event.toolTip.add(EnumChatFormatting.GOLD+StringUtil.localizeFormatted("booklet."+ModUtil.MOD_ID_LOWER+".keyToSeeRecipe", keyCode > 0 && keyCode < Keyboard.KEYBOARD_SIZE ? "'"+Keyboard.getKeyName(keyCode)+"'" : "[NONE]"));
|
||||||
}
|
|
||||||
if(Keyboard.isKeyDown(KeyBinds.keybindOpenBooklet.getKeyCode())){
|
|
||||||
GuiBooklet book = new GuiBooklet();
|
|
||||||
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
|
||||||
Minecraft.getMinecraft().displayGuiScreen(book);
|
|
||||||
book.openIndexEntry(page.getChapter().entry, InitBooklet.entries.indexOf(page.getChapter().entry)/GuiBooklet.BUTTONS_PER_PAGE+1, true);
|
|
||||||
book.openChapter(page.getChapter(), page);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else{
|
if(Keyboard.isKeyDown(KeyBinds.keybindOpenBooklet.getKeyCode())){
|
||||||
if(ConfigBoolValues.SHOW_NEED_BOOKLET_FOR_KEYBIND_INFO.isEnabled()){
|
GuiBooklet book = new GuiBooklet();
|
||||||
event.toolTip.addAll(Minecraft.getMinecraft().fontRenderer.listFormattedStringToWidth(EnumChatFormatting.DARK_RED+StringUtil.localizeFormatted("booklet."+ModUtil.MOD_ID_LOWER+".noBookletInInventory"), GuiBooklet.TOOLTIP_SPLIT_LENGTH));
|
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||||
}
|
Minecraft.getMinecraft().displayGuiScreen(book);
|
||||||
|
book.openIndexEntry(page.getChapter().entry, InitBooklet.entries.indexOf(page.getChapter().entry)/GuiBooklet.BUTTONS_PER_PAGE+1, true);
|
||||||
|
book.openChapter(page.getChapter(), page);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
if(ConfigBoolValues.SHOW_NEED_BOOKLET_FOR_KEYBIND_INFO.isEnabled()){
|
||||||
|
event.toolTip.addAll(Minecraft.getMinecraft().fontRenderer.listFormattedStringToWidth(EnumChatFormatting.DARK_RED+StringUtil.localizeFormatted("booklet."+ModUtil.MOD_ID_LOWER+".noBookletInInventory"), GuiBooklet.TOOLTIP_SPLIT_LENGTH));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue