Event cleanups

This commit is contained in:
shedaniel
2021-01-25 11:07:09 +08:00
parent 27de429afb
commit 5d4a779d05
18 changed files with 74 additions and 74 deletions

View File

@@ -30,7 +30,7 @@ public interface ChatEvent {
/**
* Invoked when server receives a message, equivalent to forge's {@code ServerChatEvent}.
*/
Event<Server> SERVER = EventFactory.createInteractionResultHolder(Server.class);
Event<Server> SERVER = EventFactory.createInteractionResultHolder();
interface Server {
@NotNull

View File

@@ -31,7 +31,7 @@ public class CommandPerformEvent {
/**
* Invoked after server parses a command but before server executes it, equivalent to forge's {@code CommandEvent}.
*/
public static final Event<Actor<CommandPerformEvent>> EVENT = EventFactory.createActorLoop(CommandPerformEvent.class);
public static final Event<Actor<CommandPerformEvent>> EVENT = EventFactory.createActorLoop();
@NotNull
private ParseResults<CommandSourceStack> results;

View File

@@ -29,7 +29,7 @@ public interface CommandRegistrationEvent {
/**
* Invoked after server registers its commands, equivalent to forge's {@code RegisterCommandsEvent} and fabric's {@code CommandRegistrationCallback}.
*/
Event<CommandRegistrationEvent> EVENT = EventFactory.createLoop(CommandRegistrationEvent.class);
Event<CommandRegistrationEvent> EVENT = EventFactory.createLoop();
void register(CommandDispatcher<CommandSourceStack> dispatcher, Commands.CommandSelection selection);
}

View File

@@ -34,16 +34,16 @@ public interface EntityEvent {
/**
* Invoked before LivingEntity#die, equivalent to forge's {@code LivingDeathEvent}.
*/
Event<LivingDeath> LIVING_DEATH = EventFactory.createInteractionResult(LivingDeath.class);
Event<LivingDeath> LIVING_DEATH = EventFactory.createInteractionResult();
/**
* Invoked before LivingEntity#hurt, equivalent to forge's {@code LivingAttackEvent}.
*/
Event<LivingAttack> LIVING_ATTACK = EventFactory.createInteractionResult(LivingAttack.class);
Event<LivingAttack> LIVING_ATTACK = EventFactory.createInteractionResult();
/**
* Invoked before entity is added to a world, equivalent to forge's {@code EntityJoinWorldEvent}.
*/
Event<Add> ADD = EventFactory.createInteractionResult(Add.class);
Event<PlaceBlock> PLACE_BLOCK = EventFactory.createInteractionResult(PlaceBlock.class);
Event<Add> ADD = EventFactory.createInteractionResult();
Event<PlaceBlock> PLACE_BLOCK = EventFactory.createInteractionResult();
interface LivingDeath {
InteractionResult die(LivingEntity entity, DamageSource source);

View File

@@ -29,8 +29,8 @@ import net.minecraft.world.level.Level;
import java.util.List;
public interface ExplosionEvent {
Event<Pre> PRE = EventFactory.createInteractionResult(Pre.class);
Event<Detonate> DETONATE = EventFactory.createInteractionResult(Detonate.class);
Event<Pre> PRE = EventFactory.createInteractionResult();
Event<Detonate> DETONATE = EventFactory.createInteractionResult();
interface Pre {
InteractionResult explode(Level world, Explosion explosion);

View File

@@ -36,19 +36,19 @@ public interface GuiEvent {
/**
* Invoked after in-game hud is rendered, equivalent to forge's {@code RenderGameOverlayEvent.Post@ElementType#ALL} and fabric's {@code HudRenderCallback}.
*/
Event<RenderHud> RENDER_HUD = EventFactory.createLoop(RenderHud.class);
Event<DebugText> DEBUG_TEXT_LEFT = EventFactory.createLoop(DebugText.class);
Event<DebugText> DEBUG_TEXT_RIGHT = EventFactory.createLoop(DebugText.class);
Event<RenderHud> RENDER_HUD = EventFactory.createLoop();
Event<DebugText> DEBUG_TEXT_LEFT = EventFactory.createLoop();
Event<DebugText> DEBUG_TEXT_RIGHT = EventFactory.createLoop();
/**
* Invoked during Screen#init after previous widgets are cleared, equivalent to forge's {@code GuiScreenEvent.InitGuiEvent.Pre}.
*/
Event<ScreenInitPre> INIT_PRE = EventFactory.createInteractionResult(ScreenInitPre.class);
Event<ScreenInitPre> INIT_PRE = EventFactory.createInteractionResult();
/**
* Invoked after Screen#init, equivalent to forge's {@code GuiScreenEvent.InitGuiEvent.Post}.
*/
Event<ScreenInitPost> INIT_POST = EventFactory.createLoop(ScreenInitPost.class);
Event<ScreenRenderPre> RENDER_PRE = EventFactory.createInteractionResult(ScreenRenderPre.class);
Event<ScreenRenderPost> RENDER_POST = EventFactory.createInteractionResult(ScreenRenderPost.class);
Event<ScreenInitPost> INIT_POST = EventFactory.createLoop();
Event<ScreenRenderPre> RENDER_PRE = EventFactory.createInteractionResult();
Event<ScreenRenderPost> RENDER_POST = EventFactory.createInteractionResult();
@Environment(EnvType.CLIENT)
interface RenderHud {

View File

@@ -32,12 +32,12 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.BlockState;
public interface InteractionEvent {
Event<LeftClickBlock> LEFT_CLICK_BLOCK = EventFactory.createInteractionResult(LeftClickBlock.class);
Event<RightClickBlock> RIGHT_CLICK_BLOCK = EventFactory.createInteractionResult(RightClickBlock.class);
Event<RightClickItem> RIGHT_CLICK_ITEM = EventFactory.createInteractionResultHolder(RightClickItem.class);
Event<ClientLeftClickAir> CLIENT_LEFT_CLICK_AIR = EventFactory.createLoop(ClientLeftClickAir.class);
Event<ClientRightClickAir> CLIENT_RIGHT_CLICK_AIR = EventFactory.createLoop(ClientRightClickAir.class);
Event<InteractEntity> INTERACT_ENTITY = EventFactory.createInteractionResult(InteractEntity.class);
Event<LeftClickBlock> LEFT_CLICK_BLOCK = EventFactory.createInteractionResult();
Event<RightClickBlock> RIGHT_CLICK_BLOCK = EventFactory.createInteractionResult();
Event<RightClickItem> RIGHT_CLICK_ITEM = EventFactory.createInteractionResultHolder();
Event<ClientLeftClickAir> CLIENT_LEFT_CLICK_AIR = EventFactory.createLoop();
Event<ClientRightClickAir> CLIENT_RIGHT_CLICK_AIR = EventFactory.createLoop();
Event<InteractEntity> INTERACT_ENTITY = EventFactory.createInteractionResult();
interface RightClickBlock {
InteractionResult click(Player player, InteractionHand hand, BlockPos pos, Direction face);

View File

@@ -29,35 +29,35 @@ public interface LifecycleEvent {
/**
* Invoked when server is starting, equivalent to forge's {@code FMLServerAboutToStartEvent} and fabric's {@code ServerLifecycleEvents#SERVER_STARTING}.
*/
Event<ServerState> SERVER_BEFORE_START = EventFactory.createLoop(ServerState.class);
Event<ServerState> SERVER_BEFORE_START = EventFactory.createLoop();
/**
* Invoked when server is starting, equivalent to forge's {@code FMLServerStartingEvent}.
*/
Event<ServerState> SERVER_STARTING = EventFactory.createLoop(ServerState.class);
Event<ServerState> SERVER_STARTING = EventFactory.createLoop();
/**
* Invoked when server has started, equivalent to forge's {@code FMLServerStartedEvent} and fabric's {@code ServerLifecycleEvents#SERVER_STARTED}.
*/
Event<ServerState> SERVER_STARTED = EventFactory.createLoop(ServerState.class);
Event<ServerState> SERVER_STARTED = EventFactory.createLoop();
/**
* Invoked when server is stopping, equivalent to forge's {@code FMLServerStoppingEvent} and fabric's {@code ServerLifecycleEvents#SERVER_STOPPING}.
*/
Event<ServerState> SERVER_STOPPING = EventFactory.createLoop(ServerState.class);
Event<ServerState> SERVER_STOPPING = EventFactory.createLoop();
/**
* Invoked when server has stopped, equivalent to forge's {@code FMLServerStoppedEvent} and fabric's {@code ServerLifecycleEvents#SERVER_STOPPED}.
*/
Event<ServerState> SERVER_STOPPED = EventFactory.createLoop(ServerState.class);
Event<ServerState> SERVER_STOPPED = EventFactory.createLoop();
/**
* Invoked after a world is loaded only on server, equivalent to forge's {@code WorldEvent.Load} and fabric's {@code ServerWorldEvents#LOAD}.
*/
Event<ServerWorldState> SERVER_WORLD_LOAD = EventFactory.createLoop(ServerWorldState.class);
Event<ServerWorldState> SERVER_WORLD_LOAD = EventFactory.createLoop();
/**
* Invoked after a world is unloaded, equivalent to forge's {@code WorldEvent.Unload} and fabric's {@code ServerWorldEvents#UNLOAD}.
*/
Event<ServerWorldState> SERVER_WORLD_UNLOAD = EventFactory.createLoop(ServerWorldState.class);
Event<ServerWorldState> SERVER_WORLD_UNLOAD = EventFactory.createLoop();
/**
* Invoked during a world is saved, equivalent to forge's {@code WorldEvent.Save}.
*/
Event<ServerWorldState> SERVER_WORLD_SAVE = EventFactory.createLoop(ServerWorldState.class);
Event<ServerWorldState> SERVER_WORLD_SAVE = EventFactory.createLoop();
interface InstanceState<T> {
void stateChanged(T instance);

View File

@@ -27,7 +27,7 @@ import net.minecraft.world.item.crafting.RecipeManager;
@Environment(EnvType.CLIENT)
public interface RecipeUpdateEvent {
Event<RecipeUpdateEvent> EVENT = EventFactory.createLoop(RecipeUpdateEvent.class);
Event<RecipeUpdateEvent> EVENT = EventFactory.createLoop();
void update(RecipeManager recipeManager);
}

View File

@@ -30,8 +30,8 @@ import java.util.function.Consumer;
@Environment(EnvType.CLIENT)
public interface TextureStitchEvent {
Event<Pre> PRE = EventFactory.createLoop(Pre.class);
Event<Post> POST = EventFactory.createLoop(Post.class);
Event<Pre> PRE = EventFactory.createLoop();
Event<Post> POST = EventFactory.createLoop();
@Environment(EnvType.CLIENT)
interface Pre {

View File

@@ -26,12 +26,12 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.Level;
public interface TickEvent<T> {
Event<Server> SERVER_PRE = EventFactory.createLoop(Server.class);
Event<Server> SERVER_POST = EventFactory.createLoop(Server.class);
Event<ServerWorld> SERVER_WORLD_PRE = EventFactory.createLoop(ServerWorld.class);
Event<ServerWorld> SERVER_WORLD_POST = EventFactory.createLoop(ServerWorld.class);
Event<Player> PLAYER_PRE = EventFactory.createLoop(Player.class);
Event<Player> PLAYER_POST = EventFactory.createLoop(Player.class);
Event<Server> SERVER_PRE = EventFactory.createLoop();
Event<Server> SERVER_POST = EventFactory.createLoop();
Event<ServerWorld> SERVER_WORLD_PRE = EventFactory.createLoop();
Event<ServerWorld> SERVER_WORLD_POST = EventFactory.createLoop();
Event<Player> PLAYER_PRE = EventFactory.createLoop();
Event<Player> PLAYER_POST = EventFactory.createLoop();
void tick(T instance);

View File

@@ -35,17 +35,17 @@ import java.util.List;
@Environment(EnvType.CLIENT)
public interface TooltipEvent {
Event<Item> ITEM = EventFactory.createLoop(Item.class);
Event<Item> ITEM = EventFactory.createLoop();
/**
* Render vanilla events are not invoked on the forge side.
*/
Event<RenderVanilla> RENDER_VANILLA_PRE = EventFactory.createInteractionResult(RenderVanilla.class);
Event<RenderVanilla> RENDER_VANILLA_PRE = EventFactory.createInteractionResult();
/**
* Render forge events are only invoked on the forge side.
*/
Event<RenderForge> RENDER_FORGE_PRE = EventFactory.createInteractionResult(RenderForge.class);
Event<RenderModifyPosition> RENDER_MODIFY_POSITION = EventFactory.createInteractionResult(RenderModifyPosition.class);
Event<RenderModifyColor> RENDER_MODIFY_COLOR = EventFactory.createInteractionResult(RenderModifyColor.class);
Event<RenderForge> RENDER_FORGE_PRE = EventFactory.createInteractionResult();
Event<RenderModifyPosition> RENDER_MODIFY_POSITION = EventFactory.createInteractionResult();
Event<RenderModifyColor> RENDER_MODIFY_COLOR = EventFactory.createInteractionResult();
@Environment(EnvType.CLIENT)
interface Item {

View File

@@ -36,11 +36,11 @@ public interface ClientChatEvent {
/**
* Invoked when client tries to send a message, equivalent to forge's {@code ClientChatEvent}.
*/
Event<Client> CLIENT = EventFactory.createInteractionResultHolder(Client.class);
Event<Client> CLIENT = EventFactory.createInteractionResultHolder();
/**
* Invoked when client receives a message, equivalent to forge's {@code ClientChatReceivedEvent}.
*/
Event<ClientReceived> CLIENT_RECEIVED = EventFactory.createInteractionResultHolder(ClientReceived.class);
Event<ClientReceived> CLIENT_RECEIVED = EventFactory.createInteractionResultHolder();
@Environment(EnvType.CLIENT)
interface Client {

View File

@@ -32,15 +32,15 @@ public interface ClientLifecycleEvent {
/**
* Invoked when client has been initialised, not available in forge.
*/
@Deprecated Event<ClientState> CLIENT_STARTED = EventFactory.createLoop(ClientState.class);
@Deprecated Event<ClientState> CLIENT_STARTED = EventFactory.createLoop();
/**
* Invoked when client is initialising, not available in forge.
*/
@Deprecated Event<ClientState> CLIENT_STOPPING = EventFactory.createLoop(ClientState.class);
@Deprecated Event<ClientState> CLIENT_STOPPING = EventFactory.createLoop();
/**
* Invoked after a world is loaded only on client, equivalent to forge's {@code WorldEvent.Load}.
*/
Event<ClientWorldState> CLIENT_WORLD_LOAD = EventFactory.createLoop(ClientWorldState.class);
Event<ClientWorldState> CLIENT_WORLD_LOAD = EventFactory.createLoop();
Event<ClientState> CLIENT_SETUP = EventFactory.createLoop();
@Deprecated

View File

@@ -28,9 +28,9 @@ import org.jetbrains.annotations.Nullable;
@Environment(EnvType.CLIENT)
public interface ClientPlayerEvent {
Event<ClientPlayerJoin> CLIENT_PLAYER_JOIN = EventFactory.createLoop(ClientPlayerJoin.class);
Event<ClientPlayerQuit> CLIENT_PLAYER_QUIT = EventFactory.createLoop(ClientPlayerQuit.class);
Event<ClientPlayerRespawn> CLIENT_PLAYER_RESPAWN = EventFactory.createLoop(ClientPlayerRespawn.class);
Event<ClientPlayerJoin> CLIENT_PLAYER_JOIN = EventFactory.createLoop();
Event<ClientPlayerQuit> CLIENT_PLAYER_QUIT = EventFactory.createLoop();
Event<ClientPlayerRespawn> CLIENT_PLAYER_RESPAWN = EventFactory.createLoop();
@Environment(EnvType.CLIENT)
interface ClientPlayerJoin {

View File

@@ -31,19 +31,19 @@ public interface ClientRawInputEvent {
/**
* Invoked after the mouse has scrolled, but doesn't have a screen opened, and in a world, equivalent to forge's {@code InputEvent.MouseScrollEvent}.
*/
Event<MouseScrolled> MOUSE_SCROLLED = EventFactory.createInteractionResult(MouseScrolled.class);
Event<MouseScrolled> MOUSE_SCROLLED = EventFactory.createInteractionResult();
/**
* Invoked after the mouse has clicked, before the screen intercepts, equivalent to forge's {@code InputEvent.RawMouseEvent}.
*/
Event<MouseClicked> MOUSE_CLICKED_PRE = EventFactory.createInteractionResult(MouseClicked.class);
Event<MouseClicked> MOUSE_CLICKED_PRE = EventFactory.createInteractionResult();
/**
* Invoked after the mouse has clicked, after the screen intercepts, equivalent to forge's {@code InputEvent.MouseInputEvent}.
*/
Event<MouseClicked> MOUSE_CLICKED_POST = EventFactory.createInteractionResult(MouseClicked.class);
Event<MouseClicked> MOUSE_CLICKED_POST = EventFactory.createInteractionResult();
/**
* Invoked after a key was pressed, after the screen intercepts, equivalent to forge's {@code InputEvent.KeyInputEvent}.
*/
Event<KeyPressed> KEY_PRESSED = EventFactory.createInteractionResult(KeyPressed.class);
Event<KeyPressed> KEY_PRESSED = EventFactory.createInteractionResult();
interface KeyPressed {
InteractionResult keyPressed(Minecraft client, int keyCode, int scanCode, int action, int modifiers);

View File

@@ -29,20 +29,20 @@ import net.minecraft.world.InteractionResult;
@Environment(EnvType.CLIENT)
public interface ClientScreenInputEvent {
Event<MouseScrolled> MOUSE_SCROLLED_PRE = EventFactory.createInteractionResult(MouseScrolled.class);
Event<MouseScrolled> MOUSE_SCROLLED_POST = EventFactory.createInteractionResult(MouseScrolled.class);
Event<MouseClicked> MOUSE_CLICKED_PRE = EventFactory.createInteractionResult(MouseClicked.class);
Event<MouseClicked> MOUSE_CLICKED_POST = EventFactory.createInteractionResult(MouseClicked.class);
Event<MouseReleased> MOUSE_RELEASED_PRE = EventFactory.createInteractionResult(MouseReleased.class);
Event<MouseReleased> MOUSE_RELEASED_POST = EventFactory.createInteractionResult(MouseReleased.class);
Event<MouseDragged> MOUSE_DRAGGED_PRE = EventFactory.createInteractionResult(MouseDragged.class);
Event<MouseDragged> MOUSE_DRAGGED_POST = EventFactory.createInteractionResult(MouseDragged.class);
Event<KeyTyped> CHAR_TYPED_PRE = EventFactory.createInteractionResult(KeyTyped.class);
Event<KeyTyped> CHAR_TYPED_POST = EventFactory.createInteractionResult(KeyTyped.class);
Event<KeyPressed> KEY_PRESSED_PRE = EventFactory.createInteractionResult(KeyPressed.class);
Event<KeyPressed> KEY_PRESSED_POST = EventFactory.createInteractionResult(KeyPressed.class);
Event<KeyReleased> KEY_RELEASED_PRE = EventFactory.createInteractionResult(KeyReleased.class);
Event<KeyReleased> KEY_RELEASED_POST = EventFactory.createInteractionResult(KeyReleased.class);
Event<MouseScrolled> MOUSE_SCROLLED_PRE = EventFactory.createInteractionResult();
Event<MouseScrolled> MOUSE_SCROLLED_POST = EventFactory.createInteractionResult();
Event<MouseClicked> MOUSE_CLICKED_PRE = EventFactory.createInteractionResult();
Event<MouseClicked> MOUSE_CLICKED_POST = EventFactory.createInteractionResult();
Event<MouseReleased> MOUSE_RELEASED_PRE = EventFactory.createInteractionResult();
Event<MouseReleased> MOUSE_RELEASED_POST = EventFactory.createInteractionResult();
Event<MouseDragged> MOUSE_DRAGGED_PRE = EventFactory.createInteractionResult();
Event<MouseDragged> MOUSE_DRAGGED_POST = EventFactory.createInteractionResult();
Event<KeyTyped> CHAR_TYPED_PRE = EventFactory.createInteractionResult();
Event<KeyTyped> CHAR_TYPED_POST = EventFactory.createInteractionResult();
Event<KeyPressed> KEY_PRESSED_PRE = EventFactory.createInteractionResult();
Event<KeyPressed> KEY_PRESSED_POST = EventFactory.createInteractionResult();
Event<KeyReleased> KEY_RELEASED_PRE = EventFactory.createInteractionResult();
Event<KeyReleased> KEY_RELEASED_POST = EventFactory.createInteractionResult();
interface KeyPressed {
InteractionResult keyPressed(Minecraft client, Screen screen, int keyCode, int scanCode, int modifiers);

View File

@@ -28,10 +28,10 @@ import net.minecraft.client.multiplayer.ClientLevel;
@Environment(EnvType.CLIENT)
public interface ClientTickEvent<T> {
Event<Client> CLIENT_PRE = EventFactory.createLoop(Client.class);
Event<Client> CLIENT_POST = EventFactory.createLoop(Client.class);
Event<ClientWorld> CLIENT_WORLD_PRE = EventFactory.createLoop(ClientWorld.class);
Event<ClientWorld> CLIENT_WORLD_POST = EventFactory.createLoop(ClientWorld.class);
Event<Client> CLIENT_PRE = EventFactory.createLoop();
Event<Client> CLIENT_POST = EventFactory.createLoop();
Event<ClientWorld> CLIENT_WORLD_PRE = EventFactory.createLoop();
Event<ClientWorld> CLIENT_WORLD_POST = EventFactory.createLoop();
void tick(T instance);