-
Notifications
You must be signed in to change notification settings - Fork 187
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
Fix for issue #1217 (dig spell evaporating TE machines) #1239
Conversation
I had this implementation before - it caused certain blocks to drop double due to the multiple function calls around breaking/harvesting. I don't remember which ones but I know they had tile entities. This will need to be tested on all vanilla/AM2 blocks with a tile entity before it can be merged in, to ensure that issue is not still present. |
I've just finished testing vanilla tile entitied blocks in my full modded setup. Unless otherwise stated, I used a projectile dig spell with fortune 3 and interact with non-solid blocks. -Beacon (unlit/lit): Normal behaviour in both cases (drops 1 beacon) Vanilla seems to be fine - no duplication or missing items. I'll take a look at AM2 blocks later on. |
Also drops the crafting size upgrade, if installed.
Here are the results of testing on AM2 blocks (this is in a pure AM2 dev environment, not my full modded setup). Testing was again done using projectile dig spells with interact non-solid blocks and either fortune 3 or silk touch. Comparison was done against using a non-enchanted diamond pickaxe or axe, whichever was appropriate for the block in question. I found a few unrelated bugs while testing - some of which were minor and were fixed, others requiring more attention were not fixed here because they fall outside the scope of these changes (making the dig spell work properly). One of them is pretty serious (client crash when breaking an active calefactor... but not if you use a spell to do it) -Arcane Deconstructor (empty/full): No duplication of dropped items, but the keystone seems to have absolutely no effect on usage or breaking. This seems to be caused by the inventory slots for keystone runes being assigned improperly and has been fixed. Works fine after that.
Interestingly enough, a dig spell works perfectly. Perhaps it's something to do with the block break animation? This exact same error has already been found in issue #1207, though the given steps to replicate it are incorrect - I can interact with a running calefactor, I just can't use a pickaxe on it. While crashing like this is a definite problem, it's outside the scope of this pull request and needs separate attention. -Warding Candle: breaks as normal. My workaround was to hook the onBlockHarvested function in BlockKeystoneChest.java and explicitly zero out the runes if the breaking player has access. This resets it to the default behaviour and it drops the chest along with its contents if you have the correct keystone. If you don't, diamond axes and dig spells just bounce right off it. This was not directly related to the dig spell, but the fix was short, it was an obvious bug and I therefore may as well add it in to the pull request. -Keystone Door: Works fine. |
The power link blocks are in fact destroyed when replaced with a block, however the moment there is not a block there anymore it will be re-created (as the power system is still trying to find a link through that point and failing). This is the intended behaviour. The block is meant to be an information block that appears when there's a broken link in the power system (ie a creeper blows out a conduit) so you can find out where it was and rebuild it. At the same time, they're designed to not hinder building in any way (especially when invisible). The Spell-Sealed door I designed during a livestream, though it appears some of the code was also lost in the same event that caused my other problems. Basically it's a door where you can put a spell in the UI, and casting that same spell on the door is the only way to open it. Without a spell in the "lock", it should function like a normal door. At least that was the goal, anyway. The Particle Emitter shouldn't be targeted by the dig spell if it's invisible - that's a bug, likely in the raytrace. |
Amendment: |
OK. Should an invisible particle emitter be completely unbreakable by players (through whatever means, be it AoE dig spells/Tinker hammers/quarries/whatever) or just immune to spells? If it's the former, I'll put a general "don't break this block if invisible" check in the main block class and if the latter, I'll put a special case check in the dig spell. |
I would say if invisible == can't break, period. |
Done. Invisible particle emitters can no longer be broken by players, though I noticed 2 more things while testing it: 1) the invisible emitter will still stop spell projectiles which have the "interact with non-solid blocks" modifier, 2) you can still right-click on invisible emitters (empty-handed) if you know where they are to bring up their GUI. Intended, or not? |
Neither of those are intended - with the exception of actually spawning the particles, and preventing other blocks from being placed there, no interaction with the particle emitter should be possible while it's invisible. |
So far, I've managed to stop projectiles and explosions from doing anything to invisible emitters, but preventing right-click interactions is pretty hard. What happens is that when you right-click on the invisible emitter, it turns visible and stops emitting particles. At that point, you can "break" it with a single hit - but this is client-side only and the dead emitter will return if you try to place another block over the top. You are also able to open the GUI at that point and make changes. Removing everything in onBlockActivated and just telling it to return false still causes the particle emitter to re-appear client-side and stop emitting particles, even though nothing should be happening. It seems to be some kind of client-server desync issue, since if you exit to the main menu and reload the world, the particles return and the emitter turns invisible again. I cannot figure out what is causing this. Any ideas? |
Might be something to do with the tile entity - check the Update() function or see if SetShow() is being called when it shouldn't. |
No luck there either. Whatever kind of server-client desync is going on, it happens when you right-click on an adjacent block to the invisible emitter. I do have a solution of sorts - by hooking PlayerInteractEvent, I'm now blocking every right or left-click on a block if there's an invisible particle emitter attached to the facing of that block. Since it's a client-server desync issue, only hooking that event on the client-side seems to be functional (thus reducing server overhead). To make it easier on users, I've also moved the functionality which saved and loaded emitter settings to the crystal wrench's alternate mode, so you don't have to keep taking out your crystal wrench to reveal invisible emitters and then putting it away to modify them. One flaw with my solution here is that you are no longer able to use machines or break blocks directly (magic and AoE tools are still effective) which are hidden behind an invisible particle emitter. Finally, I noticed another issue whilst testing this. Invisible particle emitters aren't invisible if you load in right next to them. You can see their outline, but you can't interact with them. They turn invisible if you cause a block update next to them, pull out a crystal wrench and then put it away, or change the settings on another emitter nearby. In conclusion: it works, but it's not pretty. |
And since I'm not entirely sure how to synchronise files I haven't changed with the master fork, this pull request might try to eat the changes you made to EntitySpellProjectile. I've manually stuck the current version of EntitySpellProjectile.java into my fork and branch, but it still thinks that something's changed. Keep an eye out if you do merge it... |
Sync with master branch
Ignore the previous post, everything's now synchronised. |
Notifications for non-matching keystones have been added to this branch as well. |
Fix for issue #1217 (dig spell evaporating TE machines)
Sticking a compiled and re-obfuscated version of the 009 dev build into my full modded setup for further testing, I was able to replicate issue #1217 (dig spells evaporate TE machines) on Thermal Expansion machines, ComputerCraft computers and Project Red frame motors - the spell hits and the block just vanishes into thin air, dropping nothing.
Since the actual effect code in Dig.java seems to be a re-implementation of tryHarvestBlock() in the vanilla ItemInWorldManager.java class with some additional checks tacked on for the magic parts, my approach was to trace back what the vanilla function does and start adding subroutine calls into the Dig spell's effect code until things started working again.
I've tested this modified version on TE machines and diamond ore - fortune, silk touch and unmodified spells all behave as would be expected.