Search in sources :

Example 1 with PacketBonusJump

use of com.lying.variousoddities.network.PacketBonusJump in project VariousOddities by Lyinginbedmon.

the class VOBusClient method onLivingJump.

@SubscribeEvent
public static void onLivingJump(LivingUpdateEvent event) {
    if (event.getEntityLiving() == mc.player) {
        ClientPlayerEntity player = (ClientPlayerEntity) event.getEntityLiving();
        LivingData data = LivingData.forEntity(event.getEntityLiving());
        Abilities abilities = data.getAbilities();
        Map<ResourceLocation, Ability> abilityMap = AbilityRegistry.getCreatureAbilities(player);
        if (player.movementInput.jump && abilities.canBonusJump) {
            if (AbilitySwim.isEntitySwimming(player)) {
                if (abilityMap.containsKey(AbilitySwim.REGISTRY_NAME)) {
                    abilities.doWaterJump();
                    PacketHandler.sendToServer(new PacketBonusJump(false));
                }
            } else if (!player.isOnGround()) {
                if (abilityMap.containsKey(AbilityFlight.REGISTRY_NAME) && abilityMap.get(AbilityFlight.REGISTRY_NAME).isActive()) {
                    abilities.doAirJump();
                    player.connection.sendPacket(new CEntityActionPacket(player, CEntityActionPacket.Action.START_FALL_FLYING));
                    PacketHandler.sendToServer(new PacketBonusJump());
                }
            }
        }
    }
}
Also used : Ability(com.lying.variousoddities.species.abilities.Ability) IPhasingAbility(com.lying.variousoddities.species.abilities.IPhasingAbility) Abilities(com.lying.variousoddities.capabilities.Abilities) ResourceLocation(net.minecraft.util.ResourceLocation) LivingData(com.lying.variousoddities.capabilities.LivingData) ClientPlayerEntity(net.minecraft.client.entity.player.ClientPlayerEntity) CEntityActionPacket(net.minecraft.network.play.client.CEntityActionPacket) PacketBonusJump(com.lying.variousoddities.network.PacketBonusJump) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

Abilities (com.lying.variousoddities.capabilities.Abilities)1 LivingData (com.lying.variousoddities.capabilities.LivingData)1 PacketBonusJump (com.lying.variousoddities.network.PacketBonusJump)1 Ability (com.lying.variousoddities.species.abilities.Ability)1 IPhasingAbility (com.lying.variousoddities.species.abilities.IPhasingAbility)1 ClientPlayerEntity (net.minecraft.client.entity.player.ClientPlayerEntity)1 CEntityActionPacket (net.minecraft.network.play.client.CEntityActionPacket)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)1