2016-06-23 03:49:47 +00:00
|
|
|
/*
|
|
|
|
* Minecraft Forge
|
2019-02-10 22:57:03 +00:00
|
|
|
* Copyright (c) 2016-2019.
|
2016-06-23 03:49:47 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation version 2.1
|
|
|
|
* of the License.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2019-08-05 02:34:14 +00:00
|
|
|
package net.minecraftforge.event;
|
2013-12-17 04:18:00 +00:00
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
import net.minecraft.entity.player.PlayerEntity;
|
|
|
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
2013-12-17 04:18:00 +00:00
|
|
|
import net.minecraft.world.World;
|
2019-08-05 02:34:14 +00:00
|
|
|
import net.minecraftforge.eventbus.api.Event;
|
2018-06-21 19:37:32 +00:00
|
|
|
import net.minecraftforge.fml.LogicalSide;
|
2013-12-17 04:18:00 +00:00
|
|
|
|
2019-08-05 02:34:14 +00:00
|
|
|
public class TickEvent extends Event
|
2018-06-11 01:12:46 +00:00
|
|
|
{
|
2014-01-13 13:43:33 +00:00
|
|
|
public enum Type {
|
2013-12-17 04:18:00 +00:00
|
|
|
WORLD, PLAYER, CLIENT, SERVER, RENDER;
|
|
|
|
}
|
|
|
|
|
|
|
|
public enum Phase {
|
|
|
|
START, END;
|
|
|
|
}
|
|
|
|
public final Type type;
|
2018-06-21 19:37:32 +00:00
|
|
|
public final LogicalSide side;
|
2013-12-17 04:18:00 +00:00
|
|
|
public final Phase phase;
|
2018-06-21 19:37:32 +00:00
|
|
|
public TickEvent(Type type, LogicalSide side, Phase phase)
|
2013-12-17 04:18:00 +00:00
|
|
|
{
|
|
|
|
this.type = type;
|
|
|
|
this.side = side;
|
|
|
|
this.phase = phase;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class ServerTickEvent extends TickEvent {
|
|
|
|
public ServerTickEvent(Phase phase)
|
|
|
|
{
|
2018-06-21 19:37:32 +00:00
|
|
|
super(Type.SERVER, LogicalSide.SERVER, phase);
|
2013-12-17 04:18:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class ClientTickEvent extends TickEvent {
|
|
|
|
public ClientTickEvent(Phase phase)
|
|
|
|
{
|
2018-06-21 19:37:32 +00:00
|
|
|
super(Type.CLIENT, LogicalSide.CLIENT, phase);
|
2013-12-17 04:18:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class WorldTickEvent extends TickEvent {
|
|
|
|
public final World world;
|
2018-06-21 19:37:32 +00:00
|
|
|
public WorldTickEvent(LogicalSide side, Phase phase, World world)
|
2013-12-17 04:18:00 +00:00
|
|
|
{
|
|
|
|
super(Type.WORLD, side, phase);
|
|
|
|
this.world = world;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public static class PlayerTickEvent extends TickEvent {
|
2019-05-23 23:02:15 +00:00
|
|
|
public final PlayerEntity player;
|
2013-12-17 04:18:00 +00:00
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public PlayerTickEvent(Phase phase, PlayerEntity player)
|
2013-12-17 04:18:00 +00:00
|
|
|
{
|
2019-05-23 23:02:15 +00:00
|
|
|
super(Type.PLAYER, player instanceof ServerPlayerEntity ? LogicalSide.SERVER : LogicalSide.CLIENT, phase);
|
2013-12-17 04:18:00 +00:00
|
|
|
this.player = player;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class RenderTickEvent extends TickEvent {
|
|
|
|
public final float renderTickTime;
|
|
|
|
public RenderTickEvent(Phase phase, float renderTickTime)
|
|
|
|
{
|
2018-06-21 19:37:32 +00:00
|
|
|
super(Type.RENDER, LogicalSide.CLIENT, phase);
|
2013-12-17 04:18:00 +00:00
|
|
|
this.renderTickTime = renderTickTime;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|