-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
a736d1e
commit 70eef29
Showing
28 changed files
with
555 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
dependencies { | ||
minecraft("com.mojang:minecraft:${properties["minecraft_version"]}") | ||
mappings(loom.layered { | ||
officialMojangMappings() | ||
parchment("org.parchmentmc.data:${properties["parchment"]}") | ||
}) | ||
//Kyori | ||
modCompileOnly("net.fabricmc:fabric-loader:${properties["loader_version"]}") | ||
modCompileOnly("net.fabricmc.fabric-api:fabric-api:${properties["fabric_version"]}") | ||
modCompileOnly("net.kyori:adventure-platform-mod-shared-fabric-repack:${properties["kyori_mod_implementation"]}") | ||
modCompileOnly("net.kyori:adventure-platform-fabric:${properties["kyori_mod_implementation"]}") | ||
} | ||
|
||
loom { | ||
decompilerOptions.named("vineflower") { | ||
options.put("win", "0") | ||
} | ||
} | ||
|
||
tasks.runServer { | ||
enabled = false | ||
} |
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
12 changes: 12 additions & 0 deletions
12
api/fabric-api/src/main/java/kr/toxicity/hud/api/fabric/event/EntityEvent.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,12 @@ | ||
package kr.toxicity.hud.api.fabric.event; | ||
|
||
import net.minecraft.world.entity.LivingEntity; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Entity event | ||
* @param <T> registry type | ||
*/ | ||
public interface EntityEvent<T extends FabricEvent<?>> extends FabricEvent<T> { | ||
@NotNull LivingEntity entity(); | ||
} |
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
7 changes: 7 additions & 0 deletions
7
api/fabric-api/src/main/java/kr/toxicity/hud/api/fabric/event/FabricEvent.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,7 @@ | ||
package kr.toxicity.hud.api.fabric.event; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
public interface FabricEvent<T extends FabricEvent<?>> { | ||
@NotNull EventRegistry<T> getRegistry(); | ||
} |
12 changes: 12 additions & 0 deletions
12
api/fabric-api/src/main/java/kr/toxicity/hud/api/fabric/event/PlayerEvent.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,12 @@ | ||
package kr.toxicity.hud.api.fabric.event; | ||
|
||
import net.minecraft.server.level.ServerPlayer; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Player event | ||
* @param <T> registry type | ||
*/ | ||
public interface PlayerEvent<T extends FabricEvent<?>> extends FabricEvent<T> { | ||
@NotNull ServerPlayer player(); | ||
} |
25 changes: 25 additions & 0 deletions
25
...ic-api/src/main/java/kr/toxicity/hud/api/fabric/event/entity/PlayerAttackEntityEvent.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,25 @@ | ||
package kr.toxicity.hud.api.fabric.event.entity; | ||
|
||
import kr.toxicity.hud.api.fabric.event.EntityEvent; | ||
import kr.toxicity.hud.api.fabric.event.EventRegistry; | ||
import kr.toxicity.hud.api.fabric.event.PlayerEvent; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Player attacks entity. | ||
* @param player player | ||
* @param entity entity | ||
*/ | ||
public record PlayerAttackEntityEvent(@NotNull ServerPlayer player, @NotNull LivingEntity entity) implements PlayerEvent<PlayerAttackEntityEvent>, EntityEvent<PlayerAttackEntityEvent> { | ||
/** | ||
* Event registry | ||
*/ | ||
public static final EventRegistry<PlayerAttackEntityEvent> REGISTRY = new EventRegistry<>(); | ||
|
||
@Override | ||
public @NotNull EventRegistry<PlayerAttackEntityEvent> getRegistry() { | ||
return REGISTRY; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...-api/src/main/java/kr/toxicity/hud/api/fabric/event/entity/PlayerDamageByEntityEvent.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,25 @@ | ||
package kr.toxicity.hud.api.fabric.event.entity; | ||
|
||
import kr.toxicity.hud.api.fabric.event.EntityEvent; | ||
import kr.toxicity.hud.api.fabric.event.EventRegistry; | ||
import kr.toxicity.hud.api.fabric.event.PlayerEvent; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Player damaged by entity. | ||
* @param player player | ||
* @param entity entity | ||
*/ | ||
public record PlayerDamageByEntityEvent(@NotNull ServerPlayer player, @NotNull LivingEntity entity) implements PlayerEvent<PlayerDamageByEntityEvent>, EntityEvent<PlayerDamageByEntityEvent> { | ||
/** | ||
* Event registry | ||
*/ | ||
public static final EventRegistry<PlayerDamageByEntityEvent> REGISTRY = new EventRegistry<>(); | ||
|
||
@Override | ||
public @NotNull EventRegistry<PlayerDamageByEntityEvent> getRegistry() { | ||
return REGISTRY; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
api/fabric-api/src/main/java/kr/toxicity/hud/api/fabric/event/entity/PlayerDeathEvent.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,22 @@ | ||
package kr.toxicity.hud.api.fabric.event.entity; | ||
|
||
import kr.toxicity.hud.api.fabric.event.EventRegistry; | ||
import kr.toxicity.hud.api.fabric.event.PlayerEvent; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Player is dead. | ||
* @param player player | ||
*/ | ||
public record PlayerDeathEvent(@NotNull ServerPlayer player) implements PlayerEvent<PlayerDeathEvent> { | ||
/** | ||
* Event registry | ||
*/ | ||
public static final EventRegistry<PlayerDeathEvent> REGISTRY = new EventRegistry<>(); | ||
|
||
@Override | ||
public @NotNull EventRegistry<PlayerDeathEvent> getRegistry() { | ||
return REGISTRY; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...bric-api/src/main/java/kr/toxicity/hud/api/fabric/event/entity/PlayerKillEntityEvent.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,25 @@ | ||
package kr.toxicity.hud.api.fabric.event.entity; | ||
|
||
import kr.toxicity.hud.api.fabric.event.EntityEvent; | ||
import kr.toxicity.hud.api.fabric.event.EventRegistry; | ||
import kr.toxicity.hud.api.fabric.event.FabricEvent; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Player kills entity | ||
* @param player player | ||
* @param entity entity | ||
*/ | ||
public record PlayerKillEntityEvent(@NotNull ServerPlayer player, @NotNull LivingEntity entity) implements FabricEvent<PlayerKillEntityEvent>, EntityEvent<PlayerKillEntityEvent> { | ||
/** | ||
* Event registry | ||
*/ | ||
public static final EventRegistry<PlayerKillEntityEvent> REGISTRY = new EventRegistry<>(); | ||
|
||
@Override | ||
public @NotNull EventRegistry<PlayerKillEntityEvent> getRegistry() { | ||
return REGISTRY; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
api/fabric-api/src/main/java/kr/toxicity/hud/api/fabric/trigger/HudFabricEventTrigger.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,18 @@ | ||
package kr.toxicity.hud.api.fabric.trigger; | ||
|
||
import kr.toxicity.hud.api.fabric.event.EventRegistry; | ||
import kr.toxicity.hud.api.fabric.event.FabricEvent; | ||
import kr.toxicity.hud.api.trigger.HudTrigger; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Represents Fabric platform trigger. | ||
* @param <T> registry type | ||
*/ | ||
public interface HudFabricEventTrigger<T extends FabricEvent<?>> extends HudTrigger<T> { | ||
/** | ||
* Gets event registry | ||
* @return registry | ||
*/ | ||
@NotNull EventRegistry<T> registry(); | ||
} |
26 changes: 26 additions & 0 deletions
26
api/fabric-api/src/main/java/kr/toxicity/hud/api/fabric/update/FabricUpdateEvent.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,26 @@ | ||
package kr.toxicity.hud.api.fabric.update; | ||
|
||
import kr.toxicity.hud.api.fabric.event.FabricEvent; | ||
import kr.toxicity.hud.api.update.UpdateEvent; | ||
import kr.toxicity.hud.api.update.UpdateReason; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Wrapped event of Fabric. | ||
* @param event fabric event | ||
* @see FabricEvent | ||
* @see kr.toxicity.hud.api.fabric.event.EventRegistry | ||
* @param key unique key | ||
*/ | ||
public record FabricUpdateEvent(@NotNull FabricEvent<?> event, @NotNull Object key) implements UpdateEvent { | ||
|
||
@Override | ||
public @NotNull UpdateReason getType() { | ||
return UpdateReason.FABRIC_EVENT; | ||
} | ||
|
||
@Override | ||
public @NotNull Object getKey() { | ||
return key; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,6 @@ public enum UpdateReason { | |
EMPTY, | ||
BUKKIT_EVENT, | ||
VELOCITY_EVENT, | ||
FABRIC_EVENT, | ||
OTHER | ||
} |
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
23 changes: 23 additions & 0 deletions
23
...strap/fabric/src/main/java/kr/toxicity/hud/bootstrap/fabric/mixin/entity/EntityMixin.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,23 @@ | ||
package kr.toxicity.hud.bootstrap.fabric.mixin.entity; | ||
|
||
import kr.toxicity.hud.api.fabric.event.entity.PlayerDeathEvent; | ||
import net.minecraft.core.Holder; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.level.gameevent.GameEvent; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(Entity.class) | ||
public class EntityMixin { | ||
@Inject(method = "gameEvent(Lnet/minecraft/core/Holder;)V", at = @At("HEAD")) | ||
private void gameEvent(Holder<GameEvent> event, CallbackInfo info) { | ||
if (GameEvent.ENTITY_DIE.is(event)) { | ||
if (((Object) this) instanceof ServerPlayer serverPlayer) { | ||
PlayerDeathEvent.REGISTRY.call(new PlayerDeathEvent(serverPlayer)); | ||
} | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...fabric/src/main/java/kr/toxicity/hud/bootstrap/fabric/mixin/entity/LivingEntityMixin.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,31 @@ | ||
package kr.toxicity.hud.bootstrap.fabric.mixin.entity; | ||
|
||
import kr.toxicity.hud.api.fabric.event.entity.PlayerDamageByEntityEvent; | ||
import kr.toxicity.hud.api.fabric.event.entity.PlayerAttackEntityEvent; | ||
import kr.toxicity.hud.api.fabric.event.entity.PlayerKillEntityEvent; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.damagesource.DamageSource; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(LivingEntity.class) | ||
public class LivingEntityMixin { | ||
|
||
@Inject(method = "hurtServer", at = @At("TAIL")) | ||
private void hurtServer(ServerLevel serverLevel, DamageSource damageSource, float f, CallbackInfoReturnable<Boolean> cir) { | ||
var entity = (LivingEntity) (Object) this; | ||
if (damageSource.getEntity() instanceof ServerPlayer player) { | ||
PlayerAttackEntityEvent.REGISTRY.call(new PlayerAttackEntityEvent(player, entity)); | ||
if (entity.isDeadOrDying()) { | ||
PlayerKillEntityEvent.REGISTRY.call(new PlayerKillEntityEvent(player, entity)); | ||
} | ||
} | ||
if (((Object) this) instanceof ServerPlayer player) { | ||
PlayerDamageByEntityEvent.REGISTRY.call(new PlayerDamageByEntityEvent(player, entity)); | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
bootstrap/fabric/src/main/kotlin/kr/toxicity/hud/bootstrap/fabric/module/FabricModule.kt
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,8 @@ | ||
package kr.toxicity.hud.bootstrap.fabric.module | ||
|
||
import kr.toxicity.hud.api.fabric.trigger.HudFabricEventTrigger | ||
import kr.toxicity.hud.api.yaml.YamlObject | ||
|
||
interface FabricModule : Module { | ||
override val triggers: Map<String, (YamlObject) -> HudFabricEventTrigger<*>> | ||
} |
Oops, something went wrong.