{"action":"created","issue":{"url":"https://api.github.com/repos/CharsetMC/Charset/issues/244","repository_url":"https://api.github.com/repos/CharsetMC/Charset","labels_url":"https://api.github.com/repos/CharsetMC/Charset/issues/244/labels{/name}","comments_url":"https://api.github.com/repos/CharsetMC/Charset/issues/244/comments","events_url":"https://api.github.com/repos/CharsetMC/Charset/issues/244/events","html_url":"https://github.com/CharsetMC/Charset/issues/244","id":337219846,"node_id":"MDU6SXNzdWUzMzcyMTk4NDY=","number":244,"title":"Inserting items into barrels fails after world reload with Astral Sorcery installed","user":{"login":"tommyTT","id":3993801,"node_id":"MDQ6VXNlcjM5OTM4MDE=","avatar_url":"https://avatars3.githubusercontent.com/u/3993801?v=4","gravatar_id":"","url":"https://api.github.com/users/tommyTT","html_url":"https://github.com/tommyTT","followers_url":"https://api.github.com/users/tommyTT/followers","following_url":"https://api.github.com/users/tommyTT/following{/other_user}","gists_url":"https://api.github.com/users/tommyTT/gists{/gist_id}","starred_url":"https://api.github.com/users/tommyTT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tommyTT/subscriptions","organizations_url":"https://api.github.com/users/tommyTT/orgs","repos_url":"https://api.github.com/users/tommyTT/repos","events_url":"https://api.github.com/users/tommyTT/events{/privacy}","received_events_url":"https://api.github.com/users/tommyTT/received_events","type":"User","site_admin":false},"labels":[{"id":292959318,"node_id":"MDU6TGFiZWwyOTI5NTkzMTg=","url":"https://api.github.com/repos/CharsetMC/Charset/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-06-30T14:48:02Z","updated_at":"2018-06-30T17:12:42Z","closed_at":null,"author_association":"NONE","body":"## Bug \r\nAs we discussed in my other bug report, I had trouble with the barrels \"sometimes\" not accepting items. I now was able to reliably reproduce it, It's a problem with the serialization of the Barrel TileEntity that shows up if e.g. Astral Sorcery (tested with version 1.12.2-1.9.1) is present and attaches forge capabilities. This is very similar to #243 that is already fixed.\r\n\r\n## Steps to reproduce\r\n1. Put down a barrel and insert more than 2 Stacks of items (>127 items), e.g. stone. \r\n2. Log out of the world and log back in. \r\n3. Try inserting more stone in the barrel. \r\n\r\nThe barrel won't accept the additional items. You can even take out some items from the barrel and you're not able to put them back again. You can only insert items into the barrel once it is empty.\r\n\r\n## Versions\r\nMinecraft: 1.12.2\r\nForge: 1.12.2-14.23.4.2703\r\nCharset: Latest dev version from git.asie.pl (Revision: e9028959812eb77569521c0c0976fec34ace38db)\r\nAstral Sorcery: 1.12.2-1.9.1 (added through libs folder in dev environment)\r\n\r\n## Diagnosis\r\nWhen trying to insert the items, the current item stack representing the barrel content is compared to the item stack that should be inserted into the barrel. This includes a [compatibility check](https://git.asie.pl/asie-minecraft/Charset/src/branch/1.12/src/main/java/pl/asie/charset/lib/utils/ItemUtils.java#L177) for the attached forge capabilities. In this case the check fails because the two item stacks have different capabilities after a world reload. The item stack representing the content of the barrel has the Astral Sorcery AmuletHolderCapability, the item stack from the player inventory doesn't have that capability.\r\n\r\nThe problem occurs during [deserialization](https://git.asie.pl/asie-minecraft/Charset/src/branch/1.12/src/main/java/pl/asie/charset/module/storage/barrels/TileEntityDayBarrel.java#L242) when the new ItemStack is constructed from the serialized NBT data. The [serialization ](https://git.asie.pl/asie-minecraft/Charset/src/branch/1.12/src/main/java/pl/asie/charset/module/storage/barrels/TileEntityDayBarrel.java#L328) of the Barrel TileEntity wrote the entire item stack including the item count to the NBT tag. This causes a similar problem to #243 because on deserialization from the NBT tag the item stack can temporarily have a negative item count (byte overflow). The constructor for the ItemStack calls the forge event to attach all capabilities, so when the Astral Sorcery one is asked it checks the item stack and because of the negative count the isEmpty method returns true. In that case the Astral Sorcery capability is attached (which is a bit questionable in my opinion and I will report it to the AS devs) and the item stacks that you can retrieve in the world (without the AS capability) no longer matches."},"comment":{"url":"https://api.github.com/repos/CharsetMC/Charset/issues/comments/401554163","html_url":"https://github.com/CharsetMC/Charset/issues/244#issuecomment-401554163","issue_url":"https://api.github.com/repos/CharsetMC/Charset/issues/244","id":401554163,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMTU1NDE2Mw==","user":{"login":"tommyTT","id":3993801,"node_id":"MDQ6VXNlcjM5OTM4MDE=","avatar_url":"https://avatars3.githubusercontent.com/u/3993801?v=4","gravatar_id":"","url":"https://api.github.com/users/tommyTT","html_url":"https://github.com/tommyTT","followers_url":"https://api.github.com/users/tommyTT/followers","following_url":"https://api.github.com/users/tommyTT/following{/other_user}","gists_url":"https://api.github.com/users/tommyTT/gists{/gist_id}","starred_url":"https://api.github.com/users/tommyTT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tommyTT/subscriptions","organizations_url":"https://api.github.com/users/tommyTT/orgs","repos_url":"https://api.github.com/users/tommyTT/repos","events_url":"https://api.github.com/users/tommyTT/events{/privacy}","received_events_url":"https://api.github.com/users/tommyTT/received_events","type":"User","site_admin":false},"created_at":"2018-06-30T17:12:42Z","updated_at":"2018-06-30T17:12:42Z","author_association":"NONE","body":"Looks good, I can't reproduce the bug any more. It works. Thank you!"}}
{"actor":{"display_login":"tommyTT"}}