use of de.teamlapen.vampirism.client.gui.SelectMinionTaskScreen in project Vampirism by TeamLapen.
the class ModKeys method handleInputEvent.
@SubscribeEvent
public void handleInputEvent(InputEvent event) {
// Only call isPressed once, so
KEY keyPressed = getPressedKeyBinding();
// get value here!
if (!suckKeyDown && keyPressed == KEY.SUCK) {
RayTraceResult mouseOver = Minecraft.getInstance().hitResult;
suckKeyDown = true;
PlayerEntity player = Minecraft.getInstance().player;
if (mouseOver != null && !player.isSpectator() && VampirePlayer.getOpt(player).map(vp -> vp.getLevel() > 0 && !vp.getActionHandler().isActionActive(VampireActions.bat)).orElse(false)) {
if (mouseOver instanceof EntityRayTraceResult) {
VampirismMod.dispatcher.sendToServer(new CStartFeedingPacket(((EntityRayTraceResult) mouseOver).getEntity().getId()));
} else if (mouseOver instanceof BlockRayTraceResult) {
BlockPos pos = ((BlockRayTraceResult) mouseOver).getBlockPos();
VampirismMod.dispatcher.sendToServer(new CStartFeedingPacket(pos));
} else {
LOGGER.warn("Unknown mouse over type while trying to feed");
}
}
} else if (keyPressed == KEY.ACTION) {
if (Minecraft.getInstance().player.isAlive()) {
IPlayableFaction<?> faction = VampirismPlayerAttributes.get(Minecraft.getInstance().player).faction;
if (faction != null) {
Minecraft.getInstance().setScreen(new SelectActionScreen(faction.getColor(), false));
}
}
} else if (keyPressed == KEY.SKILL) {
VampirismMod.dispatcher.sendToServer(new CSimpleInputEvent(CSimpleInputEvent.Type.VAMPIRISM_MENU));
} else if (keyPressed == KEY.VISION) {
VampirismMod.dispatcher.sendToServer(new CSimpleInputEvent(CSimpleInputEvent.Type.TOGGLE_VAMPIRE_VISION));
} else if (keyPressed == KEY.ACTION1) {
long t = System.currentTimeMillis();
if (t - lastAction1Trigger > ACTION_BUTTON_COOLDOWN) {
lastAction1Trigger = System.currentTimeMillis();
PlayerEntity player = Minecraft.getInstance().player;
if (player.isAlive()) {
FactionPlayerHandler.getOpt(player).ifPresent(factionHandler -> factionHandler.getCurrentFactionPlayer().ifPresent(factionPlayer -> toggleBoundAction(factionPlayer, factionHandler.getBoundAction(1))));
}
}
} else if (keyPressed == KEY.ACTION2) {
long t = System.currentTimeMillis();
if (t - lastAction2Trigger > ACTION_BUTTON_COOLDOWN) {
lastAction2Trigger = System.currentTimeMillis();
PlayerEntity player = Minecraft.getInstance().player;
if (player.isAlive()) {
FactionPlayerHandler.getOpt(player).ifPresent(factionHandler -> factionHandler.getCurrentFactionPlayer().ifPresent(factionPlayer -> toggleBoundAction(factionPlayer, factionHandler.getBoundAction(2))));
}
}
} else if (keyPressed == KEY.ACTION3) {
long t = System.currentTimeMillis();
if (t - lastAction3Trigger > ACTION_BUTTON_COOLDOWN) {
lastAction3Trigger = System.currentTimeMillis();
PlayerEntity player = Minecraft.getInstance().player;
if (player.isAlive()) {
FactionPlayerHandler.getOpt(player).ifPresent(factionHandler -> factionHandler.getCurrentFactionPlayer().ifPresent(factionPlayer -> toggleBoundAction(factionPlayer, factionHandler.getBoundAction(3))));
}
}
} else if (keyPressed == KEY.MINION) {
if (FactionPlayerHandler.getOpt(Minecraft.getInstance().player).map(FactionPlayerHandler::getLordLevel).orElse(0) > 0) {
Minecraft.getInstance().setScreen(new SelectMinionTaskScreen());
}
}
if (suckKeyDown && !SUCK.isDown()) {
suckKeyDown = false;
VampirismMod.dispatcher.sendToServer(new CSimpleInputEvent(CSimpleInputEvent.Type.FINISH_SUCK_BLOOD));
}
}
Aggregations