GlowstoneMC / Glowstone-Legacy

An open-source server for the Bukkit Minecraft modding interface
Other
363 stars 122 forks source link

Cacti hurt when hugged #550

Closed jaredStef closed 9 years ago

jaredStef commented 9 years ago

I added a method called canTakeCactusHurt. In the living entity class it always returns true because obviously animals aren't immune to cacti. In the GlowHumanEnity class I overrode the method so it returns true if the player is in survival mode or adventure mode. In the living entity class there is a method called takeCactusDamage. It gets the block the player is standing on as well as the blocks 1 up on each side. If they are cacti and the player canTakeCactiDamage() it hurts them. In the livingEntity class I add an else clause so that if the no damage ticks aren't greater than zero they are reset so that the player can take damage again. Aaron helped me get set up and helped with the some of the logic.

jaredStef commented 9 years ago

I just removed the whitespace in a recent commit. (the one you can see above)

dequis commented 9 years ago

+1 for hugs.

jaredStef commented 9 years ago

You can stand near the corner of cacti and not get hurt because the radius is a square but Im working on that...

dequis commented 9 years ago

Some generic method to detect hugging would be nice.

jaredStef commented 9 years ago

What would be the purpose of that other than for cacti? Its not hard and seems like a good idea, but I honestly don't see any other use cases.

turt2live commented 9 years ago

Futurrrreee

sent from mobile On Nov 16, 2014 6:56 PM, "BigxMac" notifications@github.com wrote:

What would be the purpose of that other than for cacti?

— Reply to this email directly or view it on GitHub https://github.com/GlowstoneMC/Glowstone/pull/550#issuecomment-63251506.

jaredStef commented 9 years ago

I guess I could see people wanting to make custom blocks or mini games or things. 1 commit later... Hmm thinking of a method name...

jaredStef commented 9 years ago

I got suffocation working as well but thats for another PR and branch...

jaredStef commented 9 years ago

whoops :( didn't mean to close it (clicked wrong button)

dequis commented 9 years ago

I was thinking something along the lines of isPlayerHuggingMaterial, separating it from the damage checks. Also, while i'm a fan of hugs, that might not be the best name for it.

edit: this isn't just players - isHuggingMaterial or maybe isTouchingMaterial or whatever.

ZephireNZ commented 9 years ago

I prefer 'touching' to 'hugging'. Hugging is ok, but it seems very 'cutesy' more than anything.

dequis commented 9 years ago

Note that hugs are a vanilla feature, see the footer of this page for more details

jaredStef commented 9 years ago

lol It can be called whatever. I thought I'd add some flavor and call it hugs but if the majority doesn't want hugs I guess they won't get any lol

PaulBGD commented 9 years ago

+1 for not trying to redo logic in the damage method

Tonodus commented 9 years ago

You should move isTouchingMaterial up to GlowEntity instead of LivingEntity.

jaredStef commented 9 years ago

Note: The cactus damage won't be as accurate as it would be in vanilla because I can't make it that precise until entity support is finished. In vanilla it looks at the bounding box.

ZephireNZ commented 9 years ago

Maybe put a TODO, so we know to go back to it once entities are implemented?

On 18 November 2014 11:02, BigxMac notifications@github.com wrote:

Note: The cactus damage won't be as accurate as it would be in vanilla because I can't make it that precise until entity support is finished. In vanilla it looks at the bounding box.

Reply to this email directly or view it on GitHub https://github.com/GlowstoneMC/Glowstone/pull/550#issuecomment-63384352.

jaredStef commented 9 years ago

I did.

jaredStef commented 9 years ago

I'll get on it

jaredStef commented 9 years ago

Why would I call super because I don't always want to return true I only want to do it if they are in adventure or survival, but I want all living entities such as animals to take damage

turt2live commented 9 years ago

Because later there will be other reasons why a player (or any entity for that matter) cannot take damage, including invulnerability. A simple check of super.canTakeDamage() && (adventure || survival) should be fine.

turt2live commented 9 years ago

Cacti hugging kill timer is inaccurate. It should damage 1 point every half second or so (1 point for every 10 ticks). I don't know the actual numbers, I'm just guessing based off of a quick test on vanilla.

Aaron1011 commented 9 years ago

I'm found a couple bugs:

None of the detection is going to be perfect without entity hitbox support, but being damaged on a diangonal block currently looks even weirder than on a non-diagonal block.

turt2live commented 9 years ago

@Aaron1011 The "weird" bounding box problem is not a bug. Because of the lack of true bounding boxes, it is perfectly expected (and desired) to have the behaviour you've mentioned.

Aaron1011 commented 9 years ago

I know, I stated that in my comment. But if you want to keep it that way for now, it's fine.

turt2live commented 9 years ago

And I'm responding to let the author know that the issue is perfectly valid and does not (and should not) need a fix by any means.

Aaron1011 commented 9 years ago

Okay, then.

jaredStef commented 9 years ago

I'm kinda a perfectionist and I personally hate the fact its not perfect, but I guess it will have to do for now. In the future it shouldn't be too hard to fix because all you have to do is change one method. I added a todo comment also that its not finished. I'm going to submit another PR for suffocation and work on other damages stated in Issue #203

jaredStef commented 9 years ago

I'm not being impatient or anything but I was wondering why my PR hasn't been merged yet. I have 2 more (void damage, and suffocation) I would like to submit, but I cant because they depend on this.

turt2live commented 9 years ago

The secondary review process is lengthy and the assigned reviewer has been busy for the last few weeks. It is currently on the list of things to do along with many other things.

jaredStef commented 9 years ago

ok :+1:

SpaceManiac commented 9 years ago

Merged in aaa3e8ab224adbdedc5beac2ded8565d3b5d6fa0. Wanted to get the bounding box stuff working because I felt the incredibly large damage zone wasn't working out.