-
Notifications
You must be signed in to change notification settings - Fork 9
Add support for falling blocks #520
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
base: master
Are you sure you want to change the base?
Conversation
pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/block/base/PylonFallingBlock.kt
Outdated
Show resolved
Hide resolved
pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/block/base/PylonFallingBlock.kt
Show resolved
Hide resolved
pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/block/base/PylonFallingBlock.kt
Outdated
Show resolved
Hide resolved
pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/block/BlockStorage.kt
Outdated
Show resolved
Hide resolved
LordIdra
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, generally happy with how this is implemented
pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/block/base/PylonFallingBlock.kt
Show resolved
Hide resolved
pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/block/BlockStorage.kt
Outdated
Show resolved
Hide resolved
pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/block/BlockStorage.kt
Show resolved
Hide resolved
pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/block/BlockStorage.kt
Outdated
Show resolved
Hide resolved
pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/block/PylonBlock.kt
Show resolved
Hide resolved
pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/block/base/PylonFallingBlock.kt
Show resolved
Hide resolved
pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/block/base/PylonFallingBlock.kt
Outdated
Show resolved
Hide resolved
Seggan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can confirm it (somehow) works over server restarts
pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/block/base/PylonFallingBlock.kt
Outdated
Show resolved
Hide resolved
pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/block/base/PylonFallingBlock.kt
Outdated
Show resolved
Hide resolved
pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/block/BlockListener.kt
Outdated
Show resolved
Hide resolved
OhmV-IR
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM CW
| @EventHandler(ignoreCancelled = true) | ||
| private fun fallingBlockDrop(event: EntityDropItemEvent) { | ||
| val entity = event.entity | ||
|
|
||
| if (entity !is FallingBlock) return | ||
|
|
||
| val blockSchema = fallMap[entity.uniqueId] ?: return | ||
| val relativeItem = PylonRegistry.ITEMS[blockSchema.key] | ||
| fallMap.remove(entity.uniqueId) | ||
| if (relativeItem == null) { | ||
| event.isCancelled = true | ||
| return | ||
| } | ||
|
|
||
| event.itemDrop.itemStack = relativeItem.getItemStack() | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the whole fallMap system I think should be replaced. Not all falling blocks always drop an item (like anvils for example) or they change state when landing & dropping items (again anvils)
I think the item drop should come from a method of PylonFallingBlock (have it default to the item sure but), and it should be a method call for onDropItem instead of putting all of the logic here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the whole fallMap system I think should be replaced. Not all falling blocks always drop an item (like anvils for example) or they change state when landing & dropping items (again anvils)
There is little i can do about that, there is no way to know if a falling block will drop items or change state, and i won't make a map for each specific case, unless you have a better idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I misunderstood fall map and you misunderstood my comment. The onDropItem was all I really needed I just thought we could get rid of fallMap but now assuming I've understood you need it because the entity drops the item after it's been removed? So entity storage doesn't track it anymore even though it's still being used in code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes exactly
No description provided.