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

Crash with Minecraft Comes Alive + Spikes #203

Open
glarmer opened this issue Jun 2, 2023 · 0 comments
Open

Crash with Minecraft Comes Alive + Spikes #203

glarmer opened this issue Jun 2, 2023 · 0 comments

Comments

@glarmer
Copy link

glarmer commented Jun 2, 2023

Description:
When a Minecraft Comes Alive entity comes into collision with a gold or diamond spike there is an error as they can not be cast to FakePlayerEntity. The end result is a crash.

Exception can be seen here:
https://pastebin.com/WtMu8zQN

Relevant code:
https://github.com/lucaargolo/kibe/blob/1.19/src/main/kotlin/io/github/lucaargolo/kibe/blocks/miscellaneous/Spikes.kt

override fun onEntityCollision(state: BlockState, world: World, pos: BlockPos, entity: Entity) {
    if(!world.isClient && entity is LivingEntity) {
        SpikeHelper.setSpike(entity, type)
        when(type) {
            Type.IRON, Type.STONE -> entity.damage(DamageSource.GENERIC, type.damage)
            Type.GOLD, Type.DIAMOND -> entity.damage(DamageSource.player(FakePlayerEntity(world)), type.damage)
        }
        SpikeHelper.setSpike(entity, null)
    }
}

Temp fix:
As a temporary fix I surrounded the erroring code in a try catch and just made it do the IRON/STONE damage method where no cast is used. This prevents any crashes at the very least.

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

No branches or pull requests

1 participant