/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.mojang.serialization.Codec * org.jspecify.annotations.Nullable */ package net.minecraft.world.level.gameevent; import com.mojang.serialization.Codec; import net.minecraft.core.Holder; import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.resources.Identifier; import net.minecraft.resources.RegistryFixedCodec; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.gameevent.GameEventListener; import net.minecraft.world.phys.Vec3; import org.jspecify.annotations.Nullable; public record GameEvent(int notificationRadius) { public static final Holder.Reference BLOCK_ACTIVATE = GameEvent.register("block_activate"); public static final Holder.Reference BLOCK_ATTACH = GameEvent.register("block_attach"); public static final Holder.Reference BLOCK_CHANGE = GameEvent.register("block_change"); public static final Holder.Reference BLOCK_CLOSE = GameEvent.register("block_close"); public static final Holder.Reference BLOCK_DEACTIVATE = GameEvent.register("block_deactivate"); public static final Holder.Reference BLOCK_DESTROY = GameEvent.register("block_destroy"); public static final Holder.Reference BLOCK_DETACH = GameEvent.register("block_detach"); public static final Holder.Reference BLOCK_OPEN = GameEvent.register("block_open"); public static final Holder.Reference BLOCK_PLACE = GameEvent.register("block_place"); public static final Holder.Reference CONTAINER_CLOSE = GameEvent.register("container_close"); public static final Holder.Reference CONTAINER_OPEN = GameEvent.register("container_open"); public static final Holder.Reference DRINK = GameEvent.register("drink"); public static final Holder.Reference EAT = GameEvent.register("eat"); public static final Holder.Reference ELYTRA_GLIDE = GameEvent.register("elytra_glide"); public static final Holder.Reference ENTITY_DAMAGE = GameEvent.register("entity_damage"); public static final Holder.Reference ENTITY_DIE = GameEvent.register("entity_die"); public static final Holder.Reference ENTITY_DISMOUNT = GameEvent.register("entity_dismount"); public static final Holder.Reference ENTITY_INTERACT = GameEvent.register("entity_interact"); public static final Holder.Reference ENTITY_MOUNT = GameEvent.register("entity_mount"); public static final Holder.Reference ENTITY_PLACE = GameEvent.register("entity_place"); public static final Holder.Reference ENTITY_ACTION = GameEvent.register("entity_action"); public static final Holder.Reference EQUIP = GameEvent.register("equip"); public static final Holder.Reference EXPLODE = GameEvent.register("explode"); public static final Holder.Reference FLAP = GameEvent.register("flap"); public static final Holder.Reference FLUID_PICKUP = GameEvent.register("fluid_pickup"); public static final Holder.Reference FLUID_PLACE = GameEvent.register("fluid_place"); public static final Holder.Reference HIT_GROUND = GameEvent.register("hit_ground"); public static final Holder.Reference INSTRUMENT_PLAY = GameEvent.register("instrument_play"); public static final Holder.Reference ITEM_INTERACT_FINISH = GameEvent.register("item_interact_finish"); public static final Holder.Reference ITEM_INTERACT_START = GameEvent.register("item_interact_start"); public static final Holder.Reference JUKEBOX_PLAY = GameEvent.register("jukebox_play", 10); public static final Holder.Reference JUKEBOX_STOP_PLAY = GameEvent.register("jukebox_stop_play", 10); public static final Holder.Reference LIGHTNING_STRIKE = GameEvent.register("lightning_strike"); public static final Holder.Reference NOTE_BLOCK_PLAY = GameEvent.register("note_block_play"); public static final Holder.Reference PRIME_FUSE = GameEvent.register("prime_fuse"); public static final Holder.Reference PROJECTILE_LAND = GameEvent.register("projectile_land"); public static final Holder.Reference PROJECTILE_SHOOT = GameEvent.register("projectile_shoot"); public static final Holder.Reference SCULK_SENSOR_TENDRILS_CLICKING = GameEvent.register("sculk_sensor_tendrils_clicking"); public static final Holder.Reference SHEAR = GameEvent.register("shear"); public static final Holder.Reference SHRIEK = GameEvent.register("shriek", 32); public static final Holder.Reference SPLASH = GameEvent.register("splash"); public static final Holder.Reference STEP = GameEvent.register("step"); public static final Holder.Reference SWIM = GameEvent.register("swim"); public static final Holder.Reference TELEPORT = GameEvent.register("teleport"); public static final Holder.Reference UNEQUIP = GameEvent.register("unequip"); public static final Holder.Reference RESONATE_1 = GameEvent.register("resonate_1"); public static final Holder.Reference RESONATE_2 = GameEvent.register("resonate_2"); public static final Holder.Reference RESONATE_3 = GameEvent.register("resonate_3"); public static final Holder.Reference RESONATE_4 = GameEvent.register("resonate_4"); public static final Holder.Reference RESONATE_5 = GameEvent.register("resonate_5"); public static final Holder.Reference RESONATE_6 = GameEvent.register("resonate_6"); public static final Holder.Reference RESONATE_7 = GameEvent.register("resonate_7"); public static final Holder.Reference RESONATE_8 = GameEvent.register("resonate_8"); public static final Holder.Reference RESONATE_9 = GameEvent.register("resonate_9"); public static final Holder.Reference RESONATE_10 = GameEvent.register("resonate_10"); public static final Holder.Reference RESONATE_11 = GameEvent.register("resonate_11"); public static final Holder.Reference RESONATE_12 = GameEvent.register("resonate_12"); public static final Holder.Reference RESONATE_13 = GameEvent.register("resonate_13"); public static final Holder.Reference RESONATE_14 = GameEvent.register("resonate_14"); public static final Holder.Reference RESONATE_15 = GameEvent.register("resonate_15"); public static final int DEFAULT_NOTIFICATION_RADIUS = 16; public static final Codec> CODEC = RegistryFixedCodec.create(Registries.GAME_EVENT); public static Holder bootstrap(Registry registry) { return BLOCK_ACTIVATE; } private static Holder.Reference register(String name) { return GameEvent.register(name, 16); } private static Holder.Reference register(String name, int notificationRadius) { return Registry.registerForHolder(BuiltInRegistries.GAME_EVENT, Identifier.withDefaultNamespace(name), new GameEvent(notificationRadius)); } public static final class ListenerInfo implements Comparable { private final Holder gameEvent; private final Vec3 source; private final Context context; private final GameEventListener recipient; private final double distanceToRecipient; public ListenerInfo(Holder gameEvent, Vec3 source, Context context, GameEventListener recipient, Vec3 recipientPos) { this.gameEvent = gameEvent; this.source = source; this.context = context; this.recipient = recipient; this.distanceToRecipient = source.distanceToSqr(recipientPos); } @Override public int compareTo(ListenerInfo other) { return Double.compare(this.distanceToRecipient, other.distanceToRecipient); } public Holder gameEvent() { return this.gameEvent; } public Vec3 source() { return this.source; } public Context context() { return this.context; } public GameEventListener recipient() { return this.recipient; } } public record Context(@Nullable Entity sourceEntity, @Nullable BlockState affectedState) { public static Context of(@Nullable Entity sourceEntity) { return new Context(sourceEntity, null); } public static Context of(@Nullable BlockState state) { return new Context(null, state); } public static Context of(@Nullable Entity sourceEntity, @Nullable BlockState state) { return new Context(sourceEntity, state); } } }