Search in sources :

Example 1 with PlayerSleepInBedEvent

use of net.minecraftforge.event.entity.player.PlayerSleepInBedEvent in project MinecraftForge by MinecraftForge.

the class ForgeEventFactory method onPlayerSleepInBed.

public static SleepResult onPlayerSleepInBed(EntityPlayer player, BlockPos pos) {
    PlayerSleepInBedEvent event = new PlayerSleepInBedEvent(player, pos);
    MinecraftForge.EVENT_BUS.post(event);
    return event.getResultStatus();
}
Also used : PlayerSleepInBedEvent(net.minecraftforge.event.entity.player.PlayerSleepInBedEvent)

Example 2 with PlayerSleepInBedEvent

use of net.minecraftforge.event.entity.player.PlayerSleepInBedEvent in project SpongeForge by SpongePowered.

the class SpongeForgeEventFactory method createPlayerSleepInBedEvent.

// Player events
public static PlayerSleepInBedEvent createPlayerSleepInBedEvent(Event event) {
    SleepingEvent.Pre spongeEvent = (SleepingEvent.Pre) event;
    Optional<Player> player = spongeEvent.getCause().first(Player.class);
    if (!player.isPresent()) {
        return null;
    }
    Location<World> location = spongeEvent.getBed().getLocation().get();
    BlockPos pos = new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ());
    return new PlayerSleepInBedEvent((EntityPlayer) player.get(), pos);
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) PlayerSleepInBedEvent(net.minecraftforge.event.entity.player.PlayerSleepInBedEvent) World(org.spongepowered.api.world.World) IMixinWorld(org.spongepowered.common.interfaces.world.IMixinWorld) SleepingEvent(org.spongepowered.api.event.action.SleepingEvent)

Example 3 with PlayerSleepInBedEvent

use of net.minecraftforge.event.entity.player.PlayerSleepInBedEvent in project MinecraftForge by MinecraftForge.

the class ForgeEventFactory method onPlayerSleepInBed.

public static BedSleepingProblem onPlayerSleepInBed(Player player, Optional<BlockPos> pos) {
    PlayerSleepInBedEvent event = new PlayerSleepInBedEvent(player, pos);
    MinecraftForge.EVENT_BUS.post(event);
    return event.getResultStatus();
}
Also used : PlayerSleepInBedEvent(net.minecraftforge.event.entity.player.PlayerSleepInBedEvent)

Aggregations

PlayerSleepInBedEvent (net.minecraftforge.event.entity.player.PlayerSleepInBedEvent)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 BlockPos (net.minecraft.util.math.BlockPos)1 Player (org.spongepowered.api.entity.living.player.Player)1 SleepingEvent (org.spongepowered.api.event.action.SleepingEvent)1 World (org.spongepowered.api.world.World)1 IMixinWorld (org.spongepowered.common.interfaces.world.IMixinWorld)1