-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a97bfc7
commit af94732
Showing
4 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/net/neoforged/neoforge/event/level/ExplosionKnockbackEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright (c) NeoForged and contributors | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
|
||
package net.neoforged.neoforge.event.level; | ||
|
||
import java.util.List; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.level.Explosion; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.phys.Vec3; | ||
import net.neoforged.bus.api.ICancellableEvent; | ||
import net.neoforged.neoforge.common.NeoForge; | ||
|
||
/** | ||
* ExplosionKnockbackEvent is fired once the explosion has calculated the knockback velocity to add to the entity caught in blast.<br> | ||
* <br> | ||
* This event is not {@link ICancellableEvent}.<br> | ||
* This event does not use {@link HasResult}.<br> | ||
* This event is fired on the {@link NeoForge#EVENT_BUS}.<br> | ||
*/ | ||
public class ExplosionKnockbackEvent extends ExplosionEvent { | ||
private final Entity entity; | ||
private Vec3 knockbackVelocity; | ||
|
||
public ExplosionKnockbackEvent(Level level, Explosion explosion, Entity entity, Vec3 knockbackVelocity) { | ||
super(level, explosion); | ||
this.entity = entity; | ||
this.knockbackVelocity = knockbackVelocity; | ||
} | ||
|
||
/** return the list of blocks affected by the explosion. */ | ||
public List<BlockPos> getAffectedBlocks() { | ||
return getExplosion().getToBlow(); | ||
} | ||
|
||
/** return the entity affected by the explosion knockback. */ | ||
public Entity getAffectedEntity() { | ||
return entity; | ||
} | ||
|
||
/** return the explosion knockback velocity to apply to entity. */ | ||
public Vec3 getKnockbackVelocity() { | ||
return knockbackVelocity; | ||
} | ||
|
||
/** Sets the explosion knockback velocity to add to the entity's existing velocity. */ | ||
public void setKnockbackVelocity(Vec3 newKnockbackVelocity) { | ||
this.knockbackVelocity = newKnockbackVelocity; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters