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

Fixed error when spawning non-mob entities in a peaceful world #123

Merged
merged 2 commits into from Mar 10, 2015

Conversation

36451
Copy link
Contributor

@36451 36451 commented Mar 9, 2015

Added cavespiders to the peaceful blocklist
Resolves some errors from this thread:
https://forum.cuberite.org/thread-1828.html

@36451 36451 changed the title Fixed error when throwing exp bottles in a peaceful world Fixed error when spawning non-mob entities in a peaceful world Mar 9, 2015
tigerw added a commit that referenced this pull request Mar 10, 2015
Fixed error when spawning non-mob entities in a peaceful world
@tigerw tigerw merged commit 12826af into cuberite:master Mar 10, 2015
@madmaxoft
Copy link
Member

I wonder, why do you check Ent:IsMob() == true? If the it isn't a mob, it still has a GetClass() function, so the line inside the if will not cause any trouble, and in Lua you can use any index in a table, if the item doesn't exist, you get a nil (which is handled pretty much same as false in conditionals)

@madmaxoft
Copy link
Member

Actually, this code is full of WTFs: why cast a cEntity object to a cEntity? (line 98). Also, if the cast failed somehow, the Ent variable would become nil and thus the condition on the next line will cause a runtime error in the script.

@36451
Copy link
Contributor Author

36451 commented Mar 10, 2015

The issue (as i understand it) seems to be that we sometimes get cExpBottleEntity / cArrowEntity instead of cEntity, and that causes some weird problems with Entity:GetClass().
And i added the ismob as an additional safeguard.

This might be a workaround instead of a bugfix.
Where bugfix could require modification to the server sourcecode.

@NiLSPACE
Copy link
Member

But cExpBottleEntity and cArrowEntity are a cEntity, so that shouldn't be the problem.

@36451
Copy link
Contributor Author

36451 commented Mar 10, 2015

Seems so. Still,

 [15:21:46] LUA: Plugins/Core/difficulties.lua:98: error in function 'GetClass'.
     argument #1 is 'cExpBottleEntity'; 'const cEntity' expected.

[15:21:46] Stack trace:
[15:21:46]   [C](-1): GetClass
[15:21:46]   Plugins/Core/difficulties.lua(98): (no name)
[15:21:46] Stack trace end
[15:21:46] Error in plugin Core calling function <callback>()

@NiLSPACE
Copy link
Member

That should only be a problem if you would have used tolua.type(Entity)

@madmaxoft
Copy link
Member

I think there's a problem with how ToLua handles class inheritance and const functions. Definitely an API problem, though, not a Core one.

@36451
Copy link
Contributor Author

36451 commented Mar 10, 2015

I think we can leave this until the API is fixed.
In the meantime i'll start hunting for that particular bug.

@36451
Copy link
Contributor Author

36451 commented Mar 10, 2015

cExpOrb is an extension of the cEntity, whereas cArrow and cExpBottle are extensions of cProjectileEntity, which is extending cEntity.
(It works only for direct descendants?)

36451 added a commit to 36451/Core that referenced this pull request Mar 19, 2015
madmaxoft added a commit that referenced this pull request Mar 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants