Skip to content

Commit 855c2d6

Browse files
authored
Merge pull request #283 from toxicity188/codex/implement-hitboxevent-interface-and-refactor
Codex-generated pull request
2 parents 3c3a323 + 01ca531 commit 855c2d6

File tree

18 files changed

+427
-335
lines changed

18 files changed

+427
-335
lines changed

api/src/main/java/kr/toxicity/model/api/event/ModelInteractAtEvent.java

Lines changed: 0 additions & 33 deletions
This file was deleted.

api/src/main/java/kr/toxicity/model/api/event/ModelDamagedEvent.java renamed to api/src/main/java/kr/toxicity/model/api/event/hitbox/HitBoxDamagedEvent.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
* Licensed under the MIT License.
55
* See LICENSE.md file for full license text.
66
*/
7-
package kr.toxicity.model.api.event;
7+
package kr.toxicity.model.api.event.hitbox;
88

9+
import kr.toxicity.model.api.event.CancellableEvent;
10+
import kr.toxicity.model.api.event.ModelDamageSource;
911
import kr.toxicity.model.api.nms.HitBox;
1012
import lombok.Getter;
1113
import lombok.Setter;
@@ -22,7 +24,7 @@
2224
*/
2325
@Getter
2426
@Setter
25-
public final class ModelDamagedEvent implements CancellableEvent {
27+
public final class HitBoxDamagedEvent implements CancellableEvent, HitBoxEvent {
2628

2729
private final @NotNull HitBox hitBox;
2830
private final ModelDamageSource source;
@@ -39,7 +41,7 @@ public final class ModelDamagedEvent implements CancellableEvent {
3941
* @since 2.0.0
4042
*/
4143
@ApiStatus.Internal
42-
public ModelDamagedEvent(@NotNull HitBox hitBox, @NotNull ModelDamageSource source, float damage) {
44+
public HitBoxDamagedEvent(@NotNull HitBox hitBox, @NotNull ModelDamageSource source, float damage) {
4345
this.hitBox = hitBox;
4446
this.source = source;
4547
this.damage = damage;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* This source file is part of BetterModel.
3+
* Copyright (c) 2024–2026 toxicity188
4+
* Licensed under the MIT License.
5+
* See LICENSE.md file for full license text.
6+
*/
7+
package kr.toxicity.model.api.event.hitbox;
8+
9+
import kr.toxicity.model.api.nms.HitBox;
10+
import kr.toxicity.model.api.platform.PlatformEntity;
11+
import org.jetbrains.annotations.NotNull;
12+
13+
/**
14+
* An event called when an entity dismounts from a hit box.
15+
*
16+
* @param hitBox the hit box
17+
* @param entity the entity
18+
* @since 2.1.0
19+
*/
20+
public record HitBoxDismountEvent(@NotNull HitBox hitBox, @NotNull PlatformEntity entity) implements HitBoxEvent {
21+
@Override
22+
public @NotNull HitBox getHitBox() {
23+
return hitBox;
24+
}
25+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* This source file is part of BetterModel.
3+
* Copyright (c) 2024–2026 toxicity188
4+
* Licensed under the MIT License.
5+
* See LICENSE.md file for full license text.
6+
*/
7+
package kr.toxicity.model.api.event.hitbox;
8+
9+
import kr.toxicity.model.api.event.ModelEvent;
10+
import kr.toxicity.model.api.nms.HitBox;
11+
import org.jetbrains.annotations.NotNull;
12+
13+
/**
14+
* Base contract for events associated with a {@link HitBox}.
15+
*
16+
* @since 2.1.0
17+
*/
18+
public interface HitBoxEvent extends ModelEvent {
19+
20+
/**
21+
* Returns the target hitbox of this event.
22+
*
23+
* @return target hitbox
24+
* @since 2.1.0
25+
*/
26+
@NotNull HitBox getHitBox();
27+
}
28+
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* This source file is part of BetterModel.
3+
* Copyright (c) 2024–2026 toxicity188
4+
* Licensed under the MIT License.
5+
* See LICENSE.md file for full license text.
6+
*/
7+
package kr.toxicity.model.api.event.hitbox;
8+
9+
import kr.toxicity.model.api.event.CancellableEvent;
10+
import kr.toxicity.model.api.nms.HitBox;
11+
import kr.toxicity.model.api.nms.ModelInteractionHand;
12+
import kr.toxicity.model.api.platform.PlatformPlayer;
13+
import lombok.Getter;
14+
import lombok.Setter;
15+
import org.jetbrains.annotations.ApiStatus;
16+
import org.jetbrains.annotations.NotNull;
17+
import org.joml.Vector3f;
18+
19+
/**
20+
* Triggered when a player interacts with a model's hitbox at some position.
21+
* <p>
22+
* This event corresponds to a right-click interaction.
23+
* </p>
24+
*
25+
* @since 2.0.0
26+
*/
27+
@Getter
28+
public class HitBoxInteractAtEvent implements CancellableEvent, HitBoxEvent {
29+
30+
@Setter
31+
private boolean cancelled;
32+
private final PlatformPlayer who;
33+
private final @NotNull HitBox hitBox;
34+
private final @NotNull ModelInteractionHand hand;
35+
private final @NotNull Vector3f position;
36+
37+
/**
38+
* Creates a new HitBoxInteractAtEvent.
39+
*
40+
* @param who the player interacting
41+
* @param hitBox the hitbox being interacted with
42+
* @param hand the hand used for interaction
43+
* @param position position
44+
* @since 2.0.0
45+
*/
46+
@ApiStatus.Internal
47+
public HitBoxInteractAtEvent(@NotNull PlatformPlayer who, @NotNull HitBox hitBox, @NotNull ModelInteractionHand hand, @NotNull Vector3f position) {
48+
this.who = who;
49+
this.hitBox = hitBox;
50+
this.hand = hand;
51+
this.position = position;
52+
}
53+
}

api/src/main/java/kr/toxicity/model/api/event/ModelInteractEvent.java renamed to api/src/main/java/kr/toxicity/model/api/event/hitbox/HitBoxInteractEvent.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
* Licensed under the MIT License.
55
* See LICENSE.md file for full license text.
66
*/
7-
package kr.toxicity.model.api.event;
7+
package kr.toxicity.model.api.event.hitbox;
88

9+
import kr.toxicity.model.api.event.CancellableEvent;
910
import kr.toxicity.model.api.nms.HitBox;
1011
import kr.toxicity.model.api.nms.ModelInteractionHand;
1112
import kr.toxicity.model.api.platform.PlatformPlayer;
@@ -23,26 +24,26 @@
2324
* @since 2.0.0
2425
*/
2526
@Getter
26-
public class ModelInteractEvent implements CancellableEvent {
27+
public class HitBoxInteractEvent implements CancellableEvent, HitBoxEvent {
2728

2829
@Setter
2930
private boolean cancelled;
3031
private final PlatformPlayer who;
31-
private final @NotNull HitBox hitbox;
32+
private final @NotNull HitBox hitBox;
3233
private final @NotNull ModelInteractionHand hand;
3334

3435
/**
35-
* Creates a new ModelInteractEvent.
36+
* Creates a new HitBoxInteractEvent.
3637
*
3738
* @param who the player interacting
38-
* @param hitbox the hitbox being interacted with
39+
* @param hitBox the hitbox being interacted with
3940
* @param hand the hand used for interaction
4041
* @since 2.0.0
4142
*/
4243
@ApiStatus.Internal
43-
public ModelInteractEvent(@NotNull PlatformPlayer who, @NotNull HitBox hitbox, @NotNull ModelInteractionHand hand) {
44+
public HitBoxInteractEvent(@NotNull PlatformPlayer who, @NotNull HitBox hitBox, @NotNull ModelInteractionHand hand) {
4445
this.who = who;
45-
this.hitbox = hitbox;
46+
this.hitBox = hitBox;
4647
this.hand = hand;
4748
}
4849
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* This source file is part of BetterModel.
3+
* Copyright (c) 2024–2026 toxicity188
4+
* Licensed under the MIT License.
5+
* See LICENSE.md file for full license text.
6+
*/
7+
package kr.toxicity.model.api.event.hitbox;
8+
9+
import kr.toxicity.model.api.nms.HitBox;
10+
import kr.toxicity.model.api.platform.PlatformEntity;
11+
import org.jetbrains.annotations.NotNull;
12+
13+
/**
14+
* An event called when an entity mounts to a hit box.
15+
*
16+
* @param hitBox the hit box
17+
* @param entity the entity
18+
* @since 2.1.0
19+
*/
20+
public record HitBoxMountEvent(@NotNull HitBox hitBox, @NotNull PlatformEntity entity) implements HitBoxEvent {
21+
@Override
22+
public @NotNull HitBox getHitBox() {
23+
return hitBox;
24+
}
25+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* This source file is part of BetterModel.
3+
* Copyright (c) 2024–2026 toxicity188
4+
* Licensed under the MIT License.
5+
* See LICENSE.md file for full license text.
6+
*/
7+
package kr.toxicity.model.api.event.hitbox;
8+
9+
import kr.toxicity.model.api.nms.HitBox;
10+
import org.jetbrains.annotations.NotNull;
11+
12+
/**
13+
* Triggered when a hitbox is removed.
14+
*
15+
* @param hitBox removed hitbox
16+
* @since 2.1.0
17+
*/
18+
public record HitBoxRemoveEvent(@NotNull HitBox hitBox) implements HitBoxEvent {
19+
20+
/**
21+
* Returns the removed hitbox.
22+
*
23+
* @return removed hitbox
24+
* @since 2.1.0
25+
*/
26+
@Override
27+
public @NotNull HitBox getHitBox() {
28+
return hitBox;
29+
}
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* This source file is part of BetterModel.
3+
* Copyright (c) 2024–2026 toxicity188
4+
* Licensed under the MIT License.
5+
* See LICENSE.md file for full license text.
6+
*/
7+
package kr.toxicity.model.api.event.hitbox;
8+
9+
import kr.toxicity.model.api.nms.HitBox;
10+
import org.jetbrains.annotations.NotNull;
11+
12+
/**
13+
* Triggered when a hitbox is synchronized.
14+
*
15+
* @param hitBox synchronized hitbox
16+
* @since 2.1.0
17+
*/
18+
public record HitBoxSyncEvent(@NotNull HitBox hitBox) implements HitBoxEvent {
19+
20+
/**
21+
* Returns the synchronized hitbox.
22+
*
23+
* @return synchronized hitbox
24+
* @since 2.1.0
25+
*/
26+
@Override
27+
public @NotNull HitBox getHitBox() {
28+
return hitBox;
29+
}
30+
}

0 commit comments

Comments
 (0)