mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-26 21:09:23 +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){
|
||||
GuiContainer gui = (GuiContainer)screen;
|
||||
if(gui.inventorySlots != null && gui.inventorySlots.inventorySlots != null && !gui.inventorySlots.inventorySlots.isEmpty()){
|
||||
for(Object o : gui.inventorySlots.inventorySlots){
|
||||
if(o instanceof Slot){
|
||||
Slot slot = (Slot)o;
|
||||
for(int i = 0; i < gui.inventorySlots.inventorySlots.size(); i++){
|
||||
Slot slot = gui.inventorySlots.getSlot(i);
|
||||
|
||||
int guiLeft = ReflectionHelper.getPrivateValue(GuiContainer.class, gui, 4);
|
||||
int guiTop = ReflectionHelper.getPrivateValue(GuiContainer.class, gui, 5);
|
||||
int mouseX = Mouse.getEventX()*gui.width/Minecraft.getMinecraft().displayWidth-guiLeft;
|
||||
int mouseY = gui.height-Mouse.getEventY()*gui.height/Minecraft.getMinecraft().displayHeight-1-guiTop;
|
||||
int guiLeft = ReflectionHelper.getPrivateValue(GuiContainer.class, gui, 4);
|
||||
int guiTop = ReflectionHelper.getPrivateValue(GuiContainer.class, gui, 5);
|
||||
int mouseX = Mouse.getEventX()*gui.width/Minecraft.getMinecraft().displayWidth-guiLeft;
|
||||
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){
|
||||
ItemStack stack = slot.getStack();
|
||||
if(stack != null){
|
||||
for(BookletPage page : InitBooklet.pagesWithItemStackData){
|
||||
if(page.getItemStackForPage() != null && page.getItemStackForPage().isItemEqual(stack)){
|
||||
int keyCode = KeyBinds.keybindOpenBooklet.getKeyCode();
|
||||
if(!ConfigBoolValues.NEED_BOOKLET_FOR_KEYBIND_INFO.isEnabled() || Minecraft.getMinecraft().thePlayer.inventory.hasItem(InitItems.itemLexicon)){
|
||||
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]"));
|
||||
}
|
||||
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);
|
||||
}
|
||||
if(mouseX >= slot.xDisplayPosition-1 && mouseY >= slot.yDisplayPosition-1 && mouseX <= slot.xDisplayPosition+16 && mouseY <= slot.yDisplayPosition+16){
|
||||
ItemStack stack = slot.getStack();
|
||||
if(stack != null){
|
||||
for(BookletPage page : InitBooklet.pagesWithItemStackData){
|
||||
if(page.getItemStackForPage() != null && page.getItemStackForPage().isItemEqual(stack)){
|
||||
int keyCode = KeyBinds.keybindOpenBooklet.getKeyCode();
|
||||
if(!ConfigBoolValues.NEED_BOOKLET_FOR_KEYBIND_INFO.isEnabled() || Minecraft.getMinecraft().thePlayer.inventory.hasItem(InitItems.itemLexicon)){
|
||||
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]"));
|
||||
}
|
||||
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));
|
||||
}
|
||||
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);
|
||||
}
|
||||
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