added player_escapes_sleep event. Fixes #579
This commit is contained in:
1 parent
2e661a996f
commit
a099ed79e1
6 files changed
+28
-2
No files matched your search
@@ -170,6 +170,10 @@ Triggered when a server receives a request to deploy elytra, regardless if the f
|
|||||||
### `__on_player_wakes_up(player)`
|
### `__on_player_wakes_up(player)`
|
||||||
Player wakes up from the bed mid sleep, but not when it is kicked out of bed because it finished sleeping.
|
Player wakes up from the bed mid sleep, but not when it is kicked out of bed because it finished sleeping.
|
||||||
|
|
||||||
|
### `__on_player_escapes_sleep(player)`
|
||||||
|
Same as `player_wakes_up` but only triggered when pressing the ESC button. Not sure why Mojang decided to send that event
|
||||||
|
twice when pressing escape, but might be interesting to be able to detect that.
|
||||||
|
|
||||||
### `__on_player_starts_sneaking(player)`
|
### `__on_player_starts_sneaking(player)`
|
||||||
### `__on_player_stops_sneaking(player)`
|
### `__on_player_stops_sneaking(player)`
|
||||||
### `__on_player_starts_sprinting(player)`
|
### `__on_player_starts_sprinting(player)`
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ __on_player_stops_sprinting(player) ->
|
|||||||
__on_player_switches_slot(player, from, to) ->
|
__on_player_switches_slot(player, from, to) ->
|
||||||
__on_player_swaps_hands(player) ->
|
__on_player_swaps_hands(player) ->
|
||||||
__on_player_uses_item(player, item_tuple, hand) ->
|
__on_player_uses_item(player, item_tuple, hand) ->
|
||||||
__on_player_wakes_up(player) ->
|
__on_player_wakes_up(player) ->
|
||||||
|
__on_player_escapes_sleep(player) ->
|
||||||
__on_statistic(player, category, event, value) ->
|
__on_statistic(player, category, event, value) ->
|
||||||
__on_tick() ->
|
__on_tick() ->
|
||||||
__on_tick_ender() ->
|
__on_tick_ender() ->
|
||||||
|
|||||||
@@ -115,6 +115,7 @@
|
|||||||
__on_player_swaps_hands
|
__on_player_swaps_hands
|
||||||
__on_player_uses_item
|
__on_player_uses_item
|
||||||
__on_player_wakes_up
|
__on_player_wakes_up
|
||||||
|
__on_player_escapes_sleep
|
||||||
__on_statistic
|
__on_statistic
|
||||||
__on_tick
|
__on_tick
|
||||||
__on_tick_ender
|
__on_tick_ender
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package carpet.mixins;
|
package carpet.mixins;
|
||||||
|
|
||||||
|
import carpet.CarpetSettings;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.network.packet.c2s.play.ButtonClickC2SPacket;
|
import net.minecraft.network.packet.c2s.play.ButtonClickC2SPacket;
|
||||||
import net.minecraft.network.packet.c2s.play.CraftRequestC2SPacket;
|
import net.minecraft.network.packet.c2s.play.CraftRequestC2SPacket;
|
||||||
@@ -27,6 +28,7 @@ import static carpet.script.CarpetEventServer.Event.PLAYER_CLICKS_BLOCK;
|
|||||||
import static carpet.script.CarpetEventServer.Event.PLAYER_DEPLOYS_ELYTRA;
|
import static carpet.script.CarpetEventServer.Event.PLAYER_DEPLOYS_ELYTRA;
|
||||||
import static carpet.script.CarpetEventServer.Event.PLAYER_DROPS_ITEM;
|
import static carpet.script.CarpetEventServer.Event.PLAYER_DROPS_ITEM;
|
||||||
import static carpet.script.CarpetEventServer.Event.PLAYER_DROPS_STACK;
|
import static carpet.script.CarpetEventServer.Event.PLAYER_DROPS_STACK;
|
||||||
|
import static carpet.script.CarpetEventServer.Event.PLAYER_ESCAPES_SLEEP;
|
||||||
import static carpet.script.CarpetEventServer.Event.PLAYER_INTERACTS_WITH_ENTITY;
|
import static carpet.script.CarpetEventServer.Event.PLAYER_INTERACTS_WITH_ENTITY;
|
||||||
import static carpet.script.CarpetEventServer.Event.PLAYER_RELEASED_ITEM;
|
import static carpet.script.CarpetEventServer.Event.PLAYER_RELEASED_ITEM;
|
||||||
import static carpet.script.CarpetEventServer.Event.PLAYER_RIDES;
|
import static carpet.script.CarpetEventServer.Event.PLAYER_RIDES;
|
||||||
@@ -205,7 +207,11 @@ public class ServerPlayNetworkHandler_scarpetEventsMixin
|
|||||||
private void onWakeUp(ClientCommandC2SPacket clientCommandC2SPacket_1, CallbackInfo ci)
|
private void onWakeUp(ClientCommandC2SPacket clientCommandC2SPacket_1, CallbackInfo ci)
|
||||||
{
|
{
|
||||||
//weird one - doesn't seem to work, maybe MP
|
//weird one - doesn't seem to work, maybe MP
|
||||||
PLAYER_WAKES_UP.onPlayerEvent(player);
|
if (player.isSleeping())
|
||||||
|
PLAYER_WAKES_UP.onPlayerEvent(player);
|
||||||
|
else
|
||||||
|
PLAYER_ESCAPES_SLEEP.onPlayerEvent(player);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "onClientCommand", at = @At(
|
@Inject(method = "onClientCommand", at = @At(
|
||||||
|
|||||||
@@ -337,6 +337,14 @@ public class CarpetEventServer
|
|||||||
handler.call( () -> Collections.singletonList(new EntityValue(player)), player::getCommandSource);
|
handler.call( () -> Collections.singletonList(new EntityValue(player)), player::getCommandSource);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
public static final Event PLAYER_ESCAPES_SLEEP = new Event("player_escapes_sleep", 1, false)
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onPlayerEvent(ServerPlayerEntity player)
|
||||||
|
{
|
||||||
|
handler.call( () -> Collections.singletonList(new EntityValue(player)), player::getCommandSource);
|
||||||
|
}
|
||||||
|
};
|
||||||
public static final Event PLAYER_RIDES = new Event("player_rides", 5, false)
|
public static final Event PLAYER_RIDES = new Event("player_rides", 5, false)
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -17,6 +17,12 @@ __on_player_wakes_up(player) -> (
|
|||||||
print('Player '+player+' wakes up')
|
print('Player '+player+' wakes up')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
__on_player_escapes_sleep(player) -> (
|
||||||
|
print('');
|
||||||
|
print('__on_player_escapes_sleep(player)');
|
||||||
|
print('Player '+player+' wakes up using ESC key')
|
||||||
|
);
|
||||||
|
|
||||||
__on_player_rides(player, forward, strafe, jumping, sneaking) ->
|
__on_player_rides(player, forward, strafe, jumping, sneaking) ->
|
||||||
(
|
(
|
||||||
print('');
|
print('');
|
||||||
|
|||||||
Reference in new issue
Block a user