use of it.hurts.sskirillss.relics.network.PacketRelicAbility in project relics by SSKirillSS.
the class HUDEventHandler method onKeyPressed.
@SubscribeEvent
public static void onKeyPressed(InputEvent.KeyInputEvent event) {
ClientPlayerEntity player = Minecraft.getInstance().player;
if (player == null)
return;
if (relics.size() > slots) {
if (HotkeyRegistry.HUD_UP.isDown()) {
animation = 500;
offset = offset - slots;
if (offset < 0)
offset = (relics.size() - 1) / slots * slots;
player.getCommandSenderWorld().playSound(player, player.blockPosition(), SoundEvents.UI_BUTTON_CLICK, SoundCategory.MASTER, 1.0F, 1.0F);
} else if (HotkeyRegistry.HUD_DOWN.isDown()) {
animation = 500;
offset = offset + slots;
if (offset >= relics.size())
offset = 0;
player.getCommandSenderWorld().playSound(player, player.blockPosition(), SoundEvents.UI_BUTTON_CLICK, SoundCategory.MASTER, 1.0F, 1.0F);
}
}
for (int i = 0; i < keyBindings.size(); i++) {
KeyBinding key = keyBindings.get(i);
if (!key.isDown())
continue;
animation = 500;
int id = i + offset;
if (id >= relics.size())
continue;
ImmutablePair<ItemStack, Integer> pair = relics.get(i + offset);
ItemStack stack = pair.getLeft();
if (!(stack.getItem() instanceof RelicItem))
continue;
RelicItem<?> relic = (RelicItem<?>) stack.getItem();
if (!relic.getData().hasAbility())
continue;
NetworkHandler.sendToServer(new PacketRelicAbility(pair.getRight()));
relic.castAbility(player, stack);
}
}
Aggregations