Skip to content

Commit 42b6218

Browse files
committed
fix: invalid type inference of compiler (#245)
1 parent fecb5a6 commit 42b6218

File tree

14 files changed

+251
-18
lines changed

14 files changed

+251
-18
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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.nms.v1_20_R4;
8+
9+
import kr.toxicity.model.api.nms.HitBox;
10+
import net.minecraft.world.entity.EntityType;
11+
import net.minecraft.world.entity.decoration.ArmorStand;
12+
import net.minecraft.world.level.Level;
13+
import org.jetbrains.annotations.NotNull;
14+
import org.jetbrains.annotations.Nullable;
15+
16+
public abstract class AbstractHitBox extends ArmorStand implements HitBox {
17+
18+
AbstractHitBox(@NotNull Level level) {
19+
super(EntityType.ARMOR_STAND, level);
20+
}
21+
22+
@Override //Only for provide compiler hint for Kotlin jvm
23+
public final boolean equals(@Nullable Object other) {
24+
return super.equals(other);
25+
}
26+
27+
@Override //Only for provide compiler hint for Kotlin jvm
28+
public final int hashCode() {
29+
return super.hashCode();
30+
}
31+
32+
@SuppressWarnings("removal")
33+
@Override
34+
public void remove(@NotNull RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) {
35+
super.remove(reason, eventCause);
36+
}
37+
}

nms/v1_20_R4/src/main/kotlin/kr/toxicity/model/nms/v1_20_R4/HitBoxImpl.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import net.minecraft.world.damagesource.DamageSource
3131
import net.minecraft.world.effect.MobEffectInstance
3232
import net.minecraft.world.entity.*
3333
import net.minecraft.world.entity.ai.attributes.Attributes
34-
import net.minecraft.world.entity.decoration.ArmorStand
3534
import net.minecraft.world.entity.player.Player
3635
import net.minecraft.world.entity.projectile.Projectile
3736
import net.minecraft.world.entity.projectile.ProjectileDeflection
@@ -60,7 +59,7 @@ internal class HitBoxImpl(
6059
private val listener: HitBoxListener,
6160
private val delegate: Entity,
6261
private var mountController: MountController
63-
) : ArmorStand(EntityType.ARMOR_STAND, delegate.level()), HitBox {
62+
) : AbstractHitBox(delegate.level()) {
6463
private var initialized = false
6564
private var jumpDelay = 0
6665
private var mounted = false
@@ -307,7 +306,7 @@ internal class HitBoxImpl(
307306
}
308307

309308
@Suppress("removal")
310-
override fun remove(reason: RemovalReason, cause: org.bukkit.event.entity.EntityRemoveEvent.Cause) {
309+
override fun remove(reason: RemovalReason, cause: org.bukkit.event.entity.EntityRemoveEvent.Cause?) {
311310
initialSetup()
312311
listener.remove(craftEntity)
313312
interaction.remove(reason)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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.nms.v1_21_R1;
8+
9+
import kr.toxicity.model.api.nms.HitBox;
10+
import net.minecraft.world.entity.EntityType;
11+
import net.minecraft.world.entity.decoration.ArmorStand;
12+
import net.minecraft.world.level.Level;
13+
import org.jetbrains.annotations.NotNull;
14+
import org.jetbrains.annotations.Nullable;
15+
16+
public abstract class AbstractHitBox extends ArmorStand implements HitBox {
17+
18+
AbstractHitBox(@NotNull Level level) {
19+
super(EntityType.ARMOR_STAND, level);
20+
}
21+
22+
@Override //Only for provide compiler hint for Kotlin jvm
23+
public final boolean equals(@Nullable Object other) {
24+
return super.equals(other);
25+
}
26+
27+
@Override //Only for provide compiler hint for Kotlin jvm
28+
public final int hashCode() {
29+
return super.hashCode();
30+
}
31+
32+
@SuppressWarnings("removal")
33+
@Override
34+
public void remove(@NotNull RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) {
35+
super.remove(reason, eventCause);
36+
}
37+
}

nms/v1_21_R1/src/main/kotlin/kr/toxicity/model/nms/v1_21_R1/HitBoxImpl.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import net.minecraft.world.damagesource.DamageSource
3030
import net.minecraft.world.effect.MobEffectInstance
3131
import net.minecraft.world.entity.*
3232
import net.minecraft.world.entity.ai.attributes.Attributes
33-
import net.minecraft.world.entity.decoration.ArmorStand
3433
import net.minecraft.world.entity.player.Player
3534
import net.minecraft.world.entity.projectile.Projectile
3635
import net.minecraft.world.entity.projectile.ProjectileDeflection
@@ -59,7 +58,7 @@ internal class HitBoxImpl(
5958
private val listener: HitBoxListener,
6059
private val delegate: Entity,
6160
private var mountController: MountController
62-
) : ArmorStand(EntityType.ARMOR_STAND, delegate.level()), HitBox {
61+
) : AbstractHitBox(delegate.level()) {
6362
private var initialized = false
6463
private var jumpDelay = 0
6564
private var mounted = false
@@ -295,7 +294,7 @@ internal class HitBoxImpl(
295294
}
296295

297296
@Suppress("removal")
298-
override fun remove(reason: RemovalReason, cause: org.bukkit.event.entity.EntityRemoveEvent.Cause) {
297+
override fun remove(reason: RemovalReason, cause: org.bukkit.event.entity.EntityRemoveEvent.Cause?) {
299298
initialSetup()
300299
listener.remove(craftEntity)
301300
interaction.remove(reason)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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.nms.v1_21_R2;
8+
9+
import kr.toxicity.model.api.nms.HitBox;
10+
import net.minecraft.world.entity.EntityType;
11+
import net.minecraft.world.entity.decoration.ArmorStand;
12+
import net.minecraft.world.level.Level;
13+
import org.jetbrains.annotations.NotNull;
14+
import org.jetbrains.annotations.Nullable;
15+
16+
public abstract class AbstractHitBox extends ArmorStand implements HitBox {
17+
18+
AbstractHitBox(@NotNull Level level) {
19+
super(EntityType.ARMOR_STAND, level);
20+
}
21+
22+
@Override //Only for provide compiler hint for Kotlin jvm
23+
public final boolean equals(@Nullable Object other) {
24+
return super.equals(other);
25+
}
26+
27+
@Override //Only for provide compiler hint for Kotlin jvm
28+
public final int hashCode() {
29+
return super.hashCode();
30+
}
31+
32+
@SuppressWarnings("removal")
33+
@Override
34+
public void remove(@NotNull RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) {
35+
super.remove(reason, eventCause);
36+
}
37+
}

nms/v1_21_R2/src/main/kotlin/kr/toxicity/model/nms/v1_21_R2/HitBoxImpl.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import net.minecraft.world.damagesource.DamageSource
3232
import net.minecraft.world.effect.MobEffectInstance
3333
import net.minecraft.world.entity.*
3434
import net.minecraft.world.entity.ai.attributes.Attributes
35-
import net.minecraft.world.entity.decoration.ArmorStand
3635
import net.minecraft.world.entity.player.Player
3736
import net.minecraft.world.entity.projectile.Projectile
3837
import net.minecraft.world.entity.projectile.ProjectileDeflection
@@ -61,7 +60,7 @@ internal class HitBoxImpl(
6160
private val listener: HitBoxListener,
6261
private val delegate: Entity,
6362
private var mountController: MountController
64-
) : ArmorStand(EntityType.ARMOR_STAND, delegate.level()), HitBox {
63+
) : AbstractHitBox(delegate.level()) {
6564
private var initialized = false
6665
private var jumpDelay = 0
6766
private var mounted = false
@@ -308,7 +307,7 @@ internal class HitBoxImpl(
308307
}
309308

310309
@Suppress("removal")
311-
override fun remove(reason: RemovalReason, cause: org.bukkit.event.entity.EntityRemoveEvent.Cause) {
310+
override fun remove(reason: RemovalReason, cause: org.bukkit.event.entity.EntityRemoveEvent.Cause?) {
312311
initialSetup()
313312
listener.remove(craftEntity)
314313
interaction.remove(reason)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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.nms.v1_21_R3;
8+
9+
import kr.toxicity.model.api.nms.HitBox;
10+
import net.minecraft.world.entity.EntityType;
11+
import net.minecraft.world.entity.decoration.ArmorStand;
12+
import net.minecraft.world.level.Level;
13+
import org.jetbrains.annotations.NotNull;
14+
import org.jetbrains.annotations.Nullable;
15+
16+
public abstract class AbstractHitBox extends ArmorStand implements HitBox {
17+
18+
AbstractHitBox(@NotNull Level level) {
19+
super(EntityType.ARMOR_STAND, level);
20+
}
21+
22+
@Override //Only for provide compiler hint for Kotlin jvm
23+
public final boolean equals(@Nullable Object other) {
24+
return super.equals(other);
25+
}
26+
27+
@Override //Only for provide compiler hint for Kotlin jvm
28+
public final int hashCode() {
29+
return super.hashCode();
30+
}
31+
32+
@Override
33+
public void remove(@NotNull RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) {
34+
super.remove(reason, eventCause);
35+
}
36+
}

nms/v1_21_R3/src/main/kotlin/kr/toxicity/model/nms/v1_21_R3/HitBoxImpl.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import net.minecraft.world.damagesource.DamageSource
3232
import net.minecraft.world.effect.MobEffectInstance
3333
import net.minecraft.world.entity.*
3434
import net.minecraft.world.entity.ai.attributes.Attributes
35-
import net.minecraft.world.entity.decoration.ArmorStand
3635
import net.minecraft.world.entity.player.Player
3736
import net.minecraft.world.entity.projectile.Projectile
3837
import net.minecraft.world.entity.projectile.ProjectileDeflection
@@ -62,7 +61,7 @@ internal class HitBoxImpl(
6261
private val listener: HitBoxListener,
6362
private val delegate: Entity,
6463
private var mountController: MountController
65-
) : ArmorStand(EntityType.ARMOR_STAND, delegate.level()), HitBox {
64+
) : AbstractHitBox(delegate.level()) {
6665
private var initialized = false
6766
private var jumpDelay = 0
6867
private var mounted = false
@@ -308,7 +307,7 @@ internal class HitBoxImpl(
308307
listener.sync(craftEntity)
309308
}
310309

311-
override fun remove(reason: RemovalReason, cause: EntityRemoveEvent.Cause) {
310+
override fun remove(reason: RemovalReason, cause: EntityRemoveEvent.Cause?) {
312311
initialSetup()
313312
listener.remove(craftEntity)
314313
interaction.remove(reason)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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.nms.v1_21_R4;
8+
9+
import kr.toxicity.model.api.nms.HitBox;
10+
import net.minecraft.world.entity.EntityType;
11+
import net.minecraft.world.entity.decoration.ArmorStand;
12+
import net.minecraft.world.level.Level;
13+
import org.jetbrains.annotations.NotNull;
14+
import org.jetbrains.annotations.Nullable;
15+
16+
public abstract class AbstractHitBox extends ArmorStand implements HitBox {
17+
18+
AbstractHitBox(@NotNull Level level) {
19+
super(EntityType.ARMOR_STAND, level);
20+
}
21+
22+
@Override //Only for provide compiler hint for Kotlin jvm
23+
public final boolean equals(@Nullable Object other) {
24+
return super.equals(other);
25+
}
26+
27+
@Override //Only for provide compiler hint for Kotlin jvm
28+
public final int hashCode() {
29+
return super.hashCode();
30+
}
31+
}

nms/v1_21_R4/src/main/kotlin/kr/toxicity/model/nms/v1_21_R4/HitBoxImpl.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import net.minecraft.world.damagesource.DamageSource
3131
import net.minecraft.world.effect.MobEffectInstance
3232
import net.minecraft.world.entity.*
3333
import net.minecraft.world.entity.ai.attributes.Attributes
34-
import net.minecraft.world.entity.decoration.ArmorStand
3534
import net.minecraft.world.entity.player.Player
3635
import net.minecraft.world.entity.projectile.Projectile
3736
import net.minecraft.world.entity.projectile.ProjectileDeflection
@@ -62,7 +61,7 @@ internal class HitBoxImpl(
6261
private val listener: HitBoxListener,
6362
private val delegate: Entity,
6463
private var mountController: MountController
65-
) : ArmorStand(EntityType.ARMOR_STAND, delegate.level()), HitBox {
64+
) : AbstractHitBox(delegate.level()) {
6665
private var initialized = false
6766
private var jumpDelay = 0
6867
private var mounted = false

0 commit comments

Comments
 (0)