Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checks for valid block data in Block#getEnchantPowerBonus #4

Closed
Darkhax opened this issue May 8, 2016 · 8 comments
Closed

Add checks for valid block data in Block#getEnchantPowerBonus #4

Darkhax opened this issue May 8, 2016 · 8 comments
Labels

Comments

@Darkhax
Copy link

Darkhax commented May 8, 2016

This issue is related to the conflict between AdventureBackpack2 and Wawla. The issue is caused by Wawla making a call to Block#getEnchantPowerBonus while hovering over a block in the inventory. The goal of this is to add the enchanting bonus to the tooltip of the block. Since the Inventory does not have access to XYZ coords some devs will use Origin (0,0,0) or the players position for this.

I patched this issue on Wawla's end by swallowing the exception, however to improve performance and to futureproof AdventureBackpack you should look into adding some safety checks on your end. After looking into your mod source, adding a check to see if the TileEntity is null in BlockAdventureBackpack#getAssociatedTileColorName and return an empty or error name would completely resolve this issue.

    private String getAssociatedTileColorName(IBlockAccess world, int x, int y, int z)
    {
        final TileEntity tile = world.getTileEntity(x, y, z);
        return (tile instanceof TileAdventureBackpack) ? ((TileAdventureBackpack) tile).getColorName() : "error";
    }
@runescapejon
Copy link
Owner

I will fix it asap! once i get home from work 💃

@runescapejon
Copy link
Owner

Looks like I'm going home late can you do me a favor and write the code here or make a pull request so i can add it once i get home its around 4 am here and still at work

@runescapejon
Copy link
Owner

yea i had added that code in there and i have no clue how to fix this problem
https://gyazo.com/19554c49340df1fc707e9cbcc8abe182
it have blockAdventureBackpack.name and it have the wrong ID

@Darkhax
Copy link
Author

Darkhax commented May 8, 2016

@runescapejon are you referring to the wrong item name showing up on the HUD? If so, that is unrelated to this issue. This issue is related to a NullPointerException that happens while looking at the block in your inventory.

The broken translation name is due to an issue with your unlocalized block name not matching the one in your language file. You set the unlocalized name to blockAdventureBackpack.name but the language file has it listed as block.adventurebackpack:AdventureBackpack.name. There isn't anything I can do about this other than opening up a new pull request, although you should be more than capable of fixing it yourself. Here is the link to the exact code causing the issue.

You might want to merge my PR first. not sure if you fixing the naming issue will cause merge conflicts.

@runescapejon
Copy link
Owner

i had already did block.adventurebackpack:AdventureBackpack.name in en_US.lang and it didn't fix the problem

@Darkhax
Copy link
Author

Darkhax commented May 8, 2016

The issue is that it is not looking for that localization key. If you look at the link I included in my post, you have it set to look for blockAdventureBackpack.name which is not in your file.

@runescapejon
Copy link
Owner

runescapejon commented May 8, 2016

got it https://gyazo.com/279b91ac48d375d0ee48bc78b995f694
but the id's are wrong but whatever xD

@runescapejon
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants